Fix LINT64 build.
[dragonfly.git] / contrib / ipfilter / ipsd / Celler / ip_compat.h
1 /*
2  * (C)opyright 1995 by Darren Reed.
3  *
4  * This code may be freely distributed as long as it retains this notice
5  * and is not changed in any way.  The author accepts no responsibility
6  * for the use of this software.  I hate legaleese, don't you ?
7  *
8  * @(#)ip_compat.h      1.1 9/14/95
9  */
10
11 /*
12  * These #ifdef's are here mainly for linux, but who knows, they may
13  * not be in other places or maybe one day linux will grow up and some
14  * of these will turn up there too.
15  */
16 #ifndef ICMP_UNREACH
17 # define        ICMP_UNREACH    ICMP_DEST_UNREACH
18 #endif
19 #ifndef ICMP_SOURCEQUENCH
20 # define        ICMP_SOURCEQUENCH       ICMP_SOURCE_QUENCH
21 #endif
22 #ifndef ICMP_TIMXCEED
23 # define        ICMP_TIMXCEED   ICMP_TIME_EXCEEDED
24 #endif
25 #ifndef ICMP_PARAMPROB
26 # define        ICMP_PARAMPROB  ICMP_PARAMETERPROB
27 #endif
28 #ifndef IPVERSION
29 # define        IPVERSION       4
30 #endif
31 #ifndef IPOPT_MINOFF
32 # define        IPOPT_MINOFF    4
33 #endif
34 #ifndef IPOPT_COPIED
35 # define        IPOPT_COPIED(x) ((x)&0x80)
36 #endif
37 #ifndef IPOPT_EOL
38 # define        IPOPT_EOL       0
39 #endif
40 #ifndef IPOPT_NOP
41 # define        IPOPT_NOP       1
42 #endif
43 #ifndef IP_MF
44 # define        IP_MF   ((u_short)0x2000)
45 #endif
46 #ifndef ETHERTYPE_IP
47 # define        ETHERTYPE_IP    ((u_short)0x0800)
48 #endif
49 #ifndef TH_FIN
50 # define        TH_FIN  0x01
51 #endif
52 #ifndef TH_SYN
53 # define        TH_SYN  0x02
54 #endif
55 #ifndef TH_RST
56 # define        TH_RST  0x04
57 #endif
58 #ifndef TH_PUSH
59 # define        TH_PUSH 0x08
60 #endif
61 #ifndef TH_ACK
62 # define        TH_ACK  0x10
63 #endif
64 #ifndef TH_URG
65 # define        TH_URG  0x20
66 #endif
67 #ifndef IPOPT_EOL
68 # define        IPOPT_EOL       0
69 #endif
70 #ifndef IPOPT_NOP
71 # define        IPOPT_NOP       1
72 #endif
73 #ifndef IPOPT_RR
74 # define        IPOPT_RR        7
75 #endif
76 #ifndef IPOPT_TS
77 # define        IPOPT_TS        68
78 #endif
79 #ifndef IPOPT_SECURITY
80 # define        IPOPT_SECURITY  130
81 #endif
82 #ifndef IPOPT_LSRR
83 # define        IPOPT_LSRR      131
84 #endif
85 #ifndef IPOPT_SATID
86 # define        IPOPT_SATID     136
87 #endif
88 #ifndef IPOPT_SSRR
89 # define        IPOPT_SSRR      137
90 #endif
91 #ifndef IPOPT_SECUR_UNCLASS
92 # define        IPOPT_SECUR_UNCLASS     ((u_short)0x0000)
93 #endif
94 #ifndef IPOPT_SECUR_CONFID
95 # define        IPOPT_SECUR_CONFID      ((u_short)0xf135)
96 #endif
97 #ifndef IPOPT_SECUR_EFTO
98 # define        IPOPT_SECUR_EFTO        ((u_short)0x789a)
99 #endif
100 #ifndef IPOPT_SECUR_MMMM
101 # define        IPOPT_SECUR_MMMM        ((u_short)0xbc4d)
102 #endif
103 #ifndef IPOPT_SECUR_RESTR
104 # define        IPOPT_SECUR_RESTR       ((u_short)0xaf13)
105 #endif
106 #ifndef IPOPT_SECUR_SECRET
107 # define        IPOPT_SECUR_SECRET      ((u_short)0xd788)
108 #endif
109 #ifndef IPOPT_SECUR_TOPSECRET
110 # define        IPOPT_SECUR_TOPSECRET   ((u_short)0x6bc5)
111 #endif
112
113 #ifdef linux
114 # define        icmp    icmphdr
115 # define        icmp_type       type
116 # define        icmp_code       code
117
118 /*
119  * From /usr/include/netinet/ip_var.h
120  * !%@#!$@# linux...
121  */
122 struct ipovly {
123         caddr_t ih_next, ih_prev;       /* for protocol sequence q's */
124         u_char  ih_x1;                  /* (unused) */
125         u_char  ih_pr;                  /* protocol */
126         short   ih_len;                 /* protocol length */
127         struct  in_addr ih_src;         /* source internet address */
128         struct  in_addr ih_dst;         /* destination internet address */
129 };
130
131 typedef struct  {
132         __u16   th_sport;
133         __u16   th_dport;
134         __u32   th_seq;
135         __u32   th_ack;
136 # if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\
137     defined(vax)
138         __u8    th_res:4;
139         __u8    th_off:4;
140 #else
141         __u8    th_off:4;
142         __u8    th_res:4;
143 #endif
144         __u8    th_flags;
145         __u16   th_win;
146         __u16   th_sum;
147         __u16   th_urp;
148 } tcphdr_t;
149
150 typedef struct  {
151         __u16   uh_sport;
152         __u16   uh_dport;
153         __s16   uh_ulen;
154         __u16   uh_sum;
155 } udphdr_t;
156
157 typedef struct  {
158 # if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\
159     defined(vax)
160         __u8    ip_hl:4;
161         __u8    ip_v:4;
162 # else
163         __u8    ip_hl:4;
164         __u8    ip_v:4;
165 # endif
166         __u8    ip_tos;
167         __u16   ip_len;
168         __u16   ip_id;
169         __u16   ip_off;
170         __u8    ip_ttl;
171         __u8    ip_p;
172         __u16   ip_sum;
173         struct  in_addr ip_src;
174         struct  in_addr ip_dst;
175 } ip_t;
176
177 typedef struct  {
178         __u8    ether_dhost[6];
179         __u8    ether_shost[6];
180         __u16   ether_type;
181 } ether_header_t;
182
183 # define        bcopy(a,b,c)    memmove(b,a,c)
184 # define        bcmp(a,b,c)     memcmp(a,b,c)
185
186 # define        ifnet   device
187
188 #else
189
190 typedef struct  udphdr  udphdr_t;
191 typedef struct  tcphdr  tcphdr_t;
192 typedef struct  ip      ip_t;
193 typedef struct  ether_header    ether_header_t;
194
195 #endif
196
197 #ifdef  solaris
198 # define        bcopy(a,b,c)    memmove(b,a,c)
199 # define        bcmp(a,b,c)     memcmp(a,b,c)
200 # define        bzero(a,b)      memset(a,0,b)
201 #endif