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