| 1 | /* $NetBSD: ip_compat.h,v 1.11 2016/08/05 09:05:02 christos Exp $ */ |
| 2 | |
| 3 | /* |
| 4 | * Copyright (C) 2012 by Darren Reed. |
| 5 | * |
| 6 | * See the IPFILTER.LICENCE file for details on licencing. |
| 7 | * |
| 8 | * @(#)ip_compat.h 1.8 1/14/96 |
| 9 | * Id: ip_compat.h,v 1.1.1.2 2012/07/22 13:45:09 darrenr Exp |
| 10 | */ |
| 11 | |
| 12 | #ifndef _NETINET_IP_COMPAT_H_ |
| 13 | #define _NETINET_IP_COMPAT_H_ |
| 14 | |
| 15 | #ifndef __STDC__ |
| 16 | # undef const |
| 17 | # define const |
| 18 | #endif |
| 19 | |
| 20 | #if defined(_KERNEL) || defined(KERNEL) || defined(__KERNEL__) |
| 21 | # undef KERNEL |
| 22 | # undef _KERNEL |
| 23 | # undef __KERNEL__ |
| 24 | # define KERNEL |
| 25 | # define _KERNEL |
| 26 | # define __KERNEL__ |
| 27 | #endif |
| 28 | |
| 29 | # if (defined(sun) && (defined(__svr4__) || defined(__SVR4))) |
| 30 | # define SOLARIS 1 |
| 31 | # else |
| 32 | # define SOLARIS 0 |
| 33 | # endif |
| 34 | #if (defined(SOLARIS2) && (SOLARIS2 >= 8)) |
| 35 | # ifndef USE_INET6 |
| 36 | # define USE_INET6 |
| 37 | # endif |
| 38 | #endif |
| 39 | #if defined(__FreeBSD_version) && (__FreeBSD_version >= 400000) && \ |
| 40 | !defined(_KERNEL) && !defined(USE_INET6) && !defined(NOINET6) |
| 41 | # define USE_INET6 |
| 42 | #endif |
| 43 | #if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 105000000) && \ |
| 44 | !defined(_KERNEL) && !defined(USE_INET6) && !defined(NOINET6) |
| 45 | # define USE_INET6 |
| 46 | #endif |
| 47 | #if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 106140000) && \ |
| 48 | defined(_KERNEL) && \ |
| 49 | (!defined(IPFILTER_LKM) || (__NetBSD_Version__ >= 399000100)) |
| 50 | # define IPFILTER_M_IPFILTER |
| 51 | #endif |
| 52 | #if !defined(USE_INET6) |
| 53 | # if defined(OpenBSD) && (OpenBSD >= 200206) && \ |
| 54 | !defined(_KERNEL) && !defined(USE_INET6) |
| 55 | # define USE_INET6 |
| 56 | # endif |
| 57 | # if defined(__osf__) |
| 58 | # define USE_INET6 1 |
| 59 | # endif |
| 60 | # if defined(linux) && (!defined(_KERNEL) || defined(CONFIG_IPV6)) |
| 61 | # define USE_INET6 |
| 62 | # endif |
| 63 | # if defined(HPUXREV) && (HPUXREV >= 1111) |
| 64 | # define USE_INET6 |
| 65 | # endif |
| 66 | #endif |
| 67 | |
| 68 | #if defined(BSD) && (BSD < 199103) && defined(__osf__) |
| 69 | # undef BSD |
| 70 | # define BSD 199103 |
| 71 | #endif |
| 72 | |
| 73 | #if defined(__SVR4) || defined(__svr4__) || defined(__sgi) |
| 74 | # define index strchr |
| 75 | # if !defined(_KERNEL) |
| 76 | # define bzero(a,b) memset(a,0,b) |
| 77 | # define bcmp memcmp |
| 78 | # define bcopy(a,b,c) memmove(b,a,c) |
| 79 | # endif |
| 80 | #endif |
| 81 | |
| 82 | #ifndef LIFNAMSIZ |
| 83 | # ifdef IF_NAMESIZE |
| 84 | # define LIFNAMSIZ IF_NAMESIZE |
| 85 | # else |
| 86 | # ifdef IFNAMSIZ |
| 87 | # define LIFNAMSIZ IFNAMSIZ |
| 88 | # else |
| 89 | # define LIFNAMSIZ 16 |
| 90 | # endif |
| 91 | # endif |
| 92 | #endif |
| 93 | |
| 94 | #if defined(__sgi) || defined(bsdi) || defined(__hpux) || defined(hpux) |
| 95 | struct ether_addr { |
| 96 | u_char ether_addr_octet[6]; |
| 97 | }; |
| 98 | #endif |
| 99 | |
| 100 | #if defined(__sgi) && !defined(IPFILTER_LKM) |
| 101 | # ifdef __STDC__ |
| 102 | # define IPL_EXTERN(ep) ipfilter##ep |
| 103 | # else |
| 104 | # define IPL_EXTERN(ep) ipfilter/**/ep |
| 105 | # endif |
| 106 | #else |
| 107 | # ifdef __STDC__ |
| 108 | # define IPL_EXTERN(ep) ipl##ep |
| 109 | # else |
| 110 | # define IPL_EXTERN(ep) ipl/**/ep |
| 111 | # endif |
| 112 | #endif |
| 113 | |
| 114 | /* |
| 115 | * This is a workaround for <sys/uio.h> troubles on FreeBSD and OpenBSD. |
| 116 | */ |
| 117 | #ifndef linux |
| 118 | # ifndef _KERNEL |
| 119 | # define ADD_KERNEL |
| 120 | # define _KERNEL |
| 121 | # define KERNEL |
| 122 | # endif |
| 123 | # ifdef __OpenBSD__ |
| 124 | struct file; |
| 125 | # endif |
| 126 | # include <sys/uio.h> |
| 127 | # ifdef ADD_KERNEL |
| 128 | # undef _KERNEL |
| 129 | # undef KERNEL |
| 130 | # endif |
| 131 | #endif |
| 132 | |
| 133 | # define NETBSD_GE_REV(x) (__NetBSD_Version__ >= (x)) |
| 134 | # define NETBSD_GT_REV(x) (__NetBSD_Version__ > (x)) |
| 135 | # define NETBSD_LT_REV(x) (__NetBSD_Version__ < (x)) |
| 136 | |
| 137 | # define FREEBSD_GE_REV(x) 0 |
| 138 | # define FREEBSD_GT_REV(x) 0 |
| 139 | # define FREEBSD_LT_REV(x) 0 |
| 140 | |
| 141 | # define BSDOS_GE_REV(x) 0 |
| 142 | # define BSDOS_GT_REV(x) 0 |
| 143 | # define BSDOS_LT_REV(x) 0 |
| 144 | |
| 145 | # define OPENBSD_GE_REV(x) 0 |
| 146 | # define OPENBSD_GT_REV(x) 0 |
| 147 | # define OPENBSD_LT_REV(x) 0 |
| 148 | |
| 149 | # define BSD_GE_YEAR(x) (BSD >= (x)) |
| 150 | # define BSD_GT_YEAR(x) (BSD > (x)) |
| 151 | # define BSD_LT_YEAR(x) (BSD < (x)) |
| 152 | |
| 153 | |
| 154 | /* ----------------------------------------------------------------------- */ |
| 155 | /* N E T B S D */ |
| 156 | /* ----------------------------------------------------------------------- */ |
| 157 | #ifdef __NetBSD__ |
| 158 | # define HAS_SYS_MD5_H 1 |
| 159 | # if (NetBSD >= 199905) && !defined(IPFILTER_LKM) && defined(_KERNEL) |
| 160 | # if (__NetBSD_Version__ < 399001400) |
| 161 | # include "opt_ipfilter_log.h" |
| 162 | # else |
| 163 | # if (__NetBSD_Version__ >= 799003000) |
| 164 | # if defined(_KERNEL_OPT) |
| 165 | # include "opt_ipfilter.h" |
| 166 | # endif |
| 167 | # else |
| 168 | # include "opt_ipfilter.h" |
| 169 | # endif |
| 170 | # endif |
| 171 | # endif |
| 172 | # if defined(_KERNEL) |
| 173 | # include <sys/systm.h> |
| 174 | # include <sys/malloc.h> |
| 175 | # if (__NetBSD_Version__ > 500000000) |
| 176 | # include <sys/kauth.h> |
| 177 | # endif |
| 178 | # else |
| 179 | # include <stddef.h> |
| 180 | # include <stdbool.h> |
| 181 | # endif |
| 182 | # if defined(_KERNEL) && !defined(IPFILTER_LKM) |
| 183 | # if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 599002300) |
| 184 | # define NBPFILTER 1 |
| 185 | # else |
| 186 | # include "bpfilter.h" |
| 187 | # endif |
| 188 | # if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 104110000) |
| 189 | # if (__NetBSD_Version__ >= 799003000) |
| 190 | # if defined(_KERNEL_OPT) |
| 191 | # include "opt_inet.h" |
| 192 | # endif |
| 193 | # else |
| 194 | # include "opt_inet.h" |
| 195 | # endif |
| 196 | # endif |
| 197 | # ifdef INET6 |
| 198 | # define USE_INET6 |
| 199 | # endif |
| 200 | # if (__NetBSD_Version__ >= 105000000) |
| 201 | # define HAVE_M_PULLDOWN 1 |
| 202 | # endif |
| 203 | # endif |
| 204 | |
| 205 | #ifndef _KERNEL |
| 206 | # define ipf_random arc4random |
| 207 | #endif |
| 208 | |
| 209 | # if (__NetBSD_Version__ >= 499000000) |
| 210 | # ifdef _KERNEL |
| 211 | # include <sys/rwlock.h> |
| 212 | # define USE_MUTEXES 1 |
| 213 | # define KMUTEX_T kmutex_t |
| 214 | # define KRWLOCK_T krwlock_t |
| 215 | # define MUTEX_DESTROY(x) mutex_destroy(&(x)->ipf_lk) |
| 216 | # define MUTEX_DOWNGRADE(x) rw_downgrade(&(x)->ipf_lk) |
| 217 | # define MUTEX_ENTER(x) mutex_enter(&(x)->ipf_lk) |
| 218 | # define MUTEX_EXIT(x) mutex_exit(&(x)->ipf_lk) |
| 219 | # define MUTEX_INIT(x,y) mutex_init(&(x)->ipf_lk, MUTEX_DRIVER,\ |
| 220 | IPL_SOFTNET) |
| 221 | # define MUTEX_NUKE(x) bzero((x), sizeof(*(x))) |
| 222 | # define READ_ENTER(x) rw_enter(&(x)->ipf_lk, RW_READER) |
| 223 | # define RWLOCK_INIT(x, y) rw_init(&(x)->ipf_lk) |
| 224 | # define RWLOCK_EXIT(x) rw_exit(&(x)->ipf_lk) |
| 225 | # define RW_DESTROY(x) rw_destroy(&(x)->ipf_lk) |
| 226 | # define WRITE_ENTER(x) rw_enter(&(x)->ipf_lk, RW_WRITER) |
| 227 | # define SPL_SCHED(x) ; |
| 228 | # define SPL_NET(x) ; |
| 229 | # define SPL_IMP(x) ; |
| 230 | # define SPL_X(x) ; |
| 231 | # endif |
| 232 | # endif |
| 233 | |
| 234 | #if (__NetBSD_Version__ >= 699000000) |
| 235 | # define HAVE_RBTREE 1 |
| 236 | #endif |
| 237 | |
| 238 | # ifdef _KERNEL |
| 239 | # include <sys/cprng.h> |
| 240 | # if (__NetBSD_Version__ >= 399001400) |
| 241 | # include <sys/selinfo.h> /* Not in NetBSD 3.1 */ |
| 242 | # define PROC_T struct lwp |
| 243 | # define KFREE(a) free((a), _M_IPF) |
| 244 | # define KFREES(a, b) free((a), _M_IPF) |
| 245 | # define KMALLOC(a, b) (a) = (b)malloc(sizeof (*(a)), \ |
| 246 | _M_IPF, M_NOWAIT) |
| 247 | # define KMALLOCS(a, b, c) (a) = (b)malloc((c), _M_IPF, M_NOWAIT) |
| 248 | # else |
| 249 | # define PROC_T struct proc |
| 250 | # endif |
| 251 | # define MSGDSIZE(m) mbufchainlen(m) |
| 252 | # define M_LEN(m) (m)->m_len |
| 253 | # define M_ADJ(m,x) m_adj(m, x) |
| 254 | # define M_COPY(x) m_copy((x), 0, M_COPYALL) |
| 255 | # define GETKTIME(x) microtime((struct timeval *)x) |
| 256 | # define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); } |
| 257 | # define COPYIN(a,b,c) copyin((void *)(a), (void *)(b), (c)) |
| 258 | # define COPYOUT(a,b,c) copyout((void *)(a), (void *)(b), (c)) |
| 259 | # define BCOPYIN(a,b,c) (bcopy((void *)(a), (void *)(b), (c)), 0) |
| 260 | # define BCOPYOUT(a,b,c) (bcopy((void *)(a), (void *)(b), (c)), 0) |
| 261 | # if (defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 499004900)) |
| 262 | # define POLLWAKEUP(x) selnotify(softc->ipf_selwait+x, 0, 0) |
| 263 | # endif |
| 264 | # define ASSERT(x) KASSERT(x) |
| 265 | typedef struct mbuf mb_t; |
| 266 | # endif /* _KERNEL */ |
| 267 | # if (NetBSD <= 1991011) && (NetBSD >= 199606) |
| 268 | # define IFNAME(x) ((struct ifnet *)x)->if_xname |
| 269 | # define COPYIFNAME(v, x, b) \ |
| 270 | (void) strncpy(b, \ |
| 271 | ((struct ifnet *)x)->if_xname, \ |
| 272 | LIFNAMSIZ) |
| 273 | # else |
| 274 | # define IFNAME(x) ((struct ifnet *)x)->if_name |
| 275 | # endif |
| 276 | typedef struct uio uio_t; |
| 277 | typedef u_long ioctlcmd_t; |
| 278 | typedef int minor_t; |
| 279 | typedef u_int32_t u_32_t; |
| 280 | # define U_32_T 1 |
| 281 | |
| 282 | # define OS_RECOGNISED 1 |
| 283 | #endif /* __NetBSD__ */ |
| 284 | |
| 285 | /* ----------------------------------------------------------------------- */ |
| 286 | /* G E N E R I C */ |
| 287 | /* ----------------------------------------------------------------------- */ |
| 288 | |
| 289 | /* |
| 290 | * For BSD kernels, if bpf is in the kernel, enable ipfilter to use bpf in |
| 291 | * filter rules. |
| 292 | */ |
| 293 | #if !defined(IPFILTER_BPF) |
| 294 | # if (defined(NBPF) && (NBPF > 0)) || (defined(DEV_BPF) && (DEV_BPF > 0)) || \ |
| 295 | (defined(NBPFILTER) && (NBPFILTER > 0)) |
| 296 | # define IPFILTER_BPF |
| 297 | # endif |
| 298 | #endif |
| 299 | |
| 300 | /* |
| 301 | * Userland locking primitives |
| 302 | */ |
| 303 | #if !defined(KMUTEX_FILL_SZ) |
| 304 | # define KMUTEX_FILL_SZ 1 |
| 305 | #endif |
| 306 | #if !defined(KRWLOCK_FILL_SZ) |
| 307 | # define KRWLOCK_FILL_SZ 1 |
| 308 | #endif |
| 309 | |
| 310 | typedef struct { |
| 311 | char *eMm_owner; |
| 312 | char *eMm_heldin; |
| 313 | u_int eMm_magic; |
| 314 | int eMm_held; |
| 315 | int eMm_heldat; |
| 316 | } eMmutex_t; |
| 317 | |
| 318 | typedef struct { |
| 319 | char *eMrw_owner; |
| 320 | char *eMrw_heldin; |
| 321 | u_int eMrw_magic; |
| 322 | short eMrw_read; |
| 323 | short eMrw_write; |
| 324 | int eMrw_heldat; |
| 325 | } eMrwlock_t; |
| 326 | |
| 327 | typedef union { |
| 328 | char _fill[KMUTEX_FILL_SZ]; |
| 329 | #ifdef KMUTEX_T |
| 330 | struct { |
| 331 | KMUTEX_T ipf_slk; |
| 332 | const char *ipf_lname; |
| 333 | } ipf_lkun_s; |
| 334 | #endif |
| 335 | eMmutex_t ipf_emu; |
| 336 | } ipfmutex_t; |
| 337 | |
| 338 | typedef union { |
| 339 | char _fill[KRWLOCK_FILL_SZ]; |
| 340 | #ifdef KRWLOCK_T |
| 341 | struct { |
| 342 | KRWLOCK_T ipf_slk; |
| 343 | const char *ipf_lname; |
| 344 | int ipf_sr; |
| 345 | int ipf_sw; |
| 346 | u_int ipf_magic; |
| 347 | } ipf_lkun_s; |
| 348 | #endif |
| 349 | eMrwlock_t ipf_emu; |
| 350 | } ipfrwlock_t; |
| 351 | |
| 352 | #define ipf_lk ipf_lkun_s.ipf_slk |
| 353 | #define ipf_lname ipf_lkun_s.ipf_lname |
| 354 | #define ipf_isr ipf_lkun_s.ipf_sr |
| 355 | #define ipf_isw ipf_lkun_s.ipf_sw |
| 356 | #define ipf_magic ipf_lkun_s.ipf_magic |
| 357 | |
| 358 | #if !defined(__GNUC__) || \ |
| 359 | (defined(__FreeBSD_version) && (__FreeBSD_version >= 503000)) |
| 360 | # ifndef INLINE |
| 361 | # define INLINE |
| 362 | # endif |
| 363 | #else |
| 364 | # define INLINE __inline__ |
| 365 | #endif |
| 366 | |
| 367 | #ifndef EXTERN_INLINE |
| 368 | # if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__) |
| 369 | # define EXTERN_INLINE inline |
| 370 | # else |
| 371 | # define EXTERN_INLINE extern inline |
| 372 | # endif |
| 373 | #endif |
| 374 | |
| 375 | #if defined(linux) && defined(_KERNEL) |
| 376 | extern void ipf_read_enter(ipfrwlock_t *); |
| 377 | extern void ipf_write_enter(ipfrwlock_t *); |
| 378 | extern void ipf_rw_exit(ipfrwlock_t *); |
| 379 | extern void ipf_rw_init(ipfrwlock_t *, char *); |
| 380 | extern void ipf_rw_downgrade(ipfrwlock_t *); |
| 381 | #endif |
| 382 | |
| 383 | /* |
| 384 | * In a non-kernel environment, there are a lot of macros that need to be |
| 385 | * filled in to be null-ops or to point to some compatibility function, |
| 386 | * somewhere in userland. |
| 387 | */ |
| 388 | #ifndef _KERNEL |
| 389 | typedef struct mb_s { |
| 390 | struct mb_s *mb_next; |
| 391 | char *mb_data; |
| 392 | void *mb_ifp; |
| 393 | int mb_len; |
| 394 | int mb_flags; |
| 395 | u_long mb_buf[2048]; |
| 396 | } mb_t; |
| 397 | # undef m_next |
| 398 | # define m_next mb_next |
| 399 | # undef m_len |
| 400 | # define m_len mb_len |
| 401 | # undef m_flags |
| 402 | # define m_flags mb_flags |
| 403 | # undef m_data |
| 404 | # define m_data mb_data |
| 405 | # undef M_MCAST |
| 406 | # define M_MCAST 0x01 |
| 407 | # undef M_BCAST |
| 408 | # define M_BCAST 0x02 |
| 409 | # undef M_MBCAST |
| 410 | # define M_MBCAST 0x04 |
| 411 | # define MSGDSIZE(m) msgdsize(m) |
| 412 | # define M_LEN(m) (m)->mb_len |
| 413 | # define M_ADJ(m,x) (m)->mb_len += x |
| 414 | # define M_COPY(m) dupmbt(m) |
| 415 | # define M_DUP(m) dupmbt(m) |
| 416 | # define GETKTIME(x) gettimeofday((struct timeval *)(x), NULL) |
| 417 | # define MTOD(m, t) ((t)(m)->mb_data) |
| 418 | # define FREE_MB_T(m) freembt(m) |
| 419 | # define ALLOC_MB_T(m,l) (m) = allocmbt(l) |
| 420 | # define PREP_MB_T(f, m) do { \ |
| 421 | (m)->mb_next = *(f)->fin_mp; \ |
| 422 | *(fin)->fin_mp = (m); \ |
| 423 | (f)->fin_m = (m); \ |
| 424 | } while (0) |
| 425 | # define SLEEP(x,y) 1; |
| 426 | # define WAKEUP(x,y) ; |
| 427 | # define POLLWAKEUP(y) ; |
| 428 | # define IPF_PANIC(x,y) ; |
| 429 | # define PANIC(x,y) ; |
| 430 | # define SPL_SCHED(x) ; |
| 431 | # define SPL_NET(x) ; |
| 432 | # define SPL_IMP(x) ; |
| 433 | # define SPL_X(x) ; |
| 434 | # define KMALLOC(a,b) (a) = (b)malloc(sizeof(*a)) |
| 435 | # define KMALLOCS(a,b,c) (a) = (b)malloc(c) |
| 436 | # define KFREE(x) free(x) |
| 437 | # define KFREES(x,s) free(x) |
| 438 | # define GETIFP(x, v) get_unit(x,v) |
| 439 | # define GETIFMTU_4(x) 2048 |
| 440 | # define GETIFMTU_6(x) 2048 |
| 441 | # define COPYIN(a,b,c) bcopywrap((a), (b), (c)) |
| 442 | # define COPYOUT(a,b,c) bcopywrap((a), (b), (c)) |
| 443 | # define COPYDATA(m, o, l, b) bcopy(MTOD((mb_t *)m, char *) + (o), \ |
| 444 | (b), (l)) |
| 445 | # define COPYBACK(m, o, l, b) bcopy((b), \ |
| 446 | MTOD((mb_t *)m, char *) + (o), \ |
| 447 | (l)) |
| 448 | # define UIOMOVE(a,b,c,d) ipfuiomove(a,b,c,d) |
| 449 | extern void m_copydata(mb_t *, int, int, void *); |
| 450 | extern int ipfuiomove(void *, int, int, struct uio *); |
| 451 | extern int bcopywrap(void *, void *, size_t); |
| 452 | extern mb_t *allocmbt(size_t); |
| 453 | extern mb_t *dupmbt(mb_t *); |
| 454 | extern void freembt(mb_t *); |
| 455 | |
| 456 | # define MUTEX_DESTROY(x) eMmutex_destroy(&(x)->ipf_emu, \ |
| 457 | __FILE__, __LINE__) |
| 458 | # define MUTEX_ENTER(x) eMmutex_enter(&(x)->ipf_emu, \ |
| 459 | __FILE__, __LINE__) |
| 460 | # define MUTEX_EXIT(x) eMmutex_exit(&(x)->ipf_emu, \ |
| 461 | __FILE__, __LINE__) |
| 462 | # define MUTEX_INIT(x,y) eMmutex_init(&(x)->ipf_emu, y, \ |
| 463 | __FILE__, __LINE__) |
| 464 | # define MUTEX_NUKE(x) bzero((x), sizeof(*(x))) |
| 465 | |
| 466 | # define MUTEX_DOWNGRADE(x) eMrwlock_downgrade(&(x)->ipf_emu, \ |
| 467 | __FILE__, __LINE__) |
| 468 | # define READ_ENTER(x) eMrwlock_read_enter(&(x)->ipf_emu, \ |
| 469 | __FILE__, __LINE__) |
| 470 | # define RWLOCK_INIT(x, y) eMrwlock_init(&(x)->ipf_emu, y) |
| 471 | # define RWLOCK_EXIT(x) eMrwlock_exit(&(x)->ipf_emu) |
| 472 | # define RW_DESTROY(x) eMrwlock_destroy(&(x)->ipf_emu) |
| 473 | # define WRITE_ENTER(x) eMrwlock_write_enter(&(x)->ipf_emu, \ |
| 474 | __FILE__, \ |
| 475 | __LINE__) |
| 476 | |
| 477 | # define USE_MUTEXES 1 |
| 478 | |
| 479 | extern void eMmutex_destroy(eMmutex_t *, char *, int); |
| 480 | extern void eMmutex_enter(eMmutex_t *, char *, int); |
| 481 | extern void eMmutex_exit(eMmutex_t *, char *, int); |
| 482 | extern void eMmutex_init(eMmutex_t *, char *, char *, int); |
| 483 | extern void eMrwlock_destroy(eMrwlock_t *); |
| 484 | extern void eMrwlock_exit(eMrwlock_t *); |
| 485 | extern void eMrwlock_init(eMrwlock_t *, char *); |
| 486 | extern void eMrwlock_read_enter(eMrwlock_t *, char *, int); |
| 487 | extern void eMrwlock_write_enter(eMrwlock_t *, char *, int); |
| 488 | extern void eMrwlock_downgrade(eMrwlock_t *, char *, int); |
| 489 | |
| 490 | #endif |
| 491 | |
| 492 | extern mb_t *allocmbt(size_t); |
| 493 | |
| 494 | #define MAX_IPV4HDR ((0xf << 2) + sizeof(struct icmp) + sizeof(ip_t) + 8) |
| 495 | |
| 496 | #ifndef IP_OFFMASK |
| 497 | # define IP_OFFMASK 0x1fff |
| 498 | #endif |
| 499 | |
| 500 | |
| 501 | /* |
| 502 | * On BSD's use quad_t as a guarantee for getting at least a 64bit sized |
| 503 | * object. |
| 504 | */ |
| 505 | #if !defined(__amd64__) && BSD_GT_YEAR(199306) |
| 506 | # define USE_QUAD_T |
| 507 | # define U_QUAD_T u_quad_t |
| 508 | # define QUAD_T quad_t |
| 509 | #else /* BSD > 199306 */ |
| 510 | # if !defined(U_QUAD_T) |
| 511 | # define U_QUAD_T u_long |
| 512 | # define QUAD_T long |
| 513 | # endif |
| 514 | #endif /* BSD > 199306 */ |
| 515 | |
| 516 | |
| 517 | #ifdef USE_INET6 |
| 518 | # if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || \ |
| 519 | defined(__osf__) || defined(linux) |
| 520 | # include <netinet/ip6.h> |
| 521 | # include <netinet/icmp6.h> |
| 522 | # if !defined(linux) |
| 523 | # if defined(_KERNEL) && !defined(__osf__) |
| 524 | # include <netinet6/ip6_var.h> |
| 525 | # endif |
| 526 | # endif |
| 527 | typedef struct ip6_hdr ip6_t; |
| 528 | # endif |
| 529 | #endif |
| 530 | |
| 531 | #ifndef MAX |
| 532 | # define MAX(a,b) (((a) > (b)) ? (a) : (b)) |
| 533 | #endif |
| 534 | |
| 535 | #if defined(_KERNEL) |
| 536 | # if defined(MENTAT) && !defined(INSTANCES) |
| 537 | # define COPYDATA mb_copydata |
| 538 | # define COPYBACK mb_copyback |
| 539 | # else |
| 540 | # define COPYDATA m_copydata |
| 541 | # define COPYBACK m_copyback |
| 542 | # endif |
| 543 | # if BSD_GE_YEAR(199306) || defined(__FreeBSD__) |
| 544 | # if (defined(__NetBSD_Version__) && (__NetBSD_Version__ < 105180000)) || \ |
| 545 | defined(__FreeBSD__) || (defined(OpenBSD) && (OpenBSD < 200206)) || \ |
| 546 | defined(_BSDI_VERSION) |
| 547 | # include <vm/vm.h> |
| 548 | # endif |
| 549 | # if !defined(__FreeBSD__) || FREEBSD_GE_REV(300000) |
| 550 | # if NETBSD_GE_REV(105180000) || OPENBSD_GE_REV(200111) |
| 551 | /* # include <uvm/uvm_extern.h> */ |
| 552 | # else |
| 553 | # include <vm/vm_extern.h> |
| 554 | extern vm_map_t kmem_map; |
| 555 | # endif |
| 556 | # include <sys/proc.h> |
| 557 | # else /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */ |
| 558 | # include <vm/vm_kern.h> |
| 559 | # endif /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */ |
| 560 | |
| 561 | # ifdef IPFILTER_M_IPFILTER |
| 562 | # include <sys/malloc.h> |
| 563 | MALLOC_DECLARE(M_IPFILTER); |
| 564 | # define _M_IPF M_IPFILTER |
| 565 | # else /* IPFILTER_M_IPFILTER */ |
| 566 | # ifdef M_PFIL |
| 567 | # define _M_IPF M_PFIL |
| 568 | # else |
| 569 | # ifdef M_IPFILTER |
| 570 | # define _M_IPF M_IPFILTER |
| 571 | # else |
| 572 | # define _M_IPF M_TEMP |
| 573 | # endif /* M_IPFILTER */ |
| 574 | # endif /* M_PFIL */ |
| 575 | # endif /* IPFILTER_M_IPFILTER */ |
| 576 | # if !defined(KMALLOC) |
| 577 | # define KMALLOC(a, b) (a) = (b)malloc(sizeof(*(a)), _M_IPF, M_NOWAIT) |
| 578 | # endif |
| 579 | # if !defined(KMALLOCS) |
| 580 | # define KMALLOCS(a, b, c) (a) = (b)malloc((c), _M_IPF, M_NOWAIT) |
| 581 | # endif |
| 582 | # if !defined(KFREE) |
| 583 | # define KFREE(x) free((x), _M_IPF) |
| 584 | # endif |
| 585 | # if !defined(KFREES) |
| 586 | # define KFREES(x,s) free((x), _M_IPF) |
| 587 | # endif |
| 588 | # define UIOMOVE(a,b,c,d) uiomove((void *)a,b,d) |
| 589 | # define SLEEP(id, n) tsleep((id), PPAUSE|PCATCH, n, 0) |
| 590 | # define WAKEUP(id,x) wakeup(id+x) |
| 591 | # if !defined(POLLWAKEUP) |
| 592 | # define POLLWAKEUP(x) selwakeup(softc->ipf_selwait+x) |
| 593 | # endif |
| 594 | # define GETIFP(n, v) ifunit(n) |
| 595 | # define GETIFMTU_4(x) ((struct ifnet *)x)->if_mtu |
| 596 | # define GETIFMTU_6(x) ((struct ifnet *)x)->if_mtu |
| 597 | # endif /* (Free)BSD */ |
| 598 | |
| 599 | # if !defined(USE_MUTEXES) && !defined(SPL_NET) |
| 600 | # if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199407)) || \ |
| 601 | OPENBSD_GE_REV(200006) |
| 602 | # define SPL_NET(x) x = splsoftnet() |
| 603 | # else |
| 604 | # define SPL_IMP(x) x = splimp() |
| 605 | # define SPL_NET(x) x = splnet() |
| 606 | # endif /* NetBSD && (NetBSD <= 1991011) && (NetBSD >= 199407) */ |
| 607 | # if !defined(SPL_SCHED) |
| 608 | # define SPL_SCHED(x) x = splsched() |
| 609 | # endif |
| 610 | # define SPL_X(x) (void) splx(x) |
| 611 | # endif /* !USE_MUTEXES */ |
| 612 | |
| 613 | # ifndef FREE_MB_T |
| 614 | # define FREE_MB_T(m) m_freem(m) |
| 615 | # endif |
| 616 | # ifndef ALLOC_MB_T |
| 617 | # ifdef MGETHDR |
| 618 | # define ALLOC_MB_T(m,l) do { \ |
| 619 | MGETHDR((m), M_DONTWAIT, MT_HEADER); \ |
| 620 | if ((m) != NULL) { \ |
| 621 | (m)->m_len = (l); \ |
| 622 | (m)->m_pkthdr.len = (l); \ |
| 623 | } \ |
| 624 | } while (0) |
| 625 | # else |
| 626 | # define ALLOC_MB_T(m,l) do { \ |
| 627 | MGET((m), M_DONTWAIT, MT_HEADER); \ |
| 628 | if ((m) != NULL) { \ |
| 629 | (m)->m_len = (l); \ |
| 630 | (m)->m_pkthdr.len = (l); \ |
| 631 | } \ |
| 632 | } while (0) |
| 633 | # endif |
| 634 | # endif |
| 635 | # ifndef PREP_MB_T |
| 636 | # define PREP_MB_T(f, m) do { \ |
| 637 | mb_t *_o = *(f)->fin_mp; \ |
| 638 | (m)->m_next = _o; \ |
| 639 | *(fin)->fin_mp = (m); \ |
| 640 | if (_o->m_flags & M_PKTHDR) { \ |
| 641 | (m)->m_pkthdr.len += \ |
| 642 | _o->m_pkthdr.len; \ |
| 643 | m_copy_rcvif((m), _o); \ |
| 644 | } \ |
| 645 | } while (0) |
| 646 | # endif |
| 647 | # ifndef M_DUP |
| 648 | # ifdef M_COPYALL |
| 649 | # define M_DUP(m) m_dup(m, 0, M_COPYALL, 0) |
| 650 | # else |
| 651 | # define M_DUP(m) m_dup(m) |
| 652 | # endif |
| 653 | # endif |
| 654 | |
| 655 | # ifndef MTOD |
| 656 | # define MTOD(m,t) mtod(m,t) |
| 657 | # endif |
| 658 | |
| 659 | # ifndef COPYIN |
| 660 | # define COPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) |
| 661 | # define COPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) |
| 662 | # endif |
| 663 | |
| 664 | # ifndef KMALLOC |
| 665 | # define KMALLOC(a,b) (a) = (b)new_kmem_alloc(sizeof(*(a)), \ |
| 666 | KMEM_NOSLEEP) |
| 667 | # define KMALLOCS(a,b,c) (a) = (b)new_kmem_alloc((c), KMEM_NOSLEEP) |
| 668 | # endif |
| 669 | |
| 670 | # ifndef GET_MINOR |
| 671 | # define GET_MINOR(x) minor(x) |
| 672 | # endif |
| 673 | # define PANIC(x,y) if (x) panic y |
| 674 | #endif /* _KERNEL */ |
| 675 | |
| 676 | #if !defined(IFNAME) && !defined(_KERNEL) |
| 677 | # define IFNAME(x) get_ifname((struct ifnet *)x) |
| 678 | #endif |
| 679 | #ifndef COPYIFNAME |
| 680 | # define NEED_FRGETIFNAME |
| 681 | extern char *ipf_getifname(struct ifnet *, char *); |
| 682 | # define COPYIFNAME(v, x, b) \ |
| 683 | ipf_getifname((struct ifnet *)x, b) |
| 684 | #endif |
| 685 | |
| 686 | #ifndef ASSERT |
| 687 | # ifdef _KERNEL |
| 688 | # define ASSERT(x) |
| 689 | # else |
| 690 | # define ASSERT(x) do { if (!(x)) abort(); } while (0) |
| 691 | # endif |
| 692 | #endif |
| 693 | |
| 694 | #ifndef BCOPYIN |
| 695 | # define BCOPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) |
| 696 | # define BCOPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) |
| 697 | #endif |
| 698 | |
| 699 | /* |
| 700 | * Because the ctype(3) posix definition, if used "safely" in code everywhere, |
| 701 | * would mean all normal code that walks through strings needed casts. Yuck. |
| 702 | */ |
| 703 | #define ISALNUM(x) isalnum((u_char)(x)) |
| 704 | #define ISALPHA(x) isalpha((u_char)(x)) |
| 705 | #define ISDIGIT(x) isdigit((u_char)(x)) |
| 706 | #define ISSPACE(x) isspace((u_char)(x)) |
| 707 | #define ISUPPER(x) isupper((u_char)(x)) |
| 708 | #define ISXDIGIT(x) isxdigit((u_char)(x)) |
| 709 | #define ISLOWER(x) islower((u_char)(x)) |
| 710 | #define TOUPPER(x) toupper((u_char)(x)) |
| 711 | #define TOLOWER(x) tolower((u_char)(x)) |
| 712 | |
| 713 | /* |
| 714 | * If mutexes aren't being used, turn all the mutex functions into null-ops. |
| 715 | */ |
| 716 | #if !defined(USE_MUTEXES) |
| 717 | # define USE_SPL 1 |
| 718 | # undef RW_DESTROY |
| 719 | # undef MUTEX_INIT |
| 720 | # undef MUTEX_NUKE |
| 721 | # undef MUTEX_DESTROY |
| 722 | # define MUTEX_ENTER(x) ; |
| 723 | # define READ_ENTER(x) ; |
| 724 | # define WRITE_ENTER(x) ; |
| 725 | # define MUTEX_DOWNGRADE(x) ; |
| 726 | # define RWLOCK_INIT(x, y) ; |
| 727 | # define RWLOCK_EXIT(x) ; |
| 728 | # define RW_DESTROY(x) ; |
| 729 | # define MUTEX_EXIT(x) ; |
| 730 | # define MUTEX_INIT(x,y) ; |
| 731 | # define MUTEX_DESTROY(x) ; |
| 732 | # define MUTEX_NUKE(x) ; |
| 733 | #endif /* !USE_MUTEXES */ |
| 734 | #ifndef ATOMIC_INC |
| 735 | # define ATOMIC_INC(x) (x)++ |
| 736 | # define ATOMIC_DEC(x) (x)-- |
| 737 | #endif |
| 738 | |
| 739 | #if defined(USE_SPL) && defined(_KERNEL) |
| 740 | # define SPL_INT(x) int x |
| 741 | #else |
| 742 | # define SPL_INT(x) |
| 743 | #endif |
| 744 | |
| 745 | /* |
| 746 | * If there are no atomic operations for bit sizes defined, define them to all |
| 747 | * use a generic one that works for all sizes. |
| 748 | */ |
| 749 | #ifndef ATOMIC_INCL |
| 750 | # define ATOMIC_INCL ATOMIC_INC |
| 751 | # define ATOMIC_INC64 ATOMIC_INC |
| 752 | # define ATOMIC_INC32 ATOMIC_INC |
| 753 | # define ATOMIC_DECL ATOMIC_DEC |
| 754 | # define ATOMIC_DEC64 ATOMIC_DEC |
| 755 | # define ATOMIC_DEC32 ATOMIC_DEC |
| 756 | #endif |
| 757 | |
| 758 | #ifndef HDR_T_PRIVATE |
| 759 | typedef struct tcphdr tcphdr_t; |
| 760 | typedef struct udphdr udphdr_t; |
| 761 | #endif |
| 762 | typedef struct icmp icmphdr_t; |
| 763 | typedef struct ip ip_t; |
| 764 | typedef struct ether_header ; |
| 765 | typedef struct tcpiphdr tcpiphdr_t; |
| 766 | |
| 767 | #ifndef FR_GROUPLEN |
| 768 | # define FR_GROUPLEN 16 |
| 769 | #endif |
| 770 | |
| 771 | #ifndef offsetof |
| 772 | # define offsetof(t,m) (size_t)((&((t *)0L)->m)) |
| 773 | #endif |
| 774 | #ifndef stsizeof |
| 775 | # define stsizeof(t,m) sizeof(((t *)0L)->m) |
| 776 | #endif |
| 777 | |
| 778 | /* |
| 779 | * This set of macros has been brought about because on Tru64 it is not |
| 780 | * possible to easily assign or examine values in a structure that are |
| 781 | * bit fields. |
| 782 | */ |
| 783 | #ifndef IP_V |
| 784 | # define IP_V(x) (x)->ip_v |
| 785 | #endif |
| 786 | #ifndef IP_V_A |
| 787 | # define IP_V_A(x,y) (x)->ip_v = (y) |
| 788 | #endif |
| 789 | #ifndef IP_HL |
| 790 | # define IP_HL(x) (x)->ip_hl |
| 791 | #endif |
| 792 | #ifndef IP_HL_A |
| 793 | # define IP_HL_A(x,y) (x)->ip_hl = ((y) & 0xf) |
| 794 | #endif |
| 795 | #ifndef TCP_X2 |
| 796 | # define TCP_X2(x) (x)->th_x2 |
| 797 | #endif |
| 798 | #ifndef TCP_X2_A |
| 799 | # define TCP_X2_A(x,y) (x)->th_x2 = (y) |
| 800 | #endif |
| 801 | #ifndef TCP_OFF |
| 802 | # define TCP_OFF(x) (x)->th_off |
| 803 | #endif |
| 804 | #ifndef TCP_OFF_A |
| 805 | # define TCP_OFF_A(x,y) (x)->th_off = (y) |
| 806 | #endif |
| 807 | #define IPMINLEN(i, h) ((i)->ip_len >= (IP_HL(i) * 4 + sizeof(struct h))) |
| 808 | |
| 809 | |
| 810 | /* |
| 811 | * XXX - This is one of those *awful* hacks which nobody likes |
| 812 | */ |
| 813 | #ifdef ultrix |
| 814 | #define A_A |
| 815 | #else |
| 816 | #define A_A & |
| 817 | #endif |
| 818 | |
| 819 | #define TCPF_ALL (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|\ |
| 820 | TH_ECN|TH_CWR) |
| 821 | |
| 822 | #if BSD_GE_YEAR(199306) && !defined(m_act) |
| 823 | # define m_act m_nextpkt |
| 824 | #endif |
| 825 | |
| 826 | /* |
| 827 | * Security Options for Intenet Protocol (IPSO) as defined in RFC 1108. |
| 828 | * |
| 829 | * Basic Option |
| 830 | * |
| 831 | * 00000001 - (Reserved 4) |
| 832 | * 00111101 - Top Secret |
| 833 | * 01011010 - Secret |
| 834 | * 10010110 - Confidential |
| 835 | * 01100110 - (Reserved 3) |
| 836 | * 11001100 - (Reserved 2) |
| 837 | * 10101011 - Unclassified |
| 838 | * 11110001 - (Reserved 1) |
| 839 | */ |
| 840 | #define IPSO_CLASS_RES4 0x01 |
| 841 | #define IPSO_CLASS_TOPS 0x3d |
| 842 | #define IPSO_CLASS_SECR 0x5a |
| 843 | #define IPSO_CLASS_CONF 0x96 |
| 844 | #define IPSO_CLASS_RES3 0x66 |
| 845 | #define IPSO_CLASS_RES2 0xcc |
| 846 | #define IPSO_CLASS_UNCL 0xab |
| 847 | #define IPSO_CLASS_RES1 0xf1 |
| 848 | |
| 849 | #define IPSO_AUTH_GENSER 0x80 |
| 850 | #define IPSO_AUTH_ESI 0x40 |
| 851 | #define IPSO_AUTH_SCI 0x20 |
| 852 | #define IPSO_AUTH_NSA 0x10 |
| 853 | #define IPSO_AUTH_DOE 0x08 |
| 854 | #define IPSO_AUTH_UN 0x06 |
| 855 | #define IPSO_AUTH_FTE 0x01 |
| 856 | |
| 857 | /* |
| 858 | * IP option #defines |
| 859 | */ |
| 860 | #undef IPOPT_RR |
| 861 | #define IPOPT_RR 7 |
| 862 | #undef IPOPT_ZSU |
| 863 | #define IPOPT_ZSU 10 /* ZSU */ |
| 864 | #undef IPOPT_MTUP |
| 865 | #define IPOPT_MTUP 11 /* MTUP */ |
| 866 | #undef IPOPT_MTUR |
| 867 | #define IPOPT_MTUR 12 /* MTUR */ |
| 868 | #undef IPOPT_ENCODE |
| 869 | #define IPOPT_ENCODE 15 /* ENCODE */ |
| 870 | #undef IPOPT_TS |
| 871 | #define IPOPT_TS 68 |
| 872 | #undef IPOPT_TR |
| 873 | #define IPOPT_TR 82 /* TR */ |
| 874 | #undef IPOPT_SECURITY |
| 875 | #define IPOPT_SECURITY 130 |
| 876 | #undef IPOPT_LSRR |
| 877 | #define IPOPT_LSRR 131 |
| 878 | #undef IPOPT_E_SEC |
| 879 | #define IPOPT_E_SEC 133 /* E-SEC */ |
| 880 | #undef IPOPT_CIPSO |
| 881 | #define IPOPT_CIPSO 134 /* CIPSO */ |
| 882 | #undef IPOPT_SATID |
| 883 | #define IPOPT_SATID 136 |
| 884 | #ifndef IPOPT_SID |
| 885 | # define IPOPT_SID IPOPT_SATID |
| 886 | #endif |
| 887 | #undef IPOPT_SSRR |
| 888 | #define IPOPT_SSRR 137 |
| 889 | #undef IPOPT_ADDEXT |
| 890 | #define IPOPT_ADDEXT 147 /* ADDEXT */ |
| 891 | #undef IPOPT_VISA |
| 892 | #define IPOPT_VISA 142 /* VISA */ |
| 893 | #undef IPOPT_IMITD |
| 894 | #define IPOPT_IMITD 144 /* IMITD */ |
| 895 | #undef IPOPT_EIP |
| 896 | #define IPOPT_EIP 145 /* EIP */ |
| 897 | #undef IPOPT_RTRALRT |
| 898 | #define IPOPT_RTRALRT 148 /* RTRALRT */ |
| 899 | #undef IPOPT_SDB |
| 900 | #define IPOPT_SDB 149 |
| 901 | #undef IPOPT_NSAPA |
| 902 | #define IPOPT_NSAPA 150 |
| 903 | #undef IPOPT_DPS |
| 904 | #define IPOPT_DPS 151 |
| 905 | #undef IPOPT_UMP |
| 906 | #define IPOPT_UMP 152 |
| 907 | #undef IPOPT_FINN |
| 908 | #define IPOPT_FINN 205 /* FINN */ |
| 909 | #undef IPOPT_AH |
| 910 | #define IPOPT_AH 256+IPPROTO_AH |
| 911 | |
| 912 | #ifndef TCPOPT_EOL |
| 913 | # define TCPOPT_EOL 0 |
| 914 | #endif |
| 915 | #ifndef TCPOPT_NOP |
| 916 | # define TCPOPT_NOP 1 |
| 917 | #endif |
| 918 | #ifndef TCPOPT_MAXSEG |
| 919 | # define TCPOPT_MAXSEG 2 |
| 920 | #endif |
| 921 | #ifndef TCPOLEN_MAXSEG |
| 922 | # define TCPOLEN_MAXSEG 4 |
| 923 | #endif |
| 924 | #ifndef TCPOPT_WINDOW |
| 925 | # define TCPOPT_WINDOW 3 |
| 926 | #endif |
| 927 | #ifndef TCPOLEN_WINDOW |
| 928 | # define TCPOLEN_WINDOW 3 |
| 929 | #endif |
| 930 | #ifndef TCPOPT_SACK_PERMITTED |
| 931 | # define TCPOPT_SACK_PERMITTED 4 |
| 932 | #endif |
| 933 | #ifndef TCPOLEN_SACK_PERMITTED |
| 934 | # define TCPOLEN_SACK_PERMITTED 2 |
| 935 | #endif |
| 936 | #ifndef TCPOPT_SACK |
| 937 | # define TCPOPT_SACK 5 |
| 938 | #endif |
| 939 | #ifndef TCPOPT_TIMESTAMP |
| 940 | # define TCPOPT_TIMESTAMP 8 |
| 941 | #endif |
| 942 | |
| 943 | #ifndef ICMP_MINLEN |
| 944 | # define ICMP_MINLEN 8 |
| 945 | #endif |
| 946 | #ifndef ICMP_ECHOREPLY |
| 947 | # define ICMP_ECHOREPLY 0 |
| 948 | #endif |
| 949 | #ifndef ICMP_UNREACH |
| 950 | # define ICMP_UNREACH 3 |
| 951 | #endif |
| 952 | #ifndef ICMP_UNREACH_NET |
| 953 | # define ICMP_UNREACH_NET 0 |
| 954 | #endif |
| 955 | #ifndef ICMP_UNREACH_HOST |
| 956 | # define ICMP_UNREACH_HOST 1 |
| 957 | #endif |
| 958 | #ifndef ICMP_UNREACH_PROTOCOL |
| 959 | # define ICMP_UNREACH_PROTOCOL 2 |
| 960 | #endif |
| 961 | #ifndef ICMP_UNREACH_PORT |
| 962 | # define ICMP_UNREACH_PORT 3 |
| 963 | #endif |
| 964 | #ifndef ICMP_UNREACH_NEEDFRAG |
| 965 | # define ICMP_UNREACH_NEEDFRAG 4 |
| 966 | #endif |
| 967 | #ifndef ICMP_UNREACH_SRCFAIL |
| 968 | # define ICMP_UNREACH_SRCFAIL 5 |
| 969 | #endif |
| 970 | #ifndef ICMP_UNREACH_NET_UNKNOWN |
| 971 | # define ICMP_UNREACH_NET_UNKNOWN 6 |
| 972 | #endif |
| 973 | #ifndef ICMP_UNREACH_HOST_UNKNOWN |
| 974 | # define ICMP_UNREACH_HOST_UNKNOWN 7 |
| 975 | #endif |
| 976 | #ifndef ICMP_UNREACH_ISOLATED |
| 977 | # define ICMP_UNREACH_ISOLATED 8 |
| 978 | #endif |
| 979 | #ifndef ICMP_UNREACH_NET_PROHIB |
| 980 | # define ICMP_UNREACH_NET_PROHIB 9 |
| 981 | #endif |
| 982 | #ifndef ICMP_UNREACH_HOST_PROHIB |
| 983 | # define ICMP_UNREACH_HOST_PROHIB 10 |
| 984 | #endif |
| 985 | #ifndef ICMP_UNREACH_TOSNET |
| 986 | # define ICMP_UNREACH_TOSNET 11 |
| 987 | #endif |
| 988 | #ifndef ICMP_UNREACH_TOSHOST |
| 989 | # define ICMP_UNREACH_TOSHOST 12 |
| 990 | #endif |
| 991 | #ifndef ICMP_UNREACH_ADMIN_PROHIBIT |
| 992 | # define ICMP_UNREACH_ADMIN_PROHIBIT 13 |
| 993 | #endif |
| 994 | #ifndef ICMP_UNREACH_FILTER |
| 995 | # define ICMP_UNREACH_FILTER 13 |
| 996 | #endif |
| 997 | #ifndef ICMP_UNREACH_HOST_PRECEDENCE |
| 998 | # define ICMP_UNREACH_HOST_PRECEDENCE 14 |
| 999 | #endif |
| 1000 | #ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF |
| 1001 | # define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 |
| 1002 | #endif |
| 1003 | #ifndef ICMP_SOURCEQUENCH |
| 1004 | # define ICMP_SOURCEQUENCH 4 |
| 1005 | #endif |
| 1006 | #ifndef ICMP_REDIRECT_NET |
| 1007 | # define ICMP_REDIRECT_NET 0 |
| 1008 | #endif |
| 1009 | #ifndef ICMP_REDIRECT_HOST |
| 1010 | # define ICMP_REDIRECT_HOST 1 |
| 1011 | #endif |
| 1012 | #ifndef ICMP_REDIRECT_TOSNET |
| 1013 | # define ICMP_REDIRECT_TOSNET 2 |
| 1014 | #endif |
| 1015 | #ifndef ICMP_REDIRECT_TOSHOST |
| 1016 | # define ICMP_REDIRECT_TOSHOST 3 |
| 1017 | #endif |
| 1018 | #ifndef ICMP_ALTHOSTADDR |
| 1019 | # define ICMP_ALTHOSTADDR 6 |
| 1020 | #endif |
| 1021 | #ifndef ICMP_TIMXCEED |
| 1022 | # define ICMP_TIMXCEED 11 |
| 1023 | #endif |
| 1024 | #ifndef ICMP_TIMXCEED_INTRANS |
| 1025 | # define ICMP_TIMXCEED_INTRANS 0 |
| 1026 | #endif |
| 1027 | #ifndef ICMP_TIMXCEED_REASS |
| 1028 | # define ICMP_TIMXCEED_REASS 1 |
| 1029 | #endif |
| 1030 | #ifndef ICMP_PARAMPROB |
| 1031 | # define ICMP_PARAMPROB 12 |
| 1032 | #endif |
| 1033 | #ifndef ICMP_PARAMPROB_ERRATPTR |
| 1034 | # define ICMP_PARAMPROB_ERRATPTR 0 |
| 1035 | #endif |
| 1036 | #ifndef ICMP_PARAMPROB_OPTABSENT |
| 1037 | # define ICMP_PARAMPROB_OPTABSENT 1 |
| 1038 | #endif |
| 1039 | #ifndef ICMP_PARAMPROB_LENGTH |
| 1040 | # define ICMP_PARAMPROB_LENGTH 2 |
| 1041 | #endif |
| 1042 | #ifndef ICMP_TSTAMP |
| 1043 | # define ICMP_TSTAMP 13 |
| 1044 | #endif |
| 1045 | #ifndef ICMP_TSTAMPREPLY |
| 1046 | # define ICMP_TSTAMPREPLY 14 |
| 1047 | #endif |
| 1048 | #ifndef ICMP_IREQ |
| 1049 | # define ICMP_IREQ 15 |
| 1050 | #endif |
| 1051 | #ifndef ICMP_IREQREPLY |
| 1052 | # define ICMP_IREQREPLY 16 |
| 1053 | #endif |
| 1054 | #ifndef ICMP_MASKREQ |
| 1055 | # define ICMP_MASKREQ 17 |
| 1056 | #endif |
| 1057 | #ifndef ICMP_MASKREPLY |
| 1058 | # define ICMP_MASKREPLY 18 |
| 1059 | #endif |
| 1060 | #ifndef ICMP_TRACEROUTE |
| 1061 | # define ICMP_TRACEROUTE 30 |
| 1062 | #endif |
| 1063 | #ifndef ICMP_DATACONVERR |
| 1064 | # define ICMP_DATACONVERR 31 |
| 1065 | #endif |
| 1066 | #ifndef ICMP_MOBILE_REDIRECT |
| 1067 | # define ICMP_MOBILE_REDIRECT 32 |
| 1068 | #endif |
| 1069 | #ifndef ICMP_IPV6_WHEREAREYOU |
| 1070 | # define ICMP_IPV6_WHEREAREYOU 33 |
| 1071 | #endif |
| 1072 | #ifndef ICMP_IPV6_IAMHERE |
| 1073 | # define ICMP_IPV6_IAMHERE 34 |
| 1074 | #endif |
| 1075 | #ifndef ICMP_MOBILE_REGREQUEST |
| 1076 | # define ICMP_MOBILE_REGREQUEST 35 |
| 1077 | #endif |
| 1078 | #ifndef ICMP_MOBILE_REGREPLY |
| 1079 | # define ICMP_MOBILE_REGREPLY 36 |
| 1080 | #endif |
| 1081 | #ifndef ICMP_SKIP |
| 1082 | # define ICMP_SKIP 39 |
| 1083 | #endif |
| 1084 | #ifndef ICMP_PHOTURIS |
| 1085 | # define ICMP_PHOTURIS 40 |
| 1086 | #endif |
| 1087 | #ifndef ICMP_PHOTURIS_UNKNOWN_INDEX |
| 1088 | # define ICMP_PHOTURIS_UNKNOWN_INDEX 1 |
| 1089 | #endif |
| 1090 | #ifndef ICMP_PHOTURIS_AUTH_FAILED |
| 1091 | # define ICMP_PHOTURIS_AUTH_FAILED 2 |
| 1092 | #endif |
| 1093 | #ifndef ICMP_PHOTURIS_DECRYPT_FAILED |
| 1094 | # define ICMP_PHOTURIS_DECRYPT_FAILED 3 |
| 1095 | #endif |
| 1096 | #ifndef IPVERSION |
| 1097 | # define IPVERSION 4 |
| 1098 | #endif |
| 1099 | #ifndef IPOPT_MINOFF |
| 1100 | # define IPOPT_MINOFF 4 |
| 1101 | #endif |
| 1102 | #ifndef IPOPT_COPIED |
| 1103 | # define IPOPT_COPIED(x) ((x)&0x80) |
| 1104 | #endif |
| 1105 | #ifndef IPOPT_EOL |
| 1106 | # define IPOPT_EOL 0 |
| 1107 | #endif |
| 1108 | #ifndef IPOPT_NOP |
| 1109 | # define IPOPT_NOP 1 |
| 1110 | #endif |
| 1111 | #ifndef IP_MF |
| 1112 | # define IP_MF ((u_short)0x2000) |
| 1113 | #endif |
| 1114 | #ifndef ETHERTYPE_IP |
| 1115 | # define ETHERTYPE_IP ((u_short)0x0800) |
| 1116 | #endif |
| 1117 | #ifndef TH_FIN |
| 1118 | # define TH_FIN 0x01 |
| 1119 | #endif |
| 1120 | #ifndef TH_SYN |
| 1121 | # define TH_SYN 0x02 |
| 1122 | #endif |
| 1123 | #ifndef TH_RST |
| 1124 | # define TH_RST 0x04 |
| 1125 | #endif |
| 1126 | #ifndef TH_PUSH |
| 1127 | # define TH_PUSH 0x08 |
| 1128 | #endif |
| 1129 | #ifndef TH_ACK |
| 1130 | # define TH_ACK 0x10 |
| 1131 | #endif |
| 1132 | #ifndef TH_URG |
| 1133 | # define TH_URG 0x20 |
| 1134 | #endif |
| 1135 | #undef TH_ACKMASK |
| 1136 | #define TH_ACKMASK (TH_FIN|TH_SYN|TH_RST|TH_ACK) |
| 1137 | |
| 1138 | #ifndef IPOPT_EOL |
| 1139 | # define IPOPT_EOL 0 |
| 1140 | #endif |
| 1141 | #ifndef IPOPT_NOP |
| 1142 | # define IPOPT_NOP 1 |
| 1143 | #endif |
| 1144 | #ifndef IPOPT_RR |
| 1145 | # define IPOPT_RR 7 |
| 1146 | #endif |
| 1147 | #ifndef IPOPT_TS |
| 1148 | # define IPOPT_TS 68 |
| 1149 | #endif |
| 1150 | #ifndef IPOPT_SECURITY |
| 1151 | # define IPOPT_SECURITY 130 |
| 1152 | #endif |
| 1153 | #ifndef IPOPT_LSRR |
| 1154 | # define IPOPT_LSRR 131 |
| 1155 | #endif |
| 1156 | #ifndef IPOPT_SATID |
| 1157 | # define IPOPT_SATID 136 |
| 1158 | #endif |
| 1159 | #ifndef IPOPT_SSRR |
| 1160 | # define IPOPT_SSRR 137 |
| 1161 | #endif |
| 1162 | #ifndef IPOPT_SECUR_UNCLASS |
| 1163 | # define IPOPT_SECUR_UNCLASS ((u_short)0x0000) |
| 1164 | #endif |
| 1165 | #ifndef IPOPT_SECUR_CONFID |
| 1166 | # define IPOPT_SECUR_CONFID ((u_short)0xf135) |
| 1167 | #endif |
| 1168 | #ifndef IPOPT_SECUR_EFTO |
| 1169 | # define IPOPT_SECUR_EFTO ((u_short)0x789a) |
| 1170 | #endif |
| 1171 | #ifndef IPOPT_SECUR_MMMM |
| 1172 | # define IPOPT_SECUR_MMMM ((u_short)0xbc4d) |
| 1173 | #endif |
| 1174 | #ifndef IPOPT_SECUR_RESTR |
| 1175 | # define IPOPT_SECUR_RESTR ((u_short)0xaf13) |
| 1176 | #endif |
| 1177 | #ifndef IPOPT_SECUR_SECRET |
| 1178 | # define IPOPT_SECUR_SECRET ((u_short)0xd788) |
| 1179 | #endif |
| 1180 | #ifndef IPOPT_SECUR_TOPSECRET |
| 1181 | # define IPOPT_SECUR_TOPSECRET ((u_short)0x6bc5) |
| 1182 | #endif |
| 1183 | #ifndef IPOPT_OLEN |
| 1184 | # define IPOPT_OLEN 1 |
| 1185 | #endif |
| 1186 | #ifndef IPPROTO_HOPOPTS |
| 1187 | # define IPPROTO_HOPOPTS 0 |
| 1188 | #endif |
| 1189 | #ifndef IPPROTO_IPIP |
| 1190 | # define IPPROTO_IPIP 4 |
| 1191 | #endif |
| 1192 | #ifndef IPPROTO_ENCAP |
| 1193 | # define IPPROTO_ENCAP 98 |
| 1194 | #endif |
| 1195 | #ifndef IPPROTO_IPV6 |
| 1196 | # define IPPROTO_IPV6 41 |
| 1197 | #endif |
| 1198 | #ifndef IPPROTO_ROUTING |
| 1199 | # define IPPROTO_ROUTING 43 |
| 1200 | #endif |
| 1201 | #ifndef IPPROTO_FRAGMENT |
| 1202 | # define IPPROTO_FRAGMENT 44 |
| 1203 | #endif |
| 1204 | #ifndef IPPROTO_GRE |
| 1205 | # define IPPROTO_GRE 47 /* GRE encaps RFC 1701 */ |
| 1206 | #endif |
| 1207 | #ifndef IPPROTO_ESP |
| 1208 | # define IPPROTO_ESP 50 |
| 1209 | #endif |
| 1210 | #ifndef IPPROTO_AH |
| 1211 | # define IPPROTO_AH 51 |
| 1212 | #endif |
| 1213 | #ifndef IPPROTO_ICMPV6 |
| 1214 | # define IPPROTO_ICMPV6 58 |
| 1215 | #endif |
| 1216 | #ifndef IPPROTO_NONE |
| 1217 | # define IPPROTO_NONE 59 |
| 1218 | #endif |
| 1219 | #ifndef IPPROTO_DSTOPTS |
| 1220 | # define IPPROTO_DSTOPTS 60 |
| 1221 | #endif |
| 1222 | #ifndef IPPROTO_MOBILITY |
| 1223 | # define IPPROTO_MOBILITY 135 |
| 1224 | #endif |
| 1225 | |
| 1226 | #ifndef ICMP_ROUTERADVERT |
| 1227 | # define ICMP_ROUTERADVERT 9 |
| 1228 | #endif |
| 1229 | #ifndef ICMP_ROUTERSOLICIT |
| 1230 | # define ICMP_ROUTERSOLICIT 10 |
| 1231 | #endif |
| 1232 | #ifndef ICMP6_DST_UNREACH |
| 1233 | # define ICMP6_DST_UNREACH 1 |
| 1234 | #endif |
| 1235 | #ifndef ICMP6_PACKET_TOO_BIG |
| 1236 | # define ICMP6_PACKET_TOO_BIG 2 |
| 1237 | #endif |
| 1238 | #ifndef ICMP6_TIME_EXCEEDED |
| 1239 | # define ICMP6_TIME_EXCEEDED 3 |
| 1240 | #endif |
| 1241 | #ifndef ICMP6_PARAM_PROB |
| 1242 | # define ICMP6_PARAM_PROB 4 |
| 1243 | #endif |
| 1244 | |
| 1245 | #ifndef ICMP6_ECHO_REQUEST |
| 1246 | # define ICMP6_ECHO_REQUEST 128 |
| 1247 | #endif |
| 1248 | #ifndef ICMP6_ECHO_REPLY |
| 1249 | # define ICMP6_ECHO_REPLY 129 |
| 1250 | #endif |
| 1251 | #ifndef ICMP6_MEMBERSHIP_QUERY |
| 1252 | # define ICMP6_MEMBERSHIP_QUERY 130 |
| 1253 | #endif |
| 1254 | #ifndef MLD6_LISTENER_QUERY |
| 1255 | # define MLD6_LISTENER_QUERY 130 |
| 1256 | #endif |
| 1257 | #ifndef ICMP6_MEMBERSHIP_REPORT |
| 1258 | # define ICMP6_MEMBERSHIP_REPORT 131 |
| 1259 | #endif |
| 1260 | #ifndef MLD6_LISTENER_REPORT |
| 1261 | # define MLD6_LISTENER_REPORT 131 |
| 1262 | #endif |
| 1263 | #ifndef ICMP6_MEMBERSHIP_REDUCTION |
| 1264 | # define ICMP6_MEMBERSHIP_REDUCTION 132 |
| 1265 | #endif |
| 1266 | #ifndef MLD6_LISTENER_DONE |
| 1267 | # define MLD6_LISTENER_DONE 132 |
| 1268 | #endif |
| 1269 | #ifndef ND_ROUTER_SOLICIT |
| 1270 | # define ND_ROUTER_SOLICIT 133 |
| 1271 | #endif |
| 1272 | #ifndef ND_ROUTER_ADVERT |
| 1273 | # define ND_ROUTER_ADVERT 134 |
| 1274 | #endif |
| 1275 | #ifndef ND_NEIGHBOR_SOLICIT |
| 1276 | # define ND_NEIGHBOR_SOLICIT 135 |
| 1277 | #endif |
| 1278 | #ifndef ND_NEIGHBOR_ADVERT |
| 1279 | # define ND_NEIGHBOR_ADVERT 136 |
| 1280 | #endif |
| 1281 | #ifndef ND_REDIRECT |
| 1282 | # define ND_REDIRECT 137 |
| 1283 | #endif |
| 1284 | #ifndef ICMP6_ROUTER_RENUMBERING |
| 1285 | # define ICMP6_ROUTER_RENUMBERING 138 |
| 1286 | #endif |
| 1287 | #ifndef ICMP6_WRUREQUEST |
| 1288 | # define ICMP6_WRUREQUEST 139 |
| 1289 | #endif |
| 1290 | #ifndef ICMP6_WRUREPLY |
| 1291 | # define ICMP6_WRUREPLY 140 |
| 1292 | #endif |
| 1293 | #ifndef ICMP6_FQDN_QUERY |
| 1294 | # define ICMP6_FQDN_QUERY 139 |
| 1295 | #endif |
| 1296 | #ifndef ICMP6_FQDN_REPLY |
| 1297 | # define ICMP6_FQDN_REPLY 140 |
| 1298 | #endif |
| 1299 | #ifndef ICMP6_NI_QUERY |
| 1300 | # define ICMP6_NI_QUERY 139 |
| 1301 | #endif |
| 1302 | #ifndef ICMP6_NI_REPLY |
| 1303 | # define ICMP6_NI_REPLY 140 |
| 1304 | #endif |
| 1305 | #ifndef MLD6_MTRACE_RESP |
| 1306 | # define MLD6_MTRACE_RESP 200 |
| 1307 | #endif |
| 1308 | #ifndef MLD6_MTRACE |
| 1309 | # define MLD6_MTRACE 201 |
| 1310 | #endif |
| 1311 | #ifndef ICMP6_HADISCOV_REQUEST |
| 1312 | # define ICMP6_HADISCOV_REQUEST 202 |
| 1313 | #endif |
| 1314 | #ifndef ICMP6_HADISCOV_REPLY |
| 1315 | # define ICMP6_HADISCOV_REPLY 203 |
| 1316 | #endif |
| 1317 | #ifndef ICMP6_MOBILEPREFIX_SOLICIT |
| 1318 | # define ICMP6_MOBILEPREFIX_SOLICIT 204 |
| 1319 | #endif |
| 1320 | #ifndef ICMP6_MOBILEPREFIX_ADVERT |
| 1321 | # define ICMP6_MOBILEPREFIX_ADVERT 205 |
| 1322 | #endif |
| 1323 | #ifndef ICMP6_MAXTYPE |
| 1324 | # define ICMP6_MAXTYPE 205 |
| 1325 | #endif |
| 1326 | |
| 1327 | #ifndef ICMP6_DST_UNREACH_NOROUTE |
| 1328 | # define ICMP6_DST_UNREACH_NOROUTE 0 |
| 1329 | #endif |
| 1330 | #ifndef ICMP6_DST_UNREACH_ADMIN |
| 1331 | # define ICMP6_DST_UNREACH_ADMIN 1 |
| 1332 | #endif |
| 1333 | #ifndef ICMP6_DST_UNREACH_NOTNEIGHBOR |
| 1334 | # define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 |
| 1335 | #endif |
| 1336 | #ifndef ICMP6_DST_UNREACH_BEYONDSCOPE |
| 1337 | # define ICMP6_DST_UNREACH_BEYONDSCOPE 2 |
| 1338 | #endif |
| 1339 | #ifndef ICMP6_DST_UNREACH_ADDR |
| 1340 | # define ICMP6_DST_UNREACH_ADDR 3 |
| 1341 | #endif |
| 1342 | #ifndef ICMP6_DST_UNREACH_NOPORT |
| 1343 | # define ICMP6_DST_UNREACH_NOPORT 4 |
| 1344 | #endif |
| 1345 | #ifndef ICMP6_TIME_EXCEED_TRANSIT |
| 1346 | # define ICMP6_TIME_EXCEED_TRANSIT 0 |
| 1347 | #endif |
| 1348 | #ifndef ICMP6_TIME_EXCEED_REASSEMBLY |
| 1349 | # define ICMP6_TIME_EXCEED_REASSEMBLY 1 |
| 1350 | #endif |
| 1351 | |
| 1352 | #ifndef ICMP6_NI_SUCCESS |
| 1353 | # define ICMP6_NI_SUCCESS 0 |
| 1354 | #endif |
| 1355 | #ifndef ICMP6_NI_REFUSED |
| 1356 | # define ICMP6_NI_REFUSED 1 |
| 1357 | #endif |
| 1358 | #ifndef ICMP6_NI_UNKNOWN |
| 1359 | # define ICMP6_NI_UNKNOWN 2 |
| 1360 | #endif |
| 1361 | |
| 1362 | #ifndef ICMP6_ROUTER_RENUMBERING_COMMAND |
| 1363 | # define ICMP6_ROUTER_RENUMBERING_COMMAND 0 |
| 1364 | #endif |
| 1365 | #ifndef ICMP6_ROUTER_RENUMBERING_RESULT |
| 1366 | # define ICMP6_ROUTER_RENUMBERING_RESULT 1 |
| 1367 | #endif |
| 1368 | #ifndef ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET |
| 1369 | # define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 |
| 1370 | #endif |
| 1371 | |
| 1372 | #ifndef ICMP6_PARAMPROB_HEADER |
| 1373 | # define ICMP6_PARAMPROB_HEADER 0 |
| 1374 | #endif |
| 1375 | #ifndef ICMP6_PARAMPROB_NEXTHEADER |
| 1376 | # define ICMP6_PARAMPROB_NEXTHEADER 1 |
| 1377 | #endif |
| 1378 | #ifndef ICMP6_PARAMPROB_OPTION |
| 1379 | # define ICMP6_PARAMPROB_OPTION 2 |
| 1380 | #endif |
| 1381 | |
| 1382 | #ifndef ICMP6_NI_SUBJ_IPV6 |
| 1383 | # define ICMP6_NI_SUBJ_IPV6 0 |
| 1384 | #endif |
| 1385 | #ifndef ICMP6_NI_SUBJ_FQDN |
| 1386 | # define ICMP6_NI_SUBJ_FQDN 1 |
| 1387 | #endif |
| 1388 | #ifndef ICMP6_NI_SUBJ_IPV4 |
| 1389 | # define ICMP6_NI_SUBJ_IPV4 2 |
| 1390 | #endif |
| 1391 | |
| 1392 | #ifndef MLD_MTRACE_RESP |
| 1393 | # define MLD_MTRACE_RESP 200 |
| 1394 | #endif |
| 1395 | #ifndef MLD_MTRACE |
| 1396 | # define MLD_MTRACE 201 |
| 1397 | #endif |
| 1398 | #ifndef MLD6_MTRACE_RESP |
| 1399 | # define MLD6_MTRACE_RESP MLD_MTRACE_RESP |
| 1400 | #endif |
| 1401 | #ifndef MLD6_MTRACE |
| 1402 | # define MLD6_MTRACE MLD_MTRACE |
| 1403 | #endif |
| 1404 | |
| 1405 | #if !defined(IPV6_FLOWINFO_MASK) |
| 1406 | # if (BYTE_ORDER == BIG_ENDIAN) || defined(_BIG_ENDIAN) |
| 1407 | # define IPV6_FLOWINFO_MASK 0x0fffffff /* flow info (28 bits) */ |
| 1408 | # else |
| 1409 | # if(BYTE_ORDER == LITTLE_ENDIAN) || !defined(_BIG_ENDIAN) |
| 1410 | # define IPV6_FLOWINFO_MASK 0xffffff0f /* flow info (28 bits) */ |
| 1411 | # endif /* LITTLE_ENDIAN */ |
| 1412 | # endif |
| 1413 | #endif |
| 1414 | #if !defined(IPV6_FLOWLABEL_MASK) |
| 1415 | # if (BYTE_ORDER == BIG_ENDIAN) || defined(_BIG_ENDIAN) |
| 1416 | # define IPV6_FLOWLABEL_MASK 0x000fffff /* flow label (20 bits) */ |
| 1417 | # else |
| 1418 | # if (BYTE_ORDER == LITTLE_ENDIAN) || !defined(_BIG_ENDIAN) |
| 1419 | # define IPV6_FLOWLABEL_MASK 0xffff0f00 /* flow label (20 bits) */ |
| 1420 | # endif /* LITTLE_ENDIAN */ |
| 1421 | # endif |
| 1422 | #endif |
| 1423 | |
| 1424 | /* |
| 1425 | * ECN is a new addition to TCP - RFC 2481 |
| 1426 | */ |
| 1427 | #ifndef TH_ECN |
| 1428 | # define TH_ECN 0x40 |
| 1429 | #endif |
| 1430 | #ifndef TH_CWR |
| 1431 | # define TH_CWR 0x80 |
| 1432 | #endif |
| 1433 | #define TH_ECNALL (TH_ECN|TH_CWR) |
| 1434 | |
| 1435 | /* |
| 1436 | * TCP States |
| 1437 | */ |
| 1438 | #define IPF_TCPS_LISTEN 0 /* listening for connection */ |
| 1439 | #define IPF_TCPS_SYN_SENT 1 /* active, have sent syn */ |
| 1440 | #define IPF_TCPS_SYN_RECEIVED 2 /* have send and received syn */ |
| 1441 | #define IPF_TCPS_HALF_ESTAB 3 /* for connections not fully "up" */ |
| 1442 | /* states < IPF_TCPS_ESTABLISHED are those where connections not established */ |
| 1443 | #define IPF_TCPS_ESTABLISHED 4 /* established */ |
| 1444 | #define IPF_TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */ |
| 1445 | /* states > IPF_TCPS_CLOSE_WAIT are those where user has closed */ |
| 1446 | #define IPF_TCPS_FIN_WAIT_1 6 /* have closed, sent fin */ |
| 1447 | #define IPF_TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */ |
| 1448 | #define IPF_TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */ |
| 1449 | /* states > IPF_TCPS_CLOSE_WAIT && < IPF_TCPS_FIN_WAIT_2 await ACK of FIN */ |
| 1450 | #define IPF_TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ |
| 1451 | #define IPF_TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ |
| 1452 | #define IPF_TCPS_CLOSED 11 /* closed */ |
| 1453 | #define IPF_TCP_NSTATES 12 |
| 1454 | |
| 1455 | #define TCP_MSL 120 |
| 1456 | |
| 1457 | #undef ICMP_MAX_UNREACH |
| 1458 | #define ICMP_MAX_UNREACH 14 |
| 1459 | #undef ICMP_MAXTYPE |
| 1460 | #define ICMP_MAXTYPE 18 |
| 1461 | |
| 1462 | #ifndef IFNAMSIZ |
| 1463 | #define IFNAMSIZ 16 |
| 1464 | #endif |
| 1465 | |
| 1466 | #ifndef LOG_FTP |
| 1467 | # define LOG_FTP (11<<3) |
| 1468 | #endif |
| 1469 | #ifndef LOG_AUTHPRIV |
| 1470 | # define LOG_AUTHPRIV (10<<3) |
| 1471 | #endif |
| 1472 | #ifndef LOG_AUDIT |
| 1473 | # define LOG_AUDIT (13<<3) |
| 1474 | #endif |
| 1475 | #ifndef LOG_NTP |
| 1476 | # define LOG_NTP (12<<3) |
| 1477 | #endif |
| 1478 | #ifndef LOG_SECURITY |
| 1479 | # define LOG_SECURITY (13<<3) |
| 1480 | #endif |
| 1481 | #ifndef LOG_LFMT |
| 1482 | # define LOG_LFMT (14<<3) |
| 1483 | #endif |
| 1484 | #ifndef LOG_CONSOLE |
| 1485 | # define LOG_CONSOLE (14<<3) |
| 1486 | #endif |
| 1487 | |
| 1488 | /* |
| 1489 | * ICMP error replies have an IP header (20 bytes), 8 bytes of ICMP data, |
| 1490 | * another IP header and then 64 bits of data, totalling 56. Of course, |
| 1491 | * the last 64 bits is dependent on that being available. |
| 1492 | */ |
| 1493 | #define ICMPERR_ICMPHLEN 8 |
| 1494 | #define ICMPERR_IPICMPHLEN (20 + 8) |
| 1495 | #define ICMPERR_MINPKTLEN (20 + 8 + 20) |
| 1496 | #define ICMPERR_MAXPKTLEN (20 + 8 + 20 + 8) |
| 1497 | #define ICMP6ERR_MINPKTLEN (40 + 8) |
| 1498 | #define ICMP6ERR_IPICMPHLEN (40 + 8 + 40) |
| 1499 | |
| 1500 | #ifndef MIN |
| 1501 | # define MIN(a,b) (((a)<(b))?(a):(b)) |
| 1502 | #endif |
| 1503 | |
| 1504 | #ifdef RESCUE |
| 1505 | # undef IPFILTER_BPF |
| 1506 | #endif |
| 1507 | |
| 1508 | #ifdef IPF_DEBUG |
| 1509 | # define DPRINT(x) printf x |
| 1510 | #else |
| 1511 | # define DPRINT(x) |
| 1512 | #endif |
| 1513 | |
| 1514 | #ifndef AF_INET6 |
| 1515 | # define AF_INET6 26 |
| 1516 | #endif |
| 1517 | |
| 1518 | #ifdef DTRACE_PROBE |
| 1519 | # ifdef _KERNEL |
| 1520 | # define DT(_n) DTRACE_PROBE(_n) |
| 1521 | # define DT1(_n,_a,_b) DTRACE_PROBE1(_n,_a,_b) |
| 1522 | # define DT2(_n,_a,_b,_c,_d) DTRACE_PROBE2(_n,_a,_b,_c,_d) |
| 1523 | # define DT3(_n,_a,_b,_c,_d,_e,_f) \ |
| 1524 | DTRACE_PROBE3(_n,_a,_b,_c,_d,_e,_f) |
| 1525 | # define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) \ |
| 1526 | DTRACE_PROBE4(_n,_a,_b,_c,_d,_e,_f,_g,_h) |
| 1527 | # else |
| 1528 | # define DT(_n) |
| 1529 | # define DT1(_n,_a,_b) |
| 1530 | # define DT2(_n,_a,_b,_c,_d) |
| 1531 | # define DT3(_n,_a,_b,_c,_d,_e,_f) |
| 1532 | # define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) |
| 1533 | # endif |
| 1534 | #else |
| 1535 | # define DT(_n) |
| 1536 | # define DT1(_n,_a,_b) |
| 1537 | # define DT2(_n,_a,_b,_c,_d) |
| 1538 | # define DT3(_n,_a,_b,_c,_d,_e,_f) |
| 1539 | # define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) |
| 1540 | #endif |
| 1541 | |
| 1542 | struct ip6_routing { |
| 1543 | u_char ip6r_nxt; /* next header */ |
| 1544 | u_char ip6r_len; /* length in units of 8 octets */ |
| 1545 | u_char ip6r_type; /* always zero */ |
| 1546 | u_char ip6r_segleft; /* segments left */ |
| 1547 | u_32_t ip6r_reserved; /* reserved field */ |
| 1548 | }; |
| 1549 | |
| 1550 | #endif /* __IP_COMPAT_H__ */ |
| 1551 | |