1 /*
2 Perl ARP Extension header file
3 
4 Programmed by Bastian Ballmann
5 Last update: 19.12.2003
6 
7 This program is free software; you can redistribute
8 it and/or modify it under the terms of the
9 GNU General Public License version 2 as published
10 by the Free Software Foundation.
11 
12 This program is distributed in the hope that it will
13 be useful, but WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE.
16 See the GNU General Public License for more details.
17 */
18 
19 #define ARPOP_REQUEST    1
20 #define ARPOP_REPLY      2
21 #define ARPOP_REVREQUEST 3
22 #define ARPOP_REVREPLY   4
23 #define ARPOP_INVREQUEST 8
24 #define ARPOP_INVREPLY   9
25 #define ARPHDR_ETHER     1
26 #ifndef ETH_ALEN
27 #define ETH_ALEN         6
28 #endif
29 #ifndef ETH_P_IP
30 #define ETH_P_IP         0x0800
31 #endif
32 #ifndef ETH_P_ARP
33 #define ETH_P_ARP        0x0806
34 #endif
35 #ifndef ETH_P_ALL
36 #define ETH_P_ALL        0x0000
37 #endif
38 #ifdef BSD
39 #define SOCK_TYPE        SOCK_RAW
40 #else
41 #define SOCK_TYPE        SOCK_PACKET
42 #endif
43 #define IP_ALEN          4
44 
45 /* Length of the hardware address in the standard hex-digits-and-colons
46  * notation (null terminated string) */
47 #define HEX_HW_ADDR_LEN  18
48 
49 // ARP Header Struktur
50 struct my_arphdr {
51    u_short hw_type;             // hardware type
52    u_short proto_type;          // protocol type
53    u_char ha_len;               // hardware address len
54    u_char pa_len;               // protocol address len
55    u_short opcode;              // arp opcode
56    u_char source_add[ETH_ALEN]; // source mac
57    u_char source_ip[IP_ALEN];   // source ip
58    u_char dest_add[ETH_ALEN];   // dest mac
59    u_char dest_ip[IP_ALEN];     // dest ip
60 };
61 
62 #ifdef LINUX
63   extern struct ether_addr *ether_aton (__const char *__asc) __THROW;
64 #else
65   extern struct ether_addr *ether_aton (__const char *__asc);
66 #endif
67 extern int get_mac_linux(const char *dev, char *mac);
68 extern int get_mac_bsd(const char *dev, char *mac);
69 extern int arp_lookup_linux(const char *dev, const char *ip, char *mac);
70 extern int arp_lookup_bsd(const char *dev, const char *ip, char *mac);
71 extern int send_packet_linux(const char *dev, u_char *packet, u_int packetsize);
72 extern int send_packet_bsd(const char *dev, u_char *packet, u_int packetsize);
73