17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * Copyright (C) 1993-2001, 2003 by Darren Reed. 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * See the IPFILTER.LICENCE file for details on licencing. 57c478bd9Sstevel@tonic-gate * 6ab25eeb5Syz * @(#)ip_fil.h 1.35 6/5/96 7ab25eeb5Syz * $Id: ip_fil.h,v 2.170.2.22 2005/07/16 05:55:35 darrenr Exp $ 87c478bd9Sstevel@tonic-gate * 9786c7074Sjojemann * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 107c478bd9Sstevel@tonic-gate * Use is subject to license terms. 117c478bd9Sstevel@tonic-gate */ 127c478bd9Sstevel@tonic-gate 137c478bd9Sstevel@tonic-gate #ifndef __IP_FIL_H__ 147c478bd9Sstevel@tonic-gate #define __IP_FIL_H__ 157c478bd9Sstevel@tonic-gate 16ab25eeb5Syz #include "netinet/ip_compat.h" 17ab25eeb5Syz 187c478bd9Sstevel@tonic-gate #ifndef SOLARIS 197c478bd9Sstevel@tonic-gate # define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4))) 207c478bd9Sstevel@tonic-gate #endif 217c478bd9Sstevel@tonic-gate 227c478bd9Sstevel@tonic-gate #ifndef __P 237c478bd9Sstevel@tonic-gate # ifdef __STDC__ 247c478bd9Sstevel@tonic-gate # define __P(x) x 257c478bd9Sstevel@tonic-gate # else 267c478bd9Sstevel@tonic-gate # define __P(x) () 277c478bd9Sstevel@tonic-gate # endif 287c478bd9Sstevel@tonic-gate #endif 297c478bd9Sstevel@tonic-gate 30ab25eeb5Syz #if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51) 317c478bd9Sstevel@tonic-gate # define SIOCADAFR _IOW('r', 60, struct ipfobj) 327c478bd9Sstevel@tonic-gate # define SIOCRMAFR _IOW('r', 61, struct ipfobj) 337c478bd9Sstevel@tonic-gate # define SIOCSETFF _IOW('r', 62, u_int) 347c478bd9Sstevel@tonic-gate # define SIOCGETFF _IOR('r', 63, u_int) 357c478bd9Sstevel@tonic-gate # define SIOCGETFS _IOWR('r', 64, struct ipfobj) 367c478bd9Sstevel@tonic-gate # define SIOCIPFFL _IOWR('r', 65, int) 377c478bd9Sstevel@tonic-gate # define SIOCIPFFB _IOR('r', 66, int) 387c478bd9Sstevel@tonic-gate # define SIOCADIFR _IOW('r', 67, struct ipfobj) 397c478bd9Sstevel@tonic-gate # define SIOCRMIFR _IOW('r', 68, struct ipfobj) 407c478bd9Sstevel@tonic-gate # define SIOCSWAPA _IOR('r', 69, u_int) 417c478bd9Sstevel@tonic-gate # define SIOCINAFR _IOW('r', 70, struct ipfobj) 427c478bd9Sstevel@tonic-gate # define SIOCINIFR _IOW('r', 71, struct ipfobj) 437c478bd9Sstevel@tonic-gate # define SIOCFRENB _IOW('r', 72, u_int) 447c478bd9Sstevel@tonic-gate # define SIOCFRSYN _IOW('r', 73, u_int) 457c478bd9Sstevel@tonic-gate # define SIOCFRZST _IOWR('r', 74, struct ipfobj) 467c478bd9Sstevel@tonic-gate # define SIOCZRLST _IOWR('r', 75, struct ipfobj) 477c478bd9Sstevel@tonic-gate # define SIOCAUTHW _IOWR('r', 76, struct ipfobj) 487c478bd9Sstevel@tonic-gate # define SIOCAUTHR _IOWR('r', 77, struct ipfobj) 497c478bd9Sstevel@tonic-gate # define SIOCATHST _IOWR('r', 78, struct ipfobj) 507c478bd9Sstevel@tonic-gate # define SIOCSTLCK _IOWR('r', 79, u_int) 517c478bd9Sstevel@tonic-gate # define SIOCSTPUT _IOWR('r', 80, struct ipfobj) 527c478bd9Sstevel@tonic-gate # define SIOCSTGET _IOWR('r', 81, struct ipfobj) 537c478bd9Sstevel@tonic-gate # define SIOCSTGSZ _IOWR('r', 82, struct ipfobj) 547c478bd9Sstevel@tonic-gate # define SIOCGFRST _IOWR('r', 83, struct ipfobj) 557c478bd9Sstevel@tonic-gate # define SIOCSETLG _IOWR('r', 84, int) 567c478bd9Sstevel@tonic-gate # define SIOCGETLG _IOWR('r', 85, int) 577c478bd9Sstevel@tonic-gate # define SIOCFUNCL _IOWR('r', 86, struct ipfunc_resolve) 587c478bd9Sstevel@tonic-gate # define SIOCIPFGETNEXT _IOWR('r', 87, struct ipfobj) 597c478bd9Sstevel@tonic-gate # define SIOCIPFGET _IOWR('r', 88, struct ipfobj) 607c478bd9Sstevel@tonic-gate # define SIOCIPFSET _IOWR('r', 89, struct ipfobj) 617663b816Sml # define SIOCIPFL6 _IOWR('r', 90, int) 62381a2a9aSdr # define SIOCIPFLP _IOWR('r', 91, int) 63f4b3ec61Sdh # define SIOCIPFITER _IOWR('r', 92, struct ipfobj) 64f4b3ec61Sdh # define SIOCGENITER _IOWR('r', 93, struct ipfobj) 65f4b3ec61Sdh # define SIOCGTABL _IOWR('r', 94, struct ipfobj) 66f4b3ec61Sdh # define SIOCIPFDELTOK _IOWR('r', 95, int) 67f4b3ec61Sdh # define SIOCLOOKUPITER _IOWR('r', 96, struct ipfobj) 687c478bd9Sstevel@tonic-gate #else 697c478bd9Sstevel@tonic-gate # define SIOCADAFR _IOW(r, 60, struct ipfobj) 707c478bd9Sstevel@tonic-gate # define SIOCRMAFR _IOW(r, 61, struct ipfobj) 717c478bd9Sstevel@tonic-gate # define SIOCSETFF _IOW(r, 62, u_int) 727c478bd9Sstevel@tonic-gate # define SIOCGETFF _IOR(r, 63, u_int) 737c478bd9Sstevel@tonic-gate # define SIOCGETFS _IOWR(r, 64, struct ipfobj) 747c478bd9Sstevel@tonic-gate # define SIOCIPFFL _IOWR(r, 65, int) 757c478bd9Sstevel@tonic-gate # define SIOCIPFFB _IOR(r, 66, int) 767c478bd9Sstevel@tonic-gate # define SIOCADIFR _IOW(r, 67, struct ipfobj) 777c478bd9Sstevel@tonic-gate # define SIOCRMIFR _IOW(r, 68, struct ipfobj) 787c478bd9Sstevel@tonic-gate # define SIOCSWAPA _IOR(r, 69, u_int) 797c478bd9Sstevel@tonic-gate # define SIOCINAFR _IOW(r, 70, struct ipfobj) 807c478bd9Sstevel@tonic-gate # define SIOCINIFR _IOW(r, 71, struct ipfobj) 817c478bd9Sstevel@tonic-gate # define SIOCFRENB _IOW(r, 72, u_int) 827c478bd9Sstevel@tonic-gate # define SIOCFRSYN _IOW(r, 73, u_int) 837c478bd9Sstevel@tonic-gate # define SIOCFRZST _IOWR(r, 74, struct ipfobj) 847c478bd9Sstevel@tonic-gate # define SIOCZRLST _IOWR(r, 75, struct ipfobj) 857c478bd9Sstevel@tonic-gate # define SIOCAUTHW _IOWR(r, 76, struct ipfobj) 867c478bd9Sstevel@tonic-gate # define SIOCAUTHR _IOWR(r, 77, struct ipfobj) 877c478bd9Sstevel@tonic-gate # define SIOCATHST _IOWR(r, 78, struct ipfobj) 887c478bd9Sstevel@tonic-gate # define SIOCSTLCK _IOWR(r, 79, u_int) 897c478bd9Sstevel@tonic-gate # define SIOCSTPUT _IOWR(r, 80, struct ipfobj) 907c478bd9Sstevel@tonic-gate # define SIOCSTGET _IOWR(r, 81, struct ipfobj) 917c478bd9Sstevel@tonic-gate # define SIOCSTGSZ _IOWR(r, 82, struct ipfobj) 927c478bd9Sstevel@tonic-gate # define SIOCGFRST _IOWR(r, 83, struct ipfobj) 937c478bd9Sstevel@tonic-gate # define SIOCSETLG _IOWR(r, 84, int) 947c478bd9Sstevel@tonic-gate # define SIOCGETLG _IOWR(r, 85, int) 957c478bd9Sstevel@tonic-gate # define SIOCFUNCL _IOWR(r, 86, struct ipfunc_resolve) 967c478bd9Sstevel@tonic-gate # define SIOCIPFGETNEXT _IOWR(r, 87, struct ipfobj) 977c478bd9Sstevel@tonic-gate # define SIOCIPFGET _IOWR(r, 88, struct ipfobj) 987c478bd9Sstevel@tonic-gate # define SIOCIPFSET _IOWR(r, 89, struct ipfobj) 997663b816Sml # define SIOCIPFL6 _IOWR(r, 90, int) 100381a2a9aSdr # define SIOCIPFLP _IOWR(r, 91, int) 101f4b3ec61Sdh # define SIOCIPFITER _IOWR(r, 92, struct ipfobj) 102f4b3ec61Sdh # define SIOCGENITER _IOWR(r, 93, struct ipfobj) 103f4b3ec61Sdh # define SIOCGTABL _IOWR(r, 94, struct ipfobj) 104f4b3ec61Sdh # define SIOCIPFDELTOK _IOWR(r, 95, int) 105f4b3ec61Sdh # define SIOCLOOKUPITER _IOWR(r, 96, struct ipfobj) 1067c478bd9Sstevel@tonic-gate #endif 1077c478bd9Sstevel@tonic-gate #define SIOCADDFR SIOCADAFR 1087c478bd9Sstevel@tonic-gate #define SIOCDELFR SIOCRMAFR 1097c478bd9Sstevel@tonic-gate #define SIOCINSFR SIOCINAFR 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate struct ipscan; 1137c478bd9Sstevel@tonic-gate struct ifnet; 1147c478bd9Sstevel@tonic-gate 115f4b3ec61Sdh typedef struct ipf_stack ipf_stack_t; 116f4b3ec61Sdh 117f4b3ec61Sdh typedef int (* lookupfunc_t) __P((void *, int, void *, ipf_stack_t *)); 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate /* 1217c478bd9Sstevel@tonic-gate * i6addr is used as a container for both IPv4 and IPv6 addresses, as well 1227c478bd9Sstevel@tonic-gate * as other types of objects, depending on its qualifier. 1237c478bd9Sstevel@tonic-gate */ 1247c478bd9Sstevel@tonic-gate #ifdef USE_INET6 1257c478bd9Sstevel@tonic-gate typedef union i6addr { 1267c478bd9Sstevel@tonic-gate u_32_t i6[4]; 1277c478bd9Sstevel@tonic-gate struct in_addr in4; 1287c478bd9Sstevel@tonic-gate struct in6_addr in6; 1297c478bd9Sstevel@tonic-gate void *vptr[2]; 1307c478bd9Sstevel@tonic-gate lookupfunc_t lptr[2]; 1317c478bd9Sstevel@tonic-gate } i6addr_t; 132d6c23f6fSyx #define in6_addr8 in6.s6_addr 1337c478bd9Sstevel@tonic-gate #else 1347c478bd9Sstevel@tonic-gate typedef union i6addr { 1357c478bd9Sstevel@tonic-gate u_32_t i6[4]; 1367c478bd9Sstevel@tonic-gate struct in_addr in4; 1377c478bd9Sstevel@tonic-gate void *vptr[2]; 1387c478bd9Sstevel@tonic-gate lookupfunc_t lptr[2]; 1397c478bd9Sstevel@tonic-gate } i6addr_t; 1407c478bd9Sstevel@tonic-gate #endif 141ab25eeb5Syz 142d6c23f6fSyx #define in4_addr in4.s_addr 1437c478bd9Sstevel@tonic-gate #define iplookupnum i6[0] 1447c478bd9Sstevel@tonic-gate #define iplookuptype i6[1] 1457c478bd9Sstevel@tonic-gate /* 1467c478bd9Sstevel@tonic-gate * NOTE: These DO overlap the above on 64bit systems and this IS recognised. 1477c478bd9Sstevel@tonic-gate */ 1487c478bd9Sstevel@tonic-gate #define iplookupptr vptr[0] 1497c478bd9Sstevel@tonic-gate #define iplookupfunc lptr[1] 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate #define I60(x) (((i6addr_t *)(x))->i6[0]) 1527c478bd9Sstevel@tonic-gate #define I61(x) (((i6addr_t *)(x))->i6[1]) 1537c478bd9Sstevel@tonic-gate #define I62(x) (((i6addr_t *)(x))->i6[2]) 1547c478bd9Sstevel@tonic-gate #define I63(x) (((i6addr_t *)(x))->i6[3]) 1557c478bd9Sstevel@tonic-gate #define HI60(x) ntohl(((i6addr_t *)(x))->i6[0]) 1567c478bd9Sstevel@tonic-gate #define HI61(x) ntohl(((i6addr_t *)(x))->i6[1]) 1577c478bd9Sstevel@tonic-gate #define HI62(x) ntohl(((i6addr_t *)(x))->i6[2]) 1587c478bd9Sstevel@tonic-gate #define HI63(x) ntohl(((i6addr_t *)(x))->i6[3]) 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate #define IP6_EQ(a,b) ((I63(a) == I63(b)) && (I62(a) == I62(b)) && \ 1617c478bd9Sstevel@tonic-gate (I61(a) == I61(b)) && (I60(a) == I60(b))) 1627c478bd9Sstevel@tonic-gate #define IP6_NEQ(a,b) ((I63(a) != I63(b)) || (I62(a) != I62(b)) || \ 1637c478bd9Sstevel@tonic-gate (I61(a) != I61(b)) || (I60(a) != I60(b))) 164d6c23f6fSyx #define IP6_ISZERO(a) ((I60(a) | I61(a) | I62(a) | I63(a)) == 0) 1657c478bd9Sstevel@tonic-gate #define IP6_NOTZERO(a) ((I60(a) | I61(a) | I62(a) | I63(a)) != 0) 166d6c23f6fSyx #define IP6_ISONES(a) ((I63(a) == 0xffffffff) && (I62(a) == 0xffffffff) && \ 167d6c23f6fSyx (I61(a) == 0xffffffff) && (I60(a) == 0xffffffff)) 168d6c23f6fSyx #define IP6_GT(a,b) (ntohl(HI60(a)) > ntohl(HI60(b)) || \ 169d6c23f6fSyx (HI60(a) == HI60(b) && \ 170d6c23f6fSyx (ntohl(HI61(a)) > ntohl(HI61(b)) || \ 171d6c23f6fSyx (HI61(a) == HI61(b) && \ 172d6c23f6fSyx (ntohl(HI62(a)) > ntohl(HI62(b)) || \ 173d6c23f6fSyx (HI62(a) == HI62(b) && \ 174d6c23f6fSyx ntohl(HI63(a)) > ntohl(HI63(b)))))))) 175d6c23f6fSyx #define IP6_LT(a,b) (ntohl(HI60(a)) < ntohl(HI60(b)) || \ 176d6c23f6fSyx (HI60(a) == HI60(b) && \ 177d6c23f6fSyx (ntohl(HI61(a)) < ntohl(HI61(b)) || \ 178d6c23f6fSyx (HI61(a) == HI61(b) && \ 179d6c23f6fSyx (ntohl(HI62(a)) < ntohl(HI62(b)) || \ 180d6c23f6fSyx (HI62(a) == HI62(b) && \ 181d6c23f6fSyx ntohl(HI63(a)) < ntohl(HI63(b)))))))) 1827c478bd9Sstevel@tonic-gate #define NLADD(n,x) htonl(ntohl(n) + (x)) 1837c478bd9Sstevel@tonic-gate #define IP6_INC(a) \ 1847c478bd9Sstevel@tonic-gate { i6addr_t *_i6 = (i6addr_t *)(a); \ 185d6c23f6fSyx _i6->i6[3] = NLADD(_i6->i6[3], 1); \ 186d6c23f6fSyx if (_i6->i6[3] == 0) { \ 187d6c23f6fSyx _i6->i6[2] = NLADD(_i6->i6[2], 1); \ 188d6c23f6fSyx if (_i6->i6[2] == 0) { \ 189d6c23f6fSyx _i6->i6[1] = NLADD(_i6->i6[1], 1); \ 190d6c23f6fSyx if (_i6->i6[1] == 0) { \ 191d6c23f6fSyx _i6->i6[0] = NLADD(_i6->i6[0], 1); \ 1927c478bd9Sstevel@tonic-gate } \ 1937c478bd9Sstevel@tonic-gate } \ 1947c478bd9Sstevel@tonic-gate } \ 1957c478bd9Sstevel@tonic-gate } 1967c478bd9Sstevel@tonic-gate #define IP6_ADD(a,x,d) \ 1977c478bd9Sstevel@tonic-gate { i6addr_t *_s = (i6addr_t *)(a); \ 1987c478bd9Sstevel@tonic-gate i6addr_t *_d = (i6addr_t *)(d); \ 199d6c23f6fSyx _d->i6[3] = NLADD(_s->i6[3], x); \ 200d6c23f6fSyx if (ntohl(_d->i6[3]) < ntohl(_s->i6[3])) { \ 201d6c23f6fSyx _d->i6[2] = NLADD(_d->i6[2], 1); \ 202d6c23f6fSyx if (ntohl(_d->i6[2]) < ntohl(_s->i6[2])) { \ 203d6c23f6fSyx _d->i6[1] = NLADD(_d->i6[1], 1); \ 204d6c23f6fSyx if (ntohl(_d->i6[1]) < ntohl(_s->i6[1])) { \ 205d6c23f6fSyx _d->i6[0] = NLADD(_d->i6[0], 1); \ 2067c478bd9Sstevel@tonic-gate } \ 2077c478bd9Sstevel@tonic-gate } \ 2087c478bd9Sstevel@tonic-gate } \ 2097c478bd9Sstevel@tonic-gate } 2107c478bd9Sstevel@tonic-gate #define IP6_AND(a,b,d) { i6addr_t *_s1 = (i6addr_t *)(a); \ 211d6c23f6fSyx i6addr_t *_s2 = (i6addr_t *)(b); \ 2127c478bd9Sstevel@tonic-gate i6addr_t *_d = (i6addr_t *)(d); \ 2137c478bd9Sstevel@tonic-gate _d->i6[0] = _s1->i6[0] & _s2->i6[0]; \ 2147c478bd9Sstevel@tonic-gate _d->i6[1] = _s1->i6[1] & _s2->i6[1]; \ 2157c478bd9Sstevel@tonic-gate _d->i6[2] = _s1->i6[2] & _s2->i6[2]; \ 2167c478bd9Sstevel@tonic-gate _d->i6[3] = _s1->i6[3] & _s2->i6[3]; \ 2177c478bd9Sstevel@tonic-gate } 218d6c23f6fSyx #define IP6_MASKEQ(a,m,b) \ 219d6c23f6fSyx (((I60(a) & I60(m)) == I60(b)) && \ 220d6c23f6fSyx ((I61(a) & I61(m)) == I61(b)) && \ 221d6c23f6fSyx ((I62(a) & I62(m)) == I62(b)) && \ 222d6c23f6fSyx ((I63(a) & I63(m)) == I63(b))) 223d6c23f6fSyx #define IP6_MASKNEQ(a,m,b) \ 224d6c23f6fSyx (((I60(a) & I60(m)) != I60(b)) || \ 225d6c23f6fSyx ((I61(a) & I61(m)) != I61(b)) || \ 226d6c23f6fSyx ((I62(a) & I62(m)) != I62(b)) || \ 227d6c23f6fSyx ((I63(a) & I63(m)) != I63(b))) 2287c478bd9Sstevel@tonic-gate #define IP6_MERGE(a,b,c) \ 2297c478bd9Sstevel@tonic-gate { i6addr_t *_d, *_s1, *_s2; \ 2307c478bd9Sstevel@tonic-gate _d = (i6addr_t *)(a); \ 2317c478bd9Sstevel@tonic-gate _s1 = (i6addr_t *)(b); \ 2327c478bd9Sstevel@tonic-gate _s2 = (i6addr_t *)(c); \ 2337c478bd9Sstevel@tonic-gate _d->i6[0] |= _s1->i6[0] & ~_s2->i6[0]; \ 2347c478bd9Sstevel@tonic-gate _d->i6[1] |= _s1->i6[1] & ~_s2->i6[1]; \ 2357c478bd9Sstevel@tonic-gate _d->i6[2] |= _s1->i6[2] & ~_s2->i6[2]; \ 236d6c23f6fSyx _d->i6[3] |= _s1->i6[3] & ~_s2->i6[3]; \ 2377c478bd9Sstevel@tonic-gate } 2387c478bd9Sstevel@tonic-gate 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate typedef struct fr_ip { 2417c478bd9Sstevel@tonic-gate u_32_t fi_v:4; /* IP version */ 2427c478bd9Sstevel@tonic-gate u_32_t fi_xx:4; /* spare */ 2437c478bd9Sstevel@tonic-gate u_32_t fi_tos:8; /* IP packet TOS */ 2447c478bd9Sstevel@tonic-gate u_32_t fi_ttl:8; /* IP packet TTL */ 2457c478bd9Sstevel@tonic-gate u_32_t fi_p:8; /* IP packet protocol */ 2467c478bd9Sstevel@tonic-gate u_32_t fi_optmsk; /* bitmask composed from IP options */ 2477c478bd9Sstevel@tonic-gate i6addr_t fi_src; /* source address from packet */ 2487c478bd9Sstevel@tonic-gate i6addr_t fi_dst; /* destination address from packet */ 2497c478bd9Sstevel@tonic-gate u_short fi_secmsk; /* bitmask composed from IP security options */ 2507c478bd9Sstevel@tonic-gate u_short fi_auth; /* authentication code from IP sec. options */ 2517c478bd9Sstevel@tonic-gate u_32_t fi_flx; /* packet flags */ 2527c478bd9Sstevel@tonic-gate u_32_t fi_tcpmsk; /* TCP options set/reset */ 2537c478bd9Sstevel@tonic-gate u_32_t fi_res1; /* RESERVED */ 2547c478bd9Sstevel@tonic-gate } fr_ip_t; 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate /* 2577c478bd9Sstevel@tonic-gate * For use in fi_flx 2587c478bd9Sstevel@tonic-gate */ 259cbded9aeSdr #define FI_MULTICAST 0x0001 260cbded9aeSdr #define FI_BROADCAST 0x0002 2617c478bd9Sstevel@tonic-gate #define FI_FRAG 0x0004 2627c478bd9Sstevel@tonic-gate #define FI_SHORT 0x0008 2637c478bd9Sstevel@tonic-gate #define FI_NATED 0x0010 264cbded9aeSdr #define FI_TCPUDP 0x0020 /* TCP/UCP implied comparison*/ 265cbded9aeSdr #define FI_OPTIONS 0x0040 2667c478bd9Sstevel@tonic-gate #define FI_MBCAST 0x0080 2677c478bd9Sstevel@tonic-gate #define FI_STATE 0x0100 2687c478bd9Sstevel@tonic-gate #define FI_BADNAT 0x0200 2697c478bd9Sstevel@tonic-gate #define FI_BAD 0x0400 2707c478bd9Sstevel@tonic-gate #define FI_OOW 0x0800 /* Out of state window, else match */ 2717c478bd9Sstevel@tonic-gate #define FI_ICMPERR 0x1000 272ab25eeb5Syz #define FI_FRAGBODY 0x2000 2737c478bd9Sstevel@tonic-gate #define FI_BADSRC 0x4000 2747c478bd9Sstevel@tonic-gate #define FI_LOWTTL 0x8000 275bb1d9de5SJohn Ojemann #define FI_CMP 0xcf03 /* Not FI_FRAG,FI_NATED,FI_FRAGTAIL,broadcast */ 276ab25eeb5Syz #define FI_ICMPCMP 0x0003 /* Flags we can check for ICMP error packets */ 2777c478bd9Sstevel@tonic-gate #define FI_WITH 0xeffe /* Not FI_TCPUDP */ 2787c478bd9Sstevel@tonic-gate #define FI_V6EXTHDR 0x10000 2797c478bd9Sstevel@tonic-gate #define FI_COALESCE 0x20000 280d6c23f6fSyx #define FI_ICMPQUERY 0x40000 2815b48165cSJohn Ojemann #define FI_NEWNAT 0x80000 282*40cdc2e8SAlexandr Nedvedicky #define FI_NEG_OOW 0x10000000 /* packet underflows TCP window */ 2837c478bd9Sstevel@tonic-gate #define FI_NOCKSUM 0x20000000 /* don't do a L4 checksum validation */ 2847c478bd9Sstevel@tonic-gate #define FI_DONTCACHE 0x40000000 /* don't cache the result */ 2857c478bd9Sstevel@tonic-gate #define FI_IGNORE 0x80000000 2867c478bd9Sstevel@tonic-gate 2877c478bd9Sstevel@tonic-gate #define fi_saddr fi_src.in4.s_addr 2887c478bd9Sstevel@tonic-gate #define fi_daddr fi_dst.in4.s_addr 2897c478bd9Sstevel@tonic-gate #define fi_srcnum fi_src.iplookupnum 2907c478bd9Sstevel@tonic-gate #define fi_dstnum fi_dst.iplookupnum 2917c478bd9Sstevel@tonic-gate #define fi_srctype fi_src.iplookuptype 2927c478bd9Sstevel@tonic-gate #define fi_dsttype fi_dst.iplookuptype 2937c478bd9Sstevel@tonic-gate #define fi_srcptr fi_src.iplookupptr 2947c478bd9Sstevel@tonic-gate #define fi_dstptr fi_dst.iplookupptr 2957c478bd9Sstevel@tonic-gate #define fi_srcfunc fi_src.iplookupfunc 2967c478bd9Sstevel@tonic-gate #define fi_dstfunc fi_dst.iplookupfunc 2977c478bd9Sstevel@tonic-gate 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate /* 3007c478bd9Sstevel@tonic-gate * These are both used by the state and NAT code to indicate that one port or 3017c478bd9Sstevel@tonic-gate * the other should be treated as a wildcard. 3027c478bd9Sstevel@tonic-gate * NOTE: When updating, check bit masks in ip_state.h and update there too. 3037c478bd9Sstevel@tonic-gate */ 3047c478bd9Sstevel@tonic-gate #define SI_W_SPORT 0x00000100 3057c478bd9Sstevel@tonic-gate #define SI_W_DPORT 0x00000200 3067c478bd9Sstevel@tonic-gate #define SI_WILDP (SI_W_SPORT|SI_W_DPORT) 3077c478bd9Sstevel@tonic-gate #define SI_W_SADDR 0x00000400 3087c478bd9Sstevel@tonic-gate #define SI_W_DADDR 0x00000800 3097c478bd9Sstevel@tonic-gate #define SI_WILDA (SI_W_SADDR|SI_W_DADDR) 3107c478bd9Sstevel@tonic-gate #define SI_NEWFR 0x00001000 3117c478bd9Sstevel@tonic-gate #define SI_CLONE 0x00002000 3127c478bd9Sstevel@tonic-gate #define SI_CLONED 0x00004000 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate 315f4b3ec61Sdh 316f4b3ec61Sdh 3177c478bd9Sstevel@tonic-gate typedef struct fr_info { 3187c478bd9Sstevel@tonic-gate void *fin_ifp; /* interface packet is `on' */ 319ab25eeb5Syz fr_ip_t fin_fi; /* IP Packet summary */ 3207c478bd9Sstevel@tonic-gate union { 3217c478bd9Sstevel@tonic-gate u_short fid_16[2]; /* TCP/UDP ports, ICMP code/type */ 3227c478bd9Sstevel@tonic-gate u_32_t fid_32; 3237c478bd9Sstevel@tonic-gate } fin_dat; 3247c478bd9Sstevel@tonic-gate int fin_out; /* in or out ? 1 == out, 0 == in */ 3257c478bd9Sstevel@tonic-gate int fin_rev; /* state only: 1 = reverse */ 3267c478bd9Sstevel@tonic-gate u_short fin_hlen; /* length of IP header in bytes */ 3277c478bd9Sstevel@tonic-gate u_char fin_tcpf; /* TCP header flags (SYN, ACK, etc) */ 3287c478bd9Sstevel@tonic-gate u_char fin_icode; /* ICMP error to return */ 3297c478bd9Sstevel@tonic-gate u_32_t fin_rule; /* rule # last matched */ 3307c478bd9Sstevel@tonic-gate char fin_group[FR_GROUPLEN]; /* group number, -1 for none */ 3317c478bd9Sstevel@tonic-gate struct frentry *fin_fr; /* last matching rule */ 3327c478bd9Sstevel@tonic-gate void *fin_dp; /* start of data past IP header */ 3337c478bd9Sstevel@tonic-gate int fin_dlen; /* length of data portion of packet */ 3347c478bd9Sstevel@tonic-gate int fin_plen; 335ab25eeb5Syz int fin_flen; /* length of layer 4 hdr and 3367663b816Sml ipv6 ext hdr after fragment hdr */ 337ab25eeb5Syz int fin_ipoff; /* # bytes from buffer start to hdr */ 3387663b816Sml u_32_t fin_id; /* IP packet id field */ 3397c478bd9Sstevel@tonic-gate u_short fin_off; 3407c478bd9Sstevel@tonic-gate int fin_depth; /* Group nesting depth */ 3417c478bd9Sstevel@tonic-gate int fin_error; /* Error code to return */ 3427c478bd9Sstevel@tonic-gate void *fin_nat; 3437c478bd9Sstevel@tonic-gate void *fin_state; 3447c478bd9Sstevel@tonic-gate void *fin_nattag; 345d6c23f6fSyx union { 346d6c23f6fSyx ip_t *fip_ip; 347d6c23f6fSyx #ifdef USE_INET6 348d6c23f6fSyx ip6_t *fip_ip6; 349d6c23f6fSyx #endif 350d6c23f6fSyx } fin_ipu; 3517c478bd9Sstevel@tonic-gate mb_t **fin_mp; /* pointer to pointer to mbuf */ 3527c478bd9Sstevel@tonic-gate mb_t *fin_m; /* pointer to mbuf */ 3537c478bd9Sstevel@tonic-gate #ifdef MENTAT 3547c478bd9Sstevel@tonic-gate mb_t *fin_qfm; /* pointer to mblk where pkt starts */ 355ab25eeb5Syz void *fin_qpi; 356f4b3ec61Sdh ipf_stack_t *fin_ifs; 357ab25eeb5Syz #endif 358ab25eeb5Syz #ifdef __sgi 359ab25eeb5Syz void *fin_hbuf; 3607c478bd9Sstevel@tonic-gate #endif 3617c478bd9Sstevel@tonic-gate } fr_info_t; 3627c478bd9Sstevel@tonic-gate 363d6c23f6fSyx #define fin_ip fin_ipu.fip_ip 364d6c23f6fSyx #define fin_ip6 fin_ipu.fip_ip6 3657c478bd9Sstevel@tonic-gate #define fin_v fin_fi.fi_v 3667c478bd9Sstevel@tonic-gate #define fin_p fin_fi.fi_p 3677c478bd9Sstevel@tonic-gate #define fin_flx fin_fi.fi_flx 3687c478bd9Sstevel@tonic-gate #define fin_optmsk fin_fi.fi_optmsk 3697c478bd9Sstevel@tonic-gate #define fin_secmsk fin_fi.fi_secmsk 3707c478bd9Sstevel@tonic-gate #define fin_auth fin_fi.fi_auth 3717c478bd9Sstevel@tonic-gate #define fin_src fin_fi.fi_src.in4 3727c478bd9Sstevel@tonic-gate #define fin_saddr fin_fi.fi_saddr 3737c478bd9Sstevel@tonic-gate #define fin_dst fin_fi.fi_dst.in4 3747c478bd9Sstevel@tonic-gate #define fin_daddr fin_fi.fi_daddr 3757c478bd9Sstevel@tonic-gate #define fin_data fin_dat.fid_16 3767c478bd9Sstevel@tonic-gate #define fin_sport fin_dat.fid_16[0] 3777c478bd9Sstevel@tonic-gate #define fin_dport fin_dat.fid_16[1] 3787c478bd9Sstevel@tonic-gate #define fin_ports fin_dat.fid_32 3797c478bd9Sstevel@tonic-gate 380d6c23f6fSyx #ifdef USE_INET6 381d6c23f6fSyx # define fin_src6 fin_fi.fi_src 382d6c23f6fSyx # define fin_dst6 fin_fi.fi_dst 383d6c23f6fSyx # define fin_dstip6 fin_fi.fi_dst.in6 384d6c23f6fSyx # define fin_srcip6 fin_fi.fi_src.in6 385d6c23f6fSyx #endif 386d6c23f6fSyx 3877c478bd9Sstevel@tonic-gate #define IPF_IN 0 3887c478bd9Sstevel@tonic-gate #define IPF_OUT 1 3897c478bd9Sstevel@tonic-gate 3907c478bd9Sstevel@tonic-gate typedef struct frentry *(*ipfunc_t) __P((fr_info_t *, u_32_t *)); 391f4b3ec61Sdh typedef int (*ipfuncinit_t) __P((struct frentry *, 392f4b3ec61Sdh ipf_stack_t *)); 3937c478bd9Sstevel@tonic-gate 3947c478bd9Sstevel@tonic-gate typedef struct ipfunc_resolve { 3957c478bd9Sstevel@tonic-gate char ipfu_name[32]; 3967c478bd9Sstevel@tonic-gate ipfunc_t ipfu_addr; 3977c478bd9Sstevel@tonic-gate ipfuncinit_t ipfu_init; 3987c478bd9Sstevel@tonic-gate } ipfunc_resolve_t; 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate /* 4017c478bd9Sstevel@tonic-gate * Size for compares on fr_info structures 4027c478bd9Sstevel@tonic-gate */ 4037c478bd9Sstevel@tonic-gate #define FI_CSIZE offsetof(fr_info_t, fin_icode) 4047c478bd9Sstevel@tonic-gate #define FI_LCSIZE offsetof(fr_info_t, fin_dp) 4057c478bd9Sstevel@tonic-gate 4067c478bd9Sstevel@tonic-gate /* 4077c478bd9Sstevel@tonic-gate * Size for copying cache fr_info structure 4087c478bd9Sstevel@tonic-gate */ 4097c478bd9Sstevel@tonic-gate #define FI_COPYSIZE offsetof(fr_info_t, fin_dp) 4107c478bd9Sstevel@tonic-gate 4117c478bd9Sstevel@tonic-gate /* 412ab25eeb5Syz * Structure for holding IPFilter's tag information 4137c478bd9Sstevel@tonic-gate */ 414ab25eeb5Syz #define IPFTAG_LEN 16 4157c478bd9Sstevel@tonic-gate typedef struct { 4167c478bd9Sstevel@tonic-gate union { 4177c478bd9Sstevel@tonic-gate u_32_t iptu_num[4]; 418ab25eeb5Syz char iptu_tag[IPFTAG_LEN]; 4197c478bd9Sstevel@tonic-gate } ipt_un; 4207c478bd9Sstevel@tonic-gate int ipt_not; 4217c478bd9Sstevel@tonic-gate } ipftag_t; 4227c478bd9Sstevel@tonic-gate 4237c478bd9Sstevel@tonic-gate #define ipt_tag ipt_un.iptu_tag 4247c478bd9Sstevel@tonic-gate #define ipt_num ipt_un.iptu_num 4257c478bd9Sstevel@tonic-gate 4267c478bd9Sstevel@tonic-gate 4277c478bd9Sstevel@tonic-gate /* 4287c478bd9Sstevel@tonic-gate * This structure is used to hold information about the next hop for where 4297c478bd9Sstevel@tonic-gate * to forward a packet. 4307c478bd9Sstevel@tonic-gate */ 4317c478bd9Sstevel@tonic-gate typedef struct frdest { 4327c478bd9Sstevel@tonic-gate void *fd_ifp; 4337c478bd9Sstevel@tonic-gate i6addr_t fd_ip6; 4347c478bd9Sstevel@tonic-gate char fd_ifname[LIFNAMSIZ]; 4357c478bd9Sstevel@tonic-gate } frdest_t; 4367c478bd9Sstevel@tonic-gate 4377c478bd9Sstevel@tonic-gate #define fd_ip fd_ip6.in4 4387c478bd9Sstevel@tonic-gate 4397c478bd9Sstevel@tonic-gate 4407c478bd9Sstevel@tonic-gate /* 4417c478bd9Sstevel@tonic-gate * This structure holds information about a port comparison. 4427c478bd9Sstevel@tonic-gate */ 4437c478bd9Sstevel@tonic-gate typedef struct frpcmp { 4447c478bd9Sstevel@tonic-gate int frp_cmp; /* data for port comparisons */ 4457c478bd9Sstevel@tonic-gate u_short frp_port; /* top port for <> and >< */ 4467c478bd9Sstevel@tonic-gate u_short frp_top; /* top port for <> and >< */ 4477c478bd9Sstevel@tonic-gate } frpcmp_t; 4487c478bd9Sstevel@tonic-gate 4497c478bd9Sstevel@tonic-gate #define FR_NONE 0 4507c478bd9Sstevel@tonic-gate #define FR_EQUAL 1 4517c478bd9Sstevel@tonic-gate #define FR_NEQUAL 2 4527c478bd9Sstevel@tonic-gate #define FR_LESST 3 4537c478bd9Sstevel@tonic-gate #define FR_GREATERT 4 4547c478bd9Sstevel@tonic-gate #define FR_LESSTE 5 4557c478bd9Sstevel@tonic-gate #define FR_GREATERTE 6 4567c478bd9Sstevel@tonic-gate #define FR_OUTRANGE 7 4577c478bd9Sstevel@tonic-gate #define FR_INRANGE 8 4587c478bd9Sstevel@tonic-gate #define FR_INCRANGE 9 4597c478bd9Sstevel@tonic-gate 4607c478bd9Sstevel@tonic-gate /* 4617c478bd9Sstevel@tonic-gate * Structure containing all the relevant TCP things that can be checked in 4627c478bd9Sstevel@tonic-gate * a filter rule. 4637c478bd9Sstevel@tonic-gate */ 4647c478bd9Sstevel@tonic-gate typedef struct frtuc { 4657c478bd9Sstevel@tonic-gate u_char ftu_tcpfm; /* tcp flags mask */ 4667c478bd9Sstevel@tonic-gate u_char ftu_tcpf; /* tcp flags */ 4677c478bd9Sstevel@tonic-gate frpcmp_t ftu_src; 4687c478bd9Sstevel@tonic-gate frpcmp_t ftu_dst; 4697c478bd9Sstevel@tonic-gate } frtuc_t; 4707c478bd9Sstevel@tonic-gate 4717c478bd9Sstevel@tonic-gate #define ftu_scmp ftu_src.frp_cmp 4727c478bd9Sstevel@tonic-gate #define ftu_dcmp ftu_dst.frp_cmp 4737c478bd9Sstevel@tonic-gate #define ftu_sport ftu_src.frp_port 4747c478bd9Sstevel@tonic-gate #define ftu_dport ftu_dst.frp_port 4757c478bd9Sstevel@tonic-gate #define ftu_stop ftu_src.frp_top 4767c478bd9Sstevel@tonic-gate #define ftu_dtop ftu_dst.frp_top 4777c478bd9Sstevel@tonic-gate 4787c478bd9Sstevel@tonic-gate #define FR_TCPFMAX 0x3f 4797c478bd9Sstevel@tonic-gate 4807c478bd9Sstevel@tonic-gate /* 4817c478bd9Sstevel@tonic-gate * This structure makes up what is considered to be the IPFilter specific 4827c478bd9Sstevel@tonic-gate * matching components of a filter rule, as opposed to the data structures 4837c478bd9Sstevel@tonic-gate * used to define the result which are in frentry_t and not here. 4847c478bd9Sstevel@tonic-gate */ 4857c478bd9Sstevel@tonic-gate typedef struct fripf { 486ab25eeb5Syz fr_ip_t fri_ip; 487ab25eeb5Syz fr_ip_t fri_mip; /* mask structure */ 4887c478bd9Sstevel@tonic-gate 4897c478bd9Sstevel@tonic-gate u_short fri_icmpm; /* data for ICMP packets (mask) */ 4907c478bd9Sstevel@tonic-gate u_short fri_icmp; 4917c478bd9Sstevel@tonic-gate 4927c478bd9Sstevel@tonic-gate frtuc_t fri_tuc; 4937c478bd9Sstevel@tonic-gate int fri_satype; /* addres type */ 4947c478bd9Sstevel@tonic-gate int fri_datype; /* addres type */ 4957c478bd9Sstevel@tonic-gate int fri_sifpidx; /* doing dynamic addressing */ 4967c478bd9Sstevel@tonic-gate int fri_difpidx; /* index into fr_ifps[] to use when */ 4977c478bd9Sstevel@tonic-gate } fripf_t; 4987c478bd9Sstevel@tonic-gate 4997c478bd9Sstevel@tonic-gate #define fri_dstnum fri_ip.fi_dstnum 5007c478bd9Sstevel@tonic-gate #define fri_srcnum fri_mip.fi_srcnum 5017c478bd9Sstevel@tonic-gate #define fri_dstptr fri_ip.fi_dstptr 5027c478bd9Sstevel@tonic-gate #define fri_srcptr fri_mip.fi_srcptr 5037c478bd9Sstevel@tonic-gate 5047c478bd9Sstevel@tonic-gate #define FRI_NORMAL 0 /* Normal address */ 5057c478bd9Sstevel@tonic-gate #define FRI_DYNAMIC 1 /* dynamic address */ 5067c478bd9Sstevel@tonic-gate #define FRI_LOOKUP 2 /* address is a pool # */ 5077c478bd9Sstevel@tonic-gate #define FRI_RANGE 3 /* address/mask is a range */ 5087c478bd9Sstevel@tonic-gate #define FRI_NETWORK 4 /* network address from if */ 5097c478bd9Sstevel@tonic-gate #define FRI_BROADCAST 5 /* broadcast address from if */ 5107c478bd9Sstevel@tonic-gate #define FRI_PEERADDR 6 /* Peer address for P-to-P */ 5117c478bd9Sstevel@tonic-gate #define FRI_NETMASKED 7 /* network address with netmask from if */ 5127c478bd9Sstevel@tonic-gate 5137c478bd9Sstevel@tonic-gate 5147c478bd9Sstevel@tonic-gate typedef struct frentry * (* frentfunc_t) __P((fr_info_t *)); 5157c478bd9Sstevel@tonic-gate 5167c478bd9Sstevel@tonic-gate typedef struct frentry { 5177c478bd9Sstevel@tonic-gate ipfmutex_t fr_lock; 5187c478bd9Sstevel@tonic-gate struct frentry *fr_next; 5197c478bd9Sstevel@tonic-gate struct frentry **fr_grp; 5207c478bd9Sstevel@tonic-gate struct ipscan *fr_isc; 5217c478bd9Sstevel@tonic-gate void *fr_ifas[4]; 5227c478bd9Sstevel@tonic-gate void *fr_ptr; /* for use with fr_arg */ 5237c478bd9Sstevel@tonic-gate char *fr_comment; /* text comment for rule */ 5247c478bd9Sstevel@tonic-gate int fr_ref; /* reference count - for grouping */ 5257c478bd9Sstevel@tonic-gate int fr_statecnt; /* state count - for limit rules */ 5267c478bd9Sstevel@tonic-gate /* 5277c478bd9Sstevel@tonic-gate * These are only incremented when a packet matches this rule and 5287c478bd9Sstevel@tonic-gate * it is the last match 5297c478bd9Sstevel@tonic-gate */ 5307c478bd9Sstevel@tonic-gate U_QUAD_T fr_hits; 5317c478bd9Sstevel@tonic-gate U_QUAD_T fr_bytes; 5327c478bd9Sstevel@tonic-gate 5337c478bd9Sstevel@tonic-gate /* 5347c478bd9Sstevel@tonic-gate * For PPS rate limiting 5357c478bd9Sstevel@tonic-gate */ 5367c478bd9Sstevel@tonic-gate struct timeval fr_lastpkt; 5377c478bd9Sstevel@tonic-gate int fr_curpps; 5387c478bd9Sstevel@tonic-gate 5397c478bd9Sstevel@tonic-gate union { 5407c478bd9Sstevel@tonic-gate void *fru_data; 5417c478bd9Sstevel@tonic-gate caddr_t fru_caddr; 5427c478bd9Sstevel@tonic-gate fripf_t *fru_ipf; 5437c478bd9Sstevel@tonic-gate frentfunc_t fru_func; 5447c478bd9Sstevel@tonic-gate } fr_dun; 5457c478bd9Sstevel@tonic-gate 5467c478bd9Sstevel@tonic-gate /* 5477c478bd9Sstevel@tonic-gate * Fields after this may not change whilst in the kernel. 5487c478bd9Sstevel@tonic-gate */ 5497c478bd9Sstevel@tonic-gate ipfunc_t fr_func; /* call this function */ 5507c478bd9Sstevel@tonic-gate int fr_dsize; 5517c478bd9Sstevel@tonic-gate int fr_pps; 5527c478bd9Sstevel@tonic-gate int fr_statemax; /* max reference count */ 5537c478bd9Sstevel@tonic-gate int fr_flineno; /* line number from conf file */ 5547c478bd9Sstevel@tonic-gate u_32_t fr_type; 5557c478bd9Sstevel@tonic-gate u_32_t fr_flags; /* per-rule flags && options (see below) */ 5567c478bd9Sstevel@tonic-gate u_32_t fr_logtag; /* user defined log tag # */ 5577c478bd9Sstevel@tonic-gate u_32_t fr_collect; /* collection number */ 5587c478bd9Sstevel@tonic-gate u_int fr_arg; /* misc. numeric arg for rule */ 5597c478bd9Sstevel@tonic-gate u_int fr_loglevel; /* syslog log facility + priority */ 5607c478bd9Sstevel@tonic-gate u_int fr_age[2]; /* non-TCP timeouts */ 5617c478bd9Sstevel@tonic-gate u_char fr_v; 5627c478bd9Sstevel@tonic-gate u_char fr_icode; /* return ICMP code */ 5637c478bd9Sstevel@tonic-gate char fr_group[FR_GROUPLEN]; /* group to which this rule belongs */ 5647c478bd9Sstevel@tonic-gate char fr_grhead[FR_GROUPLEN]; /* group # which this rule starts */ 565ab25eeb5Syz ipftag_t fr_nattag; 5667c478bd9Sstevel@tonic-gate char fr_ifnames[4][LIFNAMSIZ]; 5677c478bd9Sstevel@tonic-gate char fr_isctag[16]; 568ab25eeb5Syz frdest_t fr_tifs[2]; /* "to"/"reply-to" interface */ 569ab25eeb5Syz frdest_t fr_dif; /* duplicate packet interface */ 5707c478bd9Sstevel@tonic-gate /* 5717c478bd9Sstevel@tonic-gate * This must be last and will change after loaded into the kernel. 5727c478bd9Sstevel@tonic-gate */ 5737c478bd9Sstevel@tonic-gate u_int fr_cksum; /* checksum on filter rules for performance */ 5747c478bd9Sstevel@tonic-gate } frentry_t; 5757c478bd9Sstevel@tonic-gate 5767c478bd9Sstevel@tonic-gate #define fr_caddr fr_dun.fru_caddr 5777c478bd9Sstevel@tonic-gate #define fr_data fr_dun.fru_data 5787c478bd9Sstevel@tonic-gate #define fr_dfunc fr_dun.fru_func 5797c478bd9Sstevel@tonic-gate #define fr_ipf fr_dun.fru_ipf 5807c478bd9Sstevel@tonic-gate #define fr_ip fr_ipf->fri_ip 5817c478bd9Sstevel@tonic-gate #define fr_mip fr_ipf->fri_mip 5827c478bd9Sstevel@tonic-gate #define fr_icmpm fr_ipf->fri_icmpm 5837c478bd9Sstevel@tonic-gate #define fr_icmp fr_ipf->fri_icmp 5847c478bd9Sstevel@tonic-gate #define fr_tuc fr_ipf->fri_tuc 5857c478bd9Sstevel@tonic-gate #define fr_satype fr_ipf->fri_satype 5867c478bd9Sstevel@tonic-gate #define fr_datype fr_ipf->fri_datype 5877c478bd9Sstevel@tonic-gate #define fr_sifpidx fr_ipf->fri_sifpidx 5887c478bd9Sstevel@tonic-gate #define fr_difpidx fr_ipf->fri_difpidx 5897c478bd9Sstevel@tonic-gate #define fr_proto fr_ip.fi_p 5907c478bd9Sstevel@tonic-gate #define fr_mproto fr_mip.fi_p 5917c478bd9Sstevel@tonic-gate #define fr_ttl fr_ip.fi_ttl 5927c478bd9Sstevel@tonic-gate #define fr_mttl fr_mip.fi_ttl 5937c478bd9Sstevel@tonic-gate #define fr_tos fr_ip.fi_tos 5947c478bd9Sstevel@tonic-gate #define fr_mtos fr_mip.fi_tos 5957c478bd9Sstevel@tonic-gate #define fr_tcpfm fr_tuc.ftu_tcpfm 5967c478bd9Sstevel@tonic-gate #define fr_tcpf fr_tuc.ftu_tcpf 5977c478bd9Sstevel@tonic-gate #define fr_scmp fr_tuc.ftu_scmp 5987c478bd9Sstevel@tonic-gate #define fr_dcmp fr_tuc.ftu_dcmp 5997c478bd9Sstevel@tonic-gate #define fr_dport fr_tuc.ftu_dport 6007c478bd9Sstevel@tonic-gate #define fr_sport fr_tuc.ftu_sport 6017c478bd9Sstevel@tonic-gate #define fr_stop fr_tuc.ftu_stop 6027c478bd9Sstevel@tonic-gate #define fr_dtop fr_tuc.ftu_dtop 6037c478bd9Sstevel@tonic-gate #define fr_dst fr_ip.fi_dst.in4 6047c478bd9Sstevel@tonic-gate #define fr_daddr fr_ip.fi_dst.in4.s_addr 6057c478bd9Sstevel@tonic-gate #define fr_src fr_ip.fi_src.in4 6067c478bd9Sstevel@tonic-gate #define fr_saddr fr_ip.fi_src.in4.s_addr 6077c478bd9Sstevel@tonic-gate #define fr_dmsk fr_mip.fi_dst.in4 6087c478bd9Sstevel@tonic-gate #define fr_dmask fr_mip.fi_dst.in4.s_addr 6097c478bd9Sstevel@tonic-gate #define fr_smsk fr_mip.fi_src.in4 6107c478bd9Sstevel@tonic-gate #define fr_smask fr_mip.fi_src.in4.s_addr 6117c478bd9Sstevel@tonic-gate #define fr_dstnum fr_ip.fi_dstnum 6127c478bd9Sstevel@tonic-gate #define fr_srcnum fr_ip.fi_srcnum 6137c478bd9Sstevel@tonic-gate #define fr_dsttype fr_ip.fi_dsttype 6147c478bd9Sstevel@tonic-gate #define fr_srctype fr_ip.fi_srctype 6157c478bd9Sstevel@tonic-gate #define fr_dstptr fr_mip.fi_dstptr 6167c478bd9Sstevel@tonic-gate #define fr_srcptr fr_mip.fi_srcptr 6177c478bd9Sstevel@tonic-gate #define fr_dstfunc fr_mip.fi_dstfunc 6187c478bd9Sstevel@tonic-gate #define fr_srcfunc fr_mip.fi_srcfunc 6197c478bd9Sstevel@tonic-gate #define fr_optbits fr_ip.fi_optmsk 6207c478bd9Sstevel@tonic-gate #define fr_optmask fr_mip.fi_optmsk 6217c478bd9Sstevel@tonic-gate #define fr_secbits fr_ip.fi_secmsk 6227c478bd9Sstevel@tonic-gate #define fr_secmask fr_mip.fi_secmsk 6237c478bd9Sstevel@tonic-gate #define fr_authbits fr_ip.fi_auth 6247c478bd9Sstevel@tonic-gate #define fr_authmask fr_mip.fi_auth 6257c478bd9Sstevel@tonic-gate #define fr_flx fr_ip.fi_flx 6267c478bd9Sstevel@tonic-gate #define fr_mflx fr_mip.fi_flx 6277c478bd9Sstevel@tonic-gate #define fr_ifname fr_ifnames[0] 6287c478bd9Sstevel@tonic-gate #define fr_oifname fr_ifnames[2] 6297c478bd9Sstevel@tonic-gate #define fr_ifa fr_ifas[0] 6307c478bd9Sstevel@tonic-gate #define fr_oifa fr_ifas[2] 6317c478bd9Sstevel@tonic-gate #define fr_tif fr_tifs[0] 6327c478bd9Sstevel@tonic-gate #define fr_rif fr_tifs[1] 6337c478bd9Sstevel@tonic-gate 6347c478bd9Sstevel@tonic-gate #define FR_NOLOGTAG 0 6357c478bd9Sstevel@tonic-gate 6367c478bd9Sstevel@tonic-gate #ifndef offsetof 6377c478bd9Sstevel@tonic-gate #define offsetof(t,m) (int)((&((t *)0L)->m)) 6387c478bd9Sstevel@tonic-gate #endif 6397c478bd9Sstevel@tonic-gate #define FR_CMPSIZ (sizeof(struct frentry) - \ 640ab25eeb5Syz offsetof(struct frentry, fr_func)) 6417c478bd9Sstevel@tonic-gate 6427c478bd9Sstevel@tonic-gate /* 6437c478bd9Sstevel@tonic-gate * fr_type 6447c478bd9Sstevel@tonic-gate */ 6457c478bd9Sstevel@tonic-gate #define FR_T_NONE 0 6467c478bd9Sstevel@tonic-gate #define FR_T_IPF 1 /* IPF structures */ 6477c478bd9Sstevel@tonic-gate #define FR_T_BPFOPC 2 /* BPF opcode */ 6487c478bd9Sstevel@tonic-gate #define FR_T_CALLFUNC 3 /* callout to function in fr_func only */ 6497c478bd9Sstevel@tonic-gate #define FR_T_COMPIPF 4 /* compiled C code */ 6507c478bd9Sstevel@tonic-gate #define FR_T_BUILTIN 0x80000000 /* rule is in kernel space */ 6517c478bd9Sstevel@tonic-gate 6527c478bd9Sstevel@tonic-gate /* 6537c478bd9Sstevel@tonic-gate * fr_flags 6547c478bd9Sstevel@tonic-gate */ 6557c478bd9Sstevel@tonic-gate #define FR_CALL 0x00000 /* call rule */ 6567c478bd9Sstevel@tonic-gate #define FR_BLOCK 0x00001 /* do not allow packet to pass */ 6577c478bd9Sstevel@tonic-gate #define FR_PASS 0x00002 /* allow packet to pass */ 6587c478bd9Sstevel@tonic-gate #define FR_AUTH 0x00003 /* use authentication */ 6597c478bd9Sstevel@tonic-gate #define FR_PREAUTH 0x00004 /* require preauthentication */ 6607c478bd9Sstevel@tonic-gate #define FR_ACCOUNT 0x00005 /* Accounting rule */ 6617c478bd9Sstevel@tonic-gate #define FR_SKIP 0x00006 /* skip rule */ 6627c478bd9Sstevel@tonic-gate #define FR_DIVERT 0x00007 /* divert rule */ 6637c478bd9Sstevel@tonic-gate #define FR_CMDMASK 0x0000f 6647c478bd9Sstevel@tonic-gate #define FR_LOG 0x00010 /* Log */ 6657c478bd9Sstevel@tonic-gate #define FR_LOGB 0x00011 /* Log-fail */ 6667c478bd9Sstevel@tonic-gate #define FR_LOGP 0x00012 /* Log-pass */ 6677c478bd9Sstevel@tonic-gate #define FR_LOGMASK (FR_LOG|FR_CMDMASK) 6687c478bd9Sstevel@tonic-gate #define FR_CALLNOW 0x00020 /* call another function (fr_func) if matches */ 6697c478bd9Sstevel@tonic-gate #define FR_NOTSRCIP 0x00040 6707c478bd9Sstevel@tonic-gate #define FR_NOTDSTIP 0x00080 6717c478bd9Sstevel@tonic-gate #define FR_QUICK 0x00100 /* match & stop processing list */ 6727c478bd9Sstevel@tonic-gate #define FR_KEEPFRAG 0x00200 /* keep fragment information */ 6737c478bd9Sstevel@tonic-gate #define FR_KEEPSTATE 0x00400 /* keep `connection' state information */ 6747c478bd9Sstevel@tonic-gate #define FR_FASTROUTE 0x00800 /* bypass normal routing */ 6757c478bd9Sstevel@tonic-gate #define FR_RETRST 0x01000 /* Return TCP RST packet - reset connection */ 6767c478bd9Sstevel@tonic-gate #define FR_RETICMP 0x02000 /* Return ICMP unreachable packet */ 6777c478bd9Sstevel@tonic-gate #define FR_FAKEICMP 0x03000 /* Return ICMP unreachable with fake source */ 6787c478bd9Sstevel@tonic-gate #define FR_OUTQUE 0x04000 /* outgoing packets */ 6797c478bd9Sstevel@tonic-gate #define FR_INQUE 0x08000 /* ingoing packets */ 6807c478bd9Sstevel@tonic-gate #define FR_LOGBODY 0x10000 /* Log the body */ 6817c478bd9Sstevel@tonic-gate #define FR_LOGFIRST 0x20000 /* Log the first byte if state held */ 6827c478bd9Sstevel@tonic-gate #define FR_LOGORBLOCK 0x40000 /* block the packet if it can't be logged */ 6837c478bd9Sstevel@tonic-gate #define FR_DUP 0x80000 /* duplicate packet */ 6847c478bd9Sstevel@tonic-gate #define FR_FRSTRICT 0x100000 /* strict frag. cache */ 6857c478bd9Sstevel@tonic-gate #define FR_STSTRICT 0x200000 /* strict keep state */ 6867c478bd9Sstevel@tonic-gate #define FR_NEWISN 0x400000 /* new ISN for outgoing TCP */ 6877c478bd9Sstevel@tonic-gate #define FR_NOICMPERR 0x800000 /* do not match ICMP errors in state */ 688ab25eeb5Syz #define FR_STATESYNC 0x1000000 /* synchronize state to slave */ 6897c478bd9Sstevel@tonic-gate #define FR_NOMATCH 0x8000000 /* no match occured */ 6907c478bd9Sstevel@tonic-gate /* 0x10000000 FF_LOGPASS */ 6917c478bd9Sstevel@tonic-gate /* 0x20000000 FF_LOGBLOCK */ 6927c478bd9Sstevel@tonic-gate /* 0x40000000 FF_LOGNOMATCH */ 6937c478bd9Sstevel@tonic-gate /* 0x80000000 FF_BLOCKNONIP */ 6947c478bd9Sstevel@tonic-gate #define FR_COPIED 0x40000000 /* copied from user space */ 6957c478bd9Sstevel@tonic-gate #define FR_INACTIVE 0x80000000 /* only used when flush'ing rules */ 6967c478bd9Sstevel@tonic-gate 6977c478bd9Sstevel@tonic-gate #define FR_RETMASK (FR_RETICMP|FR_RETRST|FR_FAKEICMP) 6987c478bd9Sstevel@tonic-gate #define FR_ISBLOCK(x) (((x) & FR_CMDMASK) == FR_BLOCK) 6997c478bd9Sstevel@tonic-gate #define FR_ISPASS(x) (((x) & FR_CMDMASK) == FR_PASS) 7007c478bd9Sstevel@tonic-gate #define FR_ISAUTH(x) (((x) & FR_CMDMASK) == FR_AUTH) 7017c478bd9Sstevel@tonic-gate #define FR_ISPREAUTH(x) (((x) & FR_CMDMASK) == FR_PREAUTH) 7027c478bd9Sstevel@tonic-gate #define FR_ISACCOUNT(x) (((x) & FR_CMDMASK) == FR_ACCOUNT) 7037c478bd9Sstevel@tonic-gate #define FR_ISSKIP(x) (((x) & FR_CMDMASK) == FR_SKIP) 7047c478bd9Sstevel@tonic-gate #define FR_ISNOMATCH(x) ((x) & FR_NOMATCH) 7057c478bd9Sstevel@tonic-gate #define FR_INOUT (FR_INQUE|FR_OUTQUE) 7067c478bd9Sstevel@tonic-gate 7077c478bd9Sstevel@tonic-gate /* 7087c478bd9Sstevel@tonic-gate * recognized flags for SIOCGETFF and SIOCSETFF, and get put in fr_flags 7097c478bd9Sstevel@tonic-gate */ 7107c478bd9Sstevel@tonic-gate #define FF_LOGPASS 0x10000000 7117c478bd9Sstevel@tonic-gate #define FF_LOGBLOCK 0x20000000 7127c478bd9Sstevel@tonic-gate #define FF_LOGNOMATCH 0x40000000 7137c478bd9Sstevel@tonic-gate #define FF_LOGGING (FF_LOGPASS|FF_LOGBLOCK|FF_LOGNOMATCH) 7147c478bd9Sstevel@tonic-gate #define FF_BLOCKNONIP 0x80000000 /* Solaris2 Only */ 7157c478bd9Sstevel@tonic-gate 7167c478bd9Sstevel@tonic-gate 7177c478bd9Sstevel@tonic-gate /* 7187c478bd9Sstevel@tonic-gate * Structure that passes information on what/how to flush to the kernel. 7197c478bd9Sstevel@tonic-gate */ 7207c478bd9Sstevel@tonic-gate typedef struct ipfflush { 7217c478bd9Sstevel@tonic-gate int ipflu_how; 7227c478bd9Sstevel@tonic-gate int ipflu_arg; 7237c478bd9Sstevel@tonic-gate } ipfflush_t; 7247c478bd9Sstevel@tonic-gate 7257c478bd9Sstevel@tonic-gate 7267c478bd9Sstevel@tonic-gate /* 7277c478bd9Sstevel@tonic-gate * 7287c478bd9Sstevel@tonic-gate */ 7297c478bd9Sstevel@tonic-gate typedef struct ipfgetctl { 7307c478bd9Sstevel@tonic-gate u_int ipfg_min; /* min value */ 7317c478bd9Sstevel@tonic-gate u_int ipfg_current; /* current value */ 7327c478bd9Sstevel@tonic-gate u_int ipfg_max; /* max value */ 7337c478bd9Sstevel@tonic-gate u_int ipfg_default; /* default value */ 7347c478bd9Sstevel@tonic-gate u_int ipfg_steps; /* value increments */ 7357c478bd9Sstevel@tonic-gate char ipfg_name[40]; /* tag name for this control */ 7367c478bd9Sstevel@tonic-gate } ipfgetctl_t; 7377c478bd9Sstevel@tonic-gate 7387c478bd9Sstevel@tonic-gate typedef struct ipfsetctl { 7397c478bd9Sstevel@tonic-gate int ipfs_which; /* 0 = min 1 = current 2 = max 3 = default */ 7407c478bd9Sstevel@tonic-gate u_int ipfs_value; /* min value */ 7417c478bd9Sstevel@tonic-gate char ipfs_name[40]; /* tag name for this control */ 7427c478bd9Sstevel@tonic-gate } ipfsetctl_t; 7437c478bd9Sstevel@tonic-gate 7447c478bd9Sstevel@tonic-gate 7457c478bd9Sstevel@tonic-gate /* 7467c478bd9Sstevel@tonic-gate * Some of the statistics below are in their own counters, but most are kept 7477c478bd9Sstevel@tonic-gate * in this single structure so that they can all easily be collected and 7487c478bd9Sstevel@tonic-gate * copied back as required. 749e0b463afSschuster * 750e0b463afSschuster * NOTE: when changing, keep in sync with kstats (below). 7517c478bd9Sstevel@tonic-gate */ 7527c478bd9Sstevel@tonic-gate typedef struct filterstats { 7537c478bd9Sstevel@tonic-gate u_long fr_pass; /* packets allowed */ 7547c478bd9Sstevel@tonic-gate u_long fr_block; /* packets denied */ 7557c478bd9Sstevel@tonic-gate u_long fr_nom; /* packets which don't match any rule */ 7567c478bd9Sstevel@tonic-gate u_long fr_short; /* packets which are short */ 7577c478bd9Sstevel@tonic-gate u_long fr_ppkl; /* packets allowed and logged */ 7587c478bd9Sstevel@tonic-gate u_long fr_bpkl; /* packets denied and logged */ 7597c478bd9Sstevel@tonic-gate u_long fr_npkl; /* packets unmatched and logged */ 7607c478bd9Sstevel@tonic-gate u_long fr_pkl; /* packets logged */ 7617c478bd9Sstevel@tonic-gate u_long fr_skip; /* packets to be logged but buffer full */ 7627c478bd9Sstevel@tonic-gate u_long fr_ret; /* packets for which a return is sent */ 7637c478bd9Sstevel@tonic-gate u_long fr_acct; /* packets for which counting was performed */ 7647c478bd9Sstevel@tonic-gate u_long fr_bnfr; /* bad attempts to allocate fragment state */ 7657c478bd9Sstevel@tonic-gate u_long fr_nfr; /* new fragment state kept */ 7667c478bd9Sstevel@tonic-gate u_long fr_cfr; /* add new fragment state but complete pkt */ 7677c478bd9Sstevel@tonic-gate u_long fr_bads; /* bad attempts to allocate packet state */ 7687c478bd9Sstevel@tonic-gate u_long fr_ads; /* new packet state kept */ 7697c478bd9Sstevel@tonic-gate u_long fr_chit; /* cached hit */ 7707c478bd9Sstevel@tonic-gate u_long fr_tcpbad; /* TCP checksum check failures */ 7717c478bd9Sstevel@tonic-gate u_long fr_pull[2]; /* good and bad pullup attempts */ 7727c478bd9Sstevel@tonic-gate u_long fr_badsrc; /* source received doesn't match route */ 7737c478bd9Sstevel@tonic-gate u_long fr_badttl; /* TTL in packet doesn't reach minimum */ 7747c478bd9Sstevel@tonic-gate u_long fr_bad; /* bad IP packets to the filter */ 7757c478bd9Sstevel@tonic-gate u_long fr_ipv6; /* IPv6 packets in/out */ 7767c478bd9Sstevel@tonic-gate u_long fr_ppshit; /* dropped because of pps ceiling */ 7777c478bd9Sstevel@tonic-gate u_long fr_ipud; /* IP id update failures */ 7787c478bd9Sstevel@tonic-gate } filterstats_t; 7797c478bd9Sstevel@tonic-gate 780e0b463afSschuster /* 781e0b463afSschuster * kstat "copy" of the above - keep in sync! 782e0b463afSschuster * also keep in sync with initialisation code in solaris.c, ipf_kstat_init(). 783e0b463afSschuster */ 784e0b463afSschuster typedef struct filter_kstats { 785e0b463afSschuster kstat_named_t fks_pass; /* see above for comments */ 786e0b463afSschuster kstat_named_t fks_block; 787e0b463afSschuster kstat_named_t fks_nom; 788e0b463afSschuster kstat_named_t fks_short; 789e0b463afSschuster kstat_named_t fks_ppkl; 790e0b463afSschuster kstat_named_t fks_bpkl; 791e0b463afSschuster kstat_named_t fks_npkl; 792e0b463afSschuster kstat_named_t fks_pkl; 793e0b463afSschuster kstat_named_t fks_skip; 794e0b463afSschuster kstat_named_t fks_ret; 795e0b463afSschuster kstat_named_t fks_acct; 796e0b463afSschuster kstat_named_t fks_bnfr; 797e0b463afSschuster kstat_named_t fks_nfr; 798e0b463afSschuster kstat_named_t fks_cfr; 799e0b463afSschuster kstat_named_t fks_bads; 800e0b463afSschuster kstat_named_t fks_ads; 801e0b463afSschuster kstat_named_t fks_chit; 802e0b463afSschuster kstat_named_t fks_tcpbad; 803e0b463afSschuster kstat_named_t fks_pull[2]; 804e0b463afSschuster kstat_named_t fks_badsrc; 805e0b463afSschuster kstat_named_t fks_badttl; 806e0b463afSschuster kstat_named_t fks_bad; 807e0b463afSschuster kstat_named_t fks_ipv6; 808e0b463afSschuster kstat_named_t fks_ppshit; 809e0b463afSschuster kstat_named_t fks_ipud; 810e0b463afSschuster } filter_kstats_t; 811e0b463afSschuster 8127c478bd9Sstevel@tonic-gate /* 8137c478bd9Sstevel@tonic-gate * Log structure. Each packet header logged is prepended by one of these. 8147c478bd9Sstevel@tonic-gate * Following this in the log records read from the device will be an ipflog 8157c478bd9Sstevel@tonic-gate * structure which is then followed by any packet data. 8167c478bd9Sstevel@tonic-gate */ 8177c478bd9Sstevel@tonic-gate typedef struct iplog { 8187c478bd9Sstevel@tonic-gate u_32_t ipl_magic; 8197c478bd9Sstevel@tonic-gate u_int ipl_count; 820ab25eeb5Syz struct timeval ipl_time; 8217c478bd9Sstevel@tonic-gate size_t ipl_dsize; 8227c478bd9Sstevel@tonic-gate struct iplog *ipl_next; 8237c478bd9Sstevel@tonic-gate } iplog_t; 8247c478bd9Sstevel@tonic-gate 825ab25eeb5Syz #define ipl_sec ipl_time.tv_sec 826ab25eeb5Syz #define ipl_usec ipl_time.tv_usec 8277c478bd9Sstevel@tonic-gate 8287c478bd9Sstevel@tonic-gate #define IPL_MAGIC 0x49504c4d /* 'IPLM' */ 829ab25eeb5Syz #define IPL_MAGIC_NAT 0x49504c4e /* 'IPLN' */ 830ab25eeb5Syz #define IPL_MAGIC_STATE 0x49504c53 /* 'IPLS' */ 8317c478bd9Sstevel@tonic-gate #define IPLOG_SIZE sizeof(iplog_t) 8327c478bd9Sstevel@tonic-gate 8337c478bd9Sstevel@tonic-gate typedef struct ipflog { 8347c478bd9Sstevel@tonic-gate #if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \ 8357c478bd9Sstevel@tonic-gate (defined(OpenBSD) && (OpenBSD >= 199603)) 8367c478bd9Sstevel@tonic-gate #else 8377c478bd9Sstevel@tonic-gate u_int fl_unit; 8387c478bd9Sstevel@tonic-gate #endif 8397c478bd9Sstevel@tonic-gate u_32_t fl_rule; 8407c478bd9Sstevel@tonic-gate u_32_t fl_flags; 8417c478bd9Sstevel@tonic-gate u_32_t fl_lflags; 842ab25eeb5Syz u_32_t fl_logtag; 843ab25eeb5Syz ipftag_t fl_nattag; 8447c478bd9Sstevel@tonic-gate u_short fl_plen; /* extra data after hlen */ 8457c478bd9Sstevel@tonic-gate u_short fl_loglevel; /* syslog log level */ 8467c478bd9Sstevel@tonic-gate char fl_group[FR_GROUPLEN]; 8477c478bd9Sstevel@tonic-gate u_char fl_hlen; /* length of IP headers saved */ 8487c478bd9Sstevel@tonic-gate u_char fl_dir; 849ab25eeb5Syz u_char fl_xxx[2]; /* pad */ 8507c478bd9Sstevel@tonic-gate char fl_ifname[LIFNAMSIZ]; 8517c478bd9Sstevel@tonic-gate } ipflog_t; 8527c478bd9Sstevel@tonic-gate 8537c478bd9Sstevel@tonic-gate #ifndef IPF_LOGGING 8547c478bd9Sstevel@tonic-gate # define IPF_LOGGING 0 8557c478bd9Sstevel@tonic-gate #endif 8567c478bd9Sstevel@tonic-gate #ifndef IPF_DEFAULT_PASS 8577c478bd9Sstevel@tonic-gate # define IPF_DEFAULT_PASS FR_PASS 8587c478bd9Sstevel@tonic-gate #endif 8597c478bd9Sstevel@tonic-gate 8607c478bd9Sstevel@tonic-gate #define DEFAULT_IPFLOGSIZE 8192 8617c478bd9Sstevel@tonic-gate #ifndef IPFILTER_LOGSIZE 8627c478bd9Sstevel@tonic-gate # define IPFILTER_LOGSIZE DEFAULT_IPFLOGSIZE 8637c478bd9Sstevel@tonic-gate #else 864ab25eeb5Syz # if IPFILTER_LOGSIZE < DEFAULT_IPFLOGSIZE 865ab25eeb5Syz # error IPFILTER_LOGSIZE too small. Must be >= DEFAULT_IPFLOGSIZE 8667c478bd9Sstevel@tonic-gate # endif 8677c478bd9Sstevel@tonic-gate #endif 8687c478bd9Sstevel@tonic-gate 8697c478bd9Sstevel@tonic-gate #define IPF_OPTCOPY 0x07ff00 /* bit mask of copied options */ 8707c478bd9Sstevel@tonic-gate 8717c478bd9Sstevel@tonic-gate /* 8727c478bd9Sstevel@tonic-gate * Device filenames for reading log information. Use ipf on Solaris2 because 8737c478bd9Sstevel@tonic-gate * ipl is already a name used by something else. 8747c478bd9Sstevel@tonic-gate */ 8757c478bd9Sstevel@tonic-gate #ifndef IPL_NAME 8767c478bd9Sstevel@tonic-gate # if SOLARIS 8777c478bd9Sstevel@tonic-gate # define IPL_NAME "/dev/ipf" 8787c478bd9Sstevel@tonic-gate # else 8797c478bd9Sstevel@tonic-gate # define IPL_NAME "/dev/ipl" 8807c478bd9Sstevel@tonic-gate # endif 8817c478bd9Sstevel@tonic-gate #endif 8827c478bd9Sstevel@tonic-gate /* 8837c478bd9Sstevel@tonic-gate * Pathnames for various IP Filter control devices. Used by LKM 8847c478bd9Sstevel@tonic-gate * and userland, so defined here. 8857c478bd9Sstevel@tonic-gate */ 8867c478bd9Sstevel@tonic-gate #define IPNAT_NAME "/dev/ipnat" 8877c478bd9Sstevel@tonic-gate #define IPSTATE_NAME "/dev/ipstate" 8887c478bd9Sstevel@tonic-gate #define IPAUTH_NAME "/dev/ipauth" 8897c478bd9Sstevel@tonic-gate #define IPSYNC_NAME "/dev/ipsync" 8907c478bd9Sstevel@tonic-gate #define IPSCAN_NAME "/dev/ipscan" 8917c478bd9Sstevel@tonic-gate #define IPLOOKUP_NAME "/dev/iplookup" 8927c478bd9Sstevel@tonic-gate 8937c478bd9Sstevel@tonic-gate #define IPL_LOGIPF 0 /* Minor device #'s for accessing logs */ 8947c478bd9Sstevel@tonic-gate #define IPL_LOGNAT 1 8957c478bd9Sstevel@tonic-gate #define IPL_LOGSTATE 2 8967c478bd9Sstevel@tonic-gate #define IPL_LOGAUTH 3 8977c478bd9Sstevel@tonic-gate #define IPL_LOGSYNC 4 8987c478bd9Sstevel@tonic-gate #define IPL_LOGSCAN 5 8997c478bd9Sstevel@tonic-gate #define IPL_LOGLOOKUP 6 9007c478bd9Sstevel@tonic-gate #define IPL_LOGCOUNT 7 9017c478bd9Sstevel@tonic-gate #define IPL_LOGMAX 7 902f4b3ec61Sdh #define IPL_LOGSIZE (IPL_LOGMAX + 1) 9037c478bd9Sstevel@tonic-gate #define IPL_LOGALL -1 9047c478bd9Sstevel@tonic-gate #define IPL_LOGNONE -2 9057c478bd9Sstevel@tonic-gate 9067c478bd9Sstevel@tonic-gate /* 9077c478bd9Sstevel@tonic-gate * For SIOCGETFS 9087c478bd9Sstevel@tonic-gate */ 9097c478bd9Sstevel@tonic-gate typedef struct friostat { 9107c478bd9Sstevel@tonic-gate struct filterstats f_st[2]; 9117c478bd9Sstevel@tonic-gate struct frentry *f_ipf[2][2]; 9127c478bd9Sstevel@tonic-gate struct frentry *f_acct[2][2]; 9137c478bd9Sstevel@tonic-gate struct frentry *f_ipf6[2][2]; 9147c478bd9Sstevel@tonic-gate struct frentry *f_acct6[2][2]; 9157c478bd9Sstevel@tonic-gate struct frentry *f_auth; 9167c478bd9Sstevel@tonic-gate struct frgroup *f_groups[IPL_LOGSIZE][2]; 9177c478bd9Sstevel@tonic-gate u_long f_froute[2]; 9187c478bd9Sstevel@tonic-gate u_long f_ticks; 9197c478bd9Sstevel@tonic-gate int f_locks[IPL_LOGMAX]; 9207c478bd9Sstevel@tonic-gate size_t f_kmutex_sz; 9217c478bd9Sstevel@tonic-gate size_t f_krwlock_sz; 9227c478bd9Sstevel@tonic-gate int f_defpass; /* default pass - from fr_pass */ 923ab25eeb5Syz int f_active; /* 1 or 0 - active rule set */ 924ab25eeb5Syz int f_running; /* 1 if running, else 0 */ 925ab25eeb5Syz int f_logging; /* 1 if enabled, else 0 */ 926ab25eeb5Syz int f_features; 9277c478bd9Sstevel@tonic-gate char f_version[32]; /* version string */ 9287c478bd9Sstevel@tonic-gate } friostat_t; 9297c478bd9Sstevel@tonic-gate 9307c478bd9Sstevel@tonic-gate #define f_fin f_ipf[0] 9317c478bd9Sstevel@tonic-gate #define f_fin6 f_ipf6[0] 9327c478bd9Sstevel@tonic-gate #define f_fout f_ipf[1] 9337c478bd9Sstevel@tonic-gate #define f_fout6 f_ipf6[1] 9347c478bd9Sstevel@tonic-gate #define f_acctin f_acct[0] 9357c478bd9Sstevel@tonic-gate #define f_acctin6 f_acct6[0] 9367c478bd9Sstevel@tonic-gate #define f_acctout f_acct[1] 9377c478bd9Sstevel@tonic-gate #define f_acctout6 f_acct6[1] 9387c478bd9Sstevel@tonic-gate 939ab25eeb5Syz #define IPF_FEAT_LKM 0x001 940ab25eeb5Syz #define IPF_FEAT_LOG 0x002 941ab25eeb5Syz #define IPF_FEAT_LOOKUP 0x004 942ab25eeb5Syz #define IPF_FEAT_BPF 0x008 943ab25eeb5Syz #define IPF_FEAT_COMPILED 0x010 944ab25eeb5Syz #define IPF_FEAT_CKSUM 0x020 945ab25eeb5Syz #define IPF_FEAT_SYNC 0x040 946ab25eeb5Syz #define IPF_FEAT_SCAN 0x080 947ab25eeb5Syz #define IPF_FEAT_IPV6 0x100 9487c478bd9Sstevel@tonic-gate 9497c478bd9Sstevel@tonic-gate typedef struct optlist { 9507c478bd9Sstevel@tonic-gate u_short ol_val; 9517c478bd9Sstevel@tonic-gate int ol_bit; 9527c478bd9Sstevel@tonic-gate } optlist_t; 9537c478bd9Sstevel@tonic-gate 9547c478bd9Sstevel@tonic-gate 9557c478bd9Sstevel@tonic-gate /* 9567c478bd9Sstevel@tonic-gate * Group list structure. 9577c478bd9Sstevel@tonic-gate */ 9587c478bd9Sstevel@tonic-gate typedef struct frgroup { 9597c478bd9Sstevel@tonic-gate struct frgroup *fg_next; 9607c478bd9Sstevel@tonic-gate struct frentry *fg_head; 9617c478bd9Sstevel@tonic-gate struct frentry *fg_start; 9627c478bd9Sstevel@tonic-gate u_32_t fg_flags; 9637c478bd9Sstevel@tonic-gate int fg_ref; 9647c478bd9Sstevel@tonic-gate char fg_name[FR_GROUPLEN]; 9657c478bd9Sstevel@tonic-gate } frgroup_t; 9667c478bd9Sstevel@tonic-gate 9677c478bd9Sstevel@tonic-gate #define FG_NAME(g) (*(g)->fg_name == '\0' ? "" : (g)->fg_name) 9687c478bd9Sstevel@tonic-gate 9697c478bd9Sstevel@tonic-gate 9707c478bd9Sstevel@tonic-gate /* 9717c478bd9Sstevel@tonic-gate * Used by state and NAT tables 9727c478bd9Sstevel@tonic-gate */ 9737c478bd9Sstevel@tonic-gate typedef struct icmpinfo { 9747c478bd9Sstevel@tonic-gate u_short ici_id; 9757c478bd9Sstevel@tonic-gate u_short ici_seq; 9767c478bd9Sstevel@tonic-gate u_char ici_type; 9777c478bd9Sstevel@tonic-gate } icmpinfo_t; 9787c478bd9Sstevel@tonic-gate 9797c478bd9Sstevel@tonic-gate typedef struct udpinfo { 9807c478bd9Sstevel@tonic-gate u_short us_sport; 9817c478bd9Sstevel@tonic-gate u_short us_dport; 9827c478bd9Sstevel@tonic-gate } udpinfo_t; 9837c478bd9Sstevel@tonic-gate 9847c478bd9Sstevel@tonic-gate 9857c478bd9Sstevel@tonic-gate typedef struct tcpdata { 9867c478bd9Sstevel@tonic-gate u_32_t td_end; 9877c478bd9Sstevel@tonic-gate u_32_t td_maxend; 9887c478bd9Sstevel@tonic-gate u_32_t td_maxwin; 9897c478bd9Sstevel@tonic-gate u_32_t td_winscale; 9907c478bd9Sstevel@tonic-gate u_32_t td_maxseg; 9917c478bd9Sstevel@tonic-gate int td_winflags; 9927c478bd9Sstevel@tonic-gate } tcpdata_t; 9937c478bd9Sstevel@tonic-gate 9947c478bd9Sstevel@tonic-gate #define TCP_WSCALE_MAX 14 9957c478bd9Sstevel@tonic-gate 9967c478bd9Sstevel@tonic-gate #define TCP_WSCALE_SEEN 0x00000001 9977c478bd9Sstevel@tonic-gate #define TCP_WSCALE_FIRST 0x00000002 998f17d2b41San #define TCP_SACK_PERMIT 0x00000004 9997c478bd9Sstevel@tonic-gate 10007c478bd9Sstevel@tonic-gate 10017c478bd9Sstevel@tonic-gate typedef struct tcpinfo { 10027c478bd9Sstevel@tonic-gate u_short ts_sport; 10037c478bd9Sstevel@tonic-gate u_short ts_dport; 10047c478bd9Sstevel@tonic-gate tcpdata_t ts_data[2]; 10057c478bd9Sstevel@tonic-gate } tcpinfo_t; 10067c478bd9Sstevel@tonic-gate 1007ab25eeb5Syz 1008ab25eeb5Syz /* 1009ab25eeb5Syz * Structures to define a GRE header as seen in a packet. 1010ab25eeb5Syz */ 1011ab25eeb5Syz struct grebits { 1012ab25eeb5Syz u_32_t grb_C:1; 1013ab25eeb5Syz u_32_t grb_R:1; 1014ab25eeb5Syz u_32_t grb_K:1; 1015ab25eeb5Syz u_32_t grb_S:1; 1016ab25eeb5Syz u_32_t grb_s:1; 1017ab25eeb5Syz u_32_t grb_recur:1; 1018ab25eeb5Syz u_32_t grb_A:1; 1019ab25eeb5Syz u_32_t grb_flags:3; 1020ab25eeb5Syz u_32_t grb_ver:3; 1021ab25eeb5Syz u_short grb_ptype; 1022ab25eeb5Syz }; 10237c478bd9Sstevel@tonic-gate 10247c478bd9Sstevel@tonic-gate typedef struct grehdr { 10257c478bd9Sstevel@tonic-gate union { 1026ab25eeb5Syz struct grebits gru_bits; 10277c478bd9Sstevel@tonic-gate u_short gru_flags; 10287c478bd9Sstevel@tonic-gate } gr_un; 10297c478bd9Sstevel@tonic-gate u_short gr_len; 10307c478bd9Sstevel@tonic-gate u_short gr_call; 10317c478bd9Sstevel@tonic-gate } grehdr_t; 10327c478bd9Sstevel@tonic-gate 1033ab25eeb5Syz #define gr_flags gr_un.gru_flags 10347c478bd9Sstevel@tonic-gate #define gr_bits gr_un.gru_bits 1035ab25eeb5Syz #define gr_ptype gr_bits.grb_ptype 1036ab25eeb5Syz #define gr_C gr_bits.grb_C 1037ab25eeb5Syz #define gr_R gr_bits.grb_R 1038ab25eeb5Syz #define gr_K gr_bits.grb_K 1039ab25eeb5Syz #define gr_S gr_bits.grb_S 1040ab25eeb5Syz #define gr_s gr_bits.grb_s 1041ab25eeb5Syz #define gr_recur gr_bits.grb_recur 1042ab25eeb5Syz #define gr_A gr_bits.grb_A 1043ab25eeb5Syz #define gr_ver gr_bits.grb_ver 1044ab25eeb5Syz 1045ab25eeb5Syz /* 1046ab25eeb5Syz * GRE information tracked by "keep state" 1047ab25eeb5Syz */ 1048ab25eeb5Syz typedef struct greinfo { 1049ab25eeb5Syz u_short gs_call[2]; 1050ab25eeb5Syz u_short gs_flags; 1051ab25eeb5Syz u_short gs_ptype; 1052ab25eeb5Syz } greinfo_t; 1053ab25eeb5Syz 1054ab25eeb5Syz #define GRE_REV(x) ((ntohs(x) >> 13) & 7) 1055ab25eeb5Syz 1056ab25eeb5Syz 1057ab25eeb5Syz /* 1058ab25eeb5Syz * Format of an Authentication header 1059ab25eeb5Syz */ 1060ab25eeb5Syz typedef struct authhdr { 1061ab25eeb5Syz u_char ah_next; 1062ab25eeb5Syz u_char ah_plen; 1063ab25eeb5Syz u_short ah_reserved; 1064ab25eeb5Syz u_32_t ah_spi; 1065ab25eeb5Syz u_32_t ah_seq; 1066ab25eeb5Syz /* Following the sequence number field is 0 or more bytes of */ 1067ab25eeb5Syz /* authentication data, as specified by ah_plen - RFC 2402. */ 1068ab25eeb5Syz } authhdr_t; 10697c478bd9Sstevel@tonic-gate 10707c478bd9Sstevel@tonic-gate 10717c478bd9Sstevel@tonic-gate /* 10727c478bd9Sstevel@tonic-gate * Timeout tail queue list member 10737c478bd9Sstevel@tonic-gate */ 10747c478bd9Sstevel@tonic-gate typedef struct ipftqent { 10757c478bd9Sstevel@tonic-gate struct ipftqent **tqe_pnext; 10767c478bd9Sstevel@tonic-gate struct ipftqent *tqe_next; 10777c478bd9Sstevel@tonic-gate struct ipftq *tqe_ifq; 10787c478bd9Sstevel@tonic-gate void *tqe_parent; /* pointer back to NAT/state struct */ 10797c478bd9Sstevel@tonic-gate u_long tqe_die; /* when this entriy is to die */ 10807c478bd9Sstevel@tonic-gate u_long tqe_touched; 10817c478bd9Sstevel@tonic-gate int tqe_flags; 10827c478bd9Sstevel@tonic-gate int tqe_state[2]; /* current state of this entry */ 10837c478bd9Sstevel@tonic-gate } ipftqent_t; 10847c478bd9Sstevel@tonic-gate 10857c478bd9Sstevel@tonic-gate #define TQE_RULEBASED 0x00000001 10867c478bd9Sstevel@tonic-gate 10877c478bd9Sstevel@tonic-gate 10887c478bd9Sstevel@tonic-gate /* 10897c478bd9Sstevel@tonic-gate * Timeout tail queue head for IPFilter 10907c478bd9Sstevel@tonic-gate */ 10917c478bd9Sstevel@tonic-gate typedef struct ipftq { 10927c478bd9Sstevel@tonic-gate ipfmutex_t ifq_lock; 10937c478bd9Sstevel@tonic-gate u_int ifq_ttl; 10947c478bd9Sstevel@tonic-gate ipftqent_t *ifq_head; 10957c478bd9Sstevel@tonic-gate ipftqent_t **ifq_tail; 10967c478bd9Sstevel@tonic-gate struct ipftq *ifq_next; 10977c478bd9Sstevel@tonic-gate struct ipftq **ifq_pnext; 10987c478bd9Sstevel@tonic-gate int ifq_ref; 10997c478bd9Sstevel@tonic-gate u_int ifq_flags; 11007c478bd9Sstevel@tonic-gate } ipftq_t; 11017c478bd9Sstevel@tonic-gate 11027c478bd9Sstevel@tonic-gate #define IFQF_USER 0x01 /* User defined aging */ 1103ab25eeb5Syz #define IFQF_DELETE 0x02 /* Marked for deletion */ 1104ab25eeb5Syz #define IFQF_PROXY 0x04 /* Timeout queue in use by a proxy */ 11057c478bd9Sstevel@tonic-gate 11067c478bd9Sstevel@tonic-gate #define IPF_HZ_MULT 1 11077c478bd9Sstevel@tonic-gate #define IPF_HZ_DIVIDE 2 /* How many times a second ipfilter */ 11087c478bd9Sstevel@tonic-gate /* checks its timeout queues. */ 11097c478bd9Sstevel@tonic-gate #define IPF_TTLVAL(x) (((x) / IPF_HZ_MULT) * IPF_HZ_DIVIDE) 11107c478bd9Sstevel@tonic-gate 11117c478bd9Sstevel@tonic-gate /* 11127c478bd9Sstevel@tonic-gate * Structure to define address for pool lookups. 11137c478bd9Sstevel@tonic-gate */ 11147c478bd9Sstevel@tonic-gate typedef struct { 11157c478bd9Sstevel@tonic-gate u_char adf_len; 11167663b816Sml sa_family_t adf_family; 11177c478bd9Sstevel@tonic-gate i6addr_t adf_addr; 11187c478bd9Sstevel@tonic-gate } addrfamily_t; 11197c478bd9Sstevel@tonic-gate 11207c478bd9Sstevel@tonic-gate 11217c478bd9Sstevel@tonic-gate /* 11227c478bd9Sstevel@tonic-gate * Object structure description. For passing through in ioctls. 11237c478bd9Sstevel@tonic-gate */ 11247c478bd9Sstevel@tonic-gate typedef struct ipfobj { 11257c478bd9Sstevel@tonic-gate u_32_t ipfo_rev; /* IPFilter version number */ 11267c478bd9Sstevel@tonic-gate u_32_t ipfo_size; /* size of object at ipfo_ptr */ 11277c478bd9Sstevel@tonic-gate void *ipfo_ptr; /* pointer to object */ 11287c478bd9Sstevel@tonic-gate int ipfo_type; /* type of object being pointed to */ 11297c478bd9Sstevel@tonic-gate int ipfo_offset; /* bytes from ipfo_ptr where to start */ 11307c478bd9Sstevel@tonic-gate u_char ipfo_xxxpad[32]; /* reserved for future use */ 11317c478bd9Sstevel@tonic-gate } ipfobj_t; 11327c478bd9Sstevel@tonic-gate 11337c478bd9Sstevel@tonic-gate #define IPFOBJ_FRENTRY 0 /* struct frentry */ 11347c478bd9Sstevel@tonic-gate #define IPFOBJ_IPFSTAT 1 /* struct friostat */ 11357c478bd9Sstevel@tonic-gate #define IPFOBJ_IPFINFO 2 /* struct fr_info */ 11367c478bd9Sstevel@tonic-gate #define IPFOBJ_AUTHSTAT 3 /* struct fr_authstat */ 11377c478bd9Sstevel@tonic-gate #define IPFOBJ_FRAGSTAT 4 /* struct ipfrstat */ 11387c478bd9Sstevel@tonic-gate #define IPFOBJ_IPNAT 5 /* struct ipnat */ 11397c478bd9Sstevel@tonic-gate #define IPFOBJ_NATSTAT 6 /* struct natstat */ 11407c478bd9Sstevel@tonic-gate #define IPFOBJ_STATESAVE 7 /* struct ipstate_save */ 11417c478bd9Sstevel@tonic-gate #define IPFOBJ_NATSAVE 8 /* struct nat_save */ 11427c478bd9Sstevel@tonic-gate #define IPFOBJ_NATLOOKUP 9 /* struct natlookup */ 11437c478bd9Sstevel@tonic-gate #define IPFOBJ_IPSTATE 10 /* struct ipstate */ 11447c478bd9Sstevel@tonic-gate #define IPFOBJ_STATESTAT 11 /* struct ips_stat */ 11457c478bd9Sstevel@tonic-gate #define IPFOBJ_FRAUTH 12 /* struct frauth */ 11467c478bd9Sstevel@tonic-gate #define IPFOBJ_TUNEABLE 13 /* struct ipftune */ 1147f4b3ec61Sdh #define IPFOBJ_NAT 14 /* struct nat */ 1148f4b3ec61Sdh #define IPFOBJ_IPFITER 15 /* struct ipfruleiter */ 1149f4b3ec61Sdh #define IPFOBJ_GENITER 16 /* struct ipfgeniter */ 1150f4b3ec61Sdh #define IPFOBJ_GTABLE 17 /* struct ipftable */ 1151f4b3ec61Sdh #define IPFOBJ_LOOKUPITER 18 /* struct ipflookupiter */ 1152f4b3ec61Sdh #define IPFOBJ_COUNT 19 /* How many #defines are above this? */ 11537c478bd9Sstevel@tonic-gate 11547c478bd9Sstevel@tonic-gate 11557c478bd9Sstevel@tonic-gate typedef union ipftunevalptr { 11567c478bd9Sstevel@tonic-gate void *ipftp_void; 11577c478bd9Sstevel@tonic-gate u_long *ipftp_long; 11587c478bd9Sstevel@tonic-gate u_int *ipftp_int; 11597c478bd9Sstevel@tonic-gate u_short *ipftp_short; 11607c478bd9Sstevel@tonic-gate u_char *ipftp_char; 11617c478bd9Sstevel@tonic-gate } ipftunevalptr_t; 11627c478bd9Sstevel@tonic-gate 11637c478bd9Sstevel@tonic-gate typedef struct ipftuneable { 11647c478bd9Sstevel@tonic-gate ipftunevalptr_t ipft_una; 11657c478bd9Sstevel@tonic-gate char *ipft_name; 11667c478bd9Sstevel@tonic-gate u_long ipft_min; 11677c478bd9Sstevel@tonic-gate u_long ipft_max; 11687c478bd9Sstevel@tonic-gate int ipft_sz; 11697c478bd9Sstevel@tonic-gate int ipft_flags; 1170ab25eeb5Syz struct ipftuneable *ipft_next; 11717c478bd9Sstevel@tonic-gate } ipftuneable_t; 11727c478bd9Sstevel@tonic-gate 11737c478bd9Sstevel@tonic-gate #define ipft_addr ipft_una.ipftp_void 11747c478bd9Sstevel@tonic-gate #define ipft_plong ipft_una.ipftp_long 11757c478bd9Sstevel@tonic-gate #define ipft_pint ipft_una.ipftp_int 11767c478bd9Sstevel@tonic-gate #define ipft_pshort ipft_una.ipftp_short 11777c478bd9Sstevel@tonic-gate #define ipft_pchar ipft_una.ipftp_char 11787c478bd9Sstevel@tonic-gate 11797c478bd9Sstevel@tonic-gate #define IPFT_RDONLY 1 /* read-only */ 11807c478bd9Sstevel@tonic-gate #define IPFT_WRDISABLED 2 /* write when disabled only */ 11817c478bd9Sstevel@tonic-gate 11827c478bd9Sstevel@tonic-gate typedef union ipftuneval { 11837c478bd9Sstevel@tonic-gate u_long ipftu_long; 11847c478bd9Sstevel@tonic-gate u_int ipftu_int; 11857c478bd9Sstevel@tonic-gate u_short ipftu_short; 11867c478bd9Sstevel@tonic-gate u_char ipftu_char; 11877c478bd9Sstevel@tonic-gate } ipftuneval_t; 11887c478bd9Sstevel@tonic-gate 11897c478bd9Sstevel@tonic-gate typedef struct ipftune { 11907c478bd9Sstevel@tonic-gate void *ipft_cookie; 11917c478bd9Sstevel@tonic-gate ipftuneval_t ipft_un; 11927c478bd9Sstevel@tonic-gate u_long ipft_min; 11937c478bd9Sstevel@tonic-gate u_long ipft_max; 11947c478bd9Sstevel@tonic-gate int ipft_sz; 11957c478bd9Sstevel@tonic-gate int ipft_flags; 11967c478bd9Sstevel@tonic-gate char ipft_name[80]; 11977c478bd9Sstevel@tonic-gate } ipftune_t; 11987c478bd9Sstevel@tonic-gate 11997c478bd9Sstevel@tonic-gate #define ipft_vlong ipft_un.ipftu_long 12007c478bd9Sstevel@tonic-gate #define ipft_vint ipft_un.ipftu_int 12017c478bd9Sstevel@tonic-gate #define ipft_vshort ipft_un.ipftu_short 12027c478bd9Sstevel@tonic-gate #define ipft_vchar ipft_un.ipftu_char 12037c478bd9Sstevel@tonic-gate 120490b0a856Sjojemann /* 120590b0a856Sjojemann * ipfruleiter is iterator structure used for filter rules. 120690b0a856Sjojemann */ 1207f4b3ec61Sdh typedef struct ipfruleiter { 1208f4b3ec61Sdh int iri_ver; 1209f4b3ec61Sdh int iri_inout; 1210f4b3ec61Sdh char iri_group[FR_GROUPLEN]; 1211f4b3ec61Sdh int iri_active; 121290b0a856Sjojemann int iri_nrules; 1213f4b3ec61Sdh frentry_t *iri_rule; 1214f4b3ec61Sdh } ipfruleiter_t; 1215f4b3ec61Sdh 121690b0a856Sjojemann /* Values for iri_inout */ 121790b0a856Sjojemann #define F_IN 0 121890b0a856Sjojemann #define F_OUT 1 121990b0a856Sjojemann #define F_ACIN 2 122090b0a856Sjojemann #define F_ACOUT 3 122190b0a856Sjojemann 122290b0a856Sjojemann /* 122390b0a856Sjojemann * ipfgeniter is generic iterator structure used for nat rules, 122490b0a856Sjojemann * hostmap entries and nat table entries. 122590b0a856Sjojemann */ 1226f4b3ec61Sdh typedef struct ipfgeniter { 122790b0a856Sjojemann int igi_type; /* type of data we're looking at */ 122890b0a856Sjojemann int igi_nitems; 1229f4b3ec61Sdh void *igi_data; 1230f4b3ec61Sdh } ipfgeniter_t; 1231f4b3ec61Sdh 1232f4b3ec61Sdh #define IPFGENITER_IPF 0 1233f4b3ec61Sdh #define IPFGENITER_NAT 1 1234f4b3ec61Sdh #define IPFGENITER_IPNAT 2 1235f4b3ec61Sdh #define IPFGENITER_FRAG 3 1236f4b3ec61Sdh #define IPFGENITER_AUTH 4 1237f4b3ec61Sdh #define IPFGENITER_STATE 5 1238f4b3ec61Sdh #define IPFGENITER_NATFRAG 6 1239f4b3ec61Sdh #define IPFGENITER_HOSTMAP 7 1240f4b3ec61Sdh #define IPFGENITER_LOOKUP 8 1241f4b3ec61Sdh 1242f4b3ec61Sdh typedef struct ipftable { 1243f4b3ec61Sdh int ita_type; 1244f4b3ec61Sdh void *ita_table; 1245f4b3ec61Sdh } ipftable_t; 1246f4b3ec61Sdh 1247f4b3ec61Sdh typedef struct ipftoken { 1248f4b3ec61Sdh struct ipftoken *ipt_next; 1249f4b3ec61Sdh struct ipftoken **ipt_pnext; 1250f4b3ec61Sdh void *ipt_ctx; 1251f4b3ec61Sdh void *ipt_data; 1252f4b3ec61Sdh u_long ipt_die; 1253f4b3ec61Sdh int ipt_type; 1254f4b3ec61Sdh int ipt_uid; 1255f4b3ec61Sdh int ipt_subtype; 1256f4b3ec61Sdh int ipt_alive; 1257f4b3ec61Sdh } ipftoken_t; 1258f4b3ec61Sdh 1259f4b3ec61Sdh 1260381a2a9aSdr /* 1261381a2a9aSdr * sync commands 1262381a2a9aSdr */ 1263381a2a9aSdr #define IPFSYNC_RESYNC 0 1264381a2a9aSdr #define IPFSYNC_NEWIFP 1 1265381a2a9aSdr #define IPFSYNC_OLDIFP 2 1266381a2a9aSdr 1267381a2a9aSdr 12687c478bd9Sstevel@tonic-gate /* 12697c478bd9Sstevel@tonic-gate ** HPUX Port 12707c478bd9Sstevel@tonic-gate */ 12717c478bd9Sstevel@tonic-gate #ifdef __hpux 12727c478bd9Sstevel@tonic-gate /* HP-UX locking sequence deadlock detection module lock MAJOR ID */ 12737c478bd9Sstevel@tonic-gate # define IPF_SMAJ 0 /* temp assignment XXX, not critical */ 12747c478bd9Sstevel@tonic-gate #endif 12757c478bd9Sstevel@tonic-gate 12767c478bd9Sstevel@tonic-gate #if !defined(CDEV_MAJOR) && defined (__FreeBSD_version) && \ 12777c478bd9Sstevel@tonic-gate (__FreeBSD_version >= 220000) 12787c478bd9Sstevel@tonic-gate # define CDEV_MAJOR 79 12797c478bd9Sstevel@tonic-gate #endif 12807c478bd9Sstevel@tonic-gate 12817c478bd9Sstevel@tonic-gate /* 12827c478bd9Sstevel@tonic-gate * Post NetBSD 1.2 has the PFIL interface for packet filters. This turns 12837c478bd9Sstevel@tonic-gate * on those hooks. We don't need any special mods in non-IP Filter code 12847c478bd9Sstevel@tonic-gate * with this! 12857c478bd9Sstevel@tonic-gate */ 12867c478bd9Sstevel@tonic-gate #if (defined(NetBSD) && (NetBSD > 199609) && (NetBSD <= 1991011)) || \ 12877c478bd9Sstevel@tonic-gate (defined(NetBSD1_2) && NetBSD1_2 > 1) || \ 12887c478bd9Sstevel@tonic-gate (defined(__FreeBSD__) && (__FreeBSD_version >= 500043)) 12897c478bd9Sstevel@tonic-gate # if (NetBSD >= 199905) 12907c478bd9Sstevel@tonic-gate # define PFIL_HOOKS 12917c478bd9Sstevel@tonic-gate # endif 12927c478bd9Sstevel@tonic-gate # ifdef PFIL_HOOKS 12937c478bd9Sstevel@tonic-gate # define NETBSD_PF 12947c478bd9Sstevel@tonic-gate # endif 12957c478bd9Sstevel@tonic-gate #endif 12967c478bd9Sstevel@tonic-gate 12977c478bd9Sstevel@tonic-gate #ifndef _KERNEL 1298f4b3ec61Sdh extern int fr_check __P((struct ip *, int, void *, int, mb_t **, ipf_stack_t *)); 1299f4b3ec61Sdh extern int (*fr_checkp) __P((ip_t *, int, void *, int, mb_t **, ipf_stack_t *)); 13007c478bd9Sstevel@tonic-gate extern int ipf_log __P((void)); 1301f4b3ec61Sdh extern struct ifnet *get_unit __P((char *, int, ipf_stack_t *)); 13027c478bd9Sstevel@tonic-gate extern char *get_ifname __P((struct ifnet *)); 13037c478bd9Sstevel@tonic-gate # if defined(__NetBSD__) || defined(__OpenBSD__) || \ 13047c478bd9Sstevel@tonic-gate (_BSDI_VERSION >= 199701) || (__FreeBSD_version >= 300000) 1305f4b3ec61Sdh extern int frrequest __P((int, u_long, caddr_t, int, int, ipf_stack_t *)); 13067c478bd9Sstevel@tonic-gate # else 1307ab25eeb5Syz extern int iplioctl __P((int, ioctlcmd_t, caddr_t, int)); 13087c478bd9Sstevel@tonic-gate # endif 13097c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int)); 13107c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int)); 13117c478bd9Sstevel@tonic-gate extern void m_freem __P((mb_t *)); 13127c478bd9Sstevel@tonic-gate #else /* #ifndef _KERNEL */ 1313f4b3ec61Sdh extern phy_if_t get_unit __P((char *, int, ipf_stack_t *)); 13147c478bd9Sstevel@tonic-gate # if defined(__NetBSD__) && defined(PFIL_HOOKS) 13157c478bd9Sstevel@tonic-gate extern void ipfilterattach __P((int)); 13167c478bd9Sstevel@tonic-gate # endif 13177c478bd9Sstevel@tonic-gate extern int ipl_enable __P((void)); 13187c478bd9Sstevel@tonic-gate extern int ipl_disable __P((void)); 13197c478bd9Sstevel@tonic-gate # ifdef MENTAT 13207ddc9b1aSDarren Reed extern ipf_stack_t *ipf_find_stack(const zoneid_t zone); 1321ab25eeb5Syz extern int fr_check __P((struct ip *, int, void *, int, void *, 1322f4b3ec61Sdh mblk_t **, ipf_stack_t *)); 13237c478bd9Sstevel@tonic-gate # if SOLARIS 13247c478bd9Sstevel@tonic-gate # if SOLARIS2 >= 7 13257c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, intptr_t, int, cred_t *, int *)); 13267c478bd9Sstevel@tonic-gate # else 13277c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, int *, int, cred_t *, int *)); 13287c478bd9Sstevel@tonic-gate # endif 13297c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t *, int, int, cred_t *)); 13307c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, cred_t *)); 1331ab25eeb5Syz extern int iplread __P((dev_t, uio_t *, cred_t *)); 1332ab25eeb5Syz extern int iplwrite __P((dev_t, uio_t *, cred_t *)); 13337c478bd9Sstevel@tonic-gate # endif 13347c478bd9Sstevel@tonic-gate # ifdef __hpux 13357c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int, intptr_t, int)); 13367c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int)); 13377c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int)); 1338ab25eeb5Syz extern int iplread __P((dev_t, uio_t *)); 1339ab25eeb5Syz extern int iplwrite __P((dev_t, uio_t *)); 13407c478bd9Sstevel@tonic-gate extern int iplselect __P((dev_t, int)); 13417c478bd9Sstevel@tonic-gate # endif 1342f4b3ec61Sdh extern int ipfsync __P((ipf_stack_t *)); 13437c478bd9Sstevel@tonic-gate extern int fr_qout __P((queue_t *, mblk_t *)); 13447c478bd9Sstevel@tonic-gate # else /* MENTAT */ 1345f4b3ec61Sdh extern int fr_check __P((struct ip *, int, void *, int, mb_t **, ipf_stack_t *)); 1346f4b3ec61Sdh extern int (*fr_checkp) __P((ip_t *, int, void *, int, mb_t **, ipf_stack_t *)); 13477c478bd9Sstevel@tonic-gate extern size_t mbufchainlen __P((mb_t *)); 13487c478bd9Sstevel@tonic-gate # ifdef __sgi 13497c478bd9Sstevel@tonic-gate # include <sys/cred.h> 13507c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int, cred_t *, int *)); 13517c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t *, int, int, cred_t *)); 13527c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, cred_t *)); 1353ab25eeb5Syz extern int iplread __P((dev_t, uio_t *, cred_t *)); 1354ab25eeb5Syz extern int iplwrite __P((dev_t, uio_t *, cred_t *)); 1355f4b3ec61Sdh extern int ipfsync __P((ipf_stack_t *)); 13567c478bd9Sstevel@tonic-gate extern int ipfilter_sgi_attach __P((void)); 13577c478bd9Sstevel@tonic-gate extern void ipfilter_sgi_detach __P((void)); 13587c478bd9Sstevel@tonic-gate extern void ipfilter_sgi_intfsync __P((void)); 13597c478bd9Sstevel@tonic-gate # else 13607c478bd9Sstevel@tonic-gate # ifdef IPFILTER_LKM 13617c478bd9Sstevel@tonic-gate extern int iplidentify __P((char *)); 13627c478bd9Sstevel@tonic-gate # endif 13637c478bd9Sstevel@tonic-gate # if (_BSDI_VERSION >= 199510) || (__FreeBSD_version >= 220000) || \ 13647c478bd9Sstevel@tonic-gate (NetBSD >= 199511) || defined(__OpenBSD__) 13657c478bd9Sstevel@tonic-gate # if defined(__NetBSD__) || (_BSDI_VERSION >= 199701) || \ 13667c478bd9Sstevel@tonic-gate defined(__OpenBSD__) || (__FreeBSD_version >= 300000) 13677c478bd9Sstevel@tonic-gate # if (__FreeBSD_version >= 500024) 1368ab25eeb5Syz # if (__FreeBSD_version >= 502116) 1369ab25eeb5Syz extern int iplioctl __P((struct cdev*, u_long, caddr_t, int, struct thread *)); 1370ab25eeb5Syz # else 13717c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, u_long, caddr_t, int, struct thread *)); 1372ab25eeb5Syz # endif /* __FreeBSD_version >= 502116 */ 13737c478bd9Sstevel@tonic-gate # else 13747c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); 13757c478bd9Sstevel@tonic-gate # endif /* __FreeBSD_version >= 500024 */ 13767c478bd9Sstevel@tonic-gate # else 13777c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int, struct proc *)); 13787c478bd9Sstevel@tonic-gate # endif 13797c478bd9Sstevel@tonic-gate # if (__FreeBSD_version >= 500024) 1380ab25eeb5Syz # if (__FreeBSD_version >= 502116) 1381ab25eeb5Syz extern int iplopen __P((struct cdev*, int, int, struct thread *)); 1382ab25eeb5Syz extern int iplclose __P((struct cdev*, int, int, struct thread *)); 1383ab25eeb5Syz # else 13847c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int, int, struct thread *)); 13857c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, struct thread *)); 1386ab25eeb5Syz # endif /* __FreeBSD_version >= 502116 */ 13877c478bd9Sstevel@tonic-gate # else 13887c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int, int, struct proc *)); 13897c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, struct proc *)); 13907c478bd9Sstevel@tonic-gate # endif /* __FreeBSD_version >= 500024 */ 13917c478bd9Sstevel@tonic-gate # else 1392ab25eeb5Syz # ifdef linux 1393ab25eeb5Syz extern int iplioctl __P((struct inode *, struct file *, u_int, u_long)); 1394ab25eeb5Syz # else 13957c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int)); 13967c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int)); 13977c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int)); 1398ab25eeb5Syz # endif 13997c478bd9Sstevel@tonic-gate # endif /* (_BSDI_VERSION >= 199510) */ 14007c478bd9Sstevel@tonic-gate # if BSD >= 199306 1401ab25eeb5Syz # if (__FreeBSD_version >= 502116) 1402ab25eeb5Syz extern int iplread __P((struct cdev*, struct uio *, int)); 1403ab25eeb5Syz extern int iplwrite __P((struct cdev*, struct uio *, int)); 1404ab25eeb5Syz # else 14057c478bd9Sstevel@tonic-gate extern int iplread __P((dev_t, struct uio *, int)); 1406ab25eeb5Syz extern int iplwrite __P((dev_t, struct uio *, int)); 1407ab25eeb5Syz # endif /* __FreeBSD_version >= 502116 */ 14087c478bd9Sstevel@tonic-gate # else 1409ab25eeb5Syz # ifndef linux 14107c478bd9Sstevel@tonic-gate extern int iplread __P((dev_t, struct uio *)); 1411ab25eeb5Syz extern int iplwrite __P((dev_t, struct uio *)); 1412ab25eeb5Syz # endif 14137c478bd9Sstevel@tonic-gate # endif /* BSD >= 199306 */ 14147c478bd9Sstevel@tonic-gate # endif /* __ sgi */ 14157c478bd9Sstevel@tonic-gate # endif /* MENTAT */ 14167c478bd9Sstevel@tonic-gate 14177c478bd9Sstevel@tonic-gate #endif /* #ifndef _KERNEL */ 14187c478bd9Sstevel@tonic-gate 14197c478bd9Sstevel@tonic-gate extern char *memstr __P((char *, char *, int, int)); 14207c478bd9Sstevel@tonic-gate extern int count4bits __P((u_32_t)); 14217663b816Sml extern int count6bits __P((u_32_t *)); 1422f4b3ec61Sdh extern int frrequest __P((int, ioctlcmd_t, caddr_t, int, int, ipf_stack_t *)); 14237c478bd9Sstevel@tonic-gate extern char *getifname __P((struct ifnet *)); 14247ddc9b1aSDarren Reed extern int iplattach __P((ipf_stack_t *)); 1425f4b3ec61Sdh extern int ipldetach __P((ipf_stack_t *)); 14267c478bd9Sstevel@tonic-gate extern u_short ipf_cksum __P((u_short *, int)); 14277c478bd9Sstevel@tonic-gate extern int copyinptr __P((void *, void *, size_t)); 14287c478bd9Sstevel@tonic-gate extern int copyoutptr __P((void *, void *, size_t)); 1429ab25eeb5Syz extern int fr_fastroute __P((mb_t *, mb_t **, fr_info_t *, frdest_t *)); 14307c478bd9Sstevel@tonic-gate extern int fr_inobj __P((void *, void *, int)); 1431ab25eeb5Syz extern int fr_inobjsz __P((void *, void *, int, int)); 1432d6c23f6fSyx extern int fr_ioctlswitch __P((int, void *, ioctlcmd_t, int, int, void *, 1433d6c23f6fSyx ipf_stack_t *)); 1434f4b3ec61Sdh extern int fr_ipftune __P((ioctlcmd_t, void *, ipf_stack_t *)); 14357c478bd9Sstevel@tonic-gate extern int fr_outobj __P((void *, void *, int)); 1436ab25eeb5Syz extern int fr_outobjsz __P((void *, void *, int, int)); 1437ab25eeb5Syz extern void *fr_pullup __P((mb_t *, fr_info_t *, int)); 1438f4b3ec61Sdh extern void fr_resolvedest __P((struct frdest *, int, ipf_stack_t *)); 14397c478bd9Sstevel@tonic-gate extern int fr_resolvefunc __P((void *)); 1440f4b3ec61Sdh extern void *fr_resolvenic __P((char *, int, ipf_stack_t *)); 1441ab25eeb5Syz extern int fr_send_icmp_err __P((int, fr_info_t *, int)); 1442ab25eeb5Syz extern int fr_send_reset __P((fr_info_t *)); 1443ab25eeb5Syz #if (__FreeBSD_version < 490000) || !defined(_KERNEL) 14447c478bd9Sstevel@tonic-gate extern int ppsratecheck __P((struct timeval *, int *, int)); 1445ab25eeb5Syz #endif 1446f4b3ec61Sdh extern ipftq_t *fr_addtimeoutqueue __P((ipftq_t **, u_int, ipf_stack_t *)); 1447ab25eeb5Syz extern void fr_deletequeueentry __P((ipftqent_t *)); 1448ab25eeb5Syz extern int fr_deletetimeoutqueue __P((ipftq_t *)); 1449f4b3ec61Sdh extern void fr_freetimeoutqueue __P((ipftq_t *, ipf_stack_t *)); 1450d6c23f6fSyx extern void fr_movequeue __P((ipftqent_t *, ipftq_t *, ipftq_t *, 1451d6c23f6fSyx ipf_stack_t *)); 1452d6c23f6fSyx extern void fr_queueappend __P((ipftqent_t *, ipftq_t *, void *, 1453d6c23f6fSyx ipf_stack_t *)); 1454f4b3ec61Sdh extern void fr_queueback __P((ipftqent_t *, ipf_stack_t *)); 1455ab25eeb5Syz extern void fr_queuefront __P((ipftqent_t *)); 14567c478bd9Sstevel@tonic-gate extern void fr_checkv4sum __P((fr_info_t *)); 14577c478bd9Sstevel@tonic-gate extern int fr_checkl4sum __P((fr_info_t *)); 14587c478bd9Sstevel@tonic-gate extern int fr_ifpfillv4addr __P((int, struct sockaddr_in *, 14597c478bd9Sstevel@tonic-gate struct sockaddr_in *, struct in_addr *, 14607c478bd9Sstevel@tonic-gate struct in_addr *)); 14617c478bd9Sstevel@tonic-gate extern int fr_coalesce __P((fr_info_t *)); 14627c478bd9Sstevel@tonic-gate #ifdef USE_INET6 14637c478bd9Sstevel@tonic-gate extern void fr_checkv6sum __P((fr_info_t *)); 14647c478bd9Sstevel@tonic-gate extern int fr_ifpfillv6addr __P((int, struct sockaddr_in6 *, 14657c478bd9Sstevel@tonic-gate struct sockaddr_in6 *, struct in_addr *, 14667c478bd9Sstevel@tonic-gate struct in_addr *)); 14677c478bd9Sstevel@tonic-gate #endif 14687c478bd9Sstevel@tonic-gate 1469d6c23f6fSyx #define IPFILTER_COMPAT 1470d6c23f6fSyx extern int fr_incomptrans __P((ipfobj_t *, void *)); 1471d6c23f6fSyx extern int fr_outcomptrans __P((ipfobj_t *, void *)); 1472d6c23f6fSyx 1473f4b3ec61Sdh extern int fr_addipftune __P((ipftuneable_t *, ipf_stack_t *)); 1474f4b3ec61Sdh extern int fr_delipftune __P((ipftuneable_t *, ipf_stack_t *)); 1475f4b3ec61Sdh 1476f4b3ec61Sdh extern int frflush __P((minor_t, int, int, ipf_stack_t *)); 1477f4b3ec61Sdh extern void frsync __P((int, int, void *, char *, ipf_stack_t *)); 1478f4b3ec61Sdh extern frgroup_t *fr_addgroup __P((char *, void *, u_32_t, minor_t, int, 1479f4b3ec61Sdh ipf_stack_t *)); 1480f4b3ec61Sdh extern int fr_derefrule __P((frentry_t **, ipf_stack_t *)); 1481f4b3ec61Sdh extern void fr_delgroup __P((char *, minor_t, int, ipf_stack_t *)); 1482f4b3ec61Sdh extern frgroup_t *fr_findgroup __P((char *, minor_t, int, frgroup_t ***, 1483f4b3ec61Sdh ipf_stack_t *)); 1484f4b3ec61Sdh 1485f4b3ec61Sdh extern int fr_loginit __P((ipf_stack_t *)); 1486f4b3ec61Sdh extern int ipflog_clear __P((minor_t, ipf_stack_t *)); 1487f4b3ec61Sdh extern int ipflog_read __P((minor_t, struct uio *, ipf_stack_t *)); 14887c478bd9Sstevel@tonic-gate extern int ipflog __P((fr_info_t *, u_int)); 1489f4b3ec61Sdh extern int ipllog __P((int, fr_info_t *, void **, size_t *, int *, int, 1490f4b3ec61Sdh ipf_stack_t *)); 1491f4b3ec61Sdh extern void fr_logunload __P((ipf_stack_t *)); 14927c478bd9Sstevel@tonic-gate 14937c478bd9Sstevel@tonic-gate extern frentry_t *fr_acctpkt __P((fr_info_t *, u_32_t *)); 14947c478bd9Sstevel@tonic-gate extern int fr_copytolog __P((int, char *, int)); 14957c478bd9Sstevel@tonic-gate extern u_short fr_cksum __P((mb_t *, ip_t *, int, void *)); 1496f4b3ec61Sdh extern void fr_deinitialise __P((ipf_stack_t *)); 14977c478bd9Sstevel@tonic-gate extern frentry_t *fr_dolog __P((fr_info_t *, u_32_t *)); 14987c478bd9Sstevel@tonic-gate extern frentry_t *fr_dstgrpmap __P((fr_info_t *, u_32_t *)); 14997c478bd9Sstevel@tonic-gate extern void fr_fixskip __P((frentry_t **, frentry_t *, int)); 1500f4b3ec61Sdh extern void fr_forgetifp __P((void *, ipf_stack_t *)); 1501f4b3ec61Sdh extern frentry_t *fr_getrulen __P((int, char *, u_32_t, 1502f4b3ec61Sdh ipf_stack_t *)); 1503f4b3ec61Sdh extern void fr_getstat __P((struct friostat *, ipf_stack_t *)); 15047c478bd9Sstevel@tonic-gate extern int fr_ifpaddr __P((int, int, void *, 1505f4b3ec61Sdh struct in_addr *, struct in_addr *, 1506f4b3ec61Sdh ipf_stack_t *)); 1507f4b3ec61Sdh extern int fr_initialise __P((ipf_stack_t *)); 1508bb1d9de5SJohn Ojemann extern int fr_lock __P((caddr_t, int *)); 1509bb1d9de5SJohn Ojemann extern int fr_makefrip __P((int, ip_t *, fr_info_t *)); 15107c478bd9Sstevel@tonic-gate extern int fr_matchtag __P((ipftag_t *, ipftag_t *)); 15117c478bd9Sstevel@tonic-gate extern int fr_matchicmpqueryreply __P((int, icmpinfo_t *, 1512d6c23f6fSyx struct icmp *, int)); 15137c478bd9Sstevel@tonic-gate extern u_32_t fr_newisn __P((fr_info_t *)); 1514ab25eeb5Syz extern u_short fr_nextipid __P((fr_info_t *)); 1515f4b3ec61Sdh extern int fr_rulen __P((int, frentry_t *, ipf_stack_t *)); 15167c478bd9Sstevel@tonic-gate extern int fr_scanlist __P((fr_info_t *, u_32_t)); 15177c478bd9Sstevel@tonic-gate extern frentry_t *fr_srcgrpmap __P((fr_info_t *, u_32_t *)); 15187c478bd9Sstevel@tonic-gate extern int fr_tcpudpchk __P((fr_info_t *, frtuc_t *)); 15197c478bd9Sstevel@tonic-gate extern int fr_verifysrc __P((fr_info_t *fin)); 1520f4b3ec61Sdh extern int fr_zerostats __P((char *, ipf_stack_t *)); 1521d6c23f6fSyx extern ipftoken_t *ipf_findtoken __P((int, int, void *, ipf_stack_t *)); 1522d6c23f6fSyx extern int ipf_getnextrule __P((ipftoken_t *, void *, 1523d6c23f6fSyx ipf_stack_t *)); 1524f4b3ec61Sdh extern void ipf_expiretokens __P((ipf_stack_t *)); 1525d6c23f6fSyx extern void ipf_freetoken __P((ipftoken_t *, ipf_stack_t *)); 1526d6c23f6fSyx extern int ipf_deltoken __P((int,int, void *, ipf_stack_t *)); 1527d6c23f6fSyx extern int ipf_genericiter __P((void *, int, void *, 1528d6c23f6fSyx ipf_stack_t *)); 1529ab073b32Sdr #ifndef ipf_random 1530ab073b32Sdr extern u_32_t ipf_random __P((void)); 1531ab073b32Sdr #endif 1532f4b3ec61Sdh 15337c478bd9Sstevel@tonic-gate extern char ipfilter_version[]; 15347c478bd9Sstevel@tonic-gate #ifdef USE_INET6 15357c478bd9Sstevel@tonic-gate extern int icmptoicmp6types[ICMP_MAXTYPE+1]; 15367c478bd9Sstevel@tonic-gate extern int icmptoicmp6unreach[ICMP_MAX_UNREACH]; 15377c478bd9Sstevel@tonic-gate extern int icmpreplytype6[ICMP6_MAXTYPE + 1]; 15387c478bd9Sstevel@tonic-gate #endif 15397c478bd9Sstevel@tonic-gate extern int icmpreplytype4[ICMP_MAXTYPE + 1]; 15407c478bd9Sstevel@tonic-gate extern frentry_t *ipfrule_match __P((fr_info_t *)); 1541f4b3ec61Sdh 1542f4b3ec61Sdh extern void ipftuneable_alloc(ipf_stack_t *); 1543f4b3ec61Sdh extern void ipftuneable_free(ipf_stack_t *); 15447c478bd9Sstevel@tonic-gate 15457c478bd9Sstevel@tonic-gate #endif /* __IP_FIL_H__ */ 1546