Only compile raw socket code when it is supported on that platform.
[oweals/tinc.git] / lib / 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 ARPHRD_ETHER
29 #define ARPHRD_ETHER 1
30 #endif
31
32 #ifndef ETH_P_IP
33 #define ETH_P_IP 0x0800
34 #endif
35
36 #ifndef ETH_P_ARP
37 #define ETH_P_ARP 0x0806
38 #endif
39
40 #ifndef ETH_P_IPV6
41 #define ETH_P_IPV6 0x86DD
42 #endif
43
44 #ifndef HAVE_STRUCT_ETHER_HEADER
45 struct ether_header {
46         uint8_t ether_dhost[ETH_ALEN];
47         uint8_t ether_shost[ETH_ALEN];
48         uint16_t ether_type;
49 } __attribute__ ((__packed__));
50 #endif
51
52 #ifndef HAVE_STRUCT_ARPHDR
53 struct arphdr {
54         uint16_t ar_hrd;
55         uint16_t ar_pro;
56         uint8_t ar_hln;
57         uint8_t ar_pln; 
58         uint16_t ar_op; 
59 } __attribute__ ((__packed__));
60
61 #define ARPOP_REQUEST 1 
62 #define ARPOP_REPLY 2 
63 #define ARPOP_RREQUEST 3 
64 #define ARPOP_RREPLY 4 
65 #define ARPOP_InREQUEST 8 
66 #define ARPOP_InREPLY 9 
67 #define ARPOP_NAK 10 
68 #endif
69
70 #ifndef HAVE_STRUCT_ETHER_ARP
71 struct  ether_arp {
72         struct  arphdr ea_hdr;
73         uint8_t arp_sha[ETH_ALEN];
74         uint8_t arp_spa[4];
75         uint8_t arp_tha[ETH_ALEN];
76         uint8_t arp_tpa[4];
77 } __attribute__ ((__packed__));
78 #define arp_hrd ea_hdr.ar_hrd
79 #define arp_pro ea_hdr.ar_pro
80 #define arp_hln ea_hdr.ar_hln
81 #define arp_pln ea_hdr.ar_pln
82 #define arp_op ea_hdr.ar_op
83 #endif
84
85 #endif /* __TINC_ETHERNET_H__ */