Ensure ICMP_NET_ANO is defined.
[oweals/tinc.git] / lib / ipv4.h
1 /*
2     ipv4.h -- missing IPv4 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_IPV4_H__
22 #define __TINC_IPV4_H__
23
24 #ifndef AF_INET
25 #define AF_INET 2
26 #endif
27
28 #ifndef IPPROTO_ICMP
29 #define IPPROTO_ICMP 1
30 #endif
31
32 #ifndef ICMP_DEST_UNREACH
33 #define ICMP_DEST_UNREACH 3
34 #endif
35
36 #ifndef ICMP_FRAG_NEEDED
37 #define ICMP_FRAG_NEEDED 4
38 #endif
39
40 #ifndef ICMP_NET_UNKNOWN
41 #define ICMP_NET_UNKNOWN 6
42 #endif
43
44 #ifndef ICMP_NET_UNREACH
45 #define ICMP_NET_UNREACH 0
46 #endif
47
48 #ifndef ICMP_NET_ANO
49 #define ICMP_NET_ANO 9
50 #endif
51
52 #ifndef IP_MSS
53 #define       IP_MSS          576
54 #endif
55
56 #ifndef HAVE_STRUCT_IP
57 struct ip {
58 #if __BYTE_ORDER == __LITTLE_ENDIAN
59         unsigned int ip_hl:4;
60         unsigned int ip_v:4;
61 #else
62         unsigned int ip_v:4;
63         unsigned int ip_hl:4;
64 #endif
65         uint8_t ip_tos;
66         uint16_t ip_len;
67         uint16_t ip_id; 
68         uint16_t ip_off;
69 #define IP_RF 0x8000
70 #define IP_DF 0x4000
71 #define IP_MF 0x2000
72         uint8_t ip_ttl;
73         uint8_t ip_p;
74         uint16_t ip_sum;
75         struct in_addr ip_src, ip_dst;
76 } __attribute__ ((__packed__));
77 #endif
78
79 #ifndef IP_OFFMASK
80 #define IP_OFFMASK 0x1fff
81 #endif
82
83 #ifndef HAVE_STRUCT_ICMP
84 struct icmp {
85         uint8_t icmp_type;
86         uint8_t icmp_code;
87         uint16_t icmp_cksum;
88         union {
89                 uint8_t ih_pptr;
90                 struct in_addr ih_gwaddr;
91                 struct ih_idseq {
92                         uint16_t icd_id;
93                         uint16_t icd_seq;
94                 } ih_idseq;
95                 uint32_t ih_void;
96
97
98                 struct ih_pmtu {
99                         uint16_t ipm_void;
100                         uint16_t ipm_nextmtu;
101                 } ih_pmtu;
102
103                 struct ih_rtradv {
104                         uint8_t irt_num_addrs;
105                         uint8_t irt_wpa;
106                         uint16_t irt_lifetime;
107                 } ih_rtradv;
108         } icmp_hun;
109 #define icmp_pptr icmp_hun.ih_pptr
110 #define icmp_gwaddr icmp_hun.ih_gwaddr
111 #define icmp_id icmp_hun.ih_idseq.icd_id
112 #define icmp_seq icmp_hun.ih_idseq.icd_seq
113 #define icmp_void icmp_hun.ih_void
114 #define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
115 #define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
116 #define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs
117 #define icmp_wpa icmp_hun.ih_rtradv.irt_wpa
118 #define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime
119         union {
120                 struct {
121                         uint32_t its_otime;
122                         uint32_t its_rtime;
123                         uint32_t its_ttime;
124                 } id_ts;
125                 struct {
126                         struct ip idi_ip;
127                 } id_ip;
128                 uint32_t id_mask;
129                 uint8_t id_data[1];
130         } icmp_dun;
131 #define icmp_otime icmp_dun.id_ts.its_otime
132 #define icmp_rtime icmp_dun.id_ts.its_rtime
133 #define icmp_ttime icmp_dun.id_ts.its_ttime
134 #define icmp_ip icmp_dun.id_ip.idi_ip
135 #define icmp_radv icmp_dun.id_radv
136 #define icmp_mask icmp_dun.id_mask
137 #define icmp_data icmp_dun.id_data
138 } __attribute__ ((__packed__));
139 #endif
140
141 #endif /* __TINC_IPV4_H__ */