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 275ab25eeb5Syz #define FI_CMP 0xcfe3 /* Not FI_FRAG,FI_NATED,FI_FRAGTAIL */ 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 281*5b48165cSJohn Ojemann #define FI_NEWNAT 0x80000 2827c478bd9Sstevel@tonic-gate #define FI_NOCKSUM 0x20000000 /* don't do a L4 checksum validation */ 2837c478bd9Sstevel@tonic-gate #define FI_DONTCACHE 0x40000000 /* don't cache the result */ 2847c478bd9Sstevel@tonic-gate #define FI_IGNORE 0x80000000 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate #define fi_saddr fi_src.in4.s_addr 2877c478bd9Sstevel@tonic-gate #define fi_daddr fi_dst.in4.s_addr 2887c478bd9Sstevel@tonic-gate #define fi_srcnum fi_src.iplookupnum 2897c478bd9Sstevel@tonic-gate #define fi_dstnum fi_dst.iplookupnum 2907c478bd9Sstevel@tonic-gate #define fi_srctype fi_src.iplookuptype 2917c478bd9Sstevel@tonic-gate #define fi_dsttype fi_dst.iplookuptype 2927c478bd9Sstevel@tonic-gate #define fi_srcptr fi_src.iplookupptr 2937c478bd9Sstevel@tonic-gate #define fi_dstptr fi_dst.iplookupptr 2947c478bd9Sstevel@tonic-gate #define fi_srcfunc fi_src.iplookupfunc 2957c478bd9Sstevel@tonic-gate #define fi_dstfunc fi_dst.iplookupfunc 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate 2987c478bd9Sstevel@tonic-gate /* 2997c478bd9Sstevel@tonic-gate * These are both used by the state and NAT code to indicate that one port or 3007c478bd9Sstevel@tonic-gate * the other should be treated as a wildcard. 3017c478bd9Sstevel@tonic-gate * NOTE: When updating, check bit masks in ip_state.h and update there too. 3027c478bd9Sstevel@tonic-gate */ 3037c478bd9Sstevel@tonic-gate #define SI_W_SPORT 0x00000100 3047c478bd9Sstevel@tonic-gate #define SI_W_DPORT 0x00000200 3057c478bd9Sstevel@tonic-gate #define SI_WILDP (SI_W_SPORT|SI_W_DPORT) 3067c478bd9Sstevel@tonic-gate #define SI_W_SADDR 0x00000400 3077c478bd9Sstevel@tonic-gate #define SI_W_DADDR 0x00000800 3087c478bd9Sstevel@tonic-gate #define SI_WILDA (SI_W_SADDR|SI_W_DADDR) 3097c478bd9Sstevel@tonic-gate #define SI_NEWFR 0x00001000 3107c478bd9Sstevel@tonic-gate #define SI_CLONE 0x00002000 3117c478bd9Sstevel@tonic-gate #define SI_CLONED 0x00004000 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate 314f4b3ec61Sdh 315f4b3ec61Sdh 3167c478bd9Sstevel@tonic-gate typedef struct fr_info { 3177c478bd9Sstevel@tonic-gate void *fin_ifp; /* interface packet is `on' */ 318ab25eeb5Syz fr_ip_t fin_fi; /* IP Packet summary */ 3197c478bd9Sstevel@tonic-gate union { 3207c478bd9Sstevel@tonic-gate u_short fid_16[2]; /* TCP/UDP ports, ICMP code/type */ 3217c478bd9Sstevel@tonic-gate u_32_t fid_32; 3227c478bd9Sstevel@tonic-gate } fin_dat; 3237c478bd9Sstevel@tonic-gate int fin_out; /* in or out ? 1 == out, 0 == in */ 3247c478bd9Sstevel@tonic-gate int fin_rev; /* state only: 1 = reverse */ 3257c478bd9Sstevel@tonic-gate u_short fin_hlen; /* length of IP header in bytes */ 3267c478bd9Sstevel@tonic-gate u_char fin_tcpf; /* TCP header flags (SYN, ACK, etc) */ 3277c478bd9Sstevel@tonic-gate u_char fin_icode; /* ICMP error to return */ 3287c478bd9Sstevel@tonic-gate u_32_t fin_rule; /* rule # last matched */ 3297c478bd9Sstevel@tonic-gate char fin_group[FR_GROUPLEN]; /* group number, -1 for none */ 3307c478bd9Sstevel@tonic-gate struct frentry *fin_fr; /* last matching rule */ 3317c478bd9Sstevel@tonic-gate void *fin_dp; /* start of data past IP header */ 3327c478bd9Sstevel@tonic-gate int fin_dlen; /* length of data portion of packet */ 3337c478bd9Sstevel@tonic-gate int fin_plen; 334ab25eeb5Syz int fin_flen; /* length of layer 4 hdr and 3357663b816Sml ipv6 ext hdr after fragment hdr */ 336ab25eeb5Syz int fin_ipoff; /* # bytes from buffer start to hdr */ 3377663b816Sml u_32_t fin_id; /* IP packet id field */ 3387c478bd9Sstevel@tonic-gate u_short fin_off; 3397c478bd9Sstevel@tonic-gate int fin_depth; /* Group nesting depth */ 3407c478bd9Sstevel@tonic-gate int fin_error; /* Error code to return */ 3417c478bd9Sstevel@tonic-gate void *fin_nat; 3427c478bd9Sstevel@tonic-gate void *fin_state; 3437c478bd9Sstevel@tonic-gate void *fin_nattag; 344d6c23f6fSyx union { 345d6c23f6fSyx ip_t *fip_ip; 346d6c23f6fSyx #ifdef USE_INET6 347d6c23f6fSyx ip6_t *fip_ip6; 348d6c23f6fSyx #endif 349d6c23f6fSyx } fin_ipu; 3507c478bd9Sstevel@tonic-gate mb_t **fin_mp; /* pointer to pointer to mbuf */ 3517c478bd9Sstevel@tonic-gate mb_t *fin_m; /* pointer to mbuf */ 3527c478bd9Sstevel@tonic-gate #ifdef MENTAT 3537c478bd9Sstevel@tonic-gate mb_t *fin_qfm; /* pointer to mblk where pkt starts */ 354ab25eeb5Syz void *fin_qpi; 355f4b3ec61Sdh ipf_stack_t *fin_ifs; 356ab25eeb5Syz #endif 357ab25eeb5Syz #ifdef __sgi 358ab25eeb5Syz void *fin_hbuf; 3597c478bd9Sstevel@tonic-gate #endif 3607c478bd9Sstevel@tonic-gate } fr_info_t; 3617c478bd9Sstevel@tonic-gate 362d6c23f6fSyx #define fin_ip fin_ipu.fip_ip 363d6c23f6fSyx #define fin_ip6 fin_ipu.fip_ip6 3647c478bd9Sstevel@tonic-gate #define fin_v fin_fi.fi_v 3657c478bd9Sstevel@tonic-gate #define fin_p fin_fi.fi_p 3667c478bd9Sstevel@tonic-gate #define fin_flx fin_fi.fi_flx 3677c478bd9Sstevel@tonic-gate #define fin_optmsk fin_fi.fi_optmsk 3687c478bd9Sstevel@tonic-gate #define fin_secmsk fin_fi.fi_secmsk 3697c478bd9Sstevel@tonic-gate #define fin_auth fin_fi.fi_auth 3707c478bd9Sstevel@tonic-gate #define fin_src fin_fi.fi_src.in4 3717c478bd9Sstevel@tonic-gate #define fin_saddr fin_fi.fi_saddr 3727c478bd9Sstevel@tonic-gate #define fin_dst fin_fi.fi_dst.in4 3737c478bd9Sstevel@tonic-gate #define fin_daddr fin_fi.fi_daddr 3747c478bd9Sstevel@tonic-gate #define fin_data fin_dat.fid_16 3757c478bd9Sstevel@tonic-gate #define fin_sport fin_dat.fid_16[0] 3767c478bd9Sstevel@tonic-gate #define fin_dport fin_dat.fid_16[1] 3777c478bd9Sstevel@tonic-gate #define fin_ports fin_dat.fid_32 3787c478bd9Sstevel@tonic-gate 379d6c23f6fSyx #ifdef USE_INET6 380d6c23f6fSyx # define fin_src6 fin_fi.fi_src 381d6c23f6fSyx # define fin_dst6 fin_fi.fi_dst 382d6c23f6fSyx # define fin_dstip6 fin_fi.fi_dst.in6 383d6c23f6fSyx # define fin_srcip6 fin_fi.fi_src.in6 384d6c23f6fSyx #endif 385d6c23f6fSyx 3867c478bd9Sstevel@tonic-gate #define IPF_IN 0 3877c478bd9Sstevel@tonic-gate #define IPF_OUT 1 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gate typedef struct frentry *(*ipfunc_t) __P((fr_info_t *, u_32_t *)); 390f4b3ec61Sdh typedef int (*ipfuncinit_t) __P((struct frentry *, 391f4b3ec61Sdh ipf_stack_t *)); 3927c478bd9Sstevel@tonic-gate 3937c478bd9Sstevel@tonic-gate typedef struct ipfunc_resolve { 3947c478bd9Sstevel@tonic-gate char ipfu_name[32]; 3957c478bd9Sstevel@tonic-gate ipfunc_t ipfu_addr; 3967c478bd9Sstevel@tonic-gate ipfuncinit_t ipfu_init; 3977c478bd9Sstevel@tonic-gate } ipfunc_resolve_t; 3987c478bd9Sstevel@tonic-gate 3997c478bd9Sstevel@tonic-gate /* 4007c478bd9Sstevel@tonic-gate * Size for compares on fr_info structures 4017c478bd9Sstevel@tonic-gate */ 4027c478bd9Sstevel@tonic-gate #define FI_CSIZE offsetof(fr_info_t, fin_icode) 4037c478bd9Sstevel@tonic-gate #define FI_LCSIZE offsetof(fr_info_t, fin_dp) 4047c478bd9Sstevel@tonic-gate 4057c478bd9Sstevel@tonic-gate /* 4067c478bd9Sstevel@tonic-gate * Size for copying cache fr_info structure 4077c478bd9Sstevel@tonic-gate */ 4087c478bd9Sstevel@tonic-gate #define FI_COPYSIZE offsetof(fr_info_t, fin_dp) 4097c478bd9Sstevel@tonic-gate 4107c478bd9Sstevel@tonic-gate /* 411ab25eeb5Syz * Structure for holding IPFilter's tag information 4127c478bd9Sstevel@tonic-gate */ 413ab25eeb5Syz #define IPFTAG_LEN 16 4147c478bd9Sstevel@tonic-gate typedef struct { 4157c478bd9Sstevel@tonic-gate union { 4167c478bd9Sstevel@tonic-gate u_32_t iptu_num[4]; 417ab25eeb5Syz char iptu_tag[IPFTAG_LEN]; 4187c478bd9Sstevel@tonic-gate } ipt_un; 4197c478bd9Sstevel@tonic-gate int ipt_not; 4207c478bd9Sstevel@tonic-gate } ipftag_t; 4217c478bd9Sstevel@tonic-gate 4227c478bd9Sstevel@tonic-gate #define ipt_tag ipt_un.iptu_tag 4237c478bd9Sstevel@tonic-gate #define ipt_num ipt_un.iptu_num 4247c478bd9Sstevel@tonic-gate 4257c478bd9Sstevel@tonic-gate 4267c478bd9Sstevel@tonic-gate /* 4277c478bd9Sstevel@tonic-gate * This structure is used to hold information about the next hop for where 4287c478bd9Sstevel@tonic-gate * to forward a packet. 4297c478bd9Sstevel@tonic-gate */ 4307c478bd9Sstevel@tonic-gate typedef struct frdest { 4317c478bd9Sstevel@tonic-gate void *fd_ifp; 4327c478bd9Sstevel@tonic-gate i6addr_t fd_ip6; 4337c478bd9Sstevel@tonic-gate char fd_ifname[LIFNAMSIZ]; 4347c478bd9Sstevel@tonic-gate } frdest_t; 4357c478bd9Sstevel@tonic-gate 4367c478bd9Sstevel@tonic-gate #define fd_ip fd_ip6.in4 4377c478bd9Sstevel@tonic-gate 4387c478bd9Sstevel@tonic-gate 4397c478bd9Sstevel@tonic-gate /* 4407c478bd9Sstevel@tonic-gate * This structure holds information about a port comparison. 4417c478bd9Sstevel@tonic-gate */ 4427c478bd9Sstevel@tonic-gate typedef struct frpcmp { 4437c478bd9Sstevel@tonic-gate int frp_cmp; /* data for port comparisons */ 4447c478bd9Sstevel@tonic-gate u_short frp_port; /* top port for <> and >< */ 4457c478bd9Sstevel@tonic-gate u_short frp_top; /* top port for <> and >< */ 4467c478bd9Sstevel@tonic-gate } frpcmp_t; 4477c478bd9Sstevel@tonic-gate 4487c478bd9Sstevel@tonic-gate #define FR_NONE 0 4497c478bd9Sstevel@tonic-gate #define FR_EQUAL 1 4507c478bd9Sstevel@tonic-gate #define FR_NEQUAL 2 4517c478bd9Sstevel@tonic-gate #define FR_LESST 3 4527c478bd9Sstevel@tonic-gate #define FR_GREATERT 4 4537c478bd9Sstevel@tonic-gate #define FR_LESSTE 5 4547c478bd9Sstevel@tonic-gate #define FR_GREATERTE 6 4557c478bd9Sstevel@tonic-gate #define FR_OUTRANGE 7 4567c478bd9Sstevel@tonic-gate #define FR_INRANGE 8 4577c478bd9Sstevel@tonic-gate #define FR_INCRANGE 9 4587c478bd9Sstevel@tonic-gate 4597c478bd9Sstevel@tonic-gate /* 4607c478bd9Sstevel@tonic-gate * Structure containing all the relevant TCP things that can be checked in 4617c478bd9Sstevel@tonic-gate * a filter rule. 4627c478bd9Sstevel@tonic-gate */ 4637c478bd9Sstevel@tonic-gate typedef struct frtuc { 4647c478bd9Sstevel@tonic-gate u_char ftu_tcpfm; /* tcp flags mask */ 4657c478bd9Sstevel@tonic-gate u_char ftu_tcpf; /* tcp flags */ 4667c478bd9Sstevel@tonic-gate frpcmp_t ftu_src; 4677c478bd9Sstevel@tonic-gate frpcmp_t ftu_dst; 4687c478bd9Sstevel@tonic-gate } frtuc_t; 4697c478bd9Sstevel@tonic-gate 4707c478bd9Sstevel@tonic-gate #define ftu_scmp ftu_src.frp_cmp 4717c478bd9Sstevel@tonic-gate #define ftu_dcmp ftu_dst.frp_cmp 4727c478bd9Sstevel@tonic-gate #define ftu_sport ftu_src.frp_port 4737c478bd9Sstevel@tonic-gate #define ftu_dport ftu_dst.frp_port 4747c478bd9Sstevel@tonic-gate #define ftu_stop ftu_src.frp_top 4757c478bd9Sstevel@tonic-gate #define ftu_dtop ftu_dst.frp_top 4767c478bd9Sstevel@tonic-gate 4777c478bd9Sstevel@tonic-gate #define FR_TCPFMAX 0x3f 4787c478bd9Sstevel@tonic-gate 4797c478bd9Sstevel@tonic-gate /* 4807c478bd9Sstevel@tonic-gate * This structure makes up what is considered to be the IPFilter specific 4817c478bd9Sstevel@tonic-gate * matching components of a filter rule, as opposed to the data structures 4827c478bd9Sstevel@tonic-gate * used to define the result which are in frentry_t and not here. 4837c478bd9Sstevel@tonic-gate */ 4847c478bd9Sstevel@tonic-gate typedef struct fripf { 485ab25eeb5Syz fr_ip_t fri_ip; 486ab25eeb5Syz fr_ip_t fri_mip; /* mask structure */ 4877c478bd9Sstevel@tonic-gate 4887c478bd9Sstevel@tonic-gate u_short fri_icmpm; /* data for ICMP packets (mask) */ 4897c478bd9Sstevel@tonic-gate u_short fri_icmp; 4907c478bd9Sstevel@tonic-gate 4917c478bd9Sstevel@tonic-gate frtuc_t fri_tuc; 4927c478bd9Sstevel@tonic-gate int fri_satype; /* addres type */ 4937c478bd9Sstevel@tonic-gate int fri_datype; /* addres type */ 4947c478bd9Sstevel@tonic-gate int fri_sifpidx; /* doing dynamic addressing */ 4957c478bd9Sstevel@tonic-gate int fri_difpidx; /* index into fr_ifps[] to use when */ 4967c478bd9Sstevel@tonic-gate } fripf_t; 4977c478bd9Sstevel@tonic-gate 4987c478bd9Sstevel@tonic-gate #define fri_dstnum fri_ip.fi_dstnum 4997c478bd9Sstevel@tonic-gate #define fri_srcnum fri_mip.fi_srcnum 5007c478bd9Sstevel@tonic-gate #define fri_dstptr fri_ip.fi_dstptr 5017c478bd9Sstevel@tonic-gate #define fri_srcptr fri_mip.fi_srcptr 5027c478bd9Sstevel@tonic-gate 5037c478bd9Sstevel@tonic-gate #define FRI_NORMAL 0 /* Normal address */ 5047c478bd9Sstevel@tonic-gate #define FRI_DYNAMIC 1 /* dynamic address */ 5057c478bd9Sstevel@tonic-gate #define FRI_LOOKUP 2 /* address is a pool # */ 5067c478bd9Sstevel@tonic-gate #define FRI_RANGE 3 /* address/mask is a range */ 5077c478bd9Sstevel@tonic-gate #define FRI_NETWORK 4 /* network address from if */ 5087c478bd9Sstevel@tonic-gate #define FRI_BROADCAST 5 /* broadcast address from if */ 5097c478bd9Sstevel@tonic-gate #define FRI_PEERADDR 6 /* Peer address for P-to-P */ 5107c478bd9Sstevel@tonic-gate #define FRI_NETMASKED 7 /* network address with netmask from if */ 5117c478bd9Sstevel@tonic-gate 5127c478bd9Sstevel@tonic-gate 5137c478bd9Sstevel@tonic-gate typedef struct frentry * (* frentfunc_t) __P((fr_info_t *)); 5147c478bd9Sstevel@tonic-gate 5157c478bd9Sstevel@tonic-gate typedef struct frentry { 5167c478bd9Sstevel@tonic-gate ipfmutex_t fr_lock; 5177c478bd9Sstevel@tonic-gate struct frentry *fr_next; 5187c478bd9Sstevel@tonic-gate struct frentry **fr_grp; 5197c478bd9Sstevel@tonic-gate struct ipscan *fr_isc; 5207c478bd9Sstevel@tonic-gate void *fr_ifas[4]; 5217c478bd9Sstevel@tonic-gate void *fr_ptr; /* for use with fr_arg */ 5227c478bd9Sstevel@tonic-gate char *fr_comment; /* text comment for rule */ 5237c478bd9Sstevel@tonic-gate int fr_ref; /* reference count - for grouping */ 5247c478bd9Sstevel@tonic-gate int fr_statecnt; /* state count - for limit rules */ 5257c478bd9Sstevel@tonic-gate /* 5267c478bd9Sstevel@tonic-gate * These are only incremented when a packet matches this rule and 5277c478bd9Sstevel@tonic-gate * it is the last match 5287c478bd9Sstevel@tonic-gate */ 5297c478bd9Sstevel@tonic-gate U_QUAD_T fr_hits; 5307c478bd9Sstevel@tonic-gate U_QUAD_T fr_bytes; 5317c478bd9Sstevel@tonic-gate 5327c478bd9Sstevel@tonic-gate /* 5337c478bd9Sstevel@tonic-gate * For PPS rate limiting 5347c478bd9Sstevel@tonic-gate */ 5357c478bd9Sstevel@tonic-gate struct timeval fr_lastpkt; 5367c478bd9Sstevel@tonic-gate int fr_curpps; 5377c478bd9Sstevel@tonic-gate 5387c478bd9Sstevel@tonic-gate union { 5397c478bd9Sstevel@tonic-gate void *fru_data; 5407c478bd9Sstevel@tonic-gate caddr_t fru_caddr; 5417c478bd9Sstevel@tonic-gate fripf_t *fru_ipf; 5427c478bd9Sstevel@tonic-gate frentfunc_t fru_func; 5437c478bd9Sstevel@tonic-gate } fr_dun; 5447c478bd9Sstevel@tonic-gate 5457c478bd9Sstevel@tonic-gate /* 5467c478bd9Sstevel@tonic-gate * Fields after this may not change whilst in the kernel. 5477c478bd9Sstevel@tonic-gate */ 5487c478bd9Sstevel@tonic-gate ipfunc_t fr_func; /* call this function */ 5497c478bd9Sstevel@tonic-gate int fr_dsize; 5507c478bd9Sstevel@tonic-gate int fr_pps; 5517c478bd9Sstevel@tonic-gate int fr_statemax; /* max reference count */ 5527c478bd9Sstevel@tonic-gate int fr_flineno; /* line number from conf file */ 5537c478bd9Sstevel@tonic-gate u_32_t fr_type; 5547c478bd9Sstevel@tonic-gate u_32_t fr_flags; /* per-rule flags && options (see below) */ 5557c478bd9Sstevel@tonic-gate u_32_t fr_logtag; /* user defined log tag # */ 5567c478bd9Sstevel@tonic-gate u_32_t fr_collect; /* collection number */ 5577c478bd9Sstevel@tonic-gate u_int fr_arg; /* misc. numeric arg for rule */ 5587c478bd9Sstevel@tonic-gate u_int fr_loglevel; /* syslog log facility + priority */ 5597c478bd9Sstevel@tonic-gate u_int fr_age[2]; /* non-TCP timeouts */ 5607c478bd9Sstevel@tonic-gate u_char fr_v; 5617c478bd9Sstevel@tonic-gate u_char fr_icode; /* return ICMP code */ 5627c478bd9Sstevel@tonic-gate char fr_group[FR_GROUPLEN]; /* group to which this rule belongs */ 5637c478bd9Sstevel@tonic-gate char fr_grhead[FR_GROUPLEN]; /* group # which this rule starts */ 564ab25eeb5Syz ipftag_t fr_nattag; 5657c478bd9Sstevel@tonic-gate char fr_ifnames[4][LIFNAMSIZ]; 5667c478bd9Sstevel@tonic-gate char fr_isctag[16]; 567ab25eeb5Syz frdest_t fr_tifs[2]; /* "to"/"reply-to" interface */ 568ab25eeb5Syz frdest_t fr_dif; /* duplicate packet interface */ 5697c478bd9Sstevel@tonic-gate /* 5707c478bd9Sstevel@tonic-gate * This must be last and will change after loaded into the kernel. 5717c478bd9Sstevel@tonic-gate */ 5727c478bd9Sstevel@tonic-gate u_int fr_cksum; /* checksum on filter rules for performance */ 5737c478bd9Sstevel@tonic-gate } frentry_t; 5747c478bd9Sstevel@tonic-gate 5757c478bd9Sstevel@tonic-gate #define fr_caddr fr_dun.fru_caddr 5767c478bd9Sstevel@tonic-gate #define fr_data fr_dun.fru_data 5777c478bd9Sstevel@tonic-gate #define fr_dfunc fr_dun.fru_func 5787c478bd9Sstevel@tonic-gate #define fr_ipf fr_dun.fru_ipf 5797c478bd9Sstevel@tonic-gate #define fr_ip fr_ipf->fri_ip 5807c478bd9Sstevel@tonic-gate #define fr_mip fr_ipf->fri_mip 5817c478bd9Sstevel@tonic-gate #define fr_icmpm fr_ipf->fri_icmpm 5827c478bd9Sstevel@tonic-gate #define fr_icmp fr_ipf->fri_icmp 5837c478bd9Sstevel@tonic-gate #define fr_tuc fr_ipf->fri_tuc 5847c478bd9Sstevel@tonic-gate #define fr_satype fr_ipf->fri_satype 5857c478bd9Sstevel@tonic-gate #define fr_datype fr_ipf->fri_datype 5867c478bd9Sstevel@tonic-gate #define fr_sifpidx fr_ipf->fri_sifpidx 5877c478bd9Sstevel@tonic-gate #define fr_difpidx fr_ipf->fri_difpidx 5887c478bd9Sstevel@tonic-gate #define fr_proto fr_ip.fi_p 5897c478bd9Sstevel@tonic-gate #define fr_mproto fr_mip.fi_p 5907c478bd9Sstevel@tonic-gate #define fr_ttl fr_ip.fi_ttl 5917c478bd9Sstevel@tonic-gate #define fr_mttl fr_mip.fi_ttl 5927c478bd9Sstevel@tonic-gate #define fr_tos fr_ip.fi_tos 5937c478bd9Sstevel@tonic-gate #define fr_mtos fr_mip.fi_tos 5947c478bd9Sstevel@tonic-gate #define fr_tcpfm fr_tuc.ftu_tcpfm 5957c478bd9Sstevel@tonic-gate #define fr_tcpf fr_tuc.ftu_tcpf 5967c478bd9Sstevel@tonic-gate #define fr_scmp fr_tuc.ftu_scmp 5977c478bd9Sstevel@tonic-gate #define fr_dcmp fr_tuc.ftu_dcmp 5987c478bd9Sstevel@tonic-gate #define fr_dport fr_tuc.ftu_dport 5997c478bd9Sstevel@tonic-gate #define fr_sport fr_tuc.ftu_sport 6007c478bd9Sstevel@tonic-gate #define fr_stop fr_tuc.ftu_stop 6017c478bd9Sstevel@tonic-gate #define fr_dtop fr_tuc.ftu_dtop 6027c478bd9Sstevel@tonic-gate #define fr_dst fr_ip.fi_dst.in4 6037c478bd9Sstevel@tonic-gate #define fr_daddr fr_ip.fi_dst.in4.s_addr 6047c478bd9Sstevel@tonic-gate #define fr_src fr_ip.fi_src.in4 6057c478bd9Sstevel@tonic-gate #define fr_saddr fr_ip.fi_src.in4.s_addr 6067c478bd9Sstevel@tonic-gate #define fr_dmsk fr_mip.fi_dst.in4 6077c478bd9Sstevel@tonic-gate #define fr_dmask fr_mip.fi_dst.in4.s_addr 6087c478bd9Sstevel@tonic-gate #define fr_smsk fr_mip.fi_src.in4 6097c478bd9Sstevel@tonic-gate #define fr_smask fr_mip.fi_src.in4.s_addr 6107c478bd9Sstevel@tonic-gate #define fr_dstnum fr_ip.fi_dstnum 6117c478bd9Sstevel@tonic-gate #define fr_srcnum fr_ip.fi_srcnum 6127c478bd9Sstevel@tonic-gate #define fr_dsttype fr_ip.fi_dsttype 6137c478bd9Sstevel@tonic-gate #define fr_srctype fr_ip.fi_srctype 6147c478bd9Sstevel@tonic-gate #define fr_dstptr fr_mip.fi_dstptr 6157c478bd9Sstevel@tonic-gate #define fr_srcptr fr_mip.fi_srcptr 6167c478bd9Sstevel@tonic-gate #define fr_dstfunc fr_mip.fi_dstfunc 6177c478bd9Sstevel@tonic-gate #define fr_srcfunc fr_mip.fi_srcfunc 6187c478bd9Sstevel@tonic-gate #define fr_optbits fr_ip.fi_optmsk 6197c478bd9Sstevel@tonic-gate #define fr_optmask fr_mip.fi_optmsk 6207c478bd9Sstevel@tonic-gate #define fr_secbits fr_ip.fi_secmsk 6217c478bd9Sstevel@tonic-gate #define fr_secmask fr_mip.fi_secmsk 6227c478bd9Sstevel@tonic-gate #define fr_authbits fr_ip.fi_auth 6237c478bd9Sstevel@tonic-gate #define fr_authmask fr_mip.fi_auth 6247c478bd9Sstevel@tonic-gate #define fr_flx fr_ip.fi_flx 6257c478bd9Sstevel@tonic-gate #define fr_mflx fr_mip.fi_flx 6267c478bd9Sstevel@tonic-gate #define fr_ifname fr_ifnames[0] 6277c478bd9Sstevel@tonic-gate #define fr_oifname fr_ifnames[2] 6287c478bd9Sstevel@tonic-gate #define fr_ifa fr_ifas[0] 6297c478bd9Sstevel@tonic-gate #define fr_oifa fr_ifas[2] 6307c478bd9Sstevel@tonic-gate #define fr_tif fr_tifs[0] 6317c478bd9Sstevel@tonic-gate #define fr_rif fr_tifs[1] 6327c478bd9Sstevel@tonic-gate 6337c478bd9Sstevel@tonic-gate #define FR_NOLOGTAG 0 6347c478bd9Sstevel@tonic-gate 6357c478bd9Sstevel@tonic-gate #ifndef offsetof 6367c478bd9Sstevel@tonic-gate #define offsetof(t,m) (int)((&((t *)0L)->m)) 6377c478bd9Sstevel@tonic-gate #endif 6387c478bd9Sstevel@tonic-gate #define FR_CMPSIZ (sizeof(struct frentry) - \ 639ab25eeb5Syz offsetof(struct frentry, fr_func)) 6407c478bd9Sstevel@tonic-gate 6417c478bd9Sstevel@tonic-gate /* 6427c478bd9Sstevel@tonic-gate * fr_type 6437c478bd9Sstevel@tonic-gate */ 6447c478bd9Sstevel@tonic-gate #define FR_T_NONE 0 6457c478bd9Sstevel@tonic-gate #define FR_T_IPF 1 /* IPF structures */ 6467c478bd9Sstevel@tonic-gate #define FR_T_BPFOPC 2 /* BPF opcode */ 6477c478bd9Sstevel@tonic-gate #define FR_T_CALLFUNC 3 /* callout to function in fr_func only */ 6487c478bd9Sstevel@tonic-gate #define FR_T_COMPIPF 4 /* compiled C code */ 6497c478bd9Sstevel@tonic-gate #define FR_T_BUILTIN 0x80000000 /* rule is in kernel space */ 6507c478bd9Sstevel@tonic-gate 6517c478bd9Sstevel@tonic-gate /* 6527c478bd9Sstevel@tonic-gate * fr_flags 6537c478bd9Sstevel@tonic-gate */ 6547c478bd9Sstevel@tonic-gate #define FR_CALL 0x00000 /* call rule */ 6557c478bd9Sstevel@tonic-gate #define FR_BLOCK 0x00001 /* do not allow packet to pass */ 6567c478bd9Sstevel@tonic-gate #define FR_PASS 0x00002 /* allow packet to pass */ 6577c478bd9Sstevel@tonic-gate #define FR_AUTH 0x00003 /* use authentication */ 6587c478bd9Sstevel@tonic-gate #define FR_PREAUTH 0x00004 /* require preauthentication */ 6597c478bd9Sstevel@tonic-gate #define FR_ACCOUNT 0x00005 /* Accounting rule */ 6607c478bd9Sstevel@tonic-gate #define FR_SKIP 0x00006 /* skip rule */ 6617c478bd9Sstevel@tonic-gate #define FR_DIVERT 0x00007 /* divert rule */ 6627c478bd9Sstevel@tonic-gate #define FR_CMDMASK 0x0000f 6637c478bd9Sstevel@tonic-gate #define FR_LOG 0x00010 /* Log */ 6647c478bd9Sstevel@tonic-gate #define FR_LOGB 0x00011 /* Log-fail */ 6657c478bd9Sstevel@tonic-gate #define FR_LOGP 0x00012 /* Log-pass */ 6667c478bd9Sstevel@tonic-gate #define FR_LOGMASK (FR_LOG|FR_CMDMASK) 6677c478bd9Sstevel@tonic-gate #define FR_CALLNOW 0x00020 /* call another function (fr_func) if matches */ 6687c478bd9Sstevel@tonic-gate #define FR_NOTSRCIP 0x00040 6697c478bd9Sstevel@tonic-gate #define FR_NOTDSTIP 0x00080 6707c478bd9Sstevel@tonic-gate #define FR_QUICK 0x00100 /* match & stop processing list */ 6717c478bd9Sstevel@tonic-gate #define FR_KEEPFRAG 0x00200 /* keep fragment information */ 6727c478bd9Sstevel@tonic-gate #define FR_KEEPSTATE 0x00400 /* keep `connection' state information */ 6737c478bd9Sstevel@tonic-gate #define FR_FASTROUTE 0x00800 /* bypass normal routing */ 6747c478bd9Sstevel@tonic-gate #define FR_RETRST 0x01000 /* Return TCP RST packet - reset connection */ 6757c478bd9Sstevel@tonic-gate #define FR_RETICMP 0x02000 /* Return ICMP unreachable packet */ 6767c478bd9Sstevel@tonic-gate #define FR_FAKEICMP 0x03000 /* Return ICMP unreachable with fake source */ 6777c478bd9Sstevel@tonic-gate #define FR_OUTQUE 0x04000 /* outgoing packets */ 6787c478bd9Sstevel@tonic-gate #define FR_INQUE 0x08000 /* ingoing packets */ 6797c478bd9Sstevel@tonic-gate #define FR_LOGBODY 0x10000 /* Log the body */ 6807c478bd9Sstevel@tonic-gate #define FR_LOGFIRST 0x20000 /* Log the first byte if state held */ 6817c478bd9Sstevel@tonic-gate #define FR_LOGORBLOCK 0x40000 /* block the packet if it can't be logged */ 6827c478bd9Sstevel@tonic-gate #define FR_DUP 0x80000 /* duplicate packet */ 6837c478bd9Sstevel@tonic-gate #define FR_FRSTRICT 0x100000 /* strict frag. cache */ 6847c478bd9Sstevel@tonic-gate #define FR_STSTRICT 0x200000 /* strict keep state */ 6857c478bd9Sstevel@tonic-gate #define FR_NEWISN 0x400000 /* new ISN for outgoing TCP */ 6867c478bd9Sstevel@tonic-gate #define FR_NOICMPERR 0x800000 /* do not match ICMP errors in state */ 687ab25eeb5Syz #define FR_STATESYNC 0x1000000 /* synchronize state to slave */ 6887c478bd9Sstevel@tonic-gate #define FR_NOMATCH 0x8000000 /* no match occured */ 6897c478bd9Sstevel@tonic-gate /* 0x10000000 FF_LOGPASS */ 6907c478bd9Sstevel@tonic-gate /* 0x20000000 FF_LOGBLOCK */ 6917c478bd9Sstevel@tonic-gate /* 0x40000000 FF_LOGNOMATCH */ 6927c478bd9Sstevel@tonic-gate /* 0x80000000 FF_BLOCKNONIP */ 6937c478bd9Sstevel@tonic-gate #define FR_COPIED 0x40000000 /* copied from user space */ 6947c478bd9Sstevel@tonic-gate #define FR_INACTIVE 0x80000000 /* only used when flush'ing rules */ 6957c478bd9Sstevel@tonic-gate 6967c478bd9Sstevel@tonic-gate #define FR_RETMASK (FR_RETICMP|FR_RETRST|FR_FAKEICMP) 6977c478bd9Sstevel@tonic-gate #define FR_ISBLOCK(x) (((x) & FR_CMDMASK) == FR_BLOCK) 6987c478bd9Sstevel@tonic-gate #define FR_ISPASS(x) (((x) & FR_CMDMASK) == FR_PASS) 6997c478bd9Sstevel@tonic-gate #define FR_ISAUTH(x) (((x) & FR_CMDMASK) == FR_AUTH) 7007c478bd9Sstevel@tonic-gate #define FR_ISPREAUTH(x) (((x) & FR_CMDMASK) == FR_PREAUTH) 7017c478bd9Sstevel@tonic-gate #define FR_ISACCOUNT(x) (((x) & FR_CMDMASK) == FR_ACCOUNT) 7027c478bd9Sstevel@tonic-gate #define FR_ISSKIP(x) (((x) & FR_CMDMASK) == FR_SKIP) 7037c478bd9Sstevel@tonic-gate #define FR_ISNOMATCH(x) ((x) & FR_NOMATCH) 7047c478bd9Sstevel@tonic-gate #define FR_INOUT (FR_INQUE|FR_OUTQUE) 7057c478bd9Sstevel@tonic-gate 7067c478bd9Sstevel@tonic-gate /* 7077c478bd9Sstevel@tonic-gate * recognized flags for SIOCGETFF and SIOCSETFF, and get put in fr_flags 7087c478bd9Sstevel@tonic-gate */ 7097c478bd9Sstevel@tonic-gate #define FF_LOGPASS 0x10000000 7107c478bd9Sstevel@tonic-gate #define FF_LOGBLOCK 0x20000000 7117c478bd9Sstevel@tonic-gate #define FF_LOGNOMATCH 0x40000000 7127c478bd9Sstevel@tonic-gate #define FF_LOGGING (FF_LOGPASS|FF_LOGBLOCK|FF_LOGNOMATCH) 7137c478bd9Sstevel@tonic-gate #define FF_BLOCKNONIP 0x80000000 /* Solaris2 Only */ 7147c478bd9Sstevel@tonic-gate 7157c478bd9Sstevel@tonic-gate 7167c478bd9Sstevel@tonic-gate /* 7177c478bd9Sstevel@tonic-gate * Structure that passes information on what/how to flush to the kernel. 7187c478bd9Sstevel@tonic-gate */ 7197c478bd9Sstevel@tonic-gate typedef struct ipfflush { 7207c478bd9Sstevel@tonic-gate int ipflu_how; 7217c478bd9Sstevel@tonic-gate int ipflu_arg; 7227c478bd9Sstevel@tonic-gate } ipfflush_t; 7237c478bd9Sstevel@tonic-gate 7247c478bd9Sstevel@tonic-gate 7257c478bd9Sstevel@tonic-gate /* 7267c478bd9Sstevel@tonic-gate * 7277c478bd9Sstevel@tonic-gate */ 7287c478bd9Sstevel@tonic-gate typedef struct ipfgetctl { 7297c478bd9Sstevel@tonic-gate u_int ipfg_min; /* min value */ 7307c478bd9Sstevel@tonic-gate u_int ipfg_current; /* current value */ 7317c478bd9Sstevel@tonic-gate u_int ipfg_max; /* max value */ 7327c478bd9Sstevel@tonic-gate u_int ipfg_default; /* default value */ 7337c478bd9Sstevel@tonic-gate u_int ipfg_steps; /* value increments */ 7347c478bd9Sstevel@tonic-gate char ipfg_name[40]; /* tag name for this control */ 7357c478bd9Sstevel@tonic-gate } ipfgetctl_t; 7367c478bd9Sstevel@tonic-gate 7377c478bd9Sstevel@tonic-gate typedef struct ipfsetctl { 7387c478bd9Sstevel@tonic-gate int ipfs_which; /* 0 = min 1 = current 2 = max 3 = default */ 7397c478bd9Sstevel@tonic-gate u_int ipfs_value; /* min value */ 7407c478bd9Sstevel@tonic-gate char ipfs_name[40]; /* tag name for this control */ 7417c478bd9Sstevel@tonic-gate } ipfsetctl_t; 7427c478bd9Sstevel@tonic-gate 7437c478bd9Sstevel@tonic-gate 7447c478bd9Sstevel@tonic-gate /* 7457c478bd9Sstevel@tonic-gate * Some of the statistics below are in their own counters, but most are kept 7467c478bd9Sstevel@tonic-gate * in this single structure so that they can all easily be collected and 7477c478bd9Sstevel@tonic-gate * copied back as required. 748e0b463afSschuster * 749e0b463afSschuster * NOTE: when changing, keep in sync with kstats (below). 7507c478bd9Sstevel@tonic-gate */ 7517c478bd9Sstevel@tonic-gate typedef struct filterstats { 7527c478bd9Sstevel@tonic-gate u_long fr_pass; /* packets allowed */ 7537c478bd9Sstevel@tonic-gate u_long fr_block; /* packets denied */ 7547c478bd9Sstevel@tonic-gate u_long fr_nom; /* packets which don't match any rule */ 7557c478bd9Sstevel@tonic-gate u_long fr_short; /* packets which are short */ 7567c478bd9Sstevel@tonic-gate u_long fr_ppkl; /* packets allowed and logged */ 7577c478bd9Sstevel@tonic-gate u_long fr_bpkl; /* packets denied and logged */ 7587c478bd9Sstevel@tonic-gate u_long fr_npkl; /* packets unmatched and logged */ 7597c478bd9Sstevel@tonic-gate u_long fr_pkl; /* packets logged */ 7607c478bd9Sstevel@tonic-gate u_long fr_skip; /* packets to be logged but buffer full */ 7617c478bd9Sstevel@tonic-gate u_long fr_ret; /* packets for which a return is sent */ 7627c478bd9Sstevel@tonic-gate u_long fr_acct; /* packets for which counting was performed */ 7637c478bd9Sstevel@tonic-gate u_long fr_bnfr; /* bad attempts to allocate fragment state */ 7647c478bd9Sstevel@tonic-gate u_long fr_nfr; /* new fragment state kept */ 7657c478bd9Sstevel@tonic-gate u_long fr_cfr; /* add new fragment state but complete pkt */ 7667c478bd9Sstevel@tonic-gate u_long fr_bads; /* bad attempts to allocate packet state */ 7677c478bd9Sstevel@tonic-gate u_long fr_ads; /* new packet state kept */ 7687c478bd9Sstevel@tonic-gate u_long fr_chit; /* cached hit */ 7697c478bd9Sstevel@tonic-gate u_long fr_tcpbad; /* TCP checksum check failures */ 7707c478bd9Sstevel@tonic-gate u_long fr_pull[2]; /* good and bad pullup attempts */ 7717c478bd9Sstevel@tonic-gate u_long fr_badsrc; /* source received doesn't match route */ 7727c478bd9Sstevel@tonic-gate u_long fr_badttl; /* TTL in packet doesn't reach minimum */ 7737c478bd9Sstevel@tonic-gate u_long fr_bad; /* bad IP packets to the filter */ 7747c478bd9Sstevel@tonic-gate u_long fr_ipv6; /* IPv6 packets in/out */ 7757c478bd9Sstevel@tonic-gate u_long fr_ppshit; /* dropped because of pps ceiling */ 7767c478bd9Sstevel@tonic-gate u_long fr_ipud; /* IP id update failures */ 7777c478bd9Sstevel@tonic-gate } filterstats_t; 7787c478bd9Sstevel@tonic-gate 779e0b463afSschuster /* 780e0b463afSschuster * kstat "copy" of the above - keep in sync! 781e0b463afSschuster * also keep in sync with initialisation code in solaris.c, ipf_kstat_init(). 782e0b463afSschuster */ 783e0b463afSschuster typedef struct filter_kstats { 784e0b463afSschuster kstat_named_t fks_pass; /* see above for comments */ 785e0b463afSschuster kstat_named_t fks_block; 786e0b463afSschuster kstat_named_t fks_nom; 787e0b463afSschuster kstat_named_t fks_short; 788e0b463afSschuster kstat_named_t fks_ppkl; 789e0b463afSschuster kstat_named_t fks_bpkl; 790e0b463afSschuster kstat_named_t fks_npkl; 791e0b463afSschuster kstat_named_t fks_pkl; 792e0b463afSschuster kstat_named_t fks_skip; 793e0b463afSschuster kstat_named_t fks_ret; 794e0b463afSschuster kstat_named_t fks_acct; 795e0b463afSschuster kstat_named_t fks_bnfr; 796e0b463afSschuster kstat_named_t fks_nfr; 797e0b463afSschuster kstat_named_t fks_cfr; 798e0b463afSschuster kstat_named_t fks_bads; 799e0b463afSschuster kstat_named_t fks_ads; 800e0b463afSschuster kstat_named_t fks_chit; 801e0b463afSschuster kstat_named_t fks_tcpbad; 802e0b463afSschuster kstat_named_t fks_pull[2]; 803e0b463afSschuster kstat_named_t fks_badsrc; 804e0b463afSschuster kstat_named_t fks_badttl; 805e0b463afSschuster kstat_named_t fks_bad; 806e0b463afSschuster kstat_named_t fks_ipv6; 807e0b463afSschuster kstat_named_t fks_ppshit; 808e0b463afSschuster kstat_named_t fks_ipud; 809e0b463afSschuster } filter_kstats_t; 810e0b463afSschuster 8117c478bd9Sstevel@tonic-gate /* 8127c478bd9Sstevel@tonic-gate * Log structure. Each packet header logged is prepended by one of these. 8137c478bd9Sstevel@tonic-gate * Following this in the log records read from the device will be an ipflog 8147c478bd9Sstevel@tonic-gate * structure which is then followed by any packet data. 8157c478bd9Sstevel@tonic-gate */ 8167c478bd9Sstevel@tonic-gate typedef struct iplog { 8177c478bd9Sstevel@tonic-gate u_32_t ipl_magic; 8187c478bd9Sstevel@tonic-gate u_int ipl_count; 819ab25eeb5Syz struct timeval ipl_time; 8207c478bd9Sstevel@tonic-gate size_t ipl_dsize; 8217c478bd9Sstevel@tonic-gate struct iplog *ipl_next; 8227c478bd9Sstevel@tonic-gate } iplog_t; 8237c478bd9Sstevel@tonic-gate 824ab25eeb5Syz #define ipl_sec ipl_time.tv_sec 825ab25eeb5Syz #define ipl_usec ipl_time.tv_usec 8267c478bd9Sstevel@tonic-gate 8277c478bd9Sstevel@tonic-gate #define IPL_MAGIC 0x49504c4d /* 'IPLM' */ 828ab25eeb5Syz #define IPL_MAGIC_NAT 0x49504c4e /* 'IPLN' */ 829ab25eeb5Syz #define IPL_MAGIC_STATE 0x49504c53 /* 'IPLS' */ 8307c478bd9Sstevel@tonic-gate #define IPLOG_SIZE sizeof(iplog_t) 8317c478bd9Sstevel@tonic-gate 8327c478bd9Sstevel@tonic-gate typedef struct ipflog { 8337c478bd9Sstevel@tonic-gate #if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \ 8347c478bd9Sstevel@tonic-gate (defined(OpenBSD) && (OpenBSD >= 199603)) 8357c478bd9Sstevel@tonic-gate #else 8367c478bd9Sstevel@tonic-gate u_int fl_unit; 8377c478bd9Sstevel@tonic-gate #endif 8387c478bd9Sstevel@tonic-gate u_32_t fl_rule; 8397c478bd9Sstevel@tonic-gate u_32_t fl_flags; 8407c478bd9Sstevel@tonic-gate u_32_t fl_lflags; 841ab25eeb5Syz u_32_t fl_logtag; 842ab25eeb5Syz ipftag_t fl_nattag; 8437c478bd9Sstevel@tonic-gate u_short fl_plen; /* extra data after hlen */ 8447c478bd9Sstevel@tonic-gate u_short fl_loglevel; /* syslog log level */ 8457c478bd9Sstevel@tonic-gate char fl_group[FR_GROUPLEN]; 8467c478bd9Sstevel@tonic-gate u_char fl_hlen; /* length of IP headers saved */ 8477c478bd9Sstevel@tonic-gate u_char fl_dir; 848ab25eeb5Syz u_char fl_xxx[2]; /* pad */ 8497c478bd9Sstevel@tonic-gate char fl_ifname[LIFNAMSIZ]; 8507c478bd9Sstevel@tonic-gate } ipflog_t; 8517c478bd9Sstevel@tonic-gate 8527c478bd9Sstevel@tonic-gate #ifndef IPF_LOGGING 8537c478bd9Sstevel@tonic-gate # define IPF_LOGGING 0 8547c478bd9Sstevel@tonic-gate #endif 8557c478bd9Sstevel@tonic-gate #ifndef IPF_DEFAULT_PASS 8567c478bd9Sstevel@tonic-gate # define IPF_DEFAULT_PASS FR_PASS 8577c478bd9Sstevel@tonic-gate #endif 8587c478bd9Sstevel@tonic-gate 8597c478bd9Sstevel@tonic-gate #define DEFAULT_IPFLOGSIZE 8192 8607c478bd9Sstevel@tonic-gate #ifndef IPFILTER_LOGSIZE 8617c478bd9Sstevel@tonic-gate # define IPFILTER_LOGSIZE DEFAULT_IPFLOGSIZE 8627c478bd9Sstevel@tonic-gate #else 863ab25eeb5Syz # if IPFILTER_LOGSIZE < DEFAULT_IPFLOGSIZE 864ab25eeb5Syz # error IPFILTER_LOGSIZE too small. Must be >= DEFAULT_IPFLOGSIZE 8657c478bd9Sstevel@tonic-gate # endif 8667c478bd9Sstevel@tonic-gate #endif 8677c478bd9Sstevel@tonic-gate 8687c478bd9Sstevel@tonic-gate #define IPF_OPTCOPY 0x07ff00 /* bit mask of copied options */ 8697c478bd9Sstevel@tonic-gate 8707c478bd9Sstevel@tonic-gate /* 8717c478bd9Sstevel@tonic-gate * Device filenames for reading log information. Use ipf on Solaris2 because 8727c478bd9Sstevel@tonic-gate * ipl is already a name used by something else. 8737c478bd9Sstevel@tonic-gate */ 8747c478bd9Sstevel@tonic-gate #ifndef IPL_NAME 8757c478bd9Sstevel@tonic-gate # if SOLARIS 8767c478bd9Sstevel@tonic-gate # define IPL_NAME "/dev/ipf" 8777c478bd9Sstevel@tonic-gate # else 8787c478bd9Sstevel@tonic-gate # define IPL_NAME "/dev/ipl" 8797c478bd9Sstevel@tonic-gate # endif 8807c478bd9Sstevel@tonic-gate #endif 8817c478bd9Sstevel@tonic-gate /* 8827c478bd9Sstevel@tonic-gate * Pathnames for various IP Filter control devices. Used by LKM 8837c478bd9Sstevel@tonic-gate * and userland, so defined here. 8847c478bd9Sstevel@tonic-gate */ 8857c478bd9Sstevel@tonic-gate #define IPNAT_NAME "/dev/ipnat" 8867c478bd9Sstevel@tonic-gate #define IPSTATE_NAME "/dev/ipstate" 8877c478bd9Sstevel@tonic-gate #define IPAUTH_NAME "/dev/ipauth" 8887c478bd9Sstevel@tonic-gate #define IPSYNC_NAME "/dev/ipsync" 8897c478bd9Sstevel@tonic-gate #define IPSCAN_NAME "/dev/ipscan" 8907c478bd9Sstevel@tonic-gate #define IPLOOKUP_NAME "/dev/iplookup" 8917c478bd9Sstevel@tonic-gate 8927c478bd9Sstevel@tonic-gate #define IPL_LOGIPF 0 /* Minor device #'s for accessing logs */ 8937c478bd9Sstevel@tonic-gate #define IPL_LOGNAT 1 8947c478bd9Sstevel@tonic-gate #define IPL_LOGSTATE 2 8957c478bd9Sstevel@tonic-gate #define IPL_LOGAUTH 3 8967c478bd9Sstevel@tonic-gate #define IPL_LOGSYNC 4 8977c478bd9Sstevel@tonic-gate #define IPL_LOGSCAN 5 8987c478bd9Sstevel@tonic-gate #define IPL_LOGLOOKUP 6 8997c478bd9Sstevel@tonic-gate #define IPL_LOGCOUNT 7 9007c478bd9Sstevel@tonic-gate #define IPL_LOGMAX 7 901f4b3ec61Sdh #define IPL_LOGSIZE (IPL_LOGMAX + 1) 9027c478bd9Sstevel@tonic-gate #define IPL_LOGALL -1 9037c478bd9Sstevel@tonic-gate #define IPL_LOGNONE -2 9047c478bd9Sstevel@tonic-gate 9057c478bd9Sstevel@tonic-gate /* 9067c478bd9Sstevel@tonic-gate * For SIOCGETFS 9077c478bd9Sstevel@tonic-gate */ 9087c478bd9Sstevel@tonic-gate typedef struct friostat { 9097c478bd9Sstevel@tonic-gate struct filterstats f_st[2]; 9107c478bd9Sstevel@tonic-gate struct frentry *f_ipf[2][2]; 9117c478bd9Sstevel@tonic-gate struct frentry *f_acct[2][2]; 9127c478bd9Sstevel@tonic-gate struct frentry *f_ipf6[2][2]; 9137c478bd9Sstevel@tonic-gate struct frentry *f_acct6[2][2]; 9147c478bd9Sstevel@tonic-gate struct frentry *f_auth; 9157c478bd9Sstevel@tonic-gate struct frgroup *f_groups[IPL_LOGSIZE][2]; 9167c478bd9Sstevel@tonic-gate u_long f_froute[2]; 9177c478bd9Sstevel@tonic-gate u_long f_ticks; 9187c478bd9Sstevel@tonic-gate int f_locks[IPL_LOGMAX]; 9197c478bd9Sstevel@tonic-gate size_t f_kmutex_sz; 9207c478bd9Sstevel@tonic-gate size_t f_krwlock_sz; 9217c478bd9Sstevel@tonic-gate int f_defpass; /* default pass - from fr_pass */ 922ab25eeb5Syz int f_active; /* 1 or 0 - active rule set */ 923ab25eeb5Syz int f_running; /* 1 if running, else 0 */ 924ab25eeb5Syz int f_logging; /* 1 if enabled, else 0 */ 925ab25eeb5Syz int f_features; 9267c478bd9Sstevel@tonic-gate char f_version[32]; /* version string */ 9277c478bd9Sstevel@tonic-gate } friostat_t; 9287c478bd9Sstevel@tonic-gate 9297c478bd9Sstevel@tonic-gate #define f_fin f_ipf[0] 9307c478bd9Sstevel@tonic-gate #define f_fin6 f_ipf6[0] 9317c478bd9Sstevel@tonic-gate #define f_fout f_ipf[1] 9327c478bd9Sstevel@tonic-gate #define f_fout6 f_ipf6[1] 9337c478bd9Sstevel@tonic-gate #define f_acctin f_acct[0] 9347c478bd9Sstevel@tonic-gate #define f_acctin6 f_acct6[0] 9357c478bd9Sstevel@tonic-gate #define f_acctout f_acct[1] 9367c478bd9Sstevel@tonic-gate #define f_acctout6 f_acct6[1] 9377c478bd9Sstevel@tonic-gate 938ab25eeb5Syz #define IPF_FEAT_LKM 0x001 939ab25eeb5Syz #define IPF_FEAT_LOG 0x002 940ab25eeb5Syz #define IPF_FEAT_LOOKUP 0x004 941ab25eeb5Syz #define IPF_FEAT_BPF 0x008 942ab25eeb5Syz #define IPF_FEAT_COMPILED 0x010 943ab25eeb5Syz #define IPF_FEAT_CKSUM 0x020 944ab25eeb5Syz #define IPF_FEAT_SYNC 0x040 945ab25eeb5Syz #define IPF_FEAT_SCAN 0x080 946ab25eeb5Syz #define IPF_FEAT_IPV6 0x100 9477c478bd9Sstevel@tonic-gate 9487c478bd9Sstevel@tonic-gate typedef struct optlist { 9497c478bd9Sstevel@tonic-gate u_short ol_val; 9507c478bd9Sstevel@tonic-gate int ol_bit; 9517c478bd9Sstevel@tonic-gate } optlist_t; 9527c478bd9Sstevel@tonic-gate 9537c478bd9Sstevel@tonic-gate 9547c478bd9Sstevel@tonic-gate /* 9557c478bd9Sstevel@tonic-gate * Group list structure. 9567c478bd9Sstevel@tonic-gate */ 9577c478bd9Sstevel@tonic-gate typedef struct frgroup { 9587c478bd9Sstevel@tonic-gate struct frgroup *fg_next; 9597c478bd9Sstevel@tonic-gate struct frentry *fg_head; 9607c478bd9Sstevel@tonic-gate struct frentry *fg_start; 9617c478bd9Sstevel@tonic-gate u_32_t fg_flags; 9627c478bd9Sstevel@tonic-gate int fg_ref; 9637c478bd9Sstevel@tonic-gate char fg_name[FR_GROUPLEN]; 9647c478bd9Sstevel@tonic-gate } frgroup_t; 9657c478bd9Sstevel@tonic-gate 9667c478bd9Sstevel@tonic-gate #define FG_NAME(g) (*(g)->fg_name == '\0' ? "" : (g)->fg_name) 9677c478bd9Sstevel@tonic-gate 9687c478bd9Sstevel@tonic-gate 9697c478bd9Sstevel@tonic-gate /* 9707c478bd9Sstevel@tonic-gate * Used by state and NAT tables 9717c478bd9Sstevel@tonic-gate */ 9727c478bd9Sstevel@tonic-gate typedef struct icmpinfo { 9737c478bd9Sstevel@tonic-gate u_short ici_id; 9747c478bd9Sstevel@tonic-gate u_short ici_seq; 9757c478bd9Sstevel@tonic-gate u_char ici_type; 9767c478bd9Sstevel@tonic-gate } icmpinfo_t; 9777c478bd9Sstevel@tonic-gate 9787c478bd9Sstevel@tonic-gate typedef struct udpinfo { 9797c478bd9Sstevel@tonic-gate u_short us_sport; 9807c478bd9Sstevel@tonic-gate u_short us_dport; 9817c478bd9Sstevel@tonic-gate } udpinfo_t; 9827c478bd9Sstevel@tonic-gate 9837c478bd9Sstevel@tonic-gate 9847c478bd9Sstevel@tonic-gate typedef struct tcpdata { 9857c478bd9Sstevel@tonic-gate u_32_t td_end; 9867c478bd9Sstevel@tonic-gate u_32_t td_maxend; 9877c478bd9Sstevel@tonic-gate u_32_t td_maxwin; 9887c478bd9Sstevel@tonic-gate u_32_t td_winscale; 9897c478bd9Sstevel@tonic-gate u_32_t td_maxseg; 9907c478bd9Sstevel@tonic-gate int td_winflags; 9917c478bd9Sstevel@tonic-gate } tcpdata_t; 9927c478bd9Sstevel@tonic-gate 9937c478bd9Sstevel@tonic-gate #define TCP_WSCALE_MAX 14 9947c478bd9Sstevel@tonic-gate 9957c478bd9Sstevel@tonic-gate #define TCP_WSCALE_SEEN 0x00000001 9967c478bd9Sstevel@tonic-gate #define TCP_WSCALE_FIRST 0x00000002 997f17d2b41San #define TCP_SACK_PERMIT 0x00000004 9987c478bd9Sstevel@tonic-gate 9997c478bd9Sstevel@tonic-gate 10007c478bd9Sstevel@tonic-gate typedef struct tcpinfo { 10017c478bd9Sstevel@tonic-gate u_short ts_sport; 10027c478bd9Sstevel@tonic-gate u_short ts_dport; 10037c478bd9Sstevel@tonic-gate tcpdata_t ts_data[2]; 10047c478bd9Sstevel@tonic-gate } tcpinfo_t; 10057c478bd9Sstevel@tonic-gate 1006ab25eeb5Syz 1007ab25eeb5Syz /* 1008ab25eeb5Syz * Structures to define a GRE header as seen in a packet. 1009ab25eeb5Syz */ 1010ab25eeb5Syz struct grebits { 1011ab25eeb5Syz u_32_t grb_C:1; 1012ab25eeb5Syz u_32_t grb_R:1; 1013ab25eeb5Syz u_32_t grb_K:1; 1014ab25eeb5Syz u_32_t grb_S:1; 1015ab25eeb5Syz u_32_t grb_s:1; 1016ab25eeb5Syz u_32_t grb_recur:1; 1017ab25eeb5Syz u_32_t grb_A:1; 1018ab25eeb5Syz u_32_t grb_flags:3; 1019ab25eeb5Syz u_32_t grb_ver:3; 1020ab25eeb5Syz u_short grb_ptype; 1021ab25eeb5Syz }; 10227c478bd9Sstevel@tonic-gate 10237c478bd9Sstevel@tonic-gate typedef struct grehdr { 10247c478bd9Sstevel@tonic-gate union { 1025ab25eeb5Syz struct grebits gru_bits; 10267c478bd9Sstevel@tonic-gate u_short gru_flags; 10277c478bd9Sstevel@tonic-gate } gr_un; 10287c478bd9Sstevel@tonic-gate u_short gr_len; 10297c478bd9Sstevel@tonic-gate u_short gr_call; 10307c478bd9Sstevel@tonic-gate } grehdr_t; 10317c478bd9Sstevel@tonic-gate 1032ab25eeb5Syz #define gr_flags gr_un.gru_flags 10337c478bd9Sstevel@tonic-gate #define gr_bits gr_un.gru_bits 1034ab25eeb5Syz #define gr_ptype gr_bits.grb_ptype 1035ab25eeb5Syz #define gr_C gr_bits.grb_C 1036ab25eeb5Syz #define gr_R gr_bits.grb_R 1037ab25eeb5Syz #define gr_K gr_bits.grb_K 1038ab25eeb5Syz #define gr_S gr_bits.grb_S 1039ab25eeb5Syz #define gr_s gr_bits.grb_s 1040ab25eeb5Syz #define gr_recur gr_bits.grb_recur 1041ab25eeb5Syz #define gr_A gr_bits.grb_A 1042ab25eeb5Syz #define gr_ver gr_bits.grb_ver 1043ab25eeb5Syz 1044ab25eeb5Syz /* 1045ab25eeb5Syz * GRE information tracked by "keep state" 1046ab25eeb5Syz */ 1047ab25eeb5Syz typedef struct greinfo { 1048ab25eeb5Syz u_short gs_call[2]; 1049ab25eeb5Syz u_short gs_flags; 1050ab25eeb5Syz u_short gs_ptype; 1051ab25eeb5Syz } greinfo_t; 1052ab25eeb5Syz 1053ab25eeb5Syz #define GRE_REV(x) ((ntohs(x) >> 13) & 7) 1054ab25eeb5Syz 1055ab25eeb5Syz 1056ab25eeb5Syz /* 1057ab25eeb5Syz * Format of an Authentication header 1058ab25eeb5Syz */ 1059ab25eeb5Syz typedef struct authhdr { 1060ab25eeb5Syz u_char ah_next; 1061ab25eeb5Syz u_char ah_plen; 1062ab25eeb5Syz u_short ah_reserved; 1063ab25eeb5Syz u_32_t ah_spi; 1064ab25eeb5Syz u_32_t ah_seq; 1065ab25eeb5Syz /* Following the sequence number field is 0 or more bytes of */ 1066ab25eeb5Syz /* authentication data, as specified by ah_plen - RFC 2402. */ 1067ab25eeb5Syz } authhdr_t; 10687c478bd9Sstevel@tonic-gate 10697c478bd9Sstevel@tonic-gate 10707c478bd9Sstevel@tonic-gate /* 10717c478bd9Sstevel@tonic-gate * Timeout tail queue list member 10727c478bd9Sstevel@tonic-gate */ 10737c478bd9Sstevel@tonic-gate typedef struct ipftqent { 10747c478bd9Sstevel@tonic-gate struct ipftqent **tqe_pnext; 10757c478bd9Sstevel@tonic-gate struct ipftqent *tqe_next; 10767c478bd9Sstevel@tonic-gate struct ipftq *tqe_ifq; 10777c478bd9Sstevel@tonic-gate void *tqe_parent; /* pointer back to NAT/state struct */ 10787c478bd9Sstevel@tonic-gate u_long tqe_die; /* when this entriy is to die */ 10797c478bd9Sstevel@tonic-gate u_long tqe_touched; 10807c478bd9Sstevel@tonic-gate int tqe_flags; 10817c478bd9Sstevel@tonic-gate int tqe_state[2]; /* current state of this entry */ 10827c478bd9Sstevel@tonic-gate } ipftqent_t; 10837c478bd9Sstevel@tonic-gate 10847c478bd9Sstevel@tonic-gate #define TQE_RULEBASED 0x00000001 10857c478bd9Sstevel@tonic-gate 10867c478bd9Sstevel@tonic-gate 10877c478bd9Sstevel@tonic-gate /* 10887c478bd9Sstevel@tonic-gate * Timeout tail queue head for IPFilter 10897c478bd9Sstevel@tonic-gate */ 10907c478bd9Sstevel@tonic-gate typedef struct ipftq { 10917c478bd9Sstevel@tonic-gate ipfmutex_t ifq_lock; 10927c478bd9Sstevel@tonic-gate u_int ifq_ttl; 10937c478bd9Sstevel@tonic-gate ipftqent_t *ifq_head; 10947c478bd9Sstevel@tonic-gate ipftqent_t **ifq_tail; 10957c478bd9Sstevel@tonic-gate struct ipftq *ifq_next; 10967c478bd9Sstevel@tonic-gate struct ipftq **ifq_pnext; 10977c478bd9Sstevel@tonic-gate int ifq_ref; 10987c478bd9Sstevel@tonic-gate u_int ifq_flags; 10997c478bd9Sstevel@tonic-gate } ipftq_t; 11007c478bd9Sstevel@tonic-gate 11017c478bd9Sstevel@tonic-gate #define IFQF_USER 0x01 /* User defined aging */ 1102ab25eeb5Syz #define IFQF_DELETE 0x02 /* Marked for deletion */ 1103ab25eeb5Syz #define IFQF_PROXY 0x04 /* Timeout queue in use by a proxy */ 11047c478bd9Sstevel@tonic-gate 11057c478bd9Sstevel@tonic-gate #define IPF_HZ_MULT 1 11067c478bd9Sstevel@tonic-gate #define IPF_HZ_DIVIDE 2 /* How many times a second ipfilter */ 11077c478bd9Sstevel@tonic-gate /* checks its timeout queues. */ 11087c478bd9Sstevel@tonic-gate #define IPF_TTLVAL(x) (((x) / IPF_HZ_MULT) * IPF_HZ_DIVIDE) 11097c478bd9Sstevel@tonic-gate 11107c478bd9Sstevel@tonic-gate /* 11117c478bd9Sstevel@tonic-gate * Structure to define address for pool lookups. 11127c478bd9Sstevel@tonic-gate */ 11137c478bd9Sstevel@tonic-gate typedef struct { 11147c478bd9Sstevel@tonic-gate u_char adf_len; 11157663b816Sml sa_family_t adf_family; 11167c478bd9Sstevel@tonic-gate i6addr_t adf_addr; 11177c478bd9Sstevel@tonic-gate } addrfamily_t; 11187c478bd9Sstevel@tonic-gate 11197c478bd9Sstevel@tonic-gate 11207c478bd9Sstevel@tonic-gate /* 11217c478bd9Sstevel@tonic-gate * Object structure description. For passing through in ioctls. 11227c478bd9Sstevel@tonic-gate */ 11237c478bd9Sstevel@tonic-gate typedef struct ipfobj { 11247c478bd9Sstevel@tonic-gate u_32_t ipfo_rev; /* IPFilter version number */ 11257c478bd9Sstevel@tonic-gate u_32_t ipfo_size; /* size of object at ipfo_ptr */ 11267c478bd9Sstevel@tonic-gate void *ipfo_ptr; /* pointer to object */ 11277c478bd9Sstevel@tonic-gate int ipfo_type; /* type of object being pointed to */ 11287c478bd9Sstevel@tonic-gate int ipfo_offset; /* bytes from ipfo_ptr where to start */ 11297c478bd9Sstevel@tonic-gate u_char ipfo_xxxpad[32]; /* reserved for future use */ 11307c478bd9Sstevel@tonic-gate } ipfobj_t; 11317c478bd9Sstevel@tonic-gate 11327c478bd9Sstevel@tonic-gate #define IPFOBJ_FRENTRY 0 /* struct frentry */ 11337c478bd9Sstevel@tonic-gate #define IPFOBJ_IPFSTAT 1 /* struct friostat */ 11347c478bd9Sstevel@tonic-gate #define IPFOBJ_IPFINFO 2 /* struct fr_info */ 11357c478bd9Sstevel@tonic-gate #define IPFOBJ_AUTHSTAT 3 /* struct fr_authstat */ 11367c478bd9Sstevel@tonic-gate #define IPFOBJ_FRAGSTAT 4 /* struct ipfrstat */ 11377c478bd9Sstevel@tonic-gate #define IPFOBJ_IPNAT 5 /* struct ipnat */ 11387c478bd9Sstevel@tonic-gate #define IPFOBJ_NATSTAT 6 /* struct natstat */ 11397c478bd9Sstevel@tonic-gate #define IPFOBJ_STATESAVE 7 /* struct ipstate_save */ 11407c478bd9Sstevel@tonic-gate #define IPFOBJ_NATSAVE 8 /* struct nat_save */ 11417c478bd9Sstevel@tonic-gate #define IPFOBJ_NATLOOKUP 9 /* struct natlookup */ 11427c478bd9Sstevel@tonic-gate #define IPFOBJ_IPSTATE 10 /* struct ipstate */ 11437c478bd9Sstevel@tonic-gate #define IPFOBJ_STATESTAT 11 /* struct ips_stat */ 11447c478bd9Sstevel@tonic-gate #define IPFOBJ_FRAUTH 12 /* struct frauth */ 11457c478bd9Sstevel@tonic-gate #define IPFOBJ_TUNEABLE 13 /* struct ipftune */ 1146f4b3ec61Sdh #define IPFOBJ_NAT 14 /* struct nat */ 1147f4b3ec61Sdh #define IPFOBJ_IPFITER 15 /* struct ipfruleiter */ 1148f4b3ec61Sdh #define IPFOBJ_GENITER 16 /* struct ipfgeniter */ 1149f4b3ec61Sdh #define IPFOBJ_GTABLE 17 /* struct ipftable */ 1150f4b3ec61Sdh #define IPFOBJ_LOOKUPITER 18 /* struct ipflookupiter */ 1151f4b3ec61Sdh #define IPFOBJ_COUNT 19 /* How many #defines are above this? */ 11527c478bd9Sstevel@tonic-gate 11537c478bd9Sstevel@tonic-gate 11547c478bd9Sstevel@tonic-gate typedef union ipftunevalptr { 11557c478bd9Sstevel@tonic-gate void *ipftp_void; 11567c478bd9Sstevel@tonic-gate u_long *ipftp_long; 11577c478bd9Sstevel@tonic-gate u_int *ipftp_int; 11587c478bd9Sstevel@tonic-gate u_short *ipftp_short; 11597c478bd9Sstevel@tonic-gate u_char *ipftp_char; 11607c478bd9Sstevel@tonic-gate } ipftunevalptr_t; 11617c478bd9Sstevel@tonic-gate 11627c478bd9Sstevel@tonic-gate typedef struct ipftuneable { 11637c478bd9Sstevel@tonic-gate ipftunevalptr_t ipft_una; 11647c478bd9Sstevel@tonic-gate char *ipft_name; 11657c478bd9Sstevel@tonic-gate u_long ipft_min; 11667c478bd9Sstevel@tonic-gate u_long ipft_max; 11677c478bd9Sstevel@tonic-gate int ipft_sz; 11687c478bd9Sstevel@tonic-gate int ipft_flags; 1169ab25eeb5Syz struct ipftuneable *ipft_next; 11707c478bd9Sstevel@tonic-gate } ipftuneable_t; 11717c478bd9Sstevel@tonic-gate 11727c478bd9Sstevel@tonic-gate #define ipft_addr ipft_una.ipftp_void 11737c478bd9Sstevel@tonic-gate #define ipft_plong ipft_una.ipftp_long 11747c478bd9Sstevel@tonic-gate #define ipft_pint ipft_una.ipftp_int 11757c478bd9Sstevel@tonic-gate #define ipft_pshort ipft_una.ipftp_short 11767c478bd9Sstevel@tonic-gate #define ipft_pchar ipft_una.ipftp_char 11777c478bd9Sstevel@tonic-gate 11787c478bd9Sstevel@tonic-gate #define IPFT_RDONLY 1 /* read-only */ 11797c478bd9Sstevel@tonic-gate #define IPFT_WRDISABLED 2 /* write when disabled only */ 11807c478bd9Sstevel@tonic-gate 11817c478bd9Sstevel@tonic-gate typedef union ipftuneval { 11827c478bd9Sstevel@tonic-gate u_long ipftu_long; 11837c478bd9Sstevel@tonic-gate u_int ipftu_int; 11847c478bd9Sstevel@tonic-gate u_short ipftu_short; 11857c478bd9Sstevel@tonic-gate u_char ipftu_char; 11867c478bd9Sstevel@tonic-gate } ipftuneval_t; 11877c478bd9Sstevel@tonic-gate 11887c478bd9Sstevel@tonic-gate typedef struct ipftune { 11897c478bd9Sstevel@tonic-gate void *ipft_cookie; 11907c478bd9Sstevel@tonic-gate ipftuneval_t ipft_un; 11917c478bd9Sstevel@tonic-gate u_long ipft_min; 11927c478bd9Sstevel@tonic-gate u_long ipft_max; 11937c478bd9Sstevel@tonic-gate int ipft_sz; 11947c478bd9Sstevel@tonic-gate int ipft_flags; 11957c478bd9Sstevel@tonic-gate char ipft_name[80]; 11967c478bd9Sstevel@tonic-gate } ipftune_t; 11977c478bd9Sstevel@tonic-gate 11987c478bd9Sstevel@tonic-gate #define ipft_vlong ipft_un.ipftu_long 11997c478bd9Sstevel@tonic-gate #define ipft_vint ipft_un.ipftu_int 12007c478bd9Sstevel@tonic-gate #define ipft_vshort ipft_un.ipftu_short 12017c478bd9Sstevel@tonic-gate #define ipft_vchar ipft_un.ipftu_char 12027c478bd9Sstevel@tonic-gate 120390b0a856Sjojemann /* 120490b0a856Sjojemann * ipfruleiter is iterator structure used for filter rules. 120590b0a856Sjojemann */ 1206f4b3ec61Sdh typedef struct ipfruleiter { 1207f4b3ec61Sdh int iri_ver; 1208f4b3ec61Sdh int iri_inout; 1209f4b3ec61Sdh char iri_group[FR_GROUPLEN]; 1210f4b3ec61Sdh int iri_active; 121190b0a856Sjojemann int iri_nrules; 1212f4b3ec61Sdh frentry_t *iri_rule; 1213f4b3ec61Sdh } ipfruleiter_t; 1214f4b3ec61Sdh 121590b0a856Sjojemann /* Values for iri_inout */ 121690b0a856Sjojemann #define F_IN 0 121790b0a856Sjojemann #define F_OUT 1 121890b0a856Sjojemann #define F_ACIN 2 121990b0a856Sjojemann #define F_ACOUT 3 122090b0a856Sjojemann 122190b0a856Sjojemann /* 122290b0a856Sjojemann * ipfgeniter is generic iterator structure used for nat rules, 122390b0a856Sjojemann * hostmap entries and nat table entries. 122490b0a856Sjojemann */ 1225f4b3ec61Sdh typedef struct ipfgeniter { 122690b0a856Sjojemann int igi_type; /* type of data we're looking at */ 122790b0a856Sjojemann int igi_nitems; 1228f4b3ec61Sdh void *igi_data; 1229f4b3ec61Sdh } ipfgeniter_t; 1230f4b3ec61Sdh 1231f4b3ec61Sdh #define IPFGENITER_IPF 0 1232f4b3ec61Sdh #define IPFGENITER_NAT 1 1233f4b3ec61Sdh #define IPFGENITER_IPNAT 2 1234f4b3ec61Sdh #define IPFGENITER_FRAG 3 1235f4b3ec61Sdh #define IPFGENITER_AUTH 4 1236f4b3ec61Sdh #define IPFGENITER_STATE 5 1237f4b3ec61Sdh #define IPFGENITER_NATFRAG 6 1238f4b3ec61Sdh #define IPFGENITER_HOSTMAP 7 1239f4b3ec61Sdh #define IPFGENITER_LOOKUP 8 1240f4b3ec61Sdh 1241f4b3ec61Sdh typedef struct ipftable { 1242f4b3ec61Sdh int ita_type; 1243f4b3ec61Sdh void *ita_table; 1244f4b3ec61Sdh } ipftable_t; 1245f4b3ec61Sdh 1246f4b3ec61Sdh typedef struct ipftoken { 1247f4b3ec61Sdh struct ipftoken *ipt_next; 1248f4b3ec61Sdh struct ipftoken **ipt_pnext; 1249f4b3ec61Sdh void *ipt_ctx; 1250f4b3ec61Sdh void *ipt_data; 1251f4b3ec61Sdh u_long ipt_die; 1252f4b3ec61Sdh int ipt_type; 1253f4b3ec61Sdh int ipt_uid; 1254f4b3ec61Sdh int ipt_subtype; 1255f4b3ec61Sdh int ipt_alive; 1256f4b3ec61Sdh } ipftoken_t; 1257f4b3ec61Sdh 1258f4b3ec61Sdh 1259381a2a9aSdr /* 1260381a2a9aSdr * sync commands 1261381a2a9aSdr */ 1262381a2a9aSdr #define IPFSYNC_RESYNC 0 1263381a2a9aSdr #define IPFSYNC_NEWIFP 1 1264381a2a9aSdr #define IPFSYNC_OLDIFP 2 1265381a2a9aSdr 1266381a2a9aSdr 12677c478bd9Sstevel@tonic-gate /* 12687c478bd9Sstevel@tonic-gate ** HPUX Port 12697c478bd9Sstevel@tonic-gate */ 12707c478bd9Sstevel@tonic-gate #ifdef __hpux 12717c478bd9Sstevel@tonic-gate /* HP-UX locking sequence deadlock detection module lock MAJOR ID */ 12727c478bd9Sstevel@tonic-gate # define IPF_SMAJ 0 /* temp assignment XXX, not critical */ 12737c478bd9Sstevel@tonic-gate #endif 12747c478bd9Sstevel@tonic-gate 12757c478bd9Sstevel@tonic-gate #if !defined(CDEV_MAJOR) && defined (__FreeBSD_version) && \ 12767c478bd9Sstevel@tonic-gate (__FreeBSD_version >= 220000) 12777c478bd9Sstevel@tonic-gate # define CDEV_MAJOR 79 12787c478bd9Sstevel@tonic-gate #endif 12797c478bd9Sstevel@tonic-gate 12807c478bd9Sstevel@tonic-gate /* 12817c478bd9Sstevel@tonic-gate * Post NetBSD 1.2 has the PFIL interface for packet filters. This turns 12827c478bd9Sstevel@tonic-gate * on those hooks. We don't need any special mods in non-IP Filter code 12837c478bd9Sstevel@tonic-gate * with this! 12847c478bd9Sstevel@tonic-gate */ 12857c478bd9Sstevel@tonic-gate #if (defined(NetBSD) && (NetBSD > 199609) && (NetBSD <= 1991011)) || \ 12867c478bd9Sstevel@tonic-gate (defined(NetBSD1_2) && NetBSD1_2 > 1) || \ 12877c478bd9Sstevel@tonic-gate (defined(__FreeBSD__) && (__FreeBSD_version >= 500043)) 12887c478bd9Sstevel@tonic-gate # if (NetBSD >= 199905) 12897c478bd9Sstevel@tonic-gate # define PFIL_HOOKS 12907c478bd9Sstevel@tonic-gate # endif 12917c478bd9Sstevel@tonic-gate # ifdef PFIL_HOOKS 12927c478bd9Sstevel@tonic-gate # define NETBSD_PF 12937c478bd9Sstevel@tonic-gate # endif 12947c478bd9Sstevel@tonic-gate #endif 12957c478bd9Sstevel@tonic-gate 12967c478bd9Sstevel@tonic-gate #ifndef _KERNEL 1297f4b3ec61Sdh extern int fr_check __P((struct ip *, int, void *, int, mb_t **, ipf_stack_t *)); 1298f4b3ec61Sdh extern int (*fr_checkp) __P((ip_t *, int, void *, int, mb_t **, ipf_stack_t *)); 12997c478bd9Sstevel@tonic-gate extern int ipf_log __P((void)); 1300f4b3ec61Sdh extern struct ifnet *get_unit __P((char *, int, ipf_stack_t *)); 13017c478bd9Sstevel@tonic-gate extern char *get_ifname __P((struct ifnet *)); 13027c478bd9Sstevel@tonic-gate # if defined(__NetBSD__) || defined(__OpenBSD__) || \ 13037c478bd9Sstevel@tonic-gate (_BSDI_VERSION >= 199701) || (__FreeBSD_version >= 300000) 1304f4b3ec61Sdh extern int frrequest __P((int, u_long, caddr_t, int, int, ipf_stack_t *)); 13057c478bd9Sstevel@tonic-gate # else 1306ab25eeb5Syz extern int iplioctl __P((int, ioctlcmd_t, caddr_t, int)); 13077c478bd9Sstevel@tonic-gate # endif 13087c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int)); 13097c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int)); 13107c478bd9Sstevel@tonic-gate extern void m_freem __P((mb_t *)); 13117c478bd9Sstevel@tonic-gate #else /* #ifndef _KERNEL */ 1312f4b3ec61Sdh extern phy_if_t get_unit __P((char *, int, ipf_stack_t *)); 13137c478bd9Sstevel@tonic-gate # if defined(__NetBSD__) && defined(PFIL_HOOKS) 13147c478bd9Sstevel@tonic-gate extern void ipfilterattach __P((int)); 13157c478bd9Sstevel@tonic-gate # endif 13167c478bd9Sstevel@tonic-gate extern int ipl_enable __P((void)); 13177c478bd9Sstevel@tonic-gate extern int ipl_disable __P((void)); 13187c478bd9Sstevel@tonic-gate # ifdef MENTAT 1319ab25eeb5Syz extern int fr_check __P((struct ip *, int, void *, int, void *, 1320f4b3ec61Sdh mblk_t **, ipf_stack_t *)); 13217c478bd9Sstevel@tonic-gate # if SOLARIS 13227c478bd9Sstevel@tonic-gate # if SOLARIS2 >= 7 13237c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, intptr_t, int, cred_t *, int *)); 13247c478bd9Sstevel@tonic-gate # else 13257c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, int *, int, cred_t *, int *)); 13267c478bd9Sstevel@tonic-gate # endif 13277c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t *, int, int, cred_t *)); 13287c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, cred_t *)); 1329ab25eeb5Syz extern int iplread __P((dev_t, uio_t *, cred_t *)); 1330ab25eeb5Syz extern int iplwrite __P((dev_t, uio_t *, cred_t *)); 13317c478bd9Sstevel@tonic-gate # endif 13327c478bd9Sstevel@tonic-gate # ifdef __hpux 13337c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int, intptr_t, int)); 13347c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int)); 13357c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int)); 1336ab25eeb5Syz extern int iplread __P((dev_t, uio_t *)); 1337ab25eeb5Syz extern int iplwrite __P((dev_t, uio_t *)); 13387c478bd9Sstevel@tonic-gate extern int iplselect __P((dev_t, int)); 13397c478bd9Sstevel@tonic-gate # endif 1340f4b3ec61Sdh extern int ipfsync __P((ipf_stack_t *)); 13417c478bd9Sstevel@tonic-gate extern int fr_qout __P((queue_t *, mblk_t *)); 13427c478bd9Sstevel@tonic-gate # else /* MENTAT */ 1343f4b3ec61Sdh extern int fr_check __P((struct ip *, int, void *, int, mb_t **, ipf_stack_t *)); 1344f4b3ec61Sdh extern int (*fr_checkp) __P((ip_t *, int, void *, int, mb_t **, ipf_stack_t *)); 13457c478bd9Sstevel@tonic-gate extern size_t mbufchainlen __P((mb_t *)); 13467c478bd9Sstevel@tonic-gate # ifdef __sgi 13477c478bd9Sstevel@tonic-gate # include <sys/cred.h> 13487c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int, cred_t *, int *)); 13497c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t *, int, int, cred_t *)); 13507c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, cred_t *)); 1351ab25eeb5Syz extern int iplread __P((dev_t, uio_t *, cred_t *)); 1352ab25eeb5Syz extern int iplwrite __P((dev_t, uio_t *, cred_t *)); 1353f4b3ec61Sdh extern int ipfsync __P((ipf_stack_t *)); 13547c478bd9Sstevel@tonic-gate extern int ipfilter_sgi_attach __P((void)); 13557c478bd9Sstevel@tonic-gate extern void ipfilter_sgi_detach __P((void)); 13567c478bd9Sstevel@tonic-gate extern void ipfilter_sgi_intfsync __P((void)); 13577c478bd9Sstevel@tonic-gate # else 13587c478bd9Sstevel@tonic-gate # ifdef IPFILTER_LKM 13597c478bd9Sstevel@tonic-gate extern int iplidentify __P((char *)); 13607c478bd9Sstevel@tonic-gate # endif 13617c478bd9Sstevel@tonic-gate # if (_BSDI_VERSION >= 199510) || (__FreeBSD_version >= 220000) || \ 13627c478bd9Sstevel@tonic-gate (NetBSD >= 199511) || defined(__OpenBSD__) 13637c478bd9Sstevel@tonic-gate # if defined(__NetBSD__) || (_BSDI_VERSION >= 199701) || \ 13647c478bd9Sstevel@tonic-gate defined(__OpenBSD__) || (__FreeBSD_version >= 300000) 13657c478bd9Sstevel@tonic-gate # if (__FreeBSD_version >= 500024) 1366ab25eeb5Syz # if (__FreeBSD_version >= 502116) 1367ab25eeb5Syz extern int iplioctl __P((struct cdev*, u_long, caddr_t, int, struct thread *)); 1368ab25eeb5Syz # else 13697c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, u_long, caddr_t, int, struct thread *)); 1370ab25eeb5Syz # endif /* __FreeBSD_version >= 502116 */ 13717c478bd9Sstevel@tonic-gate # else 13727c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); 13737c478bd9Sstevel@tonic-gate # endif /* __FreeBSD_version >= 500024 */ 13747c478bd9Sstevel@tonic-gate # else 13757c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int, struct proc *)); 13767c478bd9Sstevel@tonic-gate # endif 13777c478bd9Sstevel@tonic-gate # if (__FreeBSD_version >= 500024) 1378ab25eeb5Syz # if (__FreeBSD_version >= 502116) 1379ab25eeb5Syz extern int iplopen __P((struct cdev*, int, int, struct thread *)); 1380ab25eeb5Syz extern int iplclose __P((struct cdev*, int, int, struct thread *)); 1381ab25eeb5Syz # else 13827c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int, int, struct thread *)); 13837c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, struct thread *)); 1384ab25eeb5Syz # endif /* __FreeBSD_version >= 502116 */ 13857c478bd9Sstevel@tonic-gate # else 13867c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int, int, struct proc *)); 13877c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, struct proc *)); 13887c478bd9Sstevel@tonic-gate # endif /* __FreeBSD_version >= 500024 */ 13897c478bd9Sstevel@tonic-gate # else 1390ab25eeb5Syz # ifdef linux 1391ab25eeb5Syz extern int iplioctl __P((struct inode *, struct file *, u_int, u_long)); 1392ab25eeb5Syz # else 13937c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int)); 13947c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int)); 13957c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int)); 1396ab25eeb5Syz # endif 13977c478bd9Sstevel@tonic-gate # endif /* (_BSDI_VERSION >= 199510) */ 13987c478bd9Sstevel@tonic-gate # if BSD >= 199306 1399ab25eeb5Syz # if (__FreeBSD_version >= 502116) 1400ab25eeb5Syz extern int iplread __P((struct cdev*, struct uio *, int)); 1401ab25eeb5Syz extern int iplwrite __P((struct cdev*, struct uio *, int)); 1402ab25eeb5Syz # else 14037c478bd9Sstevel@tonic-gate extern int iplread __P((dev_t, struct uio *, int)); 1404ab25eeb5Syz extern int iplwrite __P((dev_t, struct uio *, int)); 1405ab25eeb5Syz # endif /* __FreeBSD_version >= 502116 */ 14067c478bd9Sstevel@tonic-gate # else 1407ab25eeb5Syz # ifndef linux 14087c478bd9Sstevel@tonic-gate extern int iplread __P((dev_t, struct uio *)); 1409ab25eeb5Syz extern int iplwrite __P((dev_t, struct uio *)); 1410ab25eeb5Syz # endif 14117c478bd9Sstevel@tonic-gate # endif /* BSD >= 199306 */ 14127c478bd9Sstevel@tonic-gate # endif /* __ sgi */ 14137c478bd9Sstevel@tonic-gate # endif /* MENTAT */ 14147c478bd9Sstevel@tonic-gate 14157c478bd9Sstevel@tonic-gate #endif /* #ifndef _KERNEL */ 14167c478bd9Sstevel@tonic-gate 14177c478bd9Sstevel@tonic-gate extern char *memstr __P((char *, char *, int, int)); 14187c478bd9Sstevel@tonic-gate extern int count4bits __P((u_32_t)); 14197663b816Sml extern int count6bits __P((u_32_t *)); 1420f4b3ec61Sdh extern int frrequest __P((int, ioctlcmd_t, caddr_t, int, int, ipf_stack_t *)); 14217c478bd9Sstevel@tonic-gate extern char *getifname __P((struct ifnet *)); 1422f4b3ec61Sdh extern int iplattach __P((ipf_stack_t *, netstack_t *)); 1423f4b3ec61Sdh extern int ipldetach __P((ipf_stack_t *)); 14247c478bd9Sstevel@tonic-gate extern u_short ipf_cksum __P((u_short *, int)); 14257c478bd9Sstevel@tonic-gate extern int copyinptr __P((void *, void *, size_t)); 14267c478bd9Sstevel@tonic-gate extern int copyoutptr __P((void *, void *, size_t)); 1427ab25eeb5Syz extern int fr_fastroute __P((mb_t *, mb_t **, fr_info_t *, frdest_t *)); 14287c478bd9Sstevel@tonic-gate extern int fr_inobj __P((void *, void *, int)); 1429ab25eeb5Syz extern int fr_inobjsz __P((void *, void *, int, int)); 1430d6c23f6fSyx extern int fr_ioctlswitch __P((int, void *, ioctlcmd_t, int, int, void *, 1431d6c23f6fSyx ipf_stack_t *)); 1432f4b3ec61Sdh extern int fr_ipftune __P((ioctlcmd_t, void *, ipf_stack_t *)); 14337c478bd9Sstevel@tonic-gate extern int fr_outobj __P((void *, void *, int)); 1434ab25eeb5Syz extern int fr_outobjsz __P((void *, void *, int, int)); 1435ab25eeb5Syz extern void *fr_pullup __P((mb_t *, fr_info_t *, int)); 1436f4b3ec61Sdh extern void fr_resolvedest __P((struct frdest *, int, ipf_stack_t *)); 14377c478bd9Sstevel@tonic-gate extern int fr_resolvefunc __P((void *)); 1438f4b3ec61Sdh extern void *fr_resolvenic __P((char *, int, ipf_stack_t *)); 1439ab25eeb5Syz extern int fr_send_icmp_err __P((int, fr_info_t *, int)); 1440ab25eeb5Syz extern int fr_send_reset __P((fr_info_t *)); 1441ab25eeb5Syz #if (__FreeBSD_version < 490000) || !defined(_KERNEL) 14427c478bd9Sstevel@tonic-gate extern int ppsratecheck __P((struct timeval *, int *, int)); 1443ab25eeb5Syz #endif 1444f4b3ec61Sdh extern ipftq_t *fr_addtimeoutqueue __P((ipftq_t **, u_int, ipf_stack_t *)); 1445ab25eeb5Syz extern void fr_deletequeueentry __P((ipftqent_t *)); 1446ab25eeb5Syz extern int fr_deletetimeoutqueue __P((ipftq_t *)); 1447f4b3ec61Sdh extern void fr_freetimeoutqueue __P((ipftq_t *, ipf_stack_t *)); 1448d6c23f6fSyx extern void fr_movequeue __P((ipftqent_t *, ipftq_t *, ipftq_t *, 1449d6c23f6fSyx ipf_stack_t *)); 1450d6c23f6fSyx extern void fr_queueappend __P((ipftqent_t *, ipftq_t *, void *, 1451d6c23f6fSyx ipf_stack_t *)); 1452f4b3ec61Sdh extern void fr_queueback __P((ipftqent_t *, ipf_stack_t *)); 1453ab25eeb5Syz extern void fr_queuefront __P((ipftqent_t *)); 14547c478bd9Sstevel@tonic-gate extern void fr_checkv4sum __P((fr_info_t *)); 14557c478bd9Sstevel@tonic-gate extern int fr_checkl4sum __P((fr_info_t *)); 14567c478bd9Sstevel@tonic-gate extern int fr_ifpfillv4addr __P((int, struct sockaddr_in *, 14577c478bd9Sstevel@tonic-gate struct sockaddr_in *, struct in_addr *, 14587c478bd9Sstevel@tonic-gate struct in_addr *)); 14597c478bd9Sstevel@tonic-gate extern int fr_coalesce __P((fr_info_t *)); 14607c478bd9Sstevel@tonic-gate #ifdef USE_INET6 14617c478bd9Sstevel@tonic-gate extern void fr_checkv6sum __P((fr_info_t *)); 14627c478bd9Sstevel@tonic-gate extern int fr_ifpfillv6addr __P((int, struct sockaddr_in6 *, 14637c478bd9Sstevel@tonic-gate struct sockaddr_in6 *, struct in_addr *, 14647c478bd9Sstevel@tonic-gate struct in_addr *)); 14657c478bd9Sstevel@tonic-gate #endif 14667c478bd9Sstevel@tonic-gate 1467d6c23f6fSyx #define IPFILTER_COMPAT 1468d6c23f6fSyx extern int fr_incomptrans __P((ipfobj_t *, void *)); 1469d6c23f6fSyx extern int fr_outcomptrans __P((ipfobj_t *, void *)); 1470d6c23f6fSyx 1471f4b3ec61Sdh extern int fr_addipftune __P((ipftuneable_t *, ipf_stack_t *)); 1472f4b3ec61Sdh extern int fr_delipftune __P((ipftuneable_t *, ipf_stack_t *)); 1473f4b3ec61Sdh 1474f4b3ec61Sdh extern int frflush __P((minor_t, int, int, ipf_stack_t *)); 1475f4b3ec61Sdh extern void frsync __P((int, int, void *, char *, ipf_stack_t *)); 1476f4b3ec61Sdh extern frgroup_t *fr_addgroup __P((char *, void *, u_32_t, minor_t, int, 1477f4b3ec61Sdh ipf_stack_t *)); 1478f4b3ec61Sdh extern int fr_derefrule __P((frentry_t **, ipf_stack_t *)); 1479f4b3ec61Sdh extern void fr_delgroup __P((char *, minor_t, int, ipf_stack_t *)); 1480f4b3ec61Sdh extern frgroup_t *fr_findgroup __P((char *, minor_t, int, frgroup_t ***, 1481f4b3ec61Sdh ipf_stack_t *)); 1482f4b3ec61Sdh 1483f4b3ec61Sdh extern int fr_loginit __P((ipf_stack_t *)); 1484f4b3ec61Sdh extern int ipflog_clear __P((minor_t, ipf_stack_t *)); 1485f4b3ec61Sdh extern int ipflog_read __P((minor_t, struct uio *, ipf_stack_t *)); 14867c478bd9Sstevel@tonic-gate extern int ipflog __P((fr_info_t *, u_int)); 1487f4b3ec61Sdh extern int ipllog __P((int, fr_info_t *, void **, size_t *, int *, int, 1488f4b3ec61Sdh ipf_stack_t *)); 1489f4b3ec61Sdh extern void fr_logunload __P((ipf_stack_t *)); 14907c478bd9Sstevel@tonic-gate 14917c478bd9Sstevel@tonic-gate extern frentry_t *fr_acctpkt __P((fr_info_t *, u_32_t *)); 14927c478bd9Sstevel@tonic-gate extern int fr_copytolog __P((int, char *, int)); 14937c478bd9Sstevel@tonic-gate extern u_short fr_cksum __P((mb_t *, ip_t *, int, void *)); 1494f4b3ec61Sdh extern void fr_deinitialise __P((ipf_stack_t *)); 14957c478bd9Sstevel@tonic-gate extern frentry_t *fr_dolog __P((fr_info_t *, u_32_t *)); 14967c478bd9Sstevel@tonic-gate extern frentry_t *fr_dstgrpmap __P((fr_info_t *, u_32_t *)); 14977c478bd9Sstevel@tonic-gate extern void fr_fixskip __P((frentry_t **, frentry_t *, int)); 1498f4b3ec61Sdh extern void fr_forgetifp __P((void *, ipf_stack_t *)); 1499f4b3ec61Sdh extern frentry_t *fr_getrulen __P((int, char *, u_32_t, 1500f4b3ec61Sdh ipf_stack_t *)); 1501f4b3ec61Sdh extern void fr_getstat __P((struct friostat *, ipf_stack_t *)); 15027c478bd9Sstevel@tonic-gate extern int fr_ifpaddr __P((int, int, void *, 1503f4b3ec61Sdh struct in_addr *, struct in_addr *, 1504f4b3ec61Sdh ipf_stack_t *)); 1505f4b3ec61Sdh extern int fr_initialise __P((ipf_stack_t *)); 1506ab25eeb5Syz extern void fr_lock __P((caddr_t, int *)); 15077c478bd9Sstevel@tonic-gate extern int fr_makefrip __P((int, ip_t *, fr_info_t *)); 15087c478bd9Sstevel@tonic-gate extern int fr_matchtag __P((ipftag_t *, ipftag_t *)); 15097c478bd9Sstevel@tonic-gate extern int fr_matchicmpqueryreply __P((int, icmpinfo_t *, 1510d6c23f6fSyx struct icmp *, int)); 15117c478bd9Sstevel@tonic-gate extern u_32_t fr_newisn __P((fr_info_t *)); 1512ab25eeb5Syz extern u_short fr_nextipid __P((fr_info_t *)); 1513f4b3ec61Sdh extern int fr_rulen __P((int, frentry_t *, ipf_stack_t *)); 15147c478bd9Sstevel@tonic-gate extern int fr_scanlist __P((fr_info_t *, u_32_t)); 15157c478bd9Sstevel@tonic-gate extern frentry_t *fr_srcgrpmap __P((fr_info_t *, u_32_t *)); 15167c478bd9Sstevel@tonic-gate extern int fr_tcpudpchk __P((fr_info_t *, frtuc_t *)); 15177c478bd9Sstevel@tonic-gate extern int fr_verifysrc __P((fr_info_t *fin)); 1518f4b3ec61Sdh extern int fr_zerostats __P((char *, ipf_stack_t *)); 1519d6c23f6fSyx extern ipftoken_t *ipf_findtoken __P((int, int, void *, ipf_stack_t *)); 1520d6c23f6fSyx extern int ipf_getnextrule __P((ipftoken_t *, void *, 1521d6c23f6fSyx ipf_stack_t *)); 1522f4b3ec61Sdh extern void ipf_expiretokens __P((ipf_stack_t *)); 1523d6c23f6fSyx extern void ipf_freetoken __P((ipftoken_t *, ipf_stack_t *)); 1524d6c23f6fSyx extern int ipf_deltoken __P((int,int, void *, ipf_stack_t *)); 1525d6c23f6fSyx extern int ipf_genericiter __P((void *, int, void *, 1526d6c23f6fSyx ipf_stack_t *)); 1527ab073b32Sdr #ifndef ipf_random 1528ab073b32Sdr extern u_32_t ipf_random __P((void)); 1529ab073b32Sdr #endif 1530f4b3ec61Sdh 15317c478bd9Sstevel@tonic-gate extern char ipfilter_version[]; 15327c478bd9Sstevel@tonic-gate #ifdef USE_INET6 15337c478bd9Sstevel@tonic-gate extern int icmptoicmp6types[ICMP_MAXTYPE+1]; 15347c478bd9Sstevel@tonic-gate extern int icmptoicmp6unreach[ICMP_MAX_UNREACH]; 15357c478bd9Sstevel@tonic-gate extern int icmpreplytype6[ICMP6_MAXTYPE + 1]; 15367c478bd9Sstevel@tonic-gate #endif 15377c478bd9Sstevel@tonic-gate extern int icmpreplytype4[ICMP_MAXTYPE + 1]; 15387c478bd9Sstevel@tonic-gate extern frentry_t *ipfrule_match __P((fr_info_t *)); 1539f4b3ec61Sdh 1540f4b3ec61Sdh extern void ipftuneable_alloc(ipf_stack_t *); 1541f4b3ec61Sdh extern void ipftuneable_free(ipf_stack_t *); 15427c478bd9Sstevel@tonic-gate 15437c478bd9Sstevel@tonic-gate #endif /* __IP_FIL_H__ */ 1544