1 /* 2 * Copyright (C) 1993-2001, 2003 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 * 6 * @(#)ip_fil.h 1.35 6/5/96 7 * $Id: ip_fil.h,v 2.170.2.22 2005/07/16 05:55:35 darrenr Exp $ 8 * 9 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 10 * Use is subject to license terms. 11 */ 12 13 #ifndef __IP_FIL_H__ 14 #define __IP_FIL_H__ 15 16 #include "netinet/ip_compat.h" 17 18 #ifndef SOLARIS 19 # define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4))) 20 #endif 21 22 #ifndef __P 23 # ifdef __STDC__ 24 # define __P(x) x 25 # else 26 # define __P(x) () 27 # endif 28 #endif 29 30 #if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51) 31 # define SIOCADAFR _IOW('r', 60, struct ipfobj) 32 # define SIOCRMAFR _IOW('r', 61, struct ipfobj) 33 # define SIOCSETFF _IOW('r', 62, u_int) 34 # define SIOCGETFF _IOR('r', 63, u_int) 35 # define SIOCGETFS _IOWR('r', 64, struct ipfobj) 36 # define SIOCIPFFL _IOWR('r', 65, int) 37 # define SIOCIPFFB _IOR('r', 66, int) 38 # define SIOCADIFR _IOW('r', 67, struct ipfobj) 39 # define SIOCRMIFR _IOW('r', 68, struct ipfobj) 40 # define SIOCSWAPA _IOR('r', 69, u_int) 41 # define SIOCINAFR _IOW('r', 70, struct ipfobj) 42 # define SIOCINIFR _IOW('r', 71, struct ipfobj) 43 # define SIOCFRENB _IOW('r', 72, u_int) 44 # define SIOCFRSYN _IOW('r', 73, u_int) 45 # define SIOCFRZST _IOWR('r', 74, struct ipfobj) 46 # define SIOCZRLST _IOWR('r', 75, struct ipfobj) 47 # define SIOCAUTHW _IOWR('r', 76, struct ipfobj) 48 # define SIOCAUTHR _IOWR('r', 77, struct ipfobj) 49 # define SIOCATHST _IOWR('r', 78, struct ipfobj) 50 # define SIOCSTLCK _IOWR('r', 79, u_int) 51 # define SIOCSTPUT _IOWR('r', 80, struct ipfobj) 52 # define SIOCSTGET _IOWR('r', 81, struct ipfobj) 53 # define SIOCSTGSZ _IOWR('r', 82, struct ipfobj) 54 # define SIOCGFRST _IOWR('r', 83, struct ipfobj) 55 # define SIOCSETLG _IOWR('r', 84, int) 56 # define SIOCGETLG _IOWR('r', 85, int) 57 # define SIOCFUNCL _IOWR('r', 86, struct ipfunc_resolve) 58 # define SIOCIPFGETNEXT _IOWR('r', 87, struct ipfobj) 59 # define SIOCIPFGET _IOWR('r', 88, struct ipfobj) 60 # define SIOCIPFSET _IOWR('r', 89, struct ipfobj) 61 # define SIOCIPFL6 _IOWR('r', 90, int) 62 # define SIOCIPFLP _IOWR('r', 91, int) 63 # define SIOCIPFITER _IOWR('r', 92, struct ipfobj) 64 # define SIOCGENITER _IOWR('r', 93, struct ipfobj) 65 # define SIOCGTABL _IOWR('r', 94, struct ipfobj) 66 # define SIOCIPFDELTOK _IOWR('r', 95, int) 67 # define SIOCLOOKUPITER _IOWR('r', 96, struct ipfobj) 68 #else 69 # define SIOCADAFR _IOW(r, 60, struct ipfobj) 70 # define SIOCRMAFR _IOW(r, 61, struct ipfobj) 71 # define SIOCSETFF _IOW(r, 62, u_int) 72 # define SIOCGETFF _IOR(r, 63, u_int) 73 # define SIOCGETFS _IOWR(r, 64, struct ipfobj) 74 # define SIOCIPFFL _IOWR(r, 65, int) 75 # define SIOCIPFFB _IOR(r, 66, int) 76 # define SIOCADIFR _IOW(r, 67, struct ipfobj) 77 # define SIOCRMIFR _IOW(r, 68, struct ipfobj) 78 # define SIOCSWAPA _IOR(r, 69, u_int) 79 # define SIOCINAFR _IOW(r, 70, struct ipfobj) 80 # define SIOCINIFR _IOW(r, 71, struct ipfobj) 81 # define SIOCFRENB _IOW(r, 72, u_int) 82 # define SIOCFRSYN _IOW(r, 73, u_int) 83 # define SIOCFRZST _IOWR(r, 74, struct ipfobj) 84 # define SIOCZRLST _IOWR(r, 75, struct ipfobj) 85 # define SIOCAUTHW _IOWR(r, 76, struct ipfobj) 86 # define SIOCAUTHR _IOWR(r, 77, struct ipfobj) 87 # define SIOCATHST _IOWR(r, 78, struct ipfobj) 88 # define SIOCSTLCK _IOWR(r, 79, u_int) 89 # define SIOCSTPUT _IOWR(r, 80, struct ipfobj) 90 # define SIOCSTGET _IOWR(r, 81, struct ipfobj) 91 # define SIOCSTGSZ _IOWR(r, 82, struct ipfobj) 92 # define SIOCGFRST _IOWR(r, 83, struct ipfobj) 93 # define SIOCSETLG _IOWR(r, 84, int) 94 # define SIOCGETLG _IOWR(r, 85, int) 95 # define SIOCFUNCL _IOWR(r, 86, struct ipfunc_resolve) 96 # define SIOCIPFGETNEXT _IOWR(r, 87, struct ipfobj) 97 # define SIOCIPFGET _IOWR(r, 88, struct ipfobj) 98 # define SIOCIPFSET _IOWR(r, 89, struct ipfobj) 99 # define SIOCIPFL6 _IOWR(r, 90, int) 100 # define SIOCIPFLP _IOWR(r, 91, int) 101 # define SIOCIPFITER _IOWR(r, 92, struct ipfobj) 102 # define SIOCGENITER _IOWR(r, 93, struct ipfobj) 103 # define SIOCGTABL _IOWR(r, 94, struct ipfobj) 104 # define SIOCIPFDELTOK _IOWR(r, 95, int) 105 # define SIOCLOOKUPITER _IOWR(r, 96, struct ipfobj) 106 #endif 107 #define SIOCADDFR SIOCADAFR 108 #define SIOCDELFR SIOCRMAFR 109 #define SIOCINSFR SIOCINAFR 110 111 /* 112 * What type of table is getting flushed? 113 */ 114 115 #define NAT_FLUSH 1 116 #define STATE_FLUSH 2 117 118 /* 119 * What table flush options are available? 120 */ 121 122 #define FLUSH_LIST 0 123 #define FLUSH_TABLE_ALL 1 /* Flush entire table */ 124 #define FLUSH_TABLE_CLOSING 2 /* Flush "closing" entries" */ 125 #define FLUSH_TABLE_EXTRA 3 /* Targetted flush: almost closed, long idle */ 126 127 #define VALID_TABLE_FLUSH_OPT(x) ((x) >= 1 && (x) <= 3) 128 129 /* 130 * Define the default hi and lo watermarks used when flushing the 131 * tables. The values represent percent full of respective tables. 132 */ 133 134 #define NAT_FLUSH_HI 95 135 #define NAT_FLUSH_LO 75 136 137 #define ST_FLUSH_HI 95 138 #define ST_FLUSH_LO 75 139 140 /* 141 * How full are the tables? 142 */ 143 144 #define NAT_TAB_WATER_LEVEL(x) ((x)->ifs_nat_stats.ns_inuse * 100 \ 145 / (x)->ifs_ipf_nattable_max) 146 147 #define ST_TAB_WATER_LEVEL(x) ((x)->ifs_ips_num * 100 \ 148 / (x)->ifs_fr_statemax) 149 150 struct ipscan; 151 struct ifnet; 152 153 typedef struct ipf_stack ipf_stack_t; 154 155 typedef int (* lookupfunc_t) __P((void *, int, void *, ipf_stack_t *)); 156 157 158 /* 159 * i6addr is used as a container for both IPv4 and IPv6 addresses, as well 160 * as other types of objects, depending on its qualifier. 161 */ 162 #ifdef USE_INET6 163 typedef union i6addr { 164 u_32_t i6[4]; 165 struct in_addr in4; 166 struct in6_addr in6; 167 void *vptr[2]; 168 lookupfunc_t lptr[2]; 169 } i6addr_t; 170 #define in6_addr8 in6.s6_addr 171 #else 172 typedef union i6addr { 173 u_32_t i6[4]; 174 struct in_addr in4; 175 void *vptr[2]; 176 lookupfunc_t lptr[2]; 177 } i6addr_t; 178 #endif 179 180 #define in4_addr in4.s_addr 181 #define iplookupnum i6[0] 182 #define iplookuptype i6[1] 183 /* 184 * NOTE: These DO overlap the above on 64bit systems and this IS recognised. 185 */ 186 #define iplookupptr vptr[0] 187 #define iplookupfunc lptr[1] 188 189 #define I60(x) (((i6addr_t *)(x))->i6[0]) 190 #define I61(x) (((i6addr_t *)(x))->i6[1]) 191 #define I62(x) (((i6addr_t *)(x))->i6[2]) 192 #define I63(x) (((i6addr_t *)(x))->i6[3]) 193 #define HI60(x) ntohl(((i6addr_t *)(x))->i6[0]) 194 #define HI61(x) ntohl(((i6addr_t *)(x))->i6[1]) 195 #define HI62(x) ntohl(((i6addr_t *)(x))->i6[2]) 196 #define HI63(x) ntohl(((i6addr_t *)(x))->i6[3]) 197 198 #define IP6_EQ(a,b) ((I63(a) == I63(b)) && (I62(a) == I62(b)) && \ 199 (I61(a) == I61(b)) && (I60(a) == I60(b))) 200 #define IP6_NEQ(a,b) ((I63(a) != I63(b)) || (I62(a) != I62(b)) || \ 201 (I61(a) != I61(b)) || (I60(a) != I60(b))) 202 #define IP6_ISZERO(a) ((I60(a) | I61(a) | I62(a) | I63(a)) == 0) 203 #define IP6_NOTZERO(a) ((I60(a) | I61(a) | I62(a) | I63(a)) != 0) 204 #define IP6_ISONES(a) ((I63(a) == 0xffffffff) && (I62(a) == 0xffffffff) && \ 205 (I61(a) == 0xffffffff) && (I60(a) == 0xffffffff)) 206 #define IP6_GT(a,b) (ntohl(HI60(a)) > ntohl(HI60(b)) || \ 207 (HI60(a) == HI60(b) && \ 208 (ntohl(HI61(a)) > ntohl(HI61(b)) || \ 209 (HI61(a) == HI61(b) && \ 210 (ntohl(HI62(a)) > ntohl(HI62(b)) || \ 211 (HI62(a) == HI62(b) && \ 212 ntohl(HI63(a)) > ntohl(HI63(b)))))))) 213 #define IP6_LT(a,b) (ntohl(HI60(a)) < ntohl(HI60(b)) || \ 214 (HI60(a) == HI60(b) && \ 215 (ntohl(HI61(a)) < ntohl(HI61(b)) || \ 216 (HI61(a) == HI61(b) && \ 217 (ntohl(HI62(a)) < ntohl(HI62(b)) || \ 218 (HI62(a) == HI62(b) && \ 219 ntohl(HI63(a)) < ntohl(HI63(b)))))))) 220 #define NLADD(n,x) htonl(ntohl(n) + (x)) 221 #define IP6_INC(a) \ 222 { i6addr_t *_i6 = (i6addr_t *)(a); \ 223 _i6->i6[3] = NLADD(_i6->i6[3], 1); \ 224 if (_i6->i6[3] == 0) { \ 225 _i6->i6[2] = NLADD(_i6->i6[2], 1); \ 226 if (_i6->i6[2] == 0) { \ 227 _i6->i6[1] = NLADD(_i6->i6[1], 1); \ 228 if (_i6->i6[1] == 0) { \ 229 _i6->i6[0] = NLADD(_i6->i6[0], 1); \ 230 } \ 231 } \ 232 } \ 233 } 234 #define IP6_ADD(a,x,d) \ 235 { i6addr_t *_s = (i6addr_t *)(a); \ 236 i6addr_t *_d = (i6addr_t *)(d); \ 237 _d->i6[3] = NLADD(_s->i6[3], x); \ 238 if (ntohl(_d->i6[3]) < ntohl(_s->i6[3])) { \ 239 _d->i6[2] = NLADD(_d->i6[2], 1); \ 240 if (ntohl(_d->i6[2]) < ntohl(_s->i6[2])) { \ 241 _d->i6[1] = NLADD(_d->i6[1], 1); \ 242 if (ntohl(_d->i6[1]) < ntohl(_s->i6[1])) { \ 243 _d->i6[0] = NLADD(_d->i6[0], 1); \ 244 } \ 245 } \ 246 } \ 247 } 248 #define IP6_AND(a,b,d) { i6addr_t *_s1 = (i6addr_t *)(a); \ 249 i6addr_t *_s2 = (i6addr_t *)(b); \ 250 i6addr_t *_d = (i6addr_t *)(d); \ 251 _d->i6[0] = _s1->i6[0] & _s2->i6[0]; \ 252 _d->i6[1] = _s1->i6[1] & _s2->i6[1]; \ 253 _d->i6[2] = _s1->i6[2] & _s2->i6[2]; \ 254 _d->i6[3] = _s1->i6[3] & _s2->i6[3]; \ 255 } 256 #define IP6_MASKEQ(a,m,b) \ 257 (((I60(a) & I60(m)) == I60(b)) && \ 258 ((I61(a) & I61(m)) == I61(b)) && \ 259 ((I62(a) & I62(m)) == I62(b)) && \ 260 ((I63(a) & I63(m)) == I63(b))) 261 #define IP6_MASKNEQ(a,m,b) \ 262 (((I60(a) & I60(m)) != I60(b)) || \ 263 ((I61(a) & I61(m)) != I61(b)) || \ 264 ((I62(a) & I62(m)) != I62(b)) || \ 265 ((I63(a) & I63(m)) != I63(b))) 266 #define IP6_MERGE(a,b,c) \ 267 { i6addr_t *_d, *_s1, *_s2; \ 268 _d = (i6addr_t *)(a); \ 269 _s1 = (i6addr_t *)(b); \ 270 _s2 = (i6addr_t *)(c); \ 271 _d->i6[0] |= _s1->i6[0] & ~_s2->i6[0]; \ 272 _d->i6[1] |= _s1->i6[1] & ~_s2->i6[1]; \ 273 _d->i6[2] |= _s1->i6[2] & ~_s2->i6[2]; \ 274 _d->i6[3] |= _s1->i6[3] & ~_s2->i6[3]; \ 275 } 276 277 278 typedef struct fr_ip { 279 u_32_t fi_v:4; /* IP version */ 280 u_32_t fi_xx:4; /* spare */ 281 u_32_t fi_tos:8; /* IP packet TOS */ 282 u_32_t fi_ttl:8; /* IP packet TTL */ 283 u_32_t fi_p:8; /* IP packet protocol */ 284 u_32_t fi_optmsk; /* bitmask composed from IP options */ 285 i6addr_t fi_src; /* source address from packet */ 286 i6addr_t fi_dst; /* destination address from packet */ 287 u_short fi_secmsk; /* bitmask composed from IP security options */ 288 u_short fi_auth; /* authentication code from IP sec. options */ 289 u_32_t fi_flx; /* packet flags */ 290 u_32_t fi_tcpmsk; /* TCP options set/reset */ 291 u_32_t fi_res1; /* RESERVED */ 292 } fr_ip_t; 293 294 /* 295 * For use in fi_flx 296 */ 297 #define FI_MULTICAST 0x0001 298 #define FI_BROADCAST 0x0002 299 #define FI_FRAG 0x0004 300 #define FI_SHORT 0x0008 301 #define FI_NATED 0x0010 302 #define FI_TCPUDP 0x0020 /* TCP/UCP implied comparison*/ 303 #define FI_OPTIONS 0x0040 304 #define FI_MBCAST 0x0080 305 #define FI_STATE 0x0100 306 #define FI_BADNAT 0x0200 307 #define FI_BAD 0x0400 308 #define FI_OOW 0x0800 /* Out of state window, else match */ 309 #define FI_ICMPERR 0x1000 310 #define FI_FRAGBODY 0x2000 311 #define FI_BADSRC 0x4000 312 #define FI_LOWTTL 0x8000 313 #define FI_CMP 0xcf03 /* Not FI_FRAG,FI_NATED,FI_FRAGTAIL,broadcast */ 314 #define FI_ICMPCMP 0x0003 /* Flags we can check for ICMP error packets */ 315 #define FI_WITH 0xeffe /* Not FI_TCPUDP */ 316 #define FI_V6EXTHDR 0x10000 317 #define FI_COALESCE 0x20000 318 #define FI_ICMPQUERY 0x40000 319 #define FI_NEWNAT 0x80000 320 #define FI_NEG_OOW 0x10000000 /* packet underflows TCP window */ 321 #define FI_NOCKSUM 0x20000000 /* don't do a L4 checksum validation */ 322 #define FI_DONTCACHE 0x40000000 /* don't cache the result */ 323 #define FI_IGNORE 0x80000000 324 325 #define fi_saddr fi_src.in4.s_addr 326 #define fi_daddr fi_dst.in4.s_addr 327 #define fi_srcnum fi_src.iplookupnum 328 #define fi_dstnum fi_dst.iplookupnum 329 #define fi_srctype fi_src.iplookuptype 330 #define fi_dsttype fi_dst.iplookuptype 331 #define fi_srcptr fi_src.iplookupptr 332 #define fi_dstptr fi_dst.iplookupptr 333 #define fi_srcfunc fi_src.iplookupfunc 334 #define fi_dstfunc fi_dst.iplookupfunc 335 336 337 /* 338 * These are both used by the state and NAT code to indicate that one port or 339 * the other should be treated as a wildcard. 340 * NOTE: When updating, check bit masks in ip_state.h and update there too. 341 */ 342 #define SI_W_SPORT 0x00000100 343 #define SI_W_DPORT 0x00000200 344 #define SI_WILDP (SI_W_SPORT|SI_W_DPORT) 345 #define SI_W_SADDR 0x00000400 346 #define SI_W_DADDR 0x00000800 347 #define SI_WILDA (SI_W_SADDR|SI_W_DADDR) 348 #define SI_NEWFR 0x00001000 349 #define SI_CLONE 0x00002000 350 #define SI_CLONED 0x00004000 351 352 353 354 355 typedef struct fr_info { 356 void *fin_ifp; /* interface packet is `on' */ 357 fr_ip_t fin_fi; /* IP Packet summary */ 358 union { 359 u_short fid_16[2]; /* TCP/UDP ports, ICMP code/type */ 360 u_32_t fid_32; 361 } fin_dat; 362 int fin_out; /* in or out ? 1 == out, 0 == in */ 363 int fin_rev; /* state only: 1 = reverse */ 364 u_short fin_hlen; /* length of IP header in bytes */ 365 u_char fin_tcpf; /* TCP header flags (SYN, ACK, etc) */ 366 u_char fin_icode; /* ICMP error to return */ 367 u_32_t fin_rule; /* rule # last matched */ 368 char fin_group[FR_GROUPLEN]; /* group number, -1 for none */ 369 struct frentry *fin_fr; /* last matching rule */ 370 void *fin_dp; /* start of data past IP header */ 371 int fin_dlen; /* length of data portion of packet */ 372 int fin_plen; 373 int fin_flen; /* length of layer 4 hdr and 374 ipv6 ext hdr after fragment hdr */ 375 int fin_ipoff; /* # bytes from buffer start to hdr */ 376 u_32_t fin_id; /* IP packet id field */ 377 u_short fin_off; 378 int fin_depth; /* Group nesting depth */ 379 int fin_error; /* Error code to return */ 380 void *fin_nat; 381 void *fin_state; 382 void *fin_nattag; 383 union { 384 ip_t *fip_ip; 385 #ifdef USE_INET6 386 ip6_t *fip_ip6; 387 #endif 388 } fin_ipu; 389 mb_t **fin_mp; /* pointer to pointer to mbuf */ 390 mb_t *fin_m; /* pointer to mbuf */ 391 #ifdef MENTAT 392 mb_t *fin_qfm; /* pointer to mblk where pkt starts */ 393 void *fin_qpi; 394 ipf_stack_t *fin_ifs; 395 #endif 396 #ifdef __sgi 397 void *fin_hbuf; 398 #endif 399 } fr_info_t; 400 401 #define fin_ip fin_ipu.fip_ip 402 #define fin_ip6 fin_ipu.fip_ip6 403 #define fin_v fin_fi.fi_v 404 #define fin_p fin_fi.fi_p 405 #define fin_flx fin_fi.fi_flx 406 #define fin_optmsk fin_fi.fi_optmsk 407 #define fin_secmsk fin_fi.fi_secmsk 408 #define fin_auth fin_fi.fi_auth 409 #define fin_src fin_fi.fi_src.in4 410 #define fin_saddr fin_fi.fi_saddr 411 #define fin_dst fin_fi.fi_dst.in4 412 #define fin_daddr fin_fi.fi_daddr 413 #define fin_data fin_dat.fid_16 414 #define fin_sport fin_dat.fid_16[0] 415 #define fin_dport fin_dat.fid_16[1] 416 #define fin_ports fin_dat.fid_32 417 418 #ifdef USE_INET6 419 # define fin_src6 fin_fi.fi_src 420 # define fin_dst6 fin_fi.fi_dst 421 # define fin_dstip6 fin_fi.fi_dst.in6 422 # define fin_srcip6 fin_fi.fi_src.in6 423 #endif 424 425 #define IPF_IN 0 426 #define IPF_OUT 1 427 428 typedef struct frentry *(*ipfunc_t) __P((fr_info_t *, u_32_t *)); 429 typedef int (*ipfuncinit_t) __P((struct frentry *, 430 ipf_stack_t *)); 431 432 typedef struct ipfunc_resolve { 433 char ipfu_name[32]; 434 ipfunc_t ipfu_addr; 435 ipfuncinit_t ipfu_init; 436 } ipfunc_resolve_t; 437 438 /* 439 * Size for compares on fr_info structures 440 */ 441 #define FI_CSIZE offsetof(fr_info_t, fin_icode) 442 #define FI_LCSIZE offsetof(fr_info_t, fin_dp) 443 444 /* 445 * Size for copying cache fr_info structure 446 */ 447 #define FI_COPYSIZE offsetof(fr_info_t, fin_dp) 448 449 /* 450 * Structure for holding IPFilter's tag information 451 */ 452 #define IPFTAG_LEN 16 453 typedef struct { 454 union { 455 u_32_t iptu_num[4]; 456 char iptu_tag[IPFTAG_LEN]; 457 } ipt_un; 458 int ipt_not; 459 } ipftag_t; 460 461 #define ipt_tag ipt_un.iptu_tag 462 #define ipt_num ipt_un.iptu_num 463 464 465 /* 466 * This structure is used to hold information about the next hop for where 467 * to forward a packet. 468 */ 469 typedef struct frdest { 470 void *fd_ifp; 471 i6addr_t fd_ip6; 472 char fd_ifname[LIFNAMSIZ]; 473 } frdest_t; 474 475 #define fd_ip fd_ip6.in4 476 477 478 /* 479 * This structure holds information about a port comparison. 480 */ 481 typedef struct frpcmp { 482 int frp_cmp; /* data for port comparisons */ 483 u_short frp_port; /* top port for <> and >< */ 484 u_short frp_top; /* top port for <> and >< */ 485 } frpcmp_t; 486 487 #define FR_NONE 0 488 #define FR_EQUAL 1 489 #define FR_NEQUAL 2 490 #define FR_LESST 3 491 #define FR_GREATERT 4 492 #define FR_LESSTE 5 493 #define FR_GREATERTE 6 494 #define FR_OUTRANGE 7 495 #define FR_INRANGE 8 496 #define FR_INCRANGE 9 497 498 /* 499 * Structure containing all the relevant TCP things that can be checked in 500 * a filter rule. 501 */ 502 typedef struct frtuc { 503 u_char ftu_tcpfm; /* tcp flags mask */ 504 u_char ftu_tcpf; /* tcp flags */ 505 frpcmp_t ftu_src; 506 frpcmp_t ftu_dst; 507 } frtuc_t; 508 509 #define ftu_scmp ftu_src.frp_cmp 510 #define ftu_dcmp ftu_dst.frp_cmp 511 #define ftu_sport ftu_src.frp_port 512 #define ftu_dport ftu_dst.frp_port 513 #define ftu_stop ftu_src.frp_top 514 #define ftu_dtop ftu_dst.frp_top 515 516 #define FR_TCPFMAX 0x3f 517 518 /* 519 * This structure makes up what is considered to be the IPFilter specific 520 * matching components of a filter rule, as opposed to the data structures 521 * used to define the result which are in frentry_t and not here. 522 */ 523 typedef struct fripf { 524 fr_ip_t fri_ip; 525 fr_ip_t fri_mip; /* mask structure */ 526 527 u_short fri_icmpm; /* data for ICMP packets (mask) */ 528 u_short fri_icmp; 529 530 frtuc_t fri_tuc; 531 int fri_satype; /* addres type */ 532 int fri_datype; /* addres type */ 533 int fri_sifpidx; /* doing dynamic addressing */ 534 int fri_difpidx; /* index into fr_ifps[] to use when */ 535 } fripf_t; 536 537 #define fri_dstnum fri_ip.fi_dstnum 538 #define fri_srcnum fri_mip.fi_srcnum 539 #define fri_dstptr fri_ip.fi_dstptr 540 #define fri_srcptr fri_mip.fi_srcptr 541 542 #define FRI_NORMAL 0 /* Normal address */ 543 #define FRI_DYNAMIC 1 /* dynamic address */ 544 #define FRI_LOOKUP 2 /* address is a pool # */ 545 #define FRI_RANGE 3 /* address/mask is a range */ 546 #define FRI_NETWORK 4 /* network address from if */ 547 #define FRI_BROADCAST 5 /* broadcast address from if */ 548 #define FRI_PEERADDR 6 /* Peer address for P-to-P */ 549 #define FRI_NETMASKED 7 /* network address with netmask from if */ 550 551 552 typedef struct frentry * (* frentfunc_t) __P((fr_info_t *)); 553 554 typedef struct frentry { 555 ipfmutex_t fr_lock; 556 struct frentry *fr_next; 557 struct frentry **fr_grp; 558 struct ipscan *fr_isc; 559 void *fr_ifas[4]; 560 void *fr_ptr; /* for use with fr_arg */ 561 char *fr_comment; /* text comment for rule */ 562 int fr_ref; /* reference count - for grouping */ 563 int fr_statecnt; /* state count - for limit rules */ 564 /* 565 * These are only incremented when a packet matches this rule and 566 * it is the last match 567 */ 568 U_QUAD_T fr_hits; 569 U_QUAD_T fr_bytes; 570 571 /* 572 * For PPS rate limiting 573 */ 574 struct timeval fr_lastpkt; 575 int fr_curpps; 576 577 union { 578 void *fru_data; 579 caddr_t fru_caddr; 580 fripf_t *fru_ipf; 581 frentfunc_t fru_func; 582 } fr_dun; 583 584 /* 585 * Fields after this may not change whilst in the kernel. 586 */ 587 ipfunc_t fr_func; /* call this function */ 588 int fr_dsize; 589 int fr_pps; 590 int fr_statemax; /* max reference count */ 591 int fr_flineno; /* line number from conf file */ 592 u_32_t fr_type; 593 u_32_t fr_flags; /* per-rule flags && options (see below) */ 594 u_32_t fr_logtag; /* user defined log tag # */ 595 u_32_t fr_collect; /* collection number */ 596 u_int fr_arg; /* misc. numeric arg for rule */ 597 u_int fr_loglevel; /* syslog log facility + priority */ 598 u_int fr_age[2]; /* non-TCP timeouts */ 599 u_char fr_v; 600 u_char fr_icode; /* return ICMP code */ 601 char fr_group[FR_GROUPLEN]; /* group to which this rule belongs */ 602 char fr_grhead[FR_GROUPLEN]; /* group # which this rule starts */ 603 ipftag_t fr_nattag; 604 char fr_ifnames[4][LIFNAMSIZ]; 605 char fr_isctag[16]; 606 frdest_t fr_tifs[2]; /* "to"/"reply-to" interface */ 607 frdest_t fr_dif; /* duplicate packet interface */ 608 /* 609 * This must be last and will change after loaded into the kernel. 610 */ 611 u_int fr_cksum; /* checksum on filter rules for performance */ 612 } frentry_t; 613 614 #define fr_caddr fr_dun.fru_caddr 615 #define fr_data fr_dun.fru_data 616 #define fr_dfunc fr_dun.fru_func 617 #define fr_ipf fr_dun.fru_ipf 618 #define fr_ip fr_ipf->fri_ip 619 #define fr_mip fr_ipf->fri_mip 620 #define fr_icmpm fr_ipf->fri_icmpm 621 #define fr_icmp fr_ipf->fri_icmp 622 #define fr_tuc fr_ipf->fri_tuc 623 #define fr_satype fr_ipf->fri_satype 624 #define fr_datype fr_ipf->fri_datype 625 #define fr_sifpidx fr_ipf->fri_sifpidx 626 #define fr_difpidx fr_ipf->fri_difpidx 627 #define fr_proto fr_ip.fi_p 628 #define fr_mproto fr_mip.fi_p 629 #define fr_ttl fr_ip.fi_ttl 630 #define fr_mttl fr_mip.fi_ttl 631 #define fr_tos fr_ip.fi_tos 632 #define fr_mtos fr_mip.fi_tos 633 #define fr_tcpfm fr_tuc.ftu_tcpfm 634 #define fr_tcpf fr_tuc.ftu_tcpf 635 #define fr_scmp fr_tuc.ftu_scmp 636 #define fr_dcmp fr_tuc.ftu_dcmp 637 #define fr_dport fr_tuc.ftu_dport 638 #define fr_sport fr_tuc.ftu_sport 639 #define fr_stop fr_tuc.ftu_stop 640 #define fr_dtop fr_tuc.ftu_dtop 641 #define fr_dst fr_ip.fi_dst.in4 642 #define fr_daddr fr_ip.fi_dst.in4.s_addr 643 #define fr_src fr_ip.fi_src.in4 644 #define fr_saddr fr_ip.fi_src.in4.s_addr 645 #define fr_dmsk fr_mip.fi_dst.in4 646 #define fr_dmask fr_mip.fi_dst.in4.s_addr 647 #define fr_smsk fr_mip.fi_src.in4 648 #define fr_smask fr_mip.fi_src.in4.s_addr 649 #define fr_dstnum fr_ip.fi_dstnum 650 #define fr_srcnum fr_ip.fi_srcnum 651 #define fr_dsttype fr_ip.fi_dsttype 652 #define fr_srctype fr_ip.fi_srctype 653 #define fr_dstptr fr_mip.fi_dstptr 654 #define fr_srcptr fr_mip.fi_srcptr 655 #define fr_dstfunc fr_mip.fi_dstfunc 656 #define fr_srcfunc fr_mip.fi_srcfunc 657 #define fr_optbits fr_ip.fi_optmsk 658 #define fr_optmask fr_mip.fi_optmsk 659 #define fr_secbits fr_ip.fi_secmsk 660 #define fr_secmask fr_mip.fi_secmsk 661 #define fr_authbits fr_ip.fi_auth 662 #define fr_authmask fr_mip.fi_auth 663 #define fr_flx fr_ip.fi_flx 664 #define fr_mflx fr_mip.fi_flx 665 #define fr_ifname fr_ifnames[0] 666 #define fr_oifname fr_ifnames[2] 667 #define fr_ifa fr_ifas[0] 668 #define fr_oifa fr_ifas[2] 669 #define fr_tif fr_tifs[0] 670 #define fr_rif fr_tifs[1] 671 672 #define FR_NOLOGTAG 0 673 674 #ifndef offsetof 675 #define offsetof(t,m) (int)((&((t *)0L)->m)) 676 #endif 677 #define FR_CMPSIZ (sizeof(struct frentry) - \ 678 offsetof(struct frentry, fr_func)) 679 680 /* 681 * fr_type 682 */ 683 #define FR_T_NONE 0 684 #define FR_T_IPF 1 /* IPF structures */ 685 #define FR_T_BPFOPC 2 /* BPF opcode */ 686 #define FR_T_CALLFUNC 3 /* callout to function in fr_func only */ 687 #define FR_T_COMPIPF 4 /* compiled C code */ 688 #define FR_T_BUILTIN 0x80000000 /* rule is in kernel space */ 689 690 /* 691 * fr_flags 692 */ 693 #define FR_CALL 0x00000 /* call rule */ 694 #define FR_BLOCK 0x00001 /* do not allow packet to pass */ 695 #define FR_PASS 0x00002 /* allow packet to pass */ 696 #define FR_AUTH 0x00003 /* use authentication */ 697 #define FR_PREAUTH 0x00004 /* require preauthentication */ 698 #define FR_ACCOUNT 0x00005 /* Accounting rule */ 699 #define FR_SKIP 0x00006 /* skip rule */ 700 #define FR_DIVERT 0x00007 /* divert rule */ 701 #define FR_CMDMASK 0x0000f 702 #define FR_LOG 0x00010 /* Log */ 703 #define FR_LOGB 0x00011 /* Log-fail */ 704 #define FR_LOGP 0x00012 /* Log-pass */ 705 #define FR_LOGMASK (FR_LOG|FR_CMDMASK) 706 #define FR_CALLNOW 0x00020 /* call another function (fr_func) if matches */ 707 #define FR_NOTSRCIP 0x00040 708 #define FR_NOTDSTIP 0x00080 709 #define FR_QUICK 0x00100 /* match & stop processing list */ 710 #define FR_KEEPFRAG 0x00200 /* keep fragment information */ 711 #define FR_KEEPSTATE 0x00400 /* keep `connection' state information */ 712 #define FR_FASTROUTE 0x00800 /* bypass normal routing */ 713 #define FR_RETRST 0x01000 /* Return TCP RST packet - reset connection */ 714 #define FR_RETICMP 0x02000 /* Return ICMP unreachable packet */ 715 #define FR_FAKEICMP 0x03000 /* Return ICMP unreachable with fake source */ 716 #define FR_OUTQUE 0x04000 /* outgoing packets */ 717 #define FR_INQUE 0x08000 /* ingoing packets */ 718 #define FR_LOGBODY 0x10000 /* Log the body */ 719 #define FR_LOGFIRST 0x20000 /* Log the first byte if state held */ 720 #define FR_LOGORBLOCK 0x40000 /* block the packet if it can't be logged */ 721 #define FR_DUP 0x80000 /* duplicate packet */ 722 #define FR_FRSTRICT 0x100000 /* strict frag. cache */ 723 #define FR_STSTRICT 0x200000 /* strict keep state */ 724 #define FR_NEWISN 0x400000 /* new ISN for outgoing TCP */ 725 #define FR_NOICMPERR 0x800000 /* do not match ICMP errors in state */ 726 #define FR_STATESYNC 0x1000000 /* synchronize state to slave */ 727 #define FR_NOMATCH 0x8000000 /* no match occured */ 728 /* 0x10000000 FF_LOGPASS */ 729 /* 0x20000000 FF_LOGBLOCK */ 730 /* 0x40000000 FF_LOGNOMATCH */ 731 /* 0x80000000 FF_BLOCKNONIP */ 732 #define FR_COPIED 0x40000000 /* copied from user space */ 733 #define FR_INACTIVE 0x80000000 /* only used when flush'ing rules */ 734 735 #define FR_RETMASK (FR_RETICMP|FR_RETRST|FR_FAKEICMP) 736 #define FR_ISBLOCK(x) (((x) & FR_CMDMASK) == FR_BLOCK) 737 #define FR_ISPASS(x) (((x) & FR_CMDMASK) == FR_PASS) 738 #define FR_ISAUTH(x) (((x) & FR_CMDMASK) == FR_AUTH) 739 #define FR_ISPREAUTH(x) (((x) & FR_CMDMASK) == FR_PREAUTH) 740 #define FR_ISACCOUNT(x) (((x) & FR_CMDMASK) == FR_ACCOUNT) 741 #define FR_ISSKIP(x) (((x) & FR_CMDMASK) == FR_SKIP) 742 #define FR_ISNOMATCH(x) ((x) & FR_NOMATCH) 743 #define FR_INOUT (FR_INQUE|FR_OUTQUE) 744 745 /* 746 * recognized flags for SIOCGETFF and SIOCSETFF, and get put in fr_flags 747 */ 748 #define FF_LOGPASS 0x10000000 749 #define FF_LOGBLOCK 0x20000000 750 #define FF_LOGNOMATCH 0x40000000 751 #define FF_LOGGING (FF_LOGPASS|FF_LOGBLOCK|FF_LOGNOMATCH) 752 #define FF_BLOCKNONIP 0x80000000 /* Solaris2 Only */ 753 754 755 /* 756 * Structure that passes information on what/how to flush to the kernel. 757 */ 758 typedef struct ipfflush { 759 int ipflu_how; 760 int ipflu_arg; 761 } ipfflush_t; 762 763 764 /* 765 * 766 */ 767 typedef struct ipfgetctl { 768 u_int ipfg_min; /* min value */ 769 u_int ipfg_current; /* current value */ 770 u_int ipfg_max; /* max value */ 771 u_int ipfg_default; /* default value */ 772 u_int ipfg_steps; /* value increments */ 773 char ipfg_name[40]; /* tag name for this control */ 774 } ipfgetctl_t; 775 776 typedef struct ipfsetctl { 777 int ipfs_which; /* 0 = min 1 = current 2 = max 3 = default */ 778 u_int ipfs_value; /* min value */ 779 char ipfs_name[40]; /* tag name for this control */ 780 } ipfsetctl_t; 781 782 783 /* 784 * Some of the statistics below are in their own counters, but most are kept 785 * in this single structure so that they can all easily be collected and 786 * copied back as required. 787 * 788 * NOTE: when changing, keep in sync with kstats (below). 789 */ 790 typedef struct filterstats { 791 u_long fr_pass; /* packets allowed */ 792 u_long fr_block; /* packets denied */ 793 u_long fr_nom; /* packets which don't match any rule */ 794 u_long fr_short; /* packets which are short */ 795 u_long fr_ppkl; /* packets allowed and logged */ 796 u_long fr_bpkl; /* packets denied and logged */ 797 u_long fr_npkl; /* packets unmatched and logged */ 798 u_long fr_pkl; /* packets logged */ 799 u_long fr_skip; /* packets to be logged but buffer full */ 800 u_long fr_ret; /* packets for which a return is sent */ 801 u_long fr_acct; /* packets for which counting was performed */ 802 u_long fr_bnfr; /* bad attempts to allocate fragment state */ 803 u_long fr_nfr; /* new fragment state kept */ 804 u_long fr_cfr; /* add new fragment state but complete pkt */ 805 u_long fr_bads; /* bad attempts to allocate packet state */ 806 u_long fr_ads; /* new packet state kept */ 807 u_long fr_chit; /* cached hit */ 808 u_long fr_tcpbad; /* TCP checksum check failures */ 809 u_long fr_pull[2]; /* good and bad pullup attempts */ 810 u_long fr_badsrc; /* source received doesn't match route */ 811 u_long fr_badttl; /* TTL in packet doesn't reach minimum */ 812 u_long fr_bad; /* bad IP packets to the filter */ 813 u_long fr_ipv6; /* IPv6 packets in/out */ 814 u_long fr_ppshit; /* dropped because of pps ceiling */ 815 u_long fr_ipud; /* IP id update failures */ 816 } filterstats_t; 817 818 /* 819 * kstat "copy" of the above - keep in sync! 820 * also keep in sync with initialisation code in solaris.c, ipf_kstat_init(). 821 */ 822 typedef struct filter_kstats { 823 kstat_named_t fks_pass; /* see above for comments */ 824 kstat_named_t fks_block; 825 kstat_named_t fks_nom; 826 kstat_named_t fks_short; 827 kstat_named_t fks_ppkl; 828 kstat_named_t fks_bpkl; 829 kstat_named_t fks_npkl; 830 kstat_named_t fks_pkl; 831 kstat_named_t fks_skip; 832 kstat_named_t fks_ret; 833 kstat_named_t fks_acct; 834 kstat_named_t fks_bnfr; 835 kstat_named_t fks_nfr; 836 kstat_named_t fks_cfr; 837 kstat_named_t fks_bads; 838 kstat_named_t fks_ads; 839 kstat_named_t fks_chit; 840 kstat_named_t fks_tcpbad; 841 kstat_named_t fks_pull[2]; 842 kstat_named_t fks_badsrc; 843 kstat_named_t fks_badttl; 844 kstat_named_t fks_bad; 845 kstat_named_t fks_ipv6; 846 kstat_named_t fks_ppshit; 847 kstat_named_t fks_ipud; 848 } filter_kstats_t; 849 850 /* 851 * Log structure. Each packet header logged is prepended by one of these. 852 * Following this in the log records read from the device will be an ipflog 853 * structure which is then followed by any packet data. 854 */ 855 typedef struct iplog { 856 u_32_t ipl_magic; 857 u_int ipl_count; 858 struct timeval ipl_time; 859 size_t ipl_dsize; 860 struct iplog *ipl_next; 861 } iplog_t; 862 863 #define ipl_sec ipl_time.tv_sec 864 #define ipl_usec ipl_time.tv_usec 865 866 #define IPL_MAGIC 0x49504c4d /* 'IPLM' */ 867 #define IPL_MAGIC_NAT 0x49504c4e /* 'IPLN' */ 868 #define IPL_MAGIC_STATE 0x49504c53 /* 'IPLS' */ 869 #define IPLOG_SIZE sizeof(iplog_t) 870 871 typedef struct ipflog { 872 #if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \ 873 (defined(OpenBSD) && (OpenBSD >= 199603)) 874 #else 875 u_int fl_unit; 876 #endif 877 u_32_t fl_rule; 878 u_32_t fl_flags; 879 u_32_t fl_lflags; 880 u_32_t fl_logtag; 881 ipftag_t fl_nattag; 882 u_short fl_plen; /* extra data after hlen */ 883 u_short fl_loglevel; /* syslog log level */ 884 char fl_group[FR_GROUPLEN]; 885 u_char fl_hlen; /* length of IP headers saved */ 886 u_char fl_dir; 887 u_char fl_xxx[2]; /* pad */ 888 char fl_ifname[LIFNAMSIZ]; 889 } ipflog_t; 890 891 #ifndef IPF_LOGGING 892 # define IPF_LOGGING 0 893 #endif 894 #ifndef IPF_DEFAULT_PASS 895 # define IPF_DEFAULT_PASS FR_PASS 896 #endif 897 898 #define DEFAULT_IPFLOGSIZE 8192 899 #ifndef IPFILTER_LOGSIZE 900 # define IPFILTER_LOGSIZE DEFAULT_IPFLOGSIZE 901 #else 902 # if IPFILTER_LOGSIZE < DEFAULT_IPFLOGSIZE 903 # error IPFILTER_LOGSIZE too small. Must be >= DEFAULT_IPFLOGSIZE 904 # endif 905 #endif 906 907 #define IPF_OPTCOPY 0x07ff00 /* bit mask of copied options */ 908 909 /* 910 * Device filenames for reading log information. Use ipf on Solaris2 because 911 * ipl is already a name used by something else. 912 */ 913 #ifndef IPL_NAME 914 # if SOLARIS 915 # define IPL_NAME "/dev/ipf" 916 # else 917 # define IPL_NAME "/dev/ipl" 918 # endif 919 #endif 920 /* 921 * Pathnames for various IP Filter control devices. Used by LKM 922 * and userland, so defined here. 923 */ 924 #define IPNAT_NAME "/dev/ipnat" 925 #define IPSTATE_NAME "/dev/ipstate" 926 #define IPAUTH_NAME "/dev/ipauth" 927 #define IPSYNC_NAME "/dev/ipsync" 928 #define IPSCAN_NAME "/dev/ipscan" 929 #define IPLOOKUP_NAME "/dev/iplookup" 930 931 #define IPL_LOGIPF 0 /* Minor device #'s for accessing logs */ 932 #define IPL_LOGNAT 1 933 #define IPL_LOGSTATE 2 934 #define IPL_LOGAUTH 3 935 #define IPL_LOGSYNC 4 936 #define IPL_LOGSCAN 5 937 #define IPL_LOGLOOKUP 6 938 #define IPL_LOGCOUNT 7 939 #define IPL_LOGMAX 7 940 #define IPL_LOGSIZE (IPL_LOGMAX + 1) 941 #define IPL_LOGALL -1 942 #define IPL_LOGNONE -2 943 944 /* 945 * For SIOCGETFS 946 */ 947 typedef struct friostat { 948 struct filterstats f_st[2]; 949 struct frentry *f_ipf[2][2]; 950 struct frentry *f_acct[2][2]; 951 struct frentry *f_ipf6[2][2]; 952 struct frentry *f_acct6[2][2]; 953 struct frentry *f_auth; 954 struct frgroup *f_groups[IPL_LOGSIZE][2]; 955 u_long f_froute[2]; 956 u_long f_ticks; 957 int f_locks[IPL_LOGMAX]; 958 size_t f_kmutex_sz; 959 size_t f_krwlock_sz; 960 int f_defpass; /* default pass - from fr_pass */ 961 int f_active; /* 1 or 0 - active rule set */ 962 int f_running; /* 1 if running, else 0 */ 963 int f_logging; /* 1 if enabled, else 0 */ 964 int f_features; 965 char f_version[32]; /* version string */ 966 } friostat_t; 967 968 #define f_fin f_ipf[0] 969 #define f_fin6 f_ipf6[0] 970 #define f_fout f_ipf[1] 971 #define f_fout6 f_ipf6[1] 972 #define f_acctin f_acct[0] 973 #define f_acctin6 f_acct6[0] 974 #define f_acctout f_acct[1] 975 #define f_acctout6 f_acct6[1] 976 977 #define IPF_FEAT_LKM 0x001 978 #define IPF_FEAT_LOG 0x002 979 #define IPF_FEAT_LOOKUP 0x004 980 #define IPF_FEAT_BPF 0x008 981 #define IPF_FEAT_COMPILED 0x010 982 #define IPF_FEAT_CKSUM 0x020 983 #define IPF_FEAT_SYNC 0x040 984 #define IPF_FEAT_SCAN 0x080 985 #define IPF_FEAT_IPV6 0x100 986 987 typedef struct optlist { 988 u_short ol_val; 989 int ol_bit; 990 } optlist_t; 991 992 993 /* 994 * Group list structure. 995 */ 996 typedef struct frgroup { 997 struct frgroup *fg_next; 998 struct frentry *fg_head; 999 struct frentry *fg_start; 1000 u_32_t fg_flags; 1001 int fg_ref; 1002 char fg_name[FR_GROUPLEN]; 1003 } frgroup_t; 1004 1005 #define FG_NAME(g) (*(g)->fg_name == '\0' ? "" : (g)->fg_name) 1006 1007 1008 /* 1009 * Used by state and NAT tables 1010 */ 1011 typedef struct icmpinfo { 1012 u_short ici_id; 1013 u_short ici_seq; 1014 u_char ici_type; 1015 } icmpinfo_t; 1016 1017 typedef struct udpinfo { 1018 u_short us_sport; 1019 u_short us_dport; 1020 } udpinfo_t; 1021 1022 1023 typedef struct tcpdata { 1024 u_32_t td_end; 1025 u_32_t td_maxend; 1026 u_32_t td_maxwin; 1027 u_32_t td_winscale; 1028 u_32_t td_maxseg; 1029 int td_winflags; 1030 } tcpdata_t; 1031 1032 #define TCP_WSCALE_MAX 14 1033 1034 #define TCP_WSCALE_SEEN 0x00000001 1035 #define TCP_WSCALE_FIRST 0x00000002 1036 #define TCP_SACK_PERMIT 0x00000004 1037 1038 1039 typedef struct tcpinfo { 1040 u_short ts_sport; 1041 u_short ts_dport; 1042 tcpdata_t ts_data[2]; 1043 } tcpinfo_t; 1044 1045 1046 /* 1047 * Structures to define a GRE header as seen in a packet. 1048 */ 1049 struct grebits { 1050 u_32_t grb_C:1; 1051 u_32_t grb_R:1; 1052 u_32_t grb_K:1; 1053 u_32_t grb_S:1; 1054 u_32_t grb_s:1; 1055 u_32_t grb_recur:1; 1056 u_32_t grb_A:1; 1057 u_32_t grb_flags:3; 1058 u_32_t grb_ver:3; 1059 u_short grb_ptype; 1060 }; 1061 1062 typedef struct grehdr { 1063 union { 1064 struct grebits gru_bits; 1065 u_short gru_flags; 1066 } gr_un; 1067 u_short gr_len; 1068 u_short gr_call; 1069 } grehdr_t; 1070 1071 #define gr_flags gr_un.gru_flags 1072 #define gr_bits gr_un.gru_bits 1073 #define gr_ptype gr_bits.grb_ptype 1074 #define gr_C gr_bits.grb_C 1075 #define gr_R gr_bits.grb_R 1076 #define gr_K gr_bits.grb_K 1077 #define gr_S gr_bits.grb_S 1078 #define gr_s gr_bits.grb_s 1079 #define gr_recur gr_bits.grb_recur 1080 #define gr_A gr_bits.grb_A 1081 #define gr_ver gr_bits.grb_ver 1082 1083 /* 1084 * GRE information tracked by "keep state" 1085 */ 1086 typedef struct greinfo { 1087 u_short gs_call[2]; 1088 u_short gs_flags; 1089 u_short gs_ptype; 1090 } greinfo_t; 1091 1092 #define GRE_REV(x) ((ntohs(x) >> 13) & 7) 1093 1094 1095 /* 1096 * Format of an Authentication header 1097 */ 1098 typedef struct authhdr { 1099 u_char ah_next; 1100 u_char ah_plen; 1101 u_short ah_reserved; 1102 u_32_t ah_spi; 1103 u_32_t ah_seq; 1104 /* Following the sequence number field is 0 or more bytes of */ 1105 /* authentication data, as specified by ah_plen - RFC 2402. */ 1106 } authhdr_t; 1107 1108 1109 /* 1110 * Timeout tail queue list member 1111 */ 1112 typedef struct ipftqent { 1113 struct ipftqent **tqe_pnext; 1114 struct ipftqent *tqe_next; 1115 struct ipftq *tqe_ifq; 1116 void *tqe_parent; /* pointer back to NAT/state struct */ 1117 u_long tqe_die; /* when this entriy is to die */ 1118 u_long tqe_touched; 1119 int tqe_flags; 1120 int tqe_state[2]; /* current state of this entry */ 1121 } ipftqent_t; 1122 1123 #define TQE_RULEBASED 0x00000001 1124 1125 1126 /* 1127 * Timeout tail queue head for IPFilter 1128 */ 1129 typedef struct ipftq { 1130 ipfmutex_t ifq_lock; 1131 u_int ifq_ttl; 1132 ipftqent_t *ifq_head; 1133 ipftqent_t **ifq_tail; 1134 struct ipftq *ifq_next; 1135 struct ipftq **ifq_pnext; 1136 int ifq_ref; 1137 u_int ifq_flags; 1138 } ipftq_t; 1139 1140 #define IFQF_USER 0x01 /* User defined aging */ 1141 #define IFQF_DELETE 0x02 /* Marked for deletion */ 1142 #define IFQF_PROXY 0x04 /* Timeout queue in use by a proxy */ 1143 1144 #define IPF_HZ_MULT 1 1145 #define IPF_HZ_DIVIDE 2 /* How many times a second ipfilter */ 1146 /* checks its timeout queues. */ 1147 #define IPF_TTLVAL(x) (((x) / IPF_HZ_MULT) * IPF_HZ_DIVIDE) 1148 1149 /* 1150 * Structure to define address for pool lookups. 1151 */ 1152 typedef struct { 1153 u_char adf_len; 1154 sa_family_t adf_family; 1155 i6addr_t adf_addr; 1156 } addrfamily_t; 1157 1158 1159 /* 1160 * Object structure description. For passing through in ioctls. 1161 */ 1162 typedef struct ipfobj { 1163 u_32_t ipfo_rev; /* IPFilter version number */ 1164 u_32_t ipfo_size; /* size of object at ipfo_ptr */ 1165 void *ipfo_ptr; /* pointer to object */ 1166 int ipfo_type; /* type of object being pointed to */ 1167 int ipfo_offset; /* bytes from ipfo_ptr where to start */ 1168 u_char ipfo_xxxpad[32]; /* reserved for future use */ 1169 } ipfobj_t; 1170 1171 #define IPFOBJ_FRENTRY 0 /* struct frentry */ 1172 #define IPFOBJ_IPFSTAT 1 /* struct friostat */ 1173 #define IPFOBJ_IPFINFO 2 /* struct fr_info */ 1174 #define IPFOBJ_AUTHSTAT 3 /* struct fr_authstat */ 1175 #define IPFOBJ_FRAGSTAT 4 /* struct ipfrstat */ 1176 #define IPFOBJ_IPNAT 5 /* struct ipnat */ 1177 #define IPFOBJ_NATSTAT 6 /* struct natstat */ 1178 #define IPFOBJ_STATESAVE 7 /* struct ipstate_save */ 1179 #define IPFOBJ_NATSAVE 8 /* struct nat_save */ 1180 #define IPFOBJ_NATLOOKUP 9 /* struct natlookup */ 1181 #define IPFOBJ_IPSTATE 10 /* struct ipstate */ 1182 #define IPFOBJ_STATESTAT 11 /* struct ips_stat */ 1183 #define IPFOBJ_FRAUTH 12 /* struct frauth */ 1184 #define IPFOBJ_TUNEABLE 13 /* struct ipftune */ 1185 #define IPFOBJ_NAT 14 /* struct nat */ 1186 #define IPFOBJ_IPFITER 15 /* struct ipfruleiter */ 1187 #define IPFOBJ_GENITER 16 /* struct ipfgeniter */ 1188 #define IPFOBJ_GTABLE 17 /* struct ipftable */ 1189 #define IPFOBJ_LOOKUPITER 18 /* struct ipflookupiter */ 1190 #define IPFOBJ_COUNT 19 /* How many #defines are above this? */ 1191 1192 1193 typedef union ipftunevalptr { 1194 void *ipftp_void; 1195 u_long *ipftp_long; 1196 u_int *ipftp_int; 1197 u_short *ipftp_short; 1198 u_char *ipftp_char; 1199 } ipftunevalptr_t; 1200 1201 typedef struct ipftuneable { 1202 ipftunevalptr_t ipft_una; 1203 char *ipft_name; 1204 u_long ipft_min; 1205 u_long ipft_max; 1206 int ipft_sz; 1207 int ipft_flags; 1208 struct ipftuneable *ipft_next; 1209 } ipftuneable_t; 1210 1211 #define ipft_addr ipft_una.ipftp_void 1212 #define ipft_plong ipft_una.ipftp_long 1213 #define ipft_pint ipft_una.ipftp_int 1214 #define ipft_pshort ipft_una.ipftp_short 1215 #define ipft_pchar ipft_una.ipftp_char 1216 1217 #define IPFT_RDONLY 1 /* read-only */ 1218 #define IPFT_WRDISABLED 2 /* write when disabled only */ 1219 1220 typedef union ipftuneval { 1221 u_long ipftu_long; 1222 u_int ipftu_int; 1223 u_short ipftu_short; 1224 u_char ipftu_char; 1225 } ipftuneval_t; 1226 1227 typedef struct ipftune { 1228 void *ipft_cookie; 1229 ipftuneval_t ipft_un; 1230 u_long ipft_min; 1231 u_long ipft_max; 1232 int ipft_sz; 1233 int ipft_flags; 1234 char ipft_name[80]; 1235 } ipftune_t; 1236 1237 #define ipft_vlong ipft_un.ipftu_long 1238 #define ipft_vint ipft_un.ipftu_int 1239 #define ipft_vshort ipft_un.ipftu_short 1240 #define ipft_vchar ipft_un.ipftu_char 1241 1242 /* 1243 * ipfruleiter is iterator structure used for filter rules. 1244 */ 1245 typedef struct ipfruleiter { 1246 int iri_ver; 1247 int iri_inout; 1248 char iri_group[FR_GROUPLEN]; 1249 int iri_active; 1250 int iri_nrules; 1251 frentry_t *iri_rule; 1252 } ipfruleiter_t; 1253 1254 /* Values for iri_inout */ 1255 #define F_IN 0 1256 #define F_OUT 1 1257 #define F_ACIN 2 1258 #define F_ACOUT 3 1259 1260 /* 1261 * ipfgeniter is generic iterator structure used for nat rules, 1262 * hostmap entries and nat table entries. 1263 */ 1264 typedef struct ipfgeniter { 1265 int igi_type; /* type of data we're looking at */ 1266 int igi_nitems; 1267 void *igi_data; 1268 } ipfgeniter_t; 1269 1270 #define IPFGENITER_IPF 0 1271 #define IPFGENITER_NAT 1 1272 #define IPFGENITER_IPNAT 2 1273 #define IPFGENITER_FRAG 3 1274 #define IPFGENITER_AUTH 4 1275 #define IPFGENITER_STATE 5 1276 #define IPFGENITER_NATFRAG 6 1277 #define IPFGENITER_HOSTMAP 7 1278 #define IPFGENITER_LOOKUP 8 1279 1280 typedef struct ipftable { 1281 int ita_type; 1282 void *ita_table; 1283 } ipftable_t; 1284 1285 typedef struct ipftoken { 1286 struct ipftoken *ipt_next; 1287 struct ipftoken **ipt_pnext; 1288 void *ipt_ctx; 1289 void *ipt_data; 1290 u_long ipt_die; 1291 int ipt_type; 1292 int ipt_uid; 1293 int ipt_subtype; 1294 int ipt_alive; 1295 } ipftoken_t; 1296 1297 1298 /* 1299 * sync commands 1300 */ 1301 #define IPFSYNC_RESYNC 0 1302 #define IPFSYNC_NEWIFP 1 1303 #define IPFSYNC_OLDIFP 2 1304 1305 1306 /* 1307 ** HPUX Port 1308 */ 1309 #ifdef __hpux 1310 /* HP-UX locking sequence deadlock detection module lock MAJOR ID */ 1311 # define IPF_SMAJ 0 /* temp assignment XXX, not critical */ 1312 #endif 1313 1314 #if !defined(CDEV_MAJOR) && defined (__FreeBSD_version) && \ 1315 (__FreeBSD_version >= 220000) 1316 # define CDEV_MAJOR 79 1317 #endif 1318 1319 /* 1320 * Post NetBSD 1.2 has the PFIL interface for packet filters. This turns 1321 * on those hooks. We don't need any special mods in non-IP Filter code 1322 * with this! 1323 */ 1324 #if (defined(NetBSD) && (NetBSD > 199609) && (NetBSD <= 1991011)) || \ 1325 (defined(NetBSD1_2) && NetBSD1_2 > 1) || \ 1326 (defined(__FreeBSD__) && (__FreeBSD_version >= 500043)) 1327 # if (NetBSD >= 199905) 1328 # define PFIL_HOOKS 1329 # endif 1330 # ifdef PFIL_HOOKS 1331 # define NETBSD_PF 1332 # endif 1333 #endif 1334 1335 #ifndef _KERNEL 1336 extern int fr_check __P((struct ip *, int, void *, int, mb_t **, ipf_stack_t *)); 1337 extern int (*fr_checkp) __P((ip_t *, int, void *, int, mb_t **, ipf_stack_t *)); 1338 extern int ipf_log __P((void)); 1339 extern struct ifnet *get_unit __P((char *, int, ipf_stack_t *)); 1340 extern char *get_ifname __P((struct ifnet *)); 1341 # if defined(__NetBSD__) || defined(__OpenBSD__) || \ 1342 (_BSDI_VERSION >= 199701) || (__FreeBSD_version >= 300000) 1343 extern int frrequest __P((int, u_long, caddr_t, int, int, ipf_stack_t *)); 1344 # else 1345 extern int iplioctl __P((int, ioctlcmd_t, caddr_t, int)); 1346 # endif 1347 extern int iplopen __P((dev_t, int)); 1348 extern int iplclose __P((dev_t, int)); 1349 extern void m_freem __P((mb_t *)); 1350 #else /* #ifndef _KERNEL */ 1351 extern phy_if_t get_unit __P((char *, int, ipf_stack_t *)); 1352 # if defined(__NetBSD__) && defined(PFIL_HOOKS) 1353 extern void ipfilterattach __P((int)); 1354 # endif 1355 extern int ipl_enable __P((void)); 1356 extern int ipl_disable __P((void)); 1357 # ifdef MENTAT 1358 extern ipf_stack_t *ipf_find_stack(const zoneid_t zone); 1359 extern int fr_check __P((struct ip *, int, void *, int, void *, 1360 mblk_t **, ipf_stack_t *)); 1361 # if SOLARIS 1362 # if SOLARIS2 >= 7 1363 extern int iplioctl __P((dev_t, int, intptr_t, int, cred_t *, int *)); 1364 # else 1365 extern int iplioctl __P((dev_t, int, int *, int, cred_t *, int *)); 1366 # endif 1367 extern int iplopen __P((dev_t *, int, int, cred_t *)); 1368 extern int iplclose __P((dev_t, int, int, cred_t *)); 1369 extern int iplread __P((dev_t, uio_t *, cred_t *)); 1370 extern int iplwrite __P((dev_t, uio_t *, cred_t *)); 1371 # endif 1372 # ifdef __hpux 1373 extern int iplopen __P((dev_t, int, intptr_t, int)); 1374 extern int iplclose __P((dev_t, int, int)); 1375 extern int iplioctl __P((dev_t, int, caddr_t, int)); 1376 extern int iplread __P((dev_t, uio_t *)); 1377 extern int iplwrite __P((dev_t, uio_t *)); 1378 extern int iplselect __P((dev_t, int)); 1379 # endif 1380 extern int ipfsync __P((ipf_stack_t *)); 1381 extern int fr_qout __P((queue_t *, mblk_t *)); 1382 # else /* MENTAT */ 1383 extern int fr_check __P((struct ip *, int, void *, int, mb_t **, ipf_stack_t *)); 1384 extern int (*fr_checkp) __P((ip_t *, int, void *, int, mb_t **, ipf_stack_t *)); 1385 extern size_t mbufchainlen __P((mb_t *)); 1386 # ifdef __sgi 1387 # include <sys/cred.h> 1388 extern int iplioctl __P((dev_t, int, caddr_t, int, cred_t *, int *)); 1389 extern int iplopen __P((dev_t *, int, int, cred_t *)); 1390 extern int iplclose __P((dev_t, int, int, cred_t *)); 1391 extern int iplread __P((dev_t, uio_t *, cred_t *)); 1392 extern int iplwrite __P((dev_t, uio_t *, cred_t *)); 1393 extern int ipfsync __P((ipf_stack_t *)); 1394 extern int ipfilter_sgi_attach __P((void)); 1395 extern void ipfilter_sgi_detach __P((void)); 1396 extern void ipfilter_sgi_intfsync __P((void)); 1397 # else 1398 # ifdef IPFILTER_LKM 1399 extern int iplidentify __P((char *)); 1400 # endif 1401 # if (_BSDI_VERSION >= 199510) || (__FreeBSD_version >= 220000) || \ 1402 (NetBSD >= 199511) || defined(__OpenBSD__) 1403 # if defined(__NetBSD__) || (_BSDI_VERSION >= 199701) || \ 1404 defined(__OpenBSD__) || (__FreeBSD_version >= 300000) 1405 # if (__FreeBSD_version >= 500024) 1406 # if (__FreeBSD_version >= 502116) 1407 extern int iplioctl __P((struct cdev*, u_long, caddr_t, int, struct thread *)); 1408 # else 1409 extern int iplioctl __P((dev_t, u_long, caddr_t, int, struct thread *)); 1410 # endif /* __FreeBSD_version >= 502116 */ 1411 # else 1412 extern int iplioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); 1413 # endif /* __FreeBSD_version >= 500024 */ 1414 # else 1415 extern int iplioctl __P((dev_t, int, caddr_t, int, struct proc *)); 1416 # endif 1417 # if (__FreeBSD_version >= 500024) 1418 # if (__FreeBSD_version >= 502116) 1419 extern int iplopen __P((struct cdev*, int, int, struct thread *)); 1420 extern int iplclose __P((struct cdev*, int, int, struct thread *)); 1421 # else 1422 extern int iplopen __P((dev_t, int, int, struct thread *)); 1423 extern int iplclose __P((dev_t, int, int, struct thread *)); 1424 # endif /* __FreeBSD_version >= 502116 */ 1425 # else 1426 extern int iplopen __P((dev_t, int, int, struct proc *)); 1427 extern int iplclose __P((dev_t, int, int, struct proc *)); 1428 # endif /* __FreeBSD_version >= 500024 */ 1429 # else 1430 # ifdef linux 1431 extern int iplioctl __P((struct inode *, struct file *, u_int, u_long)); 1432 # else 1433 extern int iplopen __P((dev_t, int)); 1434 extern int iplclose __P((dev_t, int)); 1435 extern int iplioctl __P((dev_t, int, caddr_t, int)); 1436 # endif 1437 # endif /* (_BSDI_VERSION >= 199510) */ 1438 # if BSD >= 199306 1439 # if (__FreeBSD_version >= 502116) 1440 extern int iplread __P((struct cdev*, struct uio *, int)); 1441 extern int iplwrite __P((struct cdev*, struct uio *, int)); 1442 # else 1443 extern int iplread __P((dev_t, struct uio *, int)); 1444 extern int iplwrite __P((dev_t, struct uio *, int)); 1445 # endif /* __FreeBSD_version >= 502116 */ 1446 # else 1447 # ifndef linux 1448 extern int iplread __P((dev_t, struct uio *)); 1449 extern int iplwrite __P((dev_t, struct uio *)); 1450 # endif 1451 # endif /* BSD >= 199306 */ 1452 # endif /* __ sgi */ 1453 # endif /* MENTAT */ 1454 1455 #endif /* #ifndef _KERNEL */ 1456 1457 extern char *memstr __P((char *, char *, int, int)); 1458 extern int count4bits __P((u_32_t)); 1459 extern int count6bits __P((u_32_t *)); 1460 extern int frrequest __P((int, ioctlcmd_t, caddr_t, int, int, ipf_stack_t *)); 1461 extern char *getifname __P((struct ifnet *)); 1462 extern int iplattach __P((ipf_stack_t *)); 1463 extern int ipldetach __P((ipf_stack_t *)); 1464 extern u_short ipf_cksum __P((u_short *, int)); 1465 extern int copyinptr __P((void *, void *, size_t)); 1466 extern int copyoutptr __P((void *, void *, size_t)); 1467 extern int fr_fastroute __P((mb_t *, mb_t **, fr_info_t *, frdest_t *)); 1468 extern int fr_inobj __P((void *, void *, int)); 1469 extern int fr_inobjsz __P((void *, void *, int, int)); 1470 extern int fr_ioctlswitch __P((int, void *, ioctlcmd_t, int, int, void *, 1471 ipf_stack_t *)); 1472 extern int fr_ipftune __P((ioctlcmd_t, void *, ipf_stack_t *)); 1473 extern int fr_outobj __P((void *, void *, int)); 1474 extern int fr_outobjsz __P((void *, void *, int, int)); 1475 extern void *fr_pullup __P((mb_t *, fr_info_t *, int)); 1476 extern void fr_resolvedest __P((struct frdest *, int, ipf_stack_t *)); 1477 extern int fr_resolvefunc __P((void *)); 1478 extern void *fr_resolvenic __P((char *, int, ipf_stack_t *)); 1479 extern int fr_send_icmp_err __P((int, fr_info_t *, int)); 1480 extern int fr_send_reset __P((fr_info_t *)); 1481 #if (__FreeBSD_version < 490000) || !defined(_KERNEL) 1482 extern int ppsratecheck __P((struct timeval *, int *, int)); 1483 #endif 1484 extern ipftq_t *fr_addtimeoutqueue __P((ipftq_t **, u_int, ipf_stack_t *)); 1485 extern void fr_deletequeueentry __P((ipftqent_t *)); 1486 extern int fr_deletetimeoutqueue __P((ipftq_t *)); 1487 extern void fr_freetimeoutqueue __P((ipftq_t *, ipf_stack_t *)); 1488 extern void fr_movequeue __P((ipftqent_t *, ipftq_t *, ipftq_t *, 1489 ipf_stack_t *)); 1490 extern void fr_queueappend __P((ipftqent_t *, ipftq_t *, void *, 1491 ipf_stack_t *)); 1492 extern void fr_queueback __P((ipftqent_t *, ipf_stack_t *)); 1493 extern void fr_queuefront __P((ipftqent_t *)); 1494 extern void fr_checkv4sum __P((fr_info_t *)); 1495 extern int fr_checkl4sum __P((fr_info_t *)); 1496 extern int fr_ifpfillv4addr __P((int, struct sockaddr_in *, 1497 struct sockaddr_in *, struct in_addr *, 1498 struct in_addr *)); 1499 extern int fr_coalesce __P((fr_info_t *)); 1500 #ifdef USE_INET6 1501 extern void fr_checkv6sum __P((fr_info_t *)); 1502 extern int fr_ifpfillv6addr __P((int, struct sockaddr_in6 *, 1503 struct sockaddr_in6 *, struct in_addr *, 1504 struct in_addr *)); 1505 #endif 1506 1507 #define IPFILTER_COMPAT 1508 extern int fr_incomptrans __P((ipfobj_t *, void *)); 1509 extern int fr_outcomptrans __P((ipfobj_t *, void *)); 1510 1511 extern int fr_addipftune __P((ipftuneable_t *, ipf_stack_t *)); 1512 extern int fr_delipftune __P((ipftuneable_t *, ipf_stack_t *)); 1513 1514 extern int frflush __P((minor_t, int, int, ipf_stack_t *)); 1515 extern void frsync __P((int, int, void *, char *, ipf_stack_t *)); 1516 extern frgroup_t *fr_addgroup __P((char *, void *, u_32_t, minor_t, int, 1517 ipf_stack_t *)); 1518 extern int fr_derefrule __P((frentry_t **, ipf_stack_t *)); 1519 extern void fr_delgroup __P((char *, minor_t, int, ipf_stack_t *)); 1520 extern frgroup_t *fr_findgroup __P((char *, minor_t, int, frgroup_t ***, 1521 ipf_stack_t *)); 1522 1523 extern int fr_loginit __P((ipf_stack_t *)); 1524 extern int ipflog_clear __P((minor_t, ipf_stack_t *)); 1525 extern int ipflog_read __P((minor_t, struct uio *, ipf_stack_t *)); 1526 extern int ipflog __P((fr_info_t *, u_int)); 1527 extern int ipllog __P((int, fr_info_t *, void **, size_t *, int *, int, 1528 ipf_stack_t *)); 1529 extern void fr_logunload __P((ipf_stack_t *)); 1530 1531 extern frentry_t *fr_acctpkt __P((fr_info_t *, u_32_t *)); 1532 extern int fr_copytolog __P((int, char *, int)); 1533 extern u_short fr_cksum __P((mb_t *, ip_t *, int, void *)); 1534 extern void fr_deinitialise __P((ipf_stack_t *)); 1535 extern frentry_t *fr_dolog __P((fr_info_t *, u_32_t *)); 1536 extern frentry_t *fr_dstgrpmap __P((fr_info_t *, u_32_t *)); 1537 extern void fr_fixskip __P((frentry_t **, frentry_t *, int)); 1538 extern void fr_forgetifp __P((void *, ipf_stack_t *)); 1539 extern frentry_t *fr_getrulen __P((int, char *, u_32_t, 1540 ipf_stack_t *)); 1541 extern void fr_getstat __P((struct friostat *, ipf_stack_t *)); 1542 extern int fr_ifpaddr __P((int, int, void *, 1543 struct in_addr *, struct in_addr *, 1544 ipf_stack_t *)); 1545 extern int fr_initialise __P((ipf_stack_t *)); 1546 extern int fr_lock __P((caddr_t, int *)); 1547 extern int fr_makefrip __P((int, ip_t *, fr_info_t *)); 1548 extern int fr_matchtag __P((ipftag_t *, ipftag_t *)); 1549 extern int fr_matchicmpqueryreply __P((int, icmpinfo_t *, 1550 struct icmp *, int)); 1551 extern u_32_t fr_newisn __P((fr_info_t *)); 1552 extern u_short fr_nextipid __P((fr_info_t *)); 1553 extern int fr_rulen __P((int, frentry_t *, ipf_stack_t *)); 1554 extern int fr_scanlist __P((fr_info_t *, u_32_t)); 1555 extern frentry_t *fr_srcgrpmap __P((fr_info_t *, u_32_t *)); 1556 extern int fr_tcpudpchk __P((fr_info_t *, frtuc_t *)); 1557 extern int fr_verifysrc __P((fr_info_t *fin)); 1558 extern int fr_zerostats __P((char *, ipf_stack_t *)); 1559 extern ipftoken_t *ipf_findtoken __P((int, int, void *, ipf_stack_t *)); 1560 extern int ipf_getnextrule __P((ipftoken_t *, void *, 1561 ipf_stack_t *)); 1562 extern void ipf_expiretokens __P((ipf_stack_t *)); 1563 extern void ipf_freetoken __P((ipftoken_t *, ipf_stack_t *)); 1564 extern int ipf_deltoken __P((int, int, void *, ipf_stack_t *)); 1565 extern int ipf_genericiter __P((void *, int, void *, ipf_stack_t *)); 1566 extern int ipf_extraflush __P((int, ipftq_t *, ipftq_t *, ipf_stack_t *)); 1567 extern int ipf_flushclosing __P((int, int, ipftq_t *, ipftq_t *, ipf_stack_t *)); 1568 extern int ipf_earlydrop __P((int, ipftq_t *, int, ipf_stack_t *)); 1569 1570 #ifndef ipf_random 1571 extern u_32_t ipf_random __P((void)); 1572 #endif 1573 1574 extern char ipfilter_version[]; 1575 #ifdef USE_INET6 1576 extern int icmptoicmp6types[ICMP_MAXTYPE+1]; 1577 extern int icmptoicmp6unreach[ICMP_MAX_UNREACH]; 1578 extern int icmpreplytype6[ICMP6_MAXTYPE + 1]; 1579 #endif 1580 extern int icmpreplytype4[ICMP_MAXTYPE + 1]; 1581 extern frentry_t *ipfrule_match __P((fr_info_t *)); 1582 1583 extern void ipftuneable_alloc(ipf_stack_t *); 1584 extern void ipftuneable_free(ipf_stack_t *); 1585 1586 #endif /* __IP_FIL_H__ */ 1587