Add missing #defines used by fd_device.c.
[tinc] / src / ethernet.h
1 /*
2     ethernet.h -- missing Ethernet related definitions
3     Copyright (C) 2005 Ivo Timmermans
4                   2006 Guus Sliepen <guus@tinc-vpn.org>
5
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License along
17     with this program; if not, write to the Free Software Foundation, Inc.,
18     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #ifndef __TINC_ETHERNET_H__
22 #define __TINC_ETHERNET_H__
23
24 #ifndef ETH_ALEN
25 #define ETH_ALEN 6
26 #endif
27
28 #ifndef ETH_HLEN
29 #define ETH_HLEN 14
30 #endif
31
32 #ifndef ETHER_TYPE_LEN
33 #define ETHER_TYPE_LEN 2
34 #endif
35
36
37 #ifndef ARPHRD_ETHER
38 #define ARPHRD_ETHER 1
39 #endif
40
41 #ifndef ETH_P_IP
42 #define ETH_P_IP 0x0800
43 #endif
44
45 #ifndef ETH_P_ARP
46 #define ETH_P_ARP 0x0806
47 #endif
48
49 #ifndef ETH_P_IPV6
50 #define ETH_P_IPV6 0x86DD
51 #endif
52
53 #ifndef ETH_P_8021Q
54 #define ETH_P_8021Q 0x8100
55 #endif
56
57 #ifndef ETH_P_MAX
58 #define ETH_P_MAX 0xFFFF
59 #endif
60
61 #ifndef HAVE_STRUCT_ETHER_HEADER
62 struct ether_header {
63         uint8_t ether_dhost[ETH_ALEN];
64         uint8_t ether_shost[ETH_ALEN];
65         uint16_t ether_type;
66 } __attribute__ ((__gcc_struct__, __packed__));
67 #endif
68
69 #ifndef HAVE_STRUCT_ARPHDR
70 struct arphdr {
71         uint16_t ar_hrd;
72         uint16_t ar_pro;
73         uint8_t ar_hln;
74         uint8_t ar_pln;
75         uint16_t ar_op;
76 } __attribute__ ((__gcc_struct__, __packed__));
77
78 #define ARPOP_REQUEST 1
79 #define ARPOP_REPLY 2
80 #define ARPOP_RREQUEST 3
81 #define ARPOP_RREPLY 4
82 #define ARPOP_InREQUEST 8
83 #define ARPOP_InREPLY 9
84 #define ARPOP_NAK 10
85 #endif
86
87 #ifndef HAVE_STRUCT_ETHER_ARP
88 struct  ether_arp {
89         struct  arphdr ea_hdr;
90         uint8_t arp_sha[ETH_ALEN];
91         uint8_t arp_spa[4];
92         uint8_t arp_tha[ETH_ALEN];
93         uint8_t arp_tpa[4];
94 } __attribute__ ((__gcc_struct__, __packed__));
95 #define arp_hrd ea_hdr.ar_hrd
96 #define arp_pro ea_hdr.ar_pro
97 #define arp_hln ea_hdr.ar_hln
98 #define arp_pln ea_hdr.ar_pln
99 #define arp_op ea_hdr.ar_op
100 #endif
101
102 #endif /* __TINC_ETHERNET_H__ */