2 * (C)opyright 1993, 1994, 1995 by Darren Reed.
4 * Redistribution and use in source and binary forms are permitted
5 * provided that this notice is preserved and due credit is given
6 * to the original author and the contributors.
8 * @(#)ip_compat.h 1.8 1/14/96
9 * $Id: ip_compat.h,v 2.0.1.4 1997/02/04 14:24:25 darrenr Exp $
12 #ifndef __IP_COMPAT_H_
13 #define __IP_COMPAT_H__
16 #define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
19 #define MTYPE(m) ((m)->b_datap->db_type)
21 #define IPMINLEN(i, h) ((i)->ip_len >= ((i)->ip_hl * 4 + sizeof(struct h)))
24 #define IP_OFFMASK 0x1fff
28 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
32 * Security Options for Intenet Protocol (IPSO) as defined in RFC 1108.
36 * 00000001 - (Reserved 4)
37 * 00111101 - Top Secret
39 * 10010110 - Confidential
40 * 01100110 - (Reserved 3)
41 * 11001100 - (Reserved 2)
42 * 10101011 - Unclassified
43 * 11110001 - (Reserved 1)
45 #define IPSO_CLASS_RES4 0x01
46 #define IPSO_CLASS_TOPS 0x3d
47 #define IPSO_CLASS_SECR 0x5a
48 #define IPSO_CLASS_CONF 0x96
49 #define IPSO_CLASS_RES3 0x66
50 #define IPSO_CLASS_RES2 0xcc
51 #define IPSO_CLASS_UNCL 0xab
52 #define IPSO_CLASS_RES1 0xf1
54 #define IPSO_AUTH_GENSER 0x80
55 #define IPSO_AUTH_ESI 0x40
56 #define IPSO_AUTH_SCI 0x20
57 #define IPSO_AUTH_NSA 0x10
58 #define IPSO_AUTH_DOE 0x08
59 #define IPSO_AUTH_UN 0x06
60 #define IPSO_AUTH_FTE 0x01
65 /*#define IPOPT_RR 7 */
66 #define IPOPT_ZSU 10 /* ZSU */
67 #define IPOPT_MTUP 11 /* MTUP */
68 #define IPOPT_MTUR 12 /* MTUR */
69 #define IPOPT_ENCODE 15 /* ENCODE */
70 /*#define IPOPT_TS 68 */
71 #define IPOPT_TR 82 /* TR */
72 /*#define IPOPT_SECURITY 130 */
73 /*#define IPOPT_LSRR 131 */
74 #define IPOPT_E_SEC 133 /* E-SEC */
75 #define IPOPT_CIPSO 134 /* CIPSO */
76 /*#define IPOPT_SATID 136 */
78 # define IPOPT_SID IPOPT_SATID
80 /*#define IPOPT_SSRR 137 */
81 #define IPOPT_ADDEXT 147 /* ADDEXT */
82 #define IPOPT_VISA 142 /* VISA */
83 #define IPOPT_IMITD 144 /* IMITD */
84 #define IPOPT_EIP 145 /* EIP */
85 #define IPOPT_FINN 205 /* FINN */
89 * Build some macros and #defines to enable the same code to compile anywhere
90 * Well, that's the idea, anyway :-)
94 # define MUTEX_ENTER(x) mutex_enter(x)
95 # define MUTEX_EXIT(x) mutex_exit(x)
96 # define MTOD(m,t) (t)((m)->b_rptr)
97 # define IRCOPY(a,b,c) copyin((a), (b), (c))
98 # define IWCOPY(a,b,c) copyout((a), (b), (c))
100 # define MUTEX_ENTER(x) ;
101 # define MUTEX_EXIT(x) ;
103 # define MTOD(m,t) mtod(m,t)
104 # define IRCOPY(a,b,c) bcopy((a), (b), (c))
105 # define IWCOPY(a,b,c) bcopy((a), (b), (c))
107 # endif /* SOLARIS */
110 # if defined(__svr4__) || defined(__SVR4)
111 # define GETUNIT(n) get_unit((n))
113 # include <sys/kmem_alloc.h>
114 # define GETUNIT(n) ifunit((n), IFNAMSIZ)
117 # define GETUNIT(n) ifunit((n))
120 # if defined(sun) && !defined(linux)
121 # define UIOMOVE(a,b,c,d) uiomove(a,b,c,d)
122 # define SLEEP(id, n) sleep((id), PZERO+1)
123 # define KFREE(x) kmem_free((char *)(x), sizeof(*(x)))
141 * in case the ILL has disappeared...
143 int qf_hl; /* header length */
149 # define ntohs(x) (x)
150 # define ntohl(x) (x)
151 # define htons(x) (x)
152 # define htonl(x) (x)
154 # define KMALLOC(x) kmem_alloc((x), KM_NOSLEEP)
155 # define GET_MINOR(x) getminor(x)
157 # define KMALLOC(x) new_kmem_alloc((x), KMEM_NOSLEEP)
158 # endif /* __svr4__ */
159 # endif /* sun && !linux */
161 # define GET_MINOR(x) minor(x)
163 # if BSD >= 199306 || defined(__FreeBSD__)
165 # if !defined(__FreeBSD__)
166 # include <vm/vm_extern.h>
167 # include <sys/proc.h>
168 extern vm_map_t kmem_map;
170 # include <vm/vm_kern.h>
171 # endif /* __FreeBSD__ */
173 ** # define KMALLOC(x) kmem_alloc(kmem_map, (x))
174 ** # define KFREE(x) kmem_free(kmem_map, (vm_offset_t)(x), \
178 # define KMALLOC(x) malloc((x), M_PFIL, M_NOWAIT)
179 # define KFREE(x) FREE((x), M_PFIL)
181 # define KMALLOC(x) malloc((x), M_TEMP, M_NOWAIT)
182 # define KFREE(x) FREE((x), M_TEMP)
184 # define UIOMOVE(a,b,c,d) uiomove(a,b,d)
185 # define SLEEP(id, n) tsleep((id), PPAUSE|PCATCH, n, 0)
187 # if defined(NetBSD1_0) && (NetBSD1_0 > 1)
188 # define SPLNET(x) x = splsoftnet()
191 # define SPLNET(x) x = splnet()
192 # define SPLX(x) (void) splx(x)
197 # define MUTEX_ENTER(x) ;
198 # define MUTEX_EXIT(x) ;
201 # define KMALLOC(x) malloc(x)
202 # define KFREE(x) free(x)
203 # define GETUNIT(x) (x)
204 # define IRCOPY(a,b,c) bcopy((a), (b), (c))
205 # define IWCOPY(a,b,c) bcopy((a), (b), (c))
210 # define ICMP_UNREACH ICMP_DEST_UNREACH
211 # define ICMP_SOURCEQUENCH ICMP_SOURCE_QUENCH
212 # define ICMP_TIMXCEED ICMP_TIME_EXCEEDED
213 # define ICMP_PARAMPROB ICMP_PARAMETERPROB
218 # define TH_PUSH 0x08
242 # if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\
257 struct in_addr ip_src;
258 struct in_addr ip_dst;
262 * Structure of an icmp header.
265 u_char icmp_type; /* type of message, see below */
266 u_char icmp_code; /* type sub code */
267 u_short icmp_cksum; /* ones complement cksum of struct */
269 u_char ih_pptr; /* ICMP_PARAMPROB */
270 struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
277 # define icmp_pptr icmp_hun.ih_pptr
278 # define icmp_gwaddr icmp_hun.ih_gwaddr
279 # define icmp_id icmp_hun.ih_idseq.icd_id
280 # define icmp_seq icmp_hun.ih_idseq.icd_seq
281 # define icmp_void icmp_hun.ih_void
290 /* options and then 64 bits of data */
295 # define icmp_otime icmp_dun.id_ts.its_otime
296 # define icmp_rtime icmp_dun.id_ts.its_rtime
297 # define icmp_ttime icmp_dun.id_ts.its_ttime
298 # define icmp_ip icmp_dun.id_ip.idi_ip
299 # define icmp_mask icmp_dun.id_mask
300 # define icmp_data icmp_dun.id_data
304 caddr_t ih_next, ih_prev; /* for protocol sequence q's */
305 u_char ih_x1; /* (unused) */
306 u_char ih_pr; /* protocol */
307 short ih_len; /* protocol length */
308 struct in_addr ih_src; /* source internet address */
309 struct in_addr ih_dst; /* destination internet address */
312 # define SPLX(x) (void)
313 # define SPLNET(x) (void)
315 # define bcopy(a,b,c) memmove(b,a,c)
316 # define bcmp(a,b,c) memcmp(a,b,c)
318 # define UNITNAME(n) dev_get((n))
319 # define ifnet device
321 # define KMALLOC(x) kmalloc((x), GFP_ATOMIC)
322 # define KFREE(x) kfree_s((x), sizeof(*(x)))
323 # define IRCOPY(a,b,c) { \
324 error = verify_area(VERIFY_READ, \
327 memcpy_fromfs((b), (a), (c)); \
329 # define IWCOPY(a,b,c) { \
330 error = verify_area(VERIFY_WRITE, \
333 memcpy_tofs((b), (a), (c)); \
336 typedef struct tcphdr tcphdr_t;
337 typedef struct udphdr udphdr_t;
338 typedef struct icmp icmphdr_t;
339 typedef struct ip ip_t;
342 #endif /* __IP_COMPAT_H__ */