ip_compat.h revision 145519
1263936Sbr/*	$FreeBSD: head/contrib/ipfilter/ipsd/Celler/ip_compat.h 145519 2005-04-25 18:20:15Z darrenr $	*/
2263936Sbr
3263936Sbr/*
4263936Sbr * (C)opyright 1995 by Darren Reed.
5263936Sbr *
6263936Sbr * This code may be freely distributed as long as it retains this notice
7263936Sbr * and is not changed in any way.  The author accepts no responsibility
8263936Sbr * for the use of this software.  I hate legaleese, don't you ?
9263936Sbr *
10263936Sbr * @(#)ip_compat.h	1.1 9/14/95
11263936Sbr */
12263936Sbr
13263936Sbr/*
14263936Sbr * These #ifdef's are here mainly for linux, but who knows, they may
15263936Sbr * not be in other places or maybe one day linux will grow up and some
16263936Sbr * of these will turn up there too.
17263936Sbr */
18263936Sbr#ifndef	ICMP_UNREACH
19263936Sbr# define	ICMP_UNREACH	ICMP_DEST_UNREACH
20263936Sbr#endif
21263936Sbr#ifndef	ICMP_SOURCEQUENCH
22263936Sbr# define	ICMP_SOURCEQUENCH	ICMP_SOURCE_QUENCH
23263936Sbr#endif
24263936Sbr#ifndef	ICMP_TIMXCEED
25263936Sbr# define	ICMP_TIMXCEED	ICMP_TIME_EXCEEDED
26263936Sbr#endif
27263936Sbr#ifndef	ICMP_PARAMPROB
28263936Sbr# define	ICMP_PARAMPROB	ICMP_PARAMETERPROB
29263936Sbr#endif
30263936Sbr#ifndef	IPVERSION
31263936Sbr# define	IPVERSION	4
32263936Sbr#endif
33263936Sbr#ifndef	IPOPT_MINOFF
34263936Sbr# define	IPOPT_MINOFF	4
35263936Sbr#endif
36263936Sbr#ifndef	IPOPT_COPIED
37263936Sbr# define	IPOPT_COPIED(x)	((x)&0x80)
38263936Sbr#endif
39263936Sbr#ifndef	IPOPT_EOL
40263936Sbr# define	IPOPT_EOL	0
41263936Sbr#endif
42263936Sbr#ifndef	IPOPT_NOP
43263936Sbr# define	IPOPT_NOP	1
44263936Sbr#endif
45263936Sbr#ifndef	IP_MF
46263936Sbr# define	IP_MF	((u_short)0x2000)
47263936Sbr#endif
48263936Sbr#ifndef	ETHERTYPE_IP
49263936Sbr# define	ETHERTYPE_IP	((u_short)0x0800)
50263936Sbr#endif
51263936Sbr#ifndef	TH_FIN
52263936Sbr# define	TH_FIN	0x01
53263936Sbr#endif
54263936Sbr#ifndef	TH_SYN
55263936Sbr# define	TH_SYN	0x02
56263936Sbr#endif
57263936Sbr#ifndef	TH_RST
58263936Sbr# define	TH_RST	0x04
59263936Sbr#endif
60263936Sbr#ifndef	TH_PUSH
61263936Sbr# define	TH_PUSH	0x08
62263936Sbr#endif
63263936Sbr#ifndef	TH_ACK
64263936Sbr# define	TH_ACK	0x10
65263936Sbr#endif
66263936Sbr#ifndef	TH_URG
67263936Sbr# define	TH_URG	0x20
68263936Sbr#endif
69263936Sbr#ifndef	IPOPT_EOL
70263936Sbr# define	IPOPT_EOL	0
71263936Sbr#endif
72263936Sbr#ifndef	IPOPT_NOP
73263936Sbr# define	IPOPT_NOP	1
74263936Sbr#endif
75263936Sbr#ifndef	IPOPT_RR
76263936Sbr# define	IPOPT_RR	7
77263936Sbr#endif
78263936Sbr#ifndef	IPOPT_TS
79263936Sbr# define	IPOPT_TS	68
80263936Sbr#endif
81263936Sbr#ifndef	IPOPT_SECURITY
82263936Sbr# define	IPOPT_SECURITY	130
83263936Sbr#endif
84263936Sbr#ifndef	IPOPT_LSRR
85263936Sbr# define	IPOPT_LSRR	131
86263936Sbr#endif
87263936Sbr#ifndef	IPOPT_SATID
88263936Sbr# define	IPOPT_SATID	136
89263936Sbr#endif
90263936Sbr#ifndef	IPOPT_SSRR
91263936Sbr# define	IPOPT_SSRR	137
92263936Sbr#endif
93263936Sbr#ifndef	IPOPT_SECUR_UNCLASS
94263936Sbr# define	IPOPT_SECUR_UNCLASS	((u_short)0x0000)
95263936Sbr#endif
96263936Sbr#ifndef	IPOPT_SECUR_CONFID
97263936Sbr# define	IPOPT_SECUR_CONFID	((u_short)0xf135)
98263936Sbr#endif
99263936Sbr#ifndef	IPOPT_SECUR_EFTO
100263936Sbr# define	IPOPT_SECUR_EFTO	((u_short)0x789a)
101263936Sbr#endif
102263936Sbr#ifndef	IPOPT_SECUR_MMMM
103263936Sbr# define	IPOPT_SECUR_MMMM	((u_short)0xbc4d)
104263936Sbr#endif
105263936Sbr#ifndef	IPOPT_SECUR_RESTR
106263936Sbr# define	IPOPT_SECUR_RESTR	((u_short)0xaf13)
107263936Sbr#endif
108263936Sbr#ifndef	IPOPT_SECUR_SECRET
109263936Sbr# define	IPOPT_SECUR_SECRET	((u_short)0xd788)
110263936Sbr#endif
111263936Sbr#ifndef IPOPT_SECUR_TOPSECRET
112263936Sbr# define	IPOPT_SECUR_TOPSECRET	((u_short)0x6bc5)
113263936Sbr#endif
114263936Sbr
115263936Sbr#ifdef linux
116263936Sbr# define	icmp	icmphdr
117263936Sbr# define	icmp_type	type
118263936Sbr# define	icmp_code	code
119263936Sbr
120263936Sbr/*
121263936Sbr * From /usr/include/netinet/ip_var.h
122263936Sbr * !%@#!$@# linux...
123 */
124struct ipovly {
125	caddr_t	ih_next, ih_prev;	/* for protocol sequence q's */
126	u_char	ih_x1;			/* (unused) */
127	u_char	ih_pr;			/* protocol */
128	short	ih_len;			/* protocol length */
129	struct	in_addr ih_src;		/* source internet address */
130	struct	in_addr ih_dst;		/* destination internet address */
131};
132
133typedef	struct	{
134	__u16	th_sport;
135	__u16	th_dport;
136	__u32	th_seq;
137	__u32	th_ack;
138# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\
139    defined(vax)
140	__u8	th_res:4;
141	__u8	th_off:4;
142#else
143	__u8	th_off:4;
144	__u8	th_res:4;
145#endif
146	__u8	th_flags;
147	__u16	th_win;
148	__u16	th_sum;
149	__u16	th_urp;
150} tcphdr_t;
151
152typedef	struct	{
153	__u16	uh_sport;
154	__u16	uh_dport;
155	__s16	uh_ulen;
156	__u16	uh_sum;
157} udphdr_t;
158
159typedef	struct	{
160# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\
161    defined(vax)
162	__u8	ip_hl:4;
163	__u8	ip_v:4;
164# else
165	__u8	ip_hl:4;
166	__u8	ip_v:4;
167# endif
168	__u8	ip_tos;
169	__u16	ip_len;
170	__u16	ip_id;
171	__u16	ip_off;
172	__u8	ip_ttl;
173	__u8	ip_p;
174	__u16	ip_sum;
175	struct	in_addr	ip_src;
176	struct	in_addr	ip_dst;
177} ip_t;
178
179typedef	struct	{
180	__u8	ether_dhost[6];
181	__u8	ether_shost[6];
182	__u16	ether_type;
183} ether_header_t;
184
185# define	bcopy(a,b,c)	memmove(b,a,c)
186# define	bcmp(a,b,c)	memcmp(a,b,c)
187
188# define	ifnet	device
189
190#else
191
192typedef	struct	udphdr	udphdr_t;
193typedef	struct	tcphdr	tcphdr_t;
194typedef	struct	ip	ip_t;
195typedef	struct	ether_header	ether_header_t;
196
197#endif
198
199#ifdef	solaris
200# define	bcopy(a,b,c)	memmove(b,a,c)
201# define	bcmp(a,b,c)	memcmp(a,b,c)
202# define	bzero(a,b)	memset(a,0,b)
203#endif
204