1/* 2 * Copyright (C) 1993-2001 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 * 6 * @(#)ip_compat.h 1.8 1/14/96 7 * $Id: ip_compat.h,v 2.26.2.9 2001/01/14 14:58:01 darrenr Exp $
|
8 * $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_compat.h 92685 2002-03-19 11:44:16Z darrenr $
|
8 * $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_compat.h 95418 2002-04-25 03:31:39Z darrenr $ |
9 */ 10 11#ifndef __IP_COMPAT_H__ 12#define __IP_COMPAT_H__ 13 14#ifndef __P 15# ifdef __STDC__ 16# define __P(x) x 17# else 18# define __P(x) () 19# endif 20#endif 21#ifndef __STDC__ 22# undef const 23# define const 24#endif 25 26#ifndef SOLARIS 27#define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4))) 28#endif 29#if SOLARIS 30# if !defined(SOLARIS2) 31# define SOLARIS2 3 /* Pick an old version */ 32# endif 33# if SOLARIS2 >= 8 34# ifndef USE_INET6 35# define USE_INET6 36# endif 37# else 38# undef USE_INET6 39# endif 40#endif 41#if defined(sun) && !(defined(__svr4__) || defined(__SVR4)) 42# undef USE_INET6 43#endif 44 45#if defined(_KERNEL) || defined(KERNEL) || defined(__KERNEL__) 46# undef KERNEL 47# undef _KERNEL 48# undef __KERNEL__ 49# define KERNEL 50# define _KERNEL 51# define __KERNEL__ 52#endif 53 54#if defined(__SVR4) || defined(__svr4__) || defined(__sgi) 55#define index strchr 56# if !defined(KERNEL) 57# define bzero(a,b) memset(a,0,b) 58# define bcmp memcmp 59# define bcopy(a,b,c) memmove(b,a,c) 60# endif 61#endif 62 63#ifndef offsetof 64#define offsetof(t,m) (int)((&((t *)0L)->m)) 65#endif 66 67#if defined(__sgi) || defined(bsdi) 68struct ether_addr { 69 u_char ether_addr_octet[6]; 70}; 71#endif 72 73#ifndef LIFNAMSIZ 74# ifdef IF_NAMESIZE 75# define LIFNAMSIZ IF_NAMESIZE 76# else 77# ifdef IFNAMSIZ 78# define LIFNAMSIZ IFNAMSIZ 79# else 80# define LIFNAMSIZ 16 81# endif 82# endif 83#endif 84 85#if defined(__sgi) && !defined(IPFILTER_LKM) 86# ifdef __STDC__ 87# define IPL_EXTERN(ep) ipfilter##ep 88# else 89# define IPL_EXTERN(ep) ipfilter/**/ep 90# endif 91#else 92# ifdef __STDC__ 93# define IPL_EXTERN(ep) ipl##ep 94# else 95# define IPL_EXTERN(ep) ipl/**/ep 96# endif 97#endif 98 99#ifdef __sgi 100# include <sys/debug.h> 101#endif 102 103#ifdef linux 104# include <sys/sysmacros.h> 105#endif 106
|
107
|
107/* 108 * This is a workaround for <sys/uio.h> troubles on FreeBSD and OpenBSD. 109 */ 110#ifndef _KERNEL 111# define ADD_KERNEL 112# define _KERNEL 113# define KERNEL 114#endif 115#ifdef __OpenBSD__ 116struct file; 117#endif 118#include <sys/uio.h> 119#ifdef ADD_KERNEL 120# undef _KERNEL 121# undef KERNEL 122#endif 123 124#if SOLARIS 125# define MTYPE(m) ((m)->b_datap->db_type) 126# if SOLARIS2 >= 4 127# include <sys/isa_defs.h> 128# endif 129# include <sys/ioccom.h> 130# include <sys/sysmacros.h> 131# include <sys/kmem.h> 132/* 133 * because Solaris 2 defines these in two places :-/ 134 */ 135# undef IPOPT_EOL 136# undef IPOPT_NOP 137# undef IPOPT_LSRR 138# undef IPOPT_RR 139# undef IPOPT_SSRR 140# ifndef KERNEL 141# define _KERNEL 142# undef RES_INIT 143# if SOLARIS2 >= 8 144# include <netinet/ip6.h> 145# endif 146# include <inet/common.h> 147# include <inet/ip.h> 148# include <inet/ip_ire.h> 149# undef _KERNEL 150# else /* _KERNEL */ 151# if SOLARIS2 >= 8 152# include <netinet/ip6.h> 153# endif 154# include <inet/common.h> 155# include <inet/ip.h> 156# include <inet/ip_ire.h> 157# endif /* _KERNEL */ 158# if SOLARIS2 >= 8 159# include <inet/ip_if.h> 160# include <netinet/ip6.h> 161# define ipif_local_addr ipif_lcl_addr 162/* Only defined in private include file */ 163# ifndef V4_PART_OF_V6 164# define V4_PART_OF_V6(v6) v6.s6_addr32[3] 165# endif 166# endif 167 168typedef struct qif { 169 struct qif *qf_next; 170 ill_t *qf_ill; 171 kmutex_t qf_lock; 172 void *qf_iptr; 173 void *qf_optr; 174 queue_t *qf_in; 175 queue_t *qf_out; 176 struct qinit *qf_wqinfo; 177 struct qinit *qf_rqinfo; 178 struct qinit qf_wqinit; 179 struct qinit qf_rqinit; 180 mblk_t *qf_m; /* These three fields are for passing data up from */ 181 queue_t *qf_q; /* fr_qin and fr_qout to the packet processing. */ 182 size_t qf_off; 183 size_t qf_len; /* this field is used for in ipfr_fastroute */ 184 char qf_name[LIFNAMSIZ]; 185 /* 186 * in case the ILL has disappeared... 187 */ 188 size_t qf_hl; /* header length */ 189 int qf_sap; 190 size_t qf_incnt; 191 size_t qf_outcnt; 192} qif_t; 193#else /* SOLARIS */ 194# if !defined(__sgi) 195typedef int minor_t; 196# endif 197#endif /* SOLARIS */ 198#define IPMINLEN(i, h) ((i)->ip_len >= ((i)->ip_hl * 4 + sizeof(struct h))) 199
|
201#if defined(__FreeBSD__) && (__FreeBSD__ >= 5) && defined(_KERNEL)
202# include <machine/in_cksum.h>
203#endif
204
|
200#ifndef IP_OFFMASK 201#define IP_OFFMASK 0x1fff 202#endif 203 204#if BSD > 199306 205# define USE_QUAD_T 206# define U_QUAD_T u_quad_t 207# define QUAD_T quad_t 208#else /* BSD > 199306 */ 209# define U_QUAD_T u_long 210# define QUAD_T long 211#endif /* BSD > 199306 */ 212 213
|
214#if defined(__FreeBSD__) && (defined(KERNEL) || defined(_KERNEL)) 215# include <sys/param.h> 216# ifndef __FreeBSD_version 217# include <sys/osreldate.h> 218# endif 219# ifdef IPFILTER_LKM 220# define ACTUALLY_LKM_NOT_KERNEL 221# endif 222# if defined(__FreeBSD_version) && (__FreeBSD_version < 300000) 223# include <machine/spl.h> 224# else 225# if (__FreeBSD_version >= 300000) && (__FreeBSD_version < 400000) 226# if defined(IPFILTER_LKM) && !defined(ACTUALLY_LKM_NOT_KERNEL) 227# define ACTUALLY_LKM_NOT_KERNEL 228# endif 229# endif 230# endif 231#endif /* __FreeBSD__ && KERNEL */ 232 233#if defined(__FreeBSD_version) && (__FreeBSD_version >= 500000) && \ 234 defined(_KERNEL) 235# include <machine/in_cksum.h> 236#endif 237 |
238/* 239 * These operating systems already take care of the problem for us. 240 */ 241#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || \ 242 defined(__sgi) 243typedef u_int32_t u_32_t; 244# if defined(_KERNEL) && !defined(IPFILTER_LKM) 245# if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 104110000) 246# include "opt_inet.h" 247# endif 248# if defined(__FreeBSD_version) && (__FreeBSD_version >= 400000) && \ 249 !defined(KLD_MODULE) 250# include "opt_inet6.h" 251# endif 252# ifdef INET6
|
253# define USE_INET6 254# endif 255# endif 256# if !defined(_KERNEL) && !defined(IPFILTER_LKM) 257# if (defined(__FreeBSD_version) && (__FreeBSD_version >= 400000)) || \ 258 (defined(OpenBSD) && (OpenBSD >= 200111)) || \ 259 (defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 105000000)) |
260# define USE_INET6 261# endif 262# endif 263#else 264/* 265 * Really, any arch where sizeof(long) != sizeof(int). 266 */ 267# if defined(__alpha__) || defined(__alpha) || defined(_LP64) 268typedef unsigned int u_32_t; 269# else 270# if SOLARIS2 >= 6 271typedef uint32_t u_32_t; 272# else 273typedef unsigned int u_32_t; 274# endif 275# endif 276#endif /* __NetBSD__ || __OpenBSD__ || __FreeBSD__ || __sgi */ 277 278#ifdef USE_INET6 279# if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) 280# include <netinet/ip6.h> 281# ifdef _KERNEL 282# include <netinet6/ip6_var.h> 283# endif 284typedef struct ip6_hdr ip6_t; 285# endif 286# include <netinet/icmp6.h> 287union i6addr { 288 u_32_t i6[4]; 289 struct in_addr in4; 290 struct in6_addr in6; 291}; 292#else 293union i6addr { 294 u_32_t i6[4]; 295 struct in_addr in4; 296}; 297#endif 298 299#define IP6CMP(a,b) bcmp((char *)&(a), (char *)&(b), sizeof(a)) 300#define IP6EQ(a,b) (bcmp((char *)&(a), (char *)&(b), sizeof(a)) == 0) 301#define IP6NEQ(a,b) (bcmp((char *)&(a), (char *)&(b), sizeof(a)) != 0) 302#define IP6_ISZERO(a) ((((union i6addr *)(a))->i6[0] | \ 303 ((union i6addr *)(a))->i6[1] | \ 304 ((union i6addr *)(a))->i6[2] | \ 305 ((union i6addr *)(a))->i6[3]) == 0) 306#define IP6_NOTZERO(a) ((((union i6addr *)(a))->i6[0] | \ 307 ((union i6addr *)(a))->i6[1] | \ 308 ((union i6addr *)(a))->i6[2] | \ 309 ((union i6addr *)(a))->i6[3]) != 0) 310 311#ifndef MAX 312#define MAX(a,b) (((a) > (b)) ? (a) : (b)) 313#endif 314 315/* 316 * Security Options for Intenet Protocol (IPSO) as defined in RFC 1108. 317 * 318 * Basic Option 319 * 320 * 00000001 - (Reserved 4) 321 * 00111101 - Top Secret 322 * 01011010 - Secret 323 * 10010110 - Confidential 324 * 01100110 - (Reserved 3) 325 * 11001100 - (Reserved 2) 326 * 10101011 - Unclassified 327 * 11110001 - (Reserved 1) 328 */ 329#define IPSO_CLASS_RES4 0x01 330#define IPSO_CLASS_TOPS 0x3d 331#define IPSO_CLASS_SECR 0x5a 332#define IPSO_CLASS_CONF 0x96 333#define IPSO_CLASS_RES3 0x66 334#define IPSO_CLASS_RES2 0xcc 335#define IPSO_CLASS_UNCL 0xab 336#define IPSO_CLASS_RES1 0xf1 337 338#define IPSO_AUTH_GENSER 0x80 339#define IPSO_AUTH_ESI 0x40 340#define IPSO_AUTH_SCI 0x20 341#define IPSO_AUTH_NSA 0x10 342#define IPSO_AUTH_DOE 0x08 343#define IPSO_AUTH_UN 0x06 344#define IPSO_AUTH_FTE 0x01 345 346/* 347 * IP option #defines 348 */ 349/*#define IPOPT_RR 7 */ 350#define IPOPT_ZSU 10 /* ZSU */ 351#define IPOPT_MTUP 11 /* MTUP */ 352#define IPOPT_MTUR 12 /* MTUR */ 353#define IPOPT_ENCODE 15 /* ENCODE */ 354/*#define IPOPT_TS 68 */ 355#define IPOPT_TR 82 /* TR */ 356/*#define IPOPT_SECURITY 130 */ 357/*#define IPOPT_LSRR 131 */ 358#define IPOPT_E_SEC 133 /* E-SEC */ 359#define IPOPT_CIPSO 134 /* CIPSO */ 360/*#define IPOPT_SATID 136 */ 361#ifndef IPOPT_SID 362# define IPOPT_SID IPOPT_SATID 363#endif 364/*#define IPOPT_SSRR 137 */ 365#define IPOPT_ADDEXT 147 /* ADDEXT */ 366#define IPOPT_VISA 142 /* VISA */ 367#define IPOPT_IMITD 144 /* IMITD */ 368#define IPOPT_EIP 145 /* EIP */ 369#define IPOPT_FINN 205 /* FINN */ 370
|
371#ifndef TCPOPT_WSCALE 372# define TCPOPT_WSCALE 3 373#endif |
374
|
346#if defined(__FreeBSD__) && (defined(KERNEL) || defined(_KERNEL))
347# ifdef IPFILTER_LKM
348# ifndef __FreeBSD_cc_version
349# include <osreldate.h>
350# else
351# if __FreeBSD_cc_version < 430000
352# include <osreldate.h>
353# else
354# include <sys/param.h>
355# endif
356# endif
357# define ACTUALLY_LKM_NOT_KERNEL
358# else
359# ifndef __FreeBSD_cc_version
360# include <sys/osreldate.h>
361# else
362# if __FreeBSD_cc_version < 430000
363# include <sys/osreldate.h>
364# else
365# include <sys/param.h>
366# endif
367# endif
368# endif
369# if __FreeBSD__ < 3
370# include <machine/spl.h>
371# else
372# if __FreeBSD__ == 3
373# if defined(IPFILTER_LKM) && !defined(ACTUALLY_LKM_NOT_KERNEL)
374# define ACTUALLY_LKM_NOT_KERNEL
375# endif
376# endif
377# endif
378#endif /* __FreeBSD__ && KERNEL */
379
|
375/* 376 * Build some macros and #defines to enable the same code to compile anywhere 377 * Well, that's the idea, anyway :-) 378 */ 379#if SOLARIS 380typedef mblk_t mb_t; 381# if SOLARIS2 >= 7 382# ifdef lint 383# define ALIGN32(ptr) (ptr ? 0L : 0L) 384# define ALIGN16(ptr) (ptr ? 0L : 0L) 385# else 386# define ALIGN32(ptr) (ptr) 387# define ALIGN16(ptr) (ptr) 388# endif 389# endif 390#else 391typedef struct mbuf mb_t; 392#endif /* SOLARIS */ 393 394#if !SOLARIS || (SOLARIS2 < 6) || !defined(KERNEL) 395# define ATOMIC_INCL ATOMIC_INC 396# define ATOMIC_INC64 ATOMIC_INC 397# define ATOMIC_INC32 ATOMIC_INC 398# define ATOMIC_INC16 ATOMIC_INC 399# define ATOMIC_DECL ATOMIC_DEC 400# define ATOMIC_DEC64 ATOMIC_DEC 401# define ATOMIC_DEC32 ATOMIC_DEC 402# define ATOMIC_DEC16 ATOMIC_DEC 403#endif 404#ifdef __sgi 405# define hz HZ 406# include <sys/ksynch.h> 407# define IPF_LOCK_PL plhi 408# include <sys/sema.h> 409#undef kmutex_t 410typedef struct { 411 lock_t *l; 412 int pl; 413} kmutex_t; 414# undef MUTEX_INIT 415# undef MUTEX_DESTROY 416#endif 417#ifdef KERNEL 418# if SOLARIS 419# if SOLARIS2 >= 6 420# include <sys/atomic.h> 421# if SOLARIS2 == 6 422# define ATOMIC_INCL(x) atomic_add_long((uint32_t*)&(x), 1) 423# define ATOMIC_DECL(x) atomic_add_long((uint32_t*)&(x), -1) 424# else 425# define ATOMIC_INCL(x) atomic_add_long(&(x), 1) 426# define ATOMIC_DECL(x) atomic_add_long(&(x), -1) 427# endif 428# define ATOMIC_INC64(x) atomic_add_64((uint64_t*)&(x), 1) 429# define ATOMIC_INC32(x) atomic_add_32((uint32_t*)&(x), 1) 430# define ATOMIC_INC16(x) atomic_add_16((uint16_t*)&(x), 1) 431# define ATOMIC_DEC64(x) atomic_add_64((uint64_t*)&(x), -1) 432# define ATOMIC_DEC32(x) atomic_add_32((uint32_t*)&(x), -1) 433# define ATOMIC_DEC16(x) atomic_add_16((uint16_t*)&(x), -1) 434# else 435# define IRE_CACHE IRE_ROUTE 436# define ATOMIC_INC(x) { mutex_enter(&ipf_rw); (x)++; \ 437 mutex_exit(&ipf_rw); } 438# define ATOMIC_DEC(x) { mutex_enter(&ipf_rw); (x)--; \ 439 mutex_exit(&ipf_rw); } 440# endif 441# define MUTEX_ENTER(x) mutex_enter(x) 442# if 1 443# define KRWLOCK_T krwlock_t 444# define READ_ENTER(x) rw_enter(x, RW_READER) 445# define WRITE_ENTER(x) rw_enter(x, RW_WRITER) 446# define RW_UPGRADE(x) { if (rw_tryupgrade(x) == 0) { \ 447 rw_exit(x); \ 448 rw_enter(x, RW_WRITER); } \ 449 } 450# define MUTEX_DOWNGRADE(x) rw_downgrade(x) 451# define RWLOCK_INIT(x, y, z) rw_init((x), (y), RW_DRIVER, (z)) 452# define RWLOCK_EXIT(x) rw_exit(x) 453# define RW_DESTROY(x) rw_destroy(x) 454# else 455# define KRWLOCK_T kmutex_t 456# define READ_ENTER(x) mutex_enter(x) 457# define WRITE_ENTER(x) mutex_enter(x) 458# define MUTEX_DOWNGRADE(x) ; 459# define RWLOCK_INIT(x, y, z) mutex_init((x), (y), MUTEX_DRIVER, (z)) 460# define RWLOCK_EXIT(x) mutex_exit(x) 461# define RW_DESTROY(x) mutex_destroy(x) 462# endif 463# define MUTEX_INIT(x, y, z) mutex_init((x), (y), MUTEX_DRIVER, (z)) 464# define MUTEX_DESTROY(x) mutex_destroy(x) 465# define MUTEX_EXIT(x) mutex_exit(x) 466# define MTOD(m,t) (t)((m)->b_rptr) 467# define IRCOPY(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c)) 468# define IWCOPY(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c)) 469# define IRCOPYPTR ircopyptr 470# define IWCOPYPTR iwcopyptr 471# define FREE_MB_T(m) freemsg(m) 472# define SPL_NET(x) ; 473# define SPL_IMP(x) ; 474# undef SPL_X 475# define SPL_X(x) ; 476# ifdef sparc 477# define ntohs(x) (x) 478# define ntohl(x) (x) 479# define htons(x) (x) 480# define htonl(x) (x) 481# endif /* sparc */ 482# define KMALLOC(a,b) (a) = (b)kmem_alloc(sizeof(*(a)), KM_NOSLEEP) 483# define KMALLOCS(a,b,c) (a) = (b)kmem_alloc((c), KM_NOSLEEP) 484# define GET_MINOR(x) getminor(x) 485extern ill_t *get_unit __P((char *, int)); 486# define GETUNIT(n, v) get_unit(n, v) 487# define IFNAME(x) ((ill_t *)x)->ill_name 488# else /* SOLARIS */ 489# if defined(__sgi) 490# define ATOMIC_INC(x) { MUTEX_ENTER(&ipf_rw); \ 491 (x)++; MUTEX_EXIT(&ipf_rw); } 492# define ATOMIC_DEC(x) { MUTEX_ENTER(&ipf_rw); \ 493 (x)--; MUTEX_EXIT(&ipf_rw); } 494# define MUTEX_ENTER(x) (x)->pl = LOCK((x)->l, IPF_LOCK_PL); 495# define KRWLOCK_T kmutex_t 496# define READ_ENTER(x) MUTEX_ENTER(x) 497# define WRITE_ENTER(x) MUTEX_ENTER(x) 498# define RW_UPGRADE(x) ; 499# define MUTEX_DOWNGRADE(x) ; 500# define RWLOCK_EXIT(x) MUTEX_EXIT(x) 501# define MUTEX_EXIT(x) UNLOCK((x)->l, (x)->pl); 502# define MUTEX_INIT(x,y,z) (x)->l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP) 503# define MUTEX_DESTROY(x) LOCK_DEALLOC((x)->l) 504# else /* __sgi */ 505# define ATOMIC_INC(x) (x)++ 506# define ATOMIC_DEC(x) (x)-- 507# define MUTEX_ENTER(x) ; 508# define READ_ENTER(x) ; 509# define WRITE_ENTER(x) ; 510# define RW_UPGRADE(x) ; 511# define MUTEX_DOWNGRADE(x) ; 512# define RWLOCK_EXIT(x) ; 513# define MUTEX_EXIT(x) ; 514# define MUTEX_INIT(x,y,z) ; 515# define MUTEX_DESTROY(x) ; 516# endif /* __sgi */ 517# ifndef linux 518# define FREE_MB_T(m) m_freem(m) 519# define MTOD(m,t) mtod(m,t) 520# define IRCOPY(a,b,c) (bcopy((a), (b), (c)), 0) 521# define IWCOPY(a,b,c) (bcopy((a), (b), (c)), 0) 522# define IRCOPYPTR ircopyptr 523# define IWCOPYPTR iwcopyptr 524# endif /* !linux */ 525# endif /* SOLARIS */ 526 527# ifdef sun 528# if !SOLARIS 529# include <sys/kmem_alloc.h> 530# define GETUNIT(n, v) ifunit(n, IFNAMSIZ) 531# define IFNAME(x) ((struct ifnet *)x)->if_name 532# endif 533# else 534# ifndef linux 535# define GETUNIT(n, v) ifunit(n) 536# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \ 537 (defined(OpenBSD) && (OpenBSD >= 199603)) 538# define IFNAME(x) ((struct ifnet *)x)->if_xname 539# else 540# define USE_GETIFNAME 1 541# define IFNAME(x) get_ifname((struct ifnet *)x) 542extern char *get_ifname __P((struct ifnet *)); 543# endif 544# endif 545# endif /* sun */ 546 547# if defined(sun) && !defined(linux) || defined(__sgi) 548# define UIOMOVE(a,b,c,d) uiomove((caddr_t)a,b,c,d) 549# define SLEEP(id, n) sleep((id), PZERO+1) 550# define WAKEUP(id) wakeup(id) 551# define KFREE(x) kmem_free((char *)(x), sizeof(*(x))) 552# define KFREES(x,s) kmem_free((char *)(x), (s)) 553# if !SOLARIS 554extern void m_copydata __P((struct mbuf *, int, int, caddr_t)); 555extern void m_copyback __P((struct mbuf *, int, int, caddr_t)); 556# endif 557# ifdef __sgi 558# include <sys/kmem.h> 559# include <sys/ddi.h> 560# define KMALLOC(a,b) (a) = (b)kmem_alloc(sizeof(*(a)), KM_NOSLEEP) 561# define KMALLOCS(a,b,c) (a) = (b)kmem_alloc((c), KM_NOSLEEP) 562# define GET_MINOR(x) getminor(x) 563# else 564# if !SOLARIS 565# define KMALLOC(a,b) (a) = (b)new_kmem_alloc(sizeof(*(a)), \ 566 KMEM_NOSLEEP) 567# define KMALLOCS(a,b,c) (a) = (b)new_kmem_alloc((c), KMEM_NOSLEEP) 568# endif /* SOLARIS */ 569# endif /* __sgi */ 570# endif /* sun && !linux */ 571# ifndef GET_MINOR 572# define GET_MINOR(x) minor(x) 573# endif 574# if (BSD >= 199306) || defined(__FreeBSD__) 575# if (defined(__NetBSD_Version__) && (__NetBSD_Version__ < 105180000)) || \ 576 defined(__FreeBSD__) || defined(__OpenBSD__) || defined(_BSDI_VERSION) 577# include <vm/vm.h> 578# endif
|
584# if !defined(__FreeBSD__) || (defined (__FreeBSD__) && __FreeBSD__>=3)
|
579# if !defined(__FreeBSD__) || (defined (__FreeBSD_version) && \ 580 (__FreeBSD_version >= 300000)) |
581# if (defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 105180000)) || \ 582 (defined(OpenBSD) && (OpenBSD >= 200111)) 583# include <uvm/uvm_extern.h> 584# else 585# include <vm/vm_extern.h> 586extern vm_map_t kmem_map; 587# endif 588# include <sys/proc.h>
|
593# else /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD__>=3) */
|
589# else /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */ |
590# include <vm/vm_kern.h>
|
595# endif /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD__>=3) */
|
591# endif /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */ |
592# ifdef M_PFIL 593# define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), M_PFIL, M_NOWAIT) 594# define KMALLOCS(a, b, c) MALLOC((a), b, (c), M_PFIL, M_NOWAIT) 595# define KFREE(x) FREE((x), M_PFIL) 596# define KFREES(x,s) FREE((x), M_PFIL) 597# else 598# define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), M_TEMP, M_NOWAIT) 599# define KMALLOCS(a, b, c) MALLOC((a), b, (c), M_TEMP, M_NOWAIT) 600# define KFREE(x) FREE((x), M_TEMP) 601# define KFREES(x,s) FREE((x), M_TEMP) 602# endif /* M_PFIL */ 603# define UIOMOVE(a,b,c,d) uiomove(a,b,d) 604# define SLEEP(id, n) tsleep((id), PPAUSE|PCATCH, n, 0) 605# define WAKEUP(id) wakeup(id) 606# endif /* BSD */ 607# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199407)) || \ 608 (defined(OpenBSD) && (OpenBSD >= 200006)) 609# define SPL_NET(x) x = splsoftnet() 610# define SPL_X(x) (void) splx(x) 611# else 612# if !SOLARIS && !defined(linux) 613# define SPL_IMP(x) x = splimp() 614# define SPL_NET(x) x = splnet() 615# define SPL_X(x) (void) splx(x) 616# endif 617# endif /* NetBSD && (NetBSD <= 1991011) && (NetBSD >= 199407) */ 618# define PANIC(x,y) if (x) panic y 619#else /* KERNEL */ 620# define SLEEP(x,y) 1 621# define WAKEUP(x) ; 622# define PANIC(x,y) ; 623# define ATOMIC_INC(x) (x)++ 624# define ATOMIC_DEC(x) (x)-- 625# define MUTEX_ENTER(x) ; 626# define READ_ENTER(x) ; 627# define MUTEX_INIT(x,y,z) ; 628# define MUTEX_DESTROY(x) ; 629# define WRITE_ENTER(x) ; 630# define RW_UPGRADE(x) ; 631# define MUTEX_DOWNGRADE(x) ; 632# define RWLOCK_EXIT(x) ; 633# define MUTEX_EXIT(x) ; 634# define SPL_NET(x) ; 635# define SPL_IMP(x) ; 636# undef SPL_X 637# define SPL_X(x) ; 638# define KMALLOC(a,b) (a) = (b)malloc(sizeof(*a)) 639# define KMALLOCS(a,b,c) (a) = (b)malloc(c) 640# define KFREE(x) free(x) 641# define KFREES(x,s) free(x) 642# define FREE_MB_T(x) ; 643# define GETUNIT(x, v) get_unit(x,v) 644# define IRCOPY(a,b,c) (bcopy((a), (b), (c)), 0) 645# define IWCOPY(a,b,c) (bcopy((a), (b), (c)), 0) 646# define IRCOPYPTR ircopyptr 647# define IWCOPYPTR iwcopyptr 648# define IFNAME(x) get_ifname((struct ifnet *)x) 649# define UIOMOVE(a,b,c,d) ipfuiomove(a,b,c,d) 650extern void m_copydata __P((mb_t *, int, int, caddr_t)); 651extern int ipfuiomove __P((caddr_t, int, int, struct uio *)); 652#endif /* KERNEL */ 653 654/* 655 * These #ifdef's are here mainly for linux, but who knows, they may 656 * not be in other places or maybe one day linux will grow up and some 657 * of these will turn up there too. 658 */ 659#ifndef ICMP_MINLEN 660# define ICMP_MINLEN 8 661#endif 662#ifndef ICMP_ECHOREPLY 663# define ICMP_ECHOREPLY 0 664#endif 665#ifndef ICMP_UNREACH 666# define ICMP_UNREACH 3 667#endif 668#ifndef ICMP_UNREACH_NET 669# define ICMP_UNREACH_NET 0 670#endif 671#ifndef ICMP_UNREACH_HOST 672# define ICMP_UNREACH_HOST 1 673#endif 674#ifndef ICMP_UNREACH_PROTOCOL 675# define ICMP_UNREACH_PROTOCOL 2 676#endif 677#ifndef ICMP_UNREACH_PORT 678# define ICMP_UNREACH_PORT 3 679#endif 680#ifndef ICMP_UNREACH_NEEDFRAG 681# define ICMP_UNREACH_NEEDFRAG 4 682#endif 683#ifndef ICMP_UNREACH_SRCFAIL 684# define ICMP_UNREACH_SRCFAIL 5 685#endif 686#ifndef ICMP_UNREACH_NET_UNKNOWN 687# define ICMP_UNREACH_NET_UNKNOWN 6 688#endif 689#ifndef ICMP_UNREACH_HOST_UNKNOWN 690# define ICMP_UNREACH_HOST_UNKNOWN 7 691#endif 692#ifndef ICMP_UNREACH_ISOLATED 693# define ICMP_UNREACH_ISOLATED 8 694#endif 695#ifndef ICMP_UNREACH_NET_PROHIB 696# define ICMP_UNREACH_NET_PROHIB 9 697#endif 698#ifndef ICMP_UNREACH_HOST_PROHIB 699# define ICMP_UNREACH_HOST_PROHIB 10 700#endif 701#ifndef ICMP_UNREACH_TOSNET 702# define ICMP_UNREACH_TOSNET 11 703#endif 704#ifndef ICMP_UNREACH_TOSHOST 705# define ICMP_UNREACH_TOSHOST 12 706#endif 707#ifndef ICMP_UNREACH_ADMIN_PROHIBIT 708# define ICMP_UNREACH_ADMIN_PROHIBIT 13 709#endif 710#ifndef ICMP_UNREACH_HOST_PRECEDENCE 711# define ICMP_UNREACH_HOST_PRECEDENCE 14 712#endif 713#ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF 714# define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 715#endif 716#ifndef ICMP_SOURCEQUENCH 717# define ICMP_SOURCEQUENCH 4 718#endif 719#ifndef ICMP_REDIRECT_NET 720# define ICMP_REDIRECT_NET 0 721#endif 722#ifndef ICMP_REDIRECT_HOST 723# define ICMP_REDIRECT_HOST 1 724#endif 725#ifndef ICMP_REDIRECT_TOSNET 726# define ICMP_REDIRECT_TOSNET 2 727#endif 728#ifndef ICMP_REDIRECT_TOSHOST 729# define ICMP_REDIRECT_TOSHOST 3 730#endif 731#ifndef ICMP_ALTHOSTADDR 732# define ICMP_ALTHOSTADDR 6 733#endif 734#ifndef ICMP_TIMXCEED 735# define ICMP_TIMXCEED 11 736#endif 737#ifndef ICMP_TIMXCEED_INTRANS 738# define ICMP_TIMXCEED_INTRANS 0 739#endif 740#ifndef ICMP_TIMXCEED_REASS 741# define ICMP_TIMXCEED_REASS 1 742#endif 743#ifndef ICMP_PARAMPROB 744# define ICMP_PARAMPROB 12 745#endif 746#ifndef ICMP_PARAMPROB_ERRATPTR 747# define ICMP_PARAMPROB_ERRATPTR 0 748#endif 749#ifndef ICMP_PARAMPROB_OPTABSENT 750# define ICMP_PARAMPROB_OPTABSENT 1 751#endif 752#ifndef ICMP_PARAMPROB_LENGTH 753# define ICMP_PARAMPROB_LENGTH 2 754#endif 755#ifndef ICMP_TSTAMP 756# define ICMP_TSTAMP 13 757#endif 758#ifndef ICMP_TSTAMPREPLY 759# define ICMP_TSTAMPREPLY 14 760#endif 761#ifndef ICMP_IREQ 762# define ICMP_IREQ 15 763#endif 764#ifndef ICMP_IREQREPLY 765# define ICMP_IREQREPLY 16 766#endif 767#ifndef ICMP_MASKREQ 768# define ICMP_MASKREQ 17 769#endif 770#ifndef ICMP_MASKREPLY 771# define ICMP_MASKREPLY 18 772#endif 773#ifndef ICMP_TRACEROUTE 774# define ICMP_TRACEROUTE 30 775#endif 776#ifndef ICMP_DATACONVERR 777# define ICMP_DATACONVERR 31 778#endif 779#ifndef ICMP_MOBILE_REDIRECT 780# define ICMP_MOBILE_REDIRECT 32 781#endif 782#ifndef ICMP_IPV6_WHEREAREYOU 783# define ICMP_IPV6_WHEREAREYOU 33 784#endif 785#ifndef ICMP_IPV6_IAMHERE 786# define ICMP_IPV6_IAMHERE 34 787#endif 788#ifndef ICMP_MOBILE_REGREQUEST 789# define ICMP_MOBILE_REGREQUEST 35 790#endif 791#ifndef ICMP_MOBILE_REGREPLY 792# define ICMP_MOBILE_REGREPLY 36 793#endif 794#ifndef ICMP_SKIP 795# define ICMP_SKIP 39 796#endif 797#ifndef ICMP_PHOTURIS 798# define ICMP_PHOTURIS 40 799#endif 800#ifndef ICMP_PHOTURIS_UNKNOWN_INDEX 801# define ICMP_PHOTURIS_UNKNOWN_INDEX 1 802#endif 803#ifndef ICMP_PHOTURIS_AUTH_FAILED 804# define ICMP_PHOTURIS_AUTH_FAILED 2 805#endif 806#ifndef ICMP_PHOTURIS_DECRYPT_FAILED 807# define ICMP_PHOTURIS_DECRYPT_FAILED 3 808#endif 809#ifndef IPVERSION 810# define IPVERSION 4 811#endif 812#ifndef IPOPT_MINOFF 813# define IPOPT_MINOFF 4 814#endif 815#ifndef IPOPT_COPIED 816# define IPOPT_COPIED(x) ((x)&0x80) 817#endif 818#ifndef IPOPT_EOL 819# define IPOPT_EOL 0 820#endif 821#ifndef IPOPT_NOP 822# define IPOPT_NOP 1 823#endif 824#ifndef IP_MF 825# define IP_MF ((u_short)0x2000) 826#endif 827#ifndef ETHERTYPE_IP 828# define ETHERTYPE_IP ((u_short)0x0800) 829#endif 830#ifndef TH_FIN 831# define TH_FIN 0x01 832#endif 833#ifndef TH_SYN 834# define TH_SYN 0x02 835#endif 836#ifndef TH_RST 837# define TH_RST 0x04 838#endif 839#ifndef TH_PUSH 840# define TH_PUSH 0x08 841#endif 842#ifndef TH_ACK 843# define TH_ACK 0x10 844#endif 845#ifndef TH_URG 846# define TH_URG 0x20 847#endif 848#ifndef IPOPT_EOL 849# define IPOPT_EOL 0 850#endif 851#ifndef IPOPT_NOP 852# define IPOPT_NOP 1 853#endif 854#ifndef IPOPT_RR 855# define IPOPT_RR 7 856#endif 857#ifndef IPOPT_TS 858# define IPOPT_TS 68 859#endif 860#ifndef IPOPT_SECURITY 861# define IPOPT_SECURITY 130 862#endif 863#ifndef IPOPT_LSRR 864# define IPOPT_LSRR 131 865#endif 866#ifndef IPOPT_SATID 867# define IPOPT_SATID 136 868#endif 869#ifndef IPOPT_SSRR 870# define IPOPT_SSRR 137 871#endif 872#ifndef IPOPT_SECUR_UNCLASS 873# define IPOPT_SECUR_UNCLASS ((u_short)0x0000) 874#endif 875#ifndef IPOPT_SECUR_CONFID 876# define IPOPT_SECUR_CONFID ((u_short)0xf135) 877#endif 878#ifndef IPOPT_SECUR_EFTO 879# define IPOPT_SECUR_EFTO ((u_short)0x789a) 880#endif 881#ifndef IPOPT_SECUR_MMMM 882# define IPOPT_SECUR_MMMM ((u_short)0xbc4d) 883#endif 884#ifndef IPOPT_SECUR_RESTR 885# define IPOPT_SECUR_RESTR ((u_short)0xaf13) 886#endif 887#ifndef IPOPT_SECUR_SECRET 888# define IPOPT_SECUR_SECRET ((u_short)0xd788) 889#endif 890#ifndef IPOPT_SECUR_TOPSECRET 891# define IPOPT_SECUR_TOPSECRET ((u_short)0x6bc5) 892#endif 893#ifndef IPOPT_OLEN 894# define IPOPT_OLEN 1 895#endif 896#ifndef IPPROTO_GRE 897# define IPPROTO_GRE 47 /* GRE encaps RFC 1701 */ 898#endif 899#ifndef IPPROTO_ESP 900# define IPPROTO_ESP 50 901#endif 902#ifndef IPPROTO_ICMPV6 903# define IPPROTO_ICMPV6 58 904#endif 905 906#ifdef linux 907#include <linux/in_systm.h> 908/* 909 * TCP States 910 */ 911#define TCPS_CLOSED 0 /* closed */ 912#define TCPS_LISTEN 1 /* listening for connection */ 913#define TCPS_SYN_SENT 2 /* active, have sent syn */ 914#define TCPS_SYN_RECEIVED 3 /* have send and received syn */ 915/* states < TCPS_ESTABLISHED are those where connections not established */ 916#define TCPS_ESTABLISHED 4 /* established */ 917#define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */ 918/* states > TCPS_CLOSE_WAIT are those where user has closed */ 919#define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */ 920#define TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */ 921#define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */ 922/* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ 923#define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ 924#define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ 925 926/* 927 * file flags. 928 */ 929#ifdef WRITE 930#define FWRITE WRITE 931#define FREAD READ 932#else 933#define FWRITE _IOC_WRITE 934#define FREAD _IOC_READ 935#endif 936/* 937 * mbuf related problems. 938 */ 939#define mtod(m,t) (t)((m)->data) 940#define m_len len 941#define m_next next 942 943#ifdef IP_DF 944#undef IP_DF 945#endif 946#define IP_DF 0x4000 947 948typedef struct { 949 __u16 th_sport; 950 __u16 th_dport; 951 __u32 th_seq; 952 __u32 th_ack; 953# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\ 954 defined(vax) 955 __u8 th_res:4; 956 __u8 th_off:4; 957#else 958 __u8 th_off:4; 959 __u8 th_res:4; 960#endif 961 __u8 th_flags; 962 __u16 th_win; 963 __u16 th_sum; 964 __u16 th_urp; 965} tcphdr_t; 966 967typedef struct { 968 __u16 uh_sport; 969 __u16 uh_dport; 970 __u16 uh_ulen; 971 __u16 uh_sum; 972} udphdr_t; 973 974typedef struct { 975# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\ 976 defined(vax) 977 __u8 ip_hl:4; 978 __u8 ip_v:4; 979# else 980 __u8 ip_v:4; 981 __u8 ip_hl:4; 982# endif 983 __u8 ip_tos; 984 __u16 ip_len; 985 __u16 ip_id; 986 __u16 ip_off; 987 __u8 ip_ttl; 988 __u8 ip_p; 989 __u16 ip_sum; 990 struct in_addr ip_src; 991 struct in_addr ip_dst; 992} ip_t; 993 994/* 995 * Structure of an icmp header. 996 */ 997typedef struct icmp { 998 __u8 icmp_type; /* type of message, see below */ 999 __u8 icmp_code; /* type sub code */ 1000 __u16 icmp_cksum; /* ones complement cksum of struct */ 1001 union { 1002 __u8 ih_pptr; /* ICMP_PARAMPROB */ 1003 struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ 1004 struct ih_idseq { 1005 __u16 icd_id; 1006 __u16 icd_seq; 1007 } ih_idseq; 1008 int ih_void; 1009 } icmp_hun; 1010# define icmp_pptr icmp_hun.ih_pptr 1011# define icmp_gwaddr icmp_hun.ih_gwaddr 1012# define icmp_id icmp_hun.ih_idseq.icd_id 1013# define icmp_seq icmp_hun.ih_idseq.icd_seq 1014# define icmp_void icmp_hun.ih_void 1015 union { 1016 struct id_ts { 1017 n_time its_otime; 1018 n_time its_rtime; 1019 n_time its_ttime; 1020 } id_ts; 1021 struct id_ip { 1022 ip_t idi_ip; 1023 /* options and then 64 bits of data */ 1024 } id_ip; 1025 u_long id_mask; 1026 char id_data[1]; 1027 } icmp_dun; 1028# define icmp_otime icmp_dun.id_ts.its_otime 1029# define icmp_rtime icmp_dun.id_ts.its_rtime 1030# define icmp_ttime icmp_dun.id_ts.its_ttime 1031# define icmp_ip icmp_dun.id_ip.idi_ip 1032# define icmp_mask icmp_dun.id_mask 1033# define icmp_data icmp_dun.id_data 1034} icmphdr_t; 1035 1036# ifndef LINUX_IPOVLY 1037# define LINUX_IPOVLY 1038struct ipovly { 1039 caddr_t ih_next, ih_prev; /* for protocol sequence q's */ 1040 u_char ih_x1; /* (unused) */ 1041 u_char ih_pr; /* protocol */ 1042 short ih_len; /* protocol length */ 1043 struct in_addr ih_src; /* source internet address */ 1044 struct in_addr ih_dst; /* destination internet address */ 1045}; 1046# endif 1047 1048typedef struct { 1049 __u8 ether_dhost[6]; 1050 __u8 ether_shost[6]; 1051 __u16 ether_type; 1052} ether_header_t; 1053 1054typedef struct uio { 1055 int uio_resid; 1056 int uio_rw; 1057 caddr_t uio_buf; 1058} uio_t; 1059 1060# define UIO_READ 0 1061# define UIO_WRITE 1 1062# define UIOMOVE(a, b, c, d) uiomove(a,b,c,d) 1063 1064/* 1065 * For masking struct ifnet onto struct device 1066 */ 1067# define if_name name 1068 1069# ifdef KERNEL 1070# define GETUNIT(x, v) dev_get(x) 1071# define FREE_MB_T(m) kfree_skb(m, FREE_WRITE) 1072# define uniqtime do_gettimeofday 1073# undef INT_MAX 1074# undef UINT_MAX 1075# undef LONG_MAX 1076# undef ULONG_MAX 1077# include <linux/netdevice.h> 1078# define SPL_X(x) 1079# define SPL_NET(x) 1080# define SPL_IMP(x) 1081 1082# define bcmp(a,b,c) memcmp(a,b,c) 1083# define bcopy(a,b,c) memcpy(b,a,c) 1084# define bzero(a,c) memset(a,0,c) 1085 1086# define UNITNAME(n) dev_get((n)) 1087 1088# define KMALLOC(a,b) (a) = (b)kmalloc(sizeof(*(a)), GFP_ATOMIC) 1089# define KMALLOCS(a,b,c) (a) = (b)kmalloc((c), GFP_ATOMIC) 1090# define KFREE(x) kfree_s((x), sizeof(*(x))) 1091# define KFREES(x,s) kfree_s((x), (s)) 1092#define IRCOPY(const void *a, void *b, size_t c) { \ 1093 int error; \ 1094 1095 error = verify_area(VERIFY_READ, a ,c); \ 1096 if (!error) \ 1097 memcpy_fromfs(b, a, c); \ 1098 return error; \ 1099} 1100static inline int IWCOPY(const void *a, void *b, size_t c) 1101{ 1102 int error; 1103 1104 error = verify_area(VERIFY_WRITE, b, c); 1105 if (!error) 1106 memcpy_tofs(b, a, c); 1107 return error; 1108} 1109static inline int IRCOPYPTR(const void *a, void *b, size_t c) { 1110 caddr_t ca; 1111 int error; 1112 1113 error = verify_area(VERIFY_READ, a ,sizeof(ca)); 1114 if (!error) { 1115 memcpy_fromfs(ca, a, sizeof(ca)); 1116 error = verify_area(VERIFY_READ, ca , c); 1117 if (!error) 1118 memcpy_fromfs(b, ca, c); 1119 } 1120 return error; 1121} 1122static inline int IWCOPYPTR(const void *a, void *b, size_t c) { 1123 caddr_t ca; 1124 int error; 1125 1126 1127 error = verify_area(VERIFY_READ, b ,sizeof(ca)); 1128 if (!error) { 1129 memcpy_fromfs(ca, b, sizeof(ca)); 1130 error = verify_area(VERIFY_WRITE, ca, c); 1131 if (!error) 1132 memcpy_tofs(ca, a, c); 1133 } 1134 return error; 1135} 1136# else 1137# define __KERNEL__ 1138# undef INT_MAX 1139# undef UINT_MAX 1140# undef LONG_MAX 1141# undef ULONG_MAX 1142# define s8 __s8 1143# define u8 __u8 1144# define s16 __s16 1145# define u16 __u16 1146# define s32 __s32 1147# define u32 __u32 1148# include <linux/netdevice.h> 1149# undef __KERNEL__ 1150# endif 1151# define ifnet device 1152#else 1153typedef struct tcphdr tcphdr_t; 1154typedef struct udphdr udphdr_t; 1155typedef struct icmp icmphdr_t; 1156typedef struct ip ip_t; 1157typedef struct ether_header ether_header_t; 1158#endif /* linux */ 1159typedef struct tcpiphdr tcpiphdr_t; 1160 1161#if defined(hpux) || defined(linux) 1162struct ether_addr { 1163 char ether_addr_octet[6]; 1164}; 1165#endif 1166 1167/* 1168 * XXX - This is one of those *awful* hacks which nobody likes 1169 */ 1170#ifdef ultrix 1171#define A_A 1172#else 1173#define A_A & 1174#endif 1175 1176#if (BSD >= 199306) && !defined(m_act) 1177# define m_act m_nextpkt 1178#endif 1179 1180#ifndef ICMP_ROUTERADVERT 1181# define ICMP_ROUTERADVERT 9 1182#endif 1183#ifndef ICMP_ROUTERSOLICIT 1184# define ICMP_ROUTERSOLICIT 10 1185#endif 1186#undef ICMP_MAX_UNREACH 1187#define ICMP_MAX_UNREACH 14 1188#undef ICMP_MAXTYPE 1189#define ICMP_MAXTYPE 18 1190/* 1191 * ICMP error replies have an IP header (20 bytes), 8 bytes of ICMP data, 1192 * another IP header and then 64 bits of data, totalling 56. Of course, 1193 * the last 64 bits is dependant on that being available. 1194 */ 1195#define ICMPERR_ICMPHLEN 8 1196#define ICMPERR_IPICMPHLEN (20 + 8) 1197#define ICMPERR_MINPKTLEN (20 + 8 + 20) 1198#define ICMPERR_MAXPKTLEN (20 + 8 + 20 + 8) 1199#define ICMP6_MINLEN 8 1200#define ICMP6ERR_MINPKTLEN (40 + 8) 1201#define ICMP6ERR_IPICMPHLEN (40 + 8 + 40) 1202 1203#ifndef ICMP6_DST_UNREACH 1204# define ICMP6_DST_UNREACH 1 1205#endif 1206#ifndef ICMP6_PACKET_TOO_BIG 1207# define ICMP6_PACKET_TOO_BIG 2 1208#endif 1209#ifndef ICMP6_TIME_EXCEEDED 1210# define ICMP6_TIME_EXCEEDED 3 1211#endif 1212#ifndef ICMP6_PARAM_PROB 1213# define ICMP6_PARAM_PROB 4 1214#endif 1215 1216#ifndef ICMP6_ECHO_REQUEST 1217# define ICMP6_ECHO_REQUEST 128 1218#endif 1219#ifndef ICMP6_ECHO_REPLY 1220# define ICMP6_ECHO_REPLY 129 1221#endif 1222#ifndef ICMP6_MEMBERSHIP_QUERY 1223# define ICMP6_MEMBERSHIP_QUERY 130 1224#endif 1225#ifndef MLD6_LISTENER_QUERY 1226# define MLD6_LISTENER_QUERY 130 1227#endif 1228#ifndef ICMP6_MEMBERSHIP_REPORT 1229# define ICMP6_MEMBERSHIP_REPORT 131 1230#endif 1231#ifndef MLD6_LISTENER_REPORT 1232# define MLD6_LISTENER_REPORT 131 1233#endif 1234#ifndef ICMP6_MEMBERSHIP_REDUCTION 1235# define ICMP6_MEMBERSHIP_REDUCTION 132 1236#endif 1237#ifndef MLD6_LISTENER_DONE 1238# define MLD6_LISTENER_DONE 132 1239#endif 1240#ifndef ND_ROUTER_SOLICIT 1241# define ND_ROUTER_SOLICIT 133 1242#endif 1243#ifndef ND_ROUTER_ADVERT 1244# define ND_ROUTER_ADVERT 134 1245#endif 1246#ifndef ND_NEIGHBOR_SOLICIT 1247# define ND_NEIGHBOR_SOLICIT 135 1248#endif 1249#ifndef ND_NEIGHBOR_ADVERT 1250# define ND_NEIGHBOR_ADVERT 136 1251#endif 1252#ifndef ND_REDIRECT 1253# define ND_REDIRECT 137 1254#endif 1255#ifndef ICMP6_ROUTER_RENUMBERING 1256# define ICMP6_ROUTER_RENUMBERING 138 1257#endif 1258#ifndef ICMP6_WRUREQUEST 1259# define ICMP6_WRUREQUEST 139 1260#endif 1261#ifndef ICMP6_WRUREPLY 1262# define ICMP6_WRUREPLY 140 1263#endif 1264#ifndef ICMP6_FQDN_QUERY 1265# define ICMP6_FQDN_QUERY 139 1266#endif 1267#ifndef ICMP6_FQDN_REPLY 1268# define ICMP6_FQDN_REPLY 140 1269#endif 1270#ifndef ICMP6_NI_QUERY 1271# define ICMP6_NI_QUERY 139 1272#endif 1273#ifndef ICMP6_NI_REPLY 1274# define ICMP6_NI_REPLY 140 1275#endif 1276#ifndef MLD6_MTRACE_RESP 1277# define MLD6_MTRACE_RESP 200 1278#endif 1279#ifndef MLD6_MTRACE 1280# define MLD6_MTRACE 201 1281#endif 1282#ifndef ICMP6_HADISCOV_REQUEST 1283# define ICMP6_HADISCOV_REQUEST 202 1284#endif 1285#ifndef ICMP6_HADISCOV_REPLY 1286# define ICMP6_HADISCOV_REPLY 203 1287#endif 1288#ifndef ICMP6_MOBILEPREFIX_SOLICIT 1289# define ICMP6_MOBILEPREFIX_SOLICIT 204 1290#endif 1291#ifndef ICMP6_MOBILEPREFIX_ADVERT 1292# define ICMP6_MOBILEPREFIX_ADVERT 205 1293#endif 1294#ifndef ICMP6_MAXTYPE 1295# define ICMP6_MAXTYPE 205 1296#endif 1297 1298#ifndef ICMP6_DST_UNREACH_NOROUTE 1299# define ICMP6_DST_UNREACH_NOROUTE 0 1300#endif 1301#ifndef ICMP6_DST_UNREACH_ADMIN 1302# define ICMP6_DST_UNREACH_ADMIN 1 1303#endif 1304#ifndef ICMP6_DST_UNREACH_NOTNEIGHBOR 1305# define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 1306#endif 1307#ifndef ICMP6_DST_UNREACH_BEYONDSCOPE 1308# define ICMP6_DST_UNREACH_BEYONDSCOPE 2 1309#endif 1310#ifndef ICMP6_DST_UNREACH_ADDR 1311# define ICMP6_DST_UNREACH_ADDR 3 1312#endif 1313#ifndef ICMP6_DST_UNREACH_NOPORT 1314# define ICMP6_DST_UNREACH_NOPORT 4 1315#endif 1316#ifndef ICMP6_TIME_EXCEED_TRANSIT 1317# define ICMP6_TIME_EXCEED_TRANSIT 0 1318#endif 1319#ifndef ICMP6_TIME_EXCEED_REASSEMBLY 1320# define ICMP6_TIME_EXCEED_REASSEMBLY 1 1321#endif 1322 1323#ifndef ICMP6_NI_SUCCESS 1324# define ICMP6_NI_SUCCESS 0 1325#endif 1326#ifndef ICMP6_NI_REFUSED 1327# define ICMP6_NI_REFUSED 1 1328#endif 1329#ifndef ICMP6_NI_UNKNOWN 1330# define ICMP6_NI_UNKNOWN 2 1331#endif 1332 1333#ifndef ICMP6_ROUTER_RENUMBERING_COMMAND 1334# define ICMP6_ROUTER_RENUMBERING_COMMAND 0 1335#endif 1336#ifndef ICMP6_ROUTER_RENUMBERING_RESULT 1337# define ICMP6_ROUTER_RENUMBERING_RESULT 1 1338#endif 1339#ifndef ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 1340# define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 1341#endif 1342 1343#ifndef ICMP6_PARAMPROB_HEADER 1344# define ICMP6_PARAMPROB_HEADER 0 1345#endif 1346#ifndef ICMP6_PARAMPROB_NEXTHEADER 1347# define ICMP6_PARAMPROB_NEXTHEADER 1 1348#endif 1349#ifndef ICMP6_PARAMPROB_OPTION 1350# define ICMP6_PARAMPROB_OPTION 2 1351#endif 1352 1353#ifndef ICMP6_NI_SUBJ_IPV6 1354# define ICMP6_NI_SUBJ_IPV6 0 1355#endif 1356#ifndef ICMP6_NI_SUBJ_FQDN 1357# define ICMP6_NI_SUBJ_FQDN 1 1358#endif 1359#ifndef ICMP6_NI_SUBJ_IPV4 1360# define ICMP6_NI_SUBJ_IPV4 2 1361#endif 1362 1363/* 1364 * ECN is a new addition to TCP - RFC 2481 1365 */ 1366#ifndef TH_ECN 1367# define TH_ECN 0x40 1368#endif 1369#ifndef TH_CWR 1370# define TH_CWR 0x80 1371#endif 1372#define TH_ECNALL (TH_ECN|TH_CWR) 1373 1374#define TCPF_ALL (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|TH_ECN|TH_CWR) 1375 1376#endif /* __IP_COMPAT_H__ */
|