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 * 9*f4b3ec61Sdh * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 107c478bd9Sstevel@tonic-gate * Use is subject to license terms. 117c478bd9Sstevel@tonic-gate */ 127c478bd9Sstevel@tonic-gate 137c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 147c478bd9Sstevel@tonic-gate 157c478bd9Sstevel@tonic-gate #ifndef __IP_FIL_H__ 167c478bd9Sstevel@tonic-gate #define __IP_FIL_H__ 177c478bd9Sstevel@tonic-gate 18ab25eeb5Syz #include "netinet/ip_compat.h" 19ab25eeb5Syz 207c478bd9Sstevel@tonic-gate #ifndef SOLARIS 217c478bd9Sstevel@tonic-gate # define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4))) 227c478bd9Sstevel@tonic-gate #endif 237c478bd9Sstevel@tonic-gate 247c478bd9Sstevel@tonic-gate #ifndef __P 257c478bd9Sstevel@tonic-gate # ifdef __STDC__ 267c478bd9Sstevel@tonic-gate # define __P(x) x 277c478bd9Sstevel@tonic-gate # else 287c478bd9Sstevel@tonic-gate # define __P(x) () 297c478bd9Sstevel@tonic-gate # endif 307c478bd9Sstevel@tonic-gate #endif 317c478bd9Sstevel@tonic-gate 32ab25eeb5Syz #if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51) 337c478bd9Sstevel@tonic-gate # define SIOCADAFR _IOW('r', 60, struct ipfobj) 347c478bd9Sstevel@tonic-gate # define SIOCRMAFR _IOW('r', 61, struct ipfobj) 357c478bd9Sstevel@tonic-gate # define SIOCSETFF _IOW('r', 62, u_int) 367c478bd9Sstevel@tonic-gate # define SIOCGETFF _IOR('r', 63, u_int) 377c478bd9Sstevel@tonic-gate # define SIOCGETFS _IOWR('r', 64, struct ipfobj) 387c478bd9Sstevel@tonic-gate # define SIOCIPFFL _IOWR('r', 65, int) 397c478bd9Sstevel@tonic-gate # define SIOCIPFFB _IOR('r', 66, int) 407c478bd9Sstevel@tonic-gate # define SIOCADIFR _IOW('r', 67, struct ipfobj) 417c478bd9Sstevel@tonic-gate # define SIOCRMIFR _IOW('r', 68, struct ipfobj) 427c478bd9Sstevel@tonic-gate # define SIOCSWAPA _IOR('r', 69, u_int) 437c478bd9Sstevel@tonic-gate # define SIOCINAFR _IOW('r', 70, struct ipfobj) 447c478bd9Sstevel@tonic-gate # define SIOCINIFR _IOW('r', 71, struct ipfobj) 457c478bd9Sstevel@tonic-gate # define SIOCFRENB _IOW('r', 72, u_int) 467c478bd9Sstevel@tonic-gate # define SIOCFRSYN _IOW('r', 73, u_int) 477c478bd9Sstevel@tonic-gate # define SIOCFRZST _IOWR('r', 74, struct ipfobj) 487c478bd9Sstevel@tonic-gate # define SIOCZRLST _IOWR('r', 75, struct ipfobj) 497c478bd9Sstevel@tonic-gate # define SIOCAUTHW _IOWR('r', 76, struct ipfobj) 507c478bd9Sstevel@tonic-gate # define SIOCAUTHR _IOWR('r', 77, struct ipfobj) 517c478bd9Sstevel@tonic-gate # define SIOCATHST _IOWR('r', 78, struct ipfobj) 527c478bd9Sstevel@tonic-gate # define SIOCSTLCK _IOWR('r', 79, u_int) 537c478bd9Sstevel@tonic-gate # define SIOCSTPUT _IOWR('r', 80, struct ipfobj) 547c478bd9Sstevel@tonic-gate # define SIOCSTGET _IOWR('r', 81, struct ipfobj) 557c478bd9Sstevel@tonic-gate # define SIOCSTGSZ _IOWR('r', 82, struct ipfobj) 567c478bd9Sstevel@tonic-gate # define SIOCGFRST _IOWR('r', 83, struct ipfobj) 577c478bd9Sstevel@tonic-gate # define SIOCSETLG _IOWR('r', 84, int) 587c478bd9Sstevel@tonic-gate # define SIOCGETLG _IOWR('r', 85, int) 597c478bd9Sstevel@tonic-gate # define SIOCFUNCL _IOWR('r', 86, struct ipfunc_resolve) 607c478bd9Sstevel@tonic-gate # define SIOCIPFGETNEXT _IOWR('r', 87, struct ipfobj) 617c478bd9Sstevel@tonic-gate # define SIOCIPFGET _IOWR('r', 88, struct ipfobj) 627c478bd9Sstevel@tonic-gate # define SIOCIPFSET _IOWR('r', 89, struct ipfobj) 637663b816Sml # define SIOCIPFL6 _IOWR('r', 90, int) 64381a2a9aSdr # define SIOCIPFLP _IOWR('r', 91, int) 65*f4b3ec61Sdh # define SIOCIPFITER _IOWR('r', 92, struct ipfobj) 66*f4b3ec61Sdh # define SIOCGENITER _IOWR('r', 93, struct ipfobj) 67*f4b3ec61Sdh # define SIOCGTABL _IOWR('r', 94, struct ipfobj) 68*f4b3ec61Sdh # define SIOCIPFDELTOK _IOWR('r', 95, int) 69*f4b3ec61Sdh # define SIOCLOOKUPITER _IOWR('r', 96, struct ipfobj) 707c478bd9Sstevel@tonic-gate #else 717c478bd9Sstevel@tonic-gate # define SIOCADAFR _IOW(r, 60, struct ipfobj) 727c478bd9Sstevel@tonic-gate # define SIOCRMAFR _IOW(r, 61, struct ipfobj) 737c478bd9Sstevel@tonic-gate # define SIOCSETFF _IOW(r, 62, u_int) 747c478bd9Sstevel@tonic-gate # define SIOCGETFF _IOR(r, 63, u_int) 757c478bd9Sstevel@tonic-gate # define SIOCGETFS _IOWR(r, 64, struct ipfobj) 767c478bd9Sstevel@tonic-gate # define SIOCIPFFL _IOWR(r, 65, int) 777c478bd9Sstevel@tonic-gate # define SIOCIPFFB _IOR(r, 66, int) 787c478bd9Sstevel@tonic-gate # define SIOCADIFR _IOW(r, 67, struct ipfobj) 797c478bd9Sstevel@tonic-gate # define SIOCRMIFR _IOW(r, 68, struct ipfobj) 807c478bd9Sstevel@tonic-gate # define SIOCSWAPA _IOR(r, 69, u_int) 817c478bd9Sstevel@tonic-gate # define SIOCINAFR _IOW(r, 70, struct ipfobj) 827c478bd9Sstevel@tonic-gate # define SIOCINIFR _IOW(r, 71, struct ipfobj) 837c478bd9Sstevel@tonic-gate # define SIOCFRENB _IOW(r, 72, u_int) 847c478bd9Sstevel@tonic-gate # define SIOCFRSYN _IOW(r, 73, u_int) 857c478bd9Sstevel@tonic-gate # define SIOCFRZST _IOWR(r, 74, struct ipfobj) 867c478bd9Sstevel@tonic-gate # define SIOCZRLST _IOWR(r, 75, struct ipfobj) 877c478bd9Sstevel@tonic-gate # define SIOCAUTHW _IOWR(r, 76, struct ipfobj) 887c478bd9Sstevel@tonic-gate # define SIOCAUTHR _IOWR(r, 77, struct ipfobj) 897c478bd9Sstevel@tonic-gate # define SIOCATHST _IOWR(r, 78, struct ipfobj) 907c478bd9Sstevel@tonic-gate # define SIOCSTLCK _IOWR(r, 79, u_int) 917c478bd9Sstevel@tonic-gate # define SIOCSTPUT _IOWR(r, 80, struct ipfobj) 927c478bd9Sstevel@tonic-gate # define SIOCSTGET _IOWR(r, 81, struct ipfobj) 937c478bd9Sstevel@tonic-gate # define SIOCSTGSZ _IOWR(r, 82, struct ipfobj) 947c478bd9Sstevel@tonic-gate # define SIOCGFRST _IOWR(r, 83, struct ipfobj) 957c478bd9Sstevel@tonic-gate # define SIOCSETLG _IOWR(r, 84, int) 967c478bd9Sstevel@tonic-gate # define SIOCGETLG _IOWR(r, 85, int) 977c478bd9Sstevel@tonic-gate # define SIOCFUNCL _IOWR(r, 86, struct ipfunc_resolve) 987c478bd9Sstevel@tonic-gate # define SIOCIPFGETNEXT _IOWR(r, 87, struct ipfobj) 997c478bd9Sstevel@tonic-gate # define SIOCIPFGET _IOWR(r, 88, struct ipfobj) 1007c478bd9Sstevel@tonic-gate # define SIOCIPFSET _IOWR(r, 89, struct ipfobj) 1017663b816Sml # define SIOCIPFL6 _IOWR(r, 90, int) 102381a2a9aSdr # define SIOCIPFLP _IOWR(r, 91, int) 103*f4b3ec61Sdh # define SIOCIPFITER _IOWR(r, 92, struct ipfobj) 104*f4b3ec61Sdh # define SIOCGENITER _IOWR(r, 93, struct ipfobj) 105*f4b3ec61Sdh # define SIOCGTABL _IOWR(r, 94, struct ipfobj) 106*f4b3ec61Sdh # define SIOCIPFDELTOK _IOWR(r, 95, int) 107*f4b3ec61Sdh # define SIOCLOOKUPITER _IOWR(r, 96, struct ipfobj) 1087c478bd9Sstevel@tonic-gate #endif 1097c478bd9Sstevel@tonic-gate #define SIOCADDFR SIOCADAFR 1107c478bd9Sstevel@tonic-gate #define SIOCDELFR SIOCRMAFR 1117c478bd9Sstevel@tonic-gate #define SIOCINSFR SIOCINAFR 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate struct ipscan; 1157c478bd9Sstevel@tonic-gate struct ifnet; 1167c478bd9Sstevel@tonic-gate 117*f4b3ec61Sdh typedef struct ipf_stack ipf_stack_t; 118*f4b3ec61Sdh 119*f4b3ec61Sdh typedef int (* lookupfunc_t) __P((void *, int, void *, ipf_stack_t *)); 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate /* 1237c478bd9Sstevel@tonic-gate * i6addr is used as a container for both IPv4 and IPv6 addresses, as well 1247c478bd9Sstevel@tonic-gate * as other types of objects, depending on its qualifier. 1257c478bd9Sstevel@tonic-gate */ 1267c478bd9Sstevel@tonic-gate #ifdef USE_INET6 1277c478bd9Sstevel@tonic-gate typedef union i6addr { 1287c478bd9Sstevel@tonic-gate u_32_t i6[4]; 1297c478bd9Sstevel@tonic-gate struct in_addr in4; 1307c478bd9Sstevel@tonic-gate struct in6_addr in6; 1317c478bd9Sstevel@tonic-gate void *vptr[2]; 1327c478bd9Sstevel@tonic-gate lookupfunc_t lptr[2]; 1337c478bd9Sstevel@tonic-gate } i6addr_t; 1347663b816Sml #define in6_addr8 in6.s6_addr 1357c478bd9Sstevel@tonic-gate #else 1367c478bd9Sstevel@tonic-gate typedef union i6addr { 1377c478bd9Sstevel@tonic-gate u_32_t i6[4]; 1387c478bd9Sstevel@tonic-gate struct in_addr in4; 1397c478bd9Sstevel@tonic-gate void *vptr[2]; 1407c478bd9Sstevel@tonic-gate lookupfunc_t lptr[2]; 1417c478bd9Sstevel@tonic-gate } i6addr_t; 1427c478bd9Sstevel@tonic-gate #endif 143ab25eeb5Syz 1447c478bd9Sstevel@tonic-gate #define in4_addr in4.s_addr 1457c478bd9Sstevel@tonic-gate #define iplookupnum i6[0] 1467c478bd9Sstevel@tonic-gate #define iplookuptype i6[1] 1477c478bd9Sstevel@tonic-gate /* 1487c478bd9Sstevel@tonic-gate * NOTE: These DO overlap the above on 64bit systems and this IS recognised. 1497c478bd9Sstevel@tonic-gate */ 1507c478bd9Sstevel@tonic-gate #define iplookupptr vptr[0] 1517c478bd9Sstevel@tonic-gate #define iplookupfunc lptr[1] 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate #define I60(x) (((i6addr_t *)(x))->i6[0]) 1547c478bd9Sstevel@tonic-gate #define I61(x) (((i6addr_t *)(x))->i6[1]) 1557c478bd9Sstevel@tonic-gate #define I62(x) (((i6addr_t *)(x))->i6[2]) 1567c478bd9Sstevel@tonic-gate #define I63(x) (((i6addr_t *)(x))->i6[3]) 1577c478bd9Sstevel@tonic-gate #define HI60(x) ntohl(((i6addr_t *)(x))->i6[0]) 1587c478bd9Sstevel@tonic-gate #define HI61(x) ntohl(((i6addr_t *)(x))->i6[1]) 1597c478bd9Sstevel@tonic-gate #define HI62(x) ntohl(((i6addr_t *)(x))->i6[2]) 1607c478bd9Sstevel@tonic-gate #define HI63(x) ntohl(((i6addr_t *)(x))->i6[3]) 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate #define IP6_EQ(a,b) ((I63(a) == I63(b)) && (I62(a) == I62(b)) && \ 1637c478bd9Sstevel@tonic-gate (I61(a) == I61(b)) && (I60(a) == I60(b))) 1647c478bd9Sstevel@tonic-gate #define IP6_NEQ(a,b) ((I63(a) != I63(b)) || (I62(a) != I62(b)) || \ 1657c478bd9Sstevel@tonic-gate (I61(a) != I61(b)) || (I60(a) != I60(b))) 1667c478bd9Sstevel@tonic-gate #define IP6_ISZERO(a) ((I60(a) | I61(a) | I62(a) | I63(a)) == 0) 1677c478bd9Sstevel@tonic-gate #define IP6_NOTZERO(a) ((I60(a) | I61(a) | I62(a) | I63(a)) != 0) 1687c478bd9Sstevel@tonic-gate #define IP6_GT(a,b) (HI60(a) > HI60(b) || (HI60(a) == HI60(b) && \ 1697c478bd9Sstevel@tonic-gate (HI61(a) > HI61(b) || (HI61(a) == HI61(b) && \ 1707c478bd9Sstevel@tonic-gate (HI62(a) > HI62(b) || (HI62(a) == HI62(b) && \ 1717c478bd9Sstevel@tonic-gate HI63(a) > HI63(b))))))) 1727c478bd9Sstevel@tonic-gate #define IP6_LT(a,b) (HI60(a) < HI60(b) || (HI60(a) == HI60(b) && \ 1737c478bd9Sstevel@tonic-gate (HI61(a) < HI61(b) || (HI61(a) == HI61(b) && \ 1747c478bd9Sstevel@tonic-gate (HI62(a) < HI62(b) || (HI62(a) == HI62(b) && \ 1757c478bd9Sstevel@tonic-gate HI63(a) < HI63(b))))))) 1767c478bd9Sstevel@tonic-gate #define NLADD(n,x) htonl(ntohl(n) + (x)) 1777c478bd9Sstevel@tonic-gate #define IP6_INC(a) \ 1787c478bd9Sstevel@tonic-gate { i6addr_t *_i6 = (i6addr_t *)(a); \ 1797c478bd9Sstevel@tonic-gate _i6->i6[0] = NLADD(_i6->i6[0], 1); \ 1807c478bd9Sstevel@tonic-gate if (_i6->i6[0] == 0) { \ 1817c478bd9Sstevel@tonic-gate _i6->i6[0] = NLADD(_i6->i6[1], 1); \ 1827c478bd9Sstevel@tonic-gate if (_i6->i6[1] == 0) { \ 1837c478bd9Sstevel@tonic-gate _i6->i6[0] = NLADD(_i6->i6[2], 1); \ 1847c478bd9Sstevel@tonic-gate if (_i6->i6[2] == 0) { \ 1857c478bd9Sstevel@tonic-gate _i6->i6[0] = NLADD(_i6->i6[3], 1); \ 1867c478bd9Sstevel@tonic-gate } \ 1877c478bd9Sstevel@tonic-gate } \ 1887c478bd9Sstevel@tonic-gate } \ 1897c478bd9Sstevel@tonic-gate } 1907c478bd9Sstevel@tonic-gate #define IP6_ADD(a,x,d) \ 1917c478bd9Sstevel@tonic-gate { i6addr_t *_s = (i6addr_t *)(a); \ 1927c478bd9Sstevel@tonic-gate i6addr_t *_d = (i6addr_t *)(d); \ 1937c478bd9Sstevel@tonic-gate _d->i6[0] = NLADD(_s->i6[0], x); \ 1947c478bd9Sstevel@tonic-gate if (ntohl(_d->i6[0]) < ntohl(_s->i6[0])) { \ 1957c478bd9Sstevel@tonic-gate _d->i6[1] = NLADD(_d->i6[1], 1); \ 1967c478bd9Sstevel@tonic-gate if (ntohl(_d->i6[1]) < ntohl(_s->i6[1])) { \ 1977c478bd9Sstevel@tonic-gate _d->i6[2] = NLADD(_d->i6[2], 1); \ 1987c478bd9Sstevel@tonic-gate if (ntohl(_d->i6[2]) < ntohl(_s->i6[2])) { \ 1997c478bd9Sstevel@tonic-gate _d->i6[3] = NLADD(_d->i6[3], 1); \ 2007c478bd9Sstevel@tonic-gate } \ 2017c478bd9Sstevel@tonic-gate } \ 2027c478bd9Sstevel@tonic-gate } \ 2037c478bd9Sstevel@tonic-gate } 2047c478bd9Sstevel@tonic-gate #define IP6_AND(a,b,d) { i6addr_t *_s1 = (i6addr_t *)(a); \ 2057c478bd9Sstevel@tonic-gate i6addr_t *_s2 = (i6addr_t *)(d); \ 2067c478bd9Sstevel@tonic-gate i6addr_t *_d = (i6addr_t *)(d); \ 2077c478bd9Sstevel@tonic-gate _d->i6[0] = _s1->i6[0] & _s2->i6[0]; \ 2087c478bd9Sstevel@tonic-gate _d->i6[1] = _s1->i6[1] & _s2->i6[1]; \ 2097c478bd9Sstevel@tonic-gate _d->i6[2] = _s1->i6[2] & _s2->i6[2]; \ 2107c478bd9Sstevel@tonic-gate _d->i6[3] = _s1->i6[3] & _s2->i6[3]; \ 2117c478bd9Sstevel@tonic-gate } 2127c478bd9Sstevel@tonic-gate #define IP6_MERGE(a,b,c) \ 2137c478bd9Sstevel@tonic-gate { i6addr_t *_d, *_s1, *_s2; \ 2147c478bd9Sstevel@tonic-gate _d = (i6addr_t *)(a); \ 2157c478bd9Sstevel@tonic-gate _s1 = (i6addr_t *)(b); \ 2167c478bd9Sstevel@tonic-gate _s2 = (i6addr_t *)(c); \ 2177c478bd9Sstevel@tonic-gate _d->i6[0] |= _s1->i6[0] & ~_s2->i6[0]; \ 2187c478bd9Sstevel@tonic-gate _d->i6[1] |= _s1->i6[1] & ~_s2->i6[1]; \ 2197c478bd9Sstevel@tonic-gate _d->i6[2] |= _s1->i6[2] & ~_s2->i6[2]; \ 2207c478bd9Sstevel@tonic-gate _d->i6[2] |= _s1->i6[3] & ~_s2->i6[3]; \ 2217c478bd9Sstevel@tonic-gate } 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate typedef struct fr_ip { 2257c478bd9Sstevel@tonic-gate u_32_t fi_v:4; /* IP version */ 2267c478bd9Sstevel@tonic-gate u_32_t fi_xx:4; /* spare */ 2277c478bd9Sstevel@tonic-gate u_32_t fi_tos:8; /* IP packet TOS */ 2287c478bd9Sstevel@tonic-gate u_32_t fi_ttl:8; /* IP packet TTL */ 2297c478bd9Sstevel@tonic-gate u_32_t fi_p:8; /* IP packet protocol */ 2307c478bd9Sstevel@tonic-gate u_32_t fi_optmsk; /* bitmask composed from IP options */ 2317c478bd9Sstevel@tonic-gate i6addr_t fi_src; /* source address from packet */ 2327c478bd9Sstevel@tonic-gate i6addr_t fi_dst; /* destination address from packet */ 2337c478bd9Sstevel@tonic-gate u_short fi_secmsk; /* bitmask composed from IP security options */ 2347c478bd9Sstevel@tonic-gate u_short fi_auth; /* authentication code from IP sec. options */ 2357c478bd9Sstevel@tonic-gate u_32_t fi_flx; /* packet flags */ 2367c478bd9Sstevel@tonic-gate u_32_t fi_tcpmsk; /* TCP options set/reset */ 2377c478bd9Sstevel@tonic-gate u_32_t fi_res1; /* RESERVED */ 2387c478bd9Sstevel@tonic-gate } fr_ip_t; 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate /* 2417c478bd9Sstevel@tonic-gate * For use in fi_flx 2427c478bd9Sstevel@tonic-gate */ 2437c478bd9Sstevel@tonic-gate #define FI_TCPUDP 0x0001 /* TCP/UCP implied comparison*/ 2447c478bd9Sstevel@tonic-gate #define FI_OPTIONS 0x0002 2457c478bd9Sstevel@tonic-gate #define FI_FRAG 0x0004 2467c478bd9Sstevel@tonic-gate #define FI_SHORT 0x0008 2477c478bd9Sstevel@tonic-gate #define FI_NATED 0x0010 2487c478bd9Sstevel@tonic-gate #define FI_MULTICAST 0x0020 2497c478bd9Sstevel@tonic-gate #define FI_BROADCAST 0x0040 2507c478bd9Sstevel@tonic-gate #define FI_MBCAST 0x0080 2517c478bd9Sstevel@tonic-gate #define FI_STATE 0x0100 2527c478bd9Sstevel@tonic-gate #define FI_BADNAT 0x0200 2537c478bd9Sstevel@tonic-gate #define FI_BAD 0x0400 2547c478bd9Sstevel@tonic-gate #define FI_OOW 0x0800 /* Out of state window, else match */ 2557c478bd9Sstevel@tonic-gate #define FI_ICMPERR 0x1000 256ab25eeb5Syz #define FI_FRAGBODY 0x2000 2577c478bd9Sstevel@tonic-gate #define FI_BADSRC 0x4000 2587c478bd9Sstevel@tonic-gate #define FI_LOWTTL 0x8000 259ab25eeb5Syz #define FI_CMP 0xcfe3 /* Not FI_FRAG,FI_NATED,FI_FRAGTAIL */ 260ab25eeb5Syz #define FI_ICMPCMP 0x0003 /* Flags we can check for ICMP error packets */ 2617c478bd9Sstevel@tonic-gate #define FI_WITH 0xeffe /* Not FI_TCPUDP */ 2627c478bd9Sstevel@tonic-gate #define FI_V6EXTHDR 0x10000 2637c478bd9Sstevel@tonic-gate #define FI_COALESCE 0x20000 2647c478bd9Sstevel@tonic-gate #define FI_NOCKSUM 0x20000000 /* don't do a L4 checksum validation */ 2657c478bd9Sstevel@tonic-gate #define FI_DONTCACHE 0x40000000 /* don't cache the result */ 2667c478bd9Sstevel@tonic-gate #define FI_IGNORE 0x80000000 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate #define fi_saddr fi_src.in4.s_addr 2697c478bd9Sstevel@tonic-gate #define fi_daddr fi_dst.in4.s_addr 2707c478bd9Sstevel@tonic-gate #define fi_srcnum fi_src.iplookupnum 2717c478bd9Sstevel@tonic-gate #define fi_dstnum fi_dst.iplookupnum 2727c478bd9Sstevel@tonic-gate #define fi_srctype fi_src.iplookuptype 2737c478bd9Sstevel@tonic-gate #define fi_dsttype fi_dst.iplookuptype 2747c478bd9Sstevel@tonic-gate #define fi_srcptr fi_src.iplookupptr 2757c478bd9Sstevel@tonic-gate #define fi_dstptr fi_dst.iplookupptr 2767c478bd9Sstevel@tonic-gate #define fi_srcfunc fi_src.iplookupfunc 2777c478bd9Sstevel@tonic-gate #define fi_dstfunc fi_dst.iplookupfunc 2787c478bd9Sstevel@tonic-gate 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate /* 2817c478bd9Sstevel@tonic-gate * These are both used by the state and NAT code to indicate that one port or 2827c478bd9Sstevel@tonic-gate * the other should be treated as a wildcard. 2837c478bd9Sstevel@tonic-gate * NOTE: When updating, check bit masks in ip_state.h and update there too. 2847c478bd9Sstevel@tonic-gate */ 2857c478bd9Sstevel@tonic-gate #define SI_W_SPORT 0x00000100 2867c478bd9Sstevel@tonic-gate #define SI_W_DPORT 0x00000200 2877c478bd9Sstevel@tonic-gate #define SI_WILDP (SI_W_SPORT|SI_W_DPORT) 2887c478bd9Sstevel@tonic-gate #define SI_W_SADDR 0x00000400 2897c478bd9Sstevel@tonic-gate #define SI_W_DADDR 0x00000800 2907c478bd9Sstevel@tonic-gate #define SI_WILDA (SI_W_SADDR|SI_W_DADDR) 2917c478bd9Sstevel@tonic-gate #define SI_NEWFR 0x00001000 2927c478bd9Sstevel@tonic-gate #define SI_CLONE 0x00002000 2937c478bd9Sstevel@tonic-gate #define SI_CLONED 0x00004000 2947c478bd9Sstevel@tonic-gate 2957c478bd9Sstevel@tonic-gate 296*f4b3ec61Sdh 297*f4b3ec61Sdh 2987c478bd9Sstevel@tonic-gate typedef struct fr_info { 2997c478bd9Sstevel@tonic-gate void *fin_ifp; /* interface packet is `on' */ 300ab25eeb5Syz fr_ip_t fin_fi; /* IP Packet summary */ 3017c478bd9Sstevel@tonic-gate union { 3027c478bd9Sstevel@tonic-gate u_short fid_16[2]; /* TCP/UDP ports, ICMP code/type */ 3037c478bd9Sstevel@tonic-gate u_32_t fid_32; 3047c478bd9Sstevel@tonic-gate } fin_dat; 3057c478bd9Sstevel@tonic-gate int fin_out; /* in or out ? 1 == out, 0 == in */ 3067c478bd9Sstevel@tonic-gate int fin_rev; /* state only: 1 = reverse */ 3077c478bd9Sstevel@tonic-gate u_short fin_hlen; /* length of IP header in bytes */ 3087c478bd9Sstevel@tonic-gate u_char fin_tcpf; /* TCP header flags (SYN, ACK, etc) */ 3097c478bd9Sstevel@tonic-gate u_char fin_icode; /* ICMP error to return */ 3107c478bd9Sstevel@tonic-gate u_32_t fin_rule; /* rule # last matched */ 3117c478bd9Sstevel@tonic-gate char fin_group[FR_GROUPLEN]; /* group number, -1 for none */ 3127c478bd9Sstevel@tonic-gate struct frentry *fin_fr; /* last matching rule */ 3137c478bd9Sstevel@tonic-gate void *fin_dp; /* start of data past IP header */ 3147c478bd9Sstevel@tonic-gate int fin_dlen; /* length of data portion of packet */ 3157c478bd9Sstevel@tonic-gate int fin_plen; 316ab25eeb5Syz int fin_flen; /* length of layer 4 hdr and 3177663b816Sml ipv6 ext hdr after fragment hdr */ 318ab25eeb5Syz int fin_ipoff; /* # bytes from buffer start to hdr */ 3197663b816Sml u_32_t fin_id; /* IP packet id field */ 3207c478bd9Sstevel@tonic-gate u_short fin_off; 3217c478bd9Sstevel@tonic-gate int fin_depth; /* Group nesting depth */ 3227c478bd9Sstevel@tonic-gate int fin_error; /* Error code to return */ 3237c478bd9Sstevel@tonic-gate void *fin_nat; 3247c478bd9Sstevel@tonic-gate void *fin_state; 3257c478bd9Sstevel@tonic-gate void *fin_nattag; 3267c478bd9Sstevel@tonic-gate ip_t *fin_ip; 3277c478bd9Sstevel@tonic-gate mb_t **fin_mp; /* pointer to pointer to mbuf */ 3287c478bd9Sstevel@tonic-gate mb_t *fin_m; /* pointer to mbuf */ 3297c478bd9Sstevel@tonic-gate #ifdef MENTAT 3307c478bd9Sstevel@tonic-gate mb_t *fin_qfm; /* pointer to mblk where pkt starts */ 331ab25eeb5Syz void *fin_qpi; 332*f4b3ec61Sdh ipf_stack_t *fin_ifs; 333ab25eeb5Syz #endif 334ab25eeb5Syz #ifdef __sgi 335ab25eeb5Syz void *fin_hbuf; 3367c478bd9Sstevel@tonic-gate #endif 3377c478bd9Sstevel@tonic-gate } fr_info_t; 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate #define fin_v fin_fi.fi_v 3407c478bd9Sstevel@tonic-gate #define fin_p fin_fi.fi_p 3417c478bd9Sstevel@tonic-gate #define fin_flx fin_fi.fi_flx 3427c478bd9Sstevel@tonic-gate #define fin_optmsk fin_fi.fi_optmsk 3437c478bd9Sstevel@tonic-gate #define fin_secmsk fin_fi.fi_secmsk 3447c478bd9Sstevel@tonic-gate #define fin_auth fin_fi.fi_auth 3457c478bd9Sstevel@tonic-gate #define fin_src fin_fi.fi_src.in4 3467c478bd9Sstevel@tonic-gate #define fin_src6 fin_fi.fi_src.in6 3477c478bd9Sstevel@tonic-gate #define fin_saddr fin_fi.fi_saddr 3487c478bd9Sstevel@tonic-gate #define fin_dst fin_fi.fi_dst.in4 3497c478bd9Sstevel@tonic-gate #define fin_dst6 fin_fi.fi_dst.in6 3507c478bd9Sstevel@tonic-gate #define fin_daddr fin_fi.fi_daddr 3517c478bd9Sstevel@tonic-gate #define fin_data fin_dat.fid_16 3527c478bd9Sstevel@tonic-gate #define fin_sport fin_dat.fid_16[0] 3537c478bd9Sstevel@tonic-gate #define fin_dport fin_dat.fid_16[1] 3547c478bd9Sstevel@tonic-gate #define fin_ports fin_dat.fid_32 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gate #define IPF_IN 0 3577c478bd9Sstevel@tonic-gate #define IPF_OUT 1 3587c478bd9Sstevel@tonic-gate 3597c478bd9Sstevel@tonic-gate typedef struct frentry *(*ipfunc_t) __P((fr_info_t *, u_32_t *)); 360*f4b3ec61Sdh typedef int (*ipfuncinit_t) __P((struct frentry *, 361*f4b3ec61Sdh ipf_stack_t *)); 3627c478bd9Sstevel@tonic-gate 3637c478bd9Sstevel@tonic-gate typedef struct ipfunc_resolve { 3647c478bd9Sstevel@tonic-gate char ipfu_name[32]; 3657c478bd9Sstevel@tonic-gate ipfunc_t ipfu_addr; 3667c478bd9Sstevel@tonic-gate ipfuncinit_t ipfu_init; 3677c478bd9Sstevel@tonic-gate } ipfunc_resolve_t; 3687c478bd9Sstevel@tonic-gate 3697c478bd9Sstevel@tonic-gate /* 3707c478bd9Sstevel@tonic-gate * Size for compares on fr_info structures 3717c478bd9Sstevel@tonic-gate */ 3727c478bd9Sstevel@tonic-gate #define FI_CSIZE offsetof(fr_info_t, fin_icode) 3737c478bd9Sstevel@tonic-gate #define FI_LCSIZE offsetof(fr_info_t, fin_dp) 3747c478bd9Sstevel@tonic-gate 3757c478bd9Sstevel@tonic-gate /* 3767c478bd9Sstevel@tonic-gate * Size for copying cache fr_info structure 3777c478bd9Sstevel@tonic-gate */ 3787c478bd9Sstevel@tonic-gate #define FI_COPYSIZE offsetof(fr_info_t, fin_dp) 3797c478bd9Sstevel@tonic-gate 3807c478bd9Sstevel@tonic-gate /* 381ab25eeb5Syz * Structure for holding IPFilter's tag information 3827c478bd9Sstevel@tonic-gate */ 383ab25eeb5Syz #define IPFTAG_LEN 16 3847c478bd9Sstevel@tonic-gate typedef struct { 3857c478bd9Sstevel@tonic-gate union { 3867c478bd9Sstevel@tonic-gate u_32_t iptu_num[4]; 387ab25eeb5Syz char iptu_tag[IPFTAG_LEN]; 3887c478bd9Sstevel@tonic-gate } ipt_un; 3897c478bd9Sstevel@tonic-gate int ipt_not; 3907c478bd9Sstevel@tonic-gate } ipftag_t; 3917c478bd9Sstevel@tonic-gate 3927c478bd9Sstevel@tonic-gate #define ipt_tag ipt_un.iptu_tag 3937c478bd9Sstevel@tonic-gate #define ipt_num ipt_un.iptu_num 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate 3967c478bd9Sstevel@tonic-gate /* 3977c478bd9Sstevel@tonic-gate * This structure is used to hold information about the next hop for where 3987c478bd9Sstevel@tonic-gate * to forward a packet. 3997c478bd9Sstevel@tonic-gate */ 4007c478bd9Sstevel@tonic-gate typedef struct frdest { 4017c478bd9Sstevel@tonic-gate void *fd_ifp; 4027c478bd9Sstevel@tonic-gate i6addr_t fd_ip6; 4037c478bd9Sstevel@tonic-gate char fd_ifname[LIFNAMSIZ]; 4047c478bd9Sstevel@tonic-gate } frdest_t; 4057c478bd9Sstevel@tonic-gate 4067c478bd9Sstevel@tonic-gate #define fd_ip fd_ip6.in4 4077c478bd9Sstevel@tonic-gate 4087c478bd9Sstevel@tonic-gate 4097c478bd9Sstevel@tonic-gate /* 4107c478bd9Sstevel@tonic-gate * This structure holds information about a port comparison. 4117c478bd9Sstevel@tonic-gate */ 4127c478bd9Sstevel@tonic-gate typedef struct frpcmp { 4137c478bd9Sstevel@tonic-gate int frp_cmp; /* data for port comparisons */ 4147c478bd9Sstevel@tonic-gate u_short frp_port; /* top port for <> and >< */ 4157c478bd9Sstevel@tonic-gate u_short frp_top; /* top port for <> and >< */ 4167c478bd9Sstevel@tonic-gate } frpcmp_t; 4177c478bd9Sstevel@tonic-gate 4187c478bd9Sstevel@tonic-gate #define FR_NONE 0 4197c478bd9Sstevel@tonic-gate #define FR_EQUAL 1 4207c478bd9Sstevel@tonic-gate #define FR_NEQUAL 2 4217c478bd9Sstevel@tonic-gate #define FR_LESST 3 4227c478bd9Sstevel@tonic-gate #define FR_GREATERT 4 4237c478bd9Sstevel@tonic-gate #define FR_LESSTE 5 4247c478bd9Sstevel@tonic-gate #define FR_GREATERTE 6 4257c478bd9Sstevel@tonic-gate #define FR_OUTRANGE 7 4267c478bd9Sstevel@tonic-gate #define FR_INRANGE 8 4277c478bd9Sstevel@tonic-gate #define FR_INCRANGE 9 4287c478bd9Sstevel@tonic-gate 4297c478bd9Sstevel@tonic-gate /* 4307c478bd9Sstevel@tonic-gate * Structure containing all the relevant TCP things that can be checked in 4317c478bd9Sstevel@tonic-gate * a filter rule. 4327c478bd9Sstevel@tonic-gate */ 4337c478bd9Sstevel@tonic-gate typedef struct frtuc { 4347c478bd9Sstevel@tonic-gate u_char ftu_tcpfm; /* tcp flags mask */ 4357c478bd9Sstevel@tonic-gate u_char ftu_tcpf; /* tcp flags */ 4367c478bd9Sstevel@tonic-gate frpcmp_t ftu_src; 4377c478bd9Sstevel@tonic-gate frpcmp_t ftu_dst; 4387c478bd9Sstevel@tonic-gate } frtuc_t; 4397c478bd9Sstevel@tonic-gate 4407c478bd9Sstevel@tonic-gate #define ftu_scmp ftu_src.frp_cmp 4417c478bd9Sstevel@tonic-gate #define ftu_dcmp ftu_dst.frp_cmp 4427c478bd9Sstevel@tonic-gate #define ftu_sport ftu_src.frp_port 4437c478bd9Sstevel@tonic-gate #define ftu_dport ftu_dst.frp_port 4447c478bd9Sstevel@tonic-gate #define ftu_stop ftu_src.frp_top 4457c478bd9Sstevel@tonic-gate #define ftu_dtop ftu_dst.frp_top 4467c478bd9Sstevel@tonic-gate 4477c478bd9Sstevel@tonic-gate #define FR_TCPFMAX 0x3f 4487c478bd9Sstevel@tonic-gate 4497c478bd9Sstevel@tonic-gate /* 4507c478bd9Sstevel@tonic-gate * This structure makes up what is considered to be the IPFilter specific 4517c478bd9Sstevel@tonic-gate * matching components of a filter rule, as opposed to the data structures 4527c478bd9Sstevel@tonic-gate * used to define the result which are in frentry_t and not here. 4537c478bd9Sstevel@tonic-gate */ 4547c478bd9Sstevel@tonic-gate typedef struct fripf { 455ab25eeb5Syz fr_ip_t fri_ip; 456ab25eeb5Syz fr_ip_t fri_mip; /* mask structure */ 4577c478bd9Sstevel@tonic-gate 4587c478bd9Sstevel@tonic-gate u_short fri_icmpm; /* data for ICMP packets (mask) */ 4597c478bd9Sstevel@tonic-gate u_short fri_icmp; 4607c478bd9Sstevel@tonic-gate 4617c478bd9Sstevel@tonic-gate frtuc_t fri_tuc; 4627c478bd9Sstevel@tonic-gate int fri_satype; /* addres type */ 4637c478bd9Sstevel@tonic-gate int fri_datype; /* addres type */ 4647c478bd9Sstevel@tonic-gate int fri_sifpidx; /* doing dynamic addressing */ 4657c478bd9Sstevel@tonic-gate int fri_difpidx; /* index into fr_ifps[] to use when */ 4667c478bd9Sstevel@tonic-gate } fripf_t; 4677c478bd9Sstevel@tonic-gate 4687c478bd9Sstevel@tonic-gate #define fri_dstnum fri_ip.fi_dstnum 4697c478bd9Sstevel@tonic-gate #define fri_srcnum fri_mip.fi_srcnum 4707c478bd9Sstevel@tonic-gate #define fri_dstptr fri_ip.fi_dstptr 4717c478bd9Sstevel@tonic-gate #define fri_srcptr fri_mip.fi_srcptr 4727c478bd9Sstevel@tonic-gate 4737c478bd9Sstevel@tonic-gate #define FRI_NORMAL 0 /* Normal address */ 4747c478bd9Sstevel@tonic-gate #define FRI_DYNAMIC 1 /* dynamic address */ 4757c478bd9Sstevel@tonic-gate #define FRI_LOOKUP 2 /* address is a pool # */ 4767c478bd9Sstevel@tonic-gate #define FRI_RANGE 3 /* address/mask is a range */ 4777c478bd9Sstevel@tonic-gate #define FRI_NETWORK 4 /* network address from if */ 4787c478bd9Sstevel@tonic-gate #define FRI_BROADCAST 5 /* broadcast address from if */ 4797c478bd9Sstevel@tonic-gate #define FRI_PEERADDR 6 /* Peer address for P-to-P */ 4807c478bd9Sstevel@tonic-gate #define FRI_NETMASKED 7 /* network address with netmask from if */ 4817c478bd9Sstevel@tonic-gate 4827c478bd9Sstevel@tonic-gate 4837c478bd9Sstevel@tonic-gate typedef struct frentry * (* frentfunc_t) __P((fr_info_t *)); 4847c478bd9Sstevel@tonic-gate 4857c478bd9Sstevel@tonic-gate typedef struct frentry { 4867c478bd9Sstevel@tonic-gate ipfmutex_t fr_lock; 4877c478bd9Sstevel@tonic-gate struct frentry *fr_next; 4887c478bd9Sstevel@tonic-gate struct frentry **fr_grp; 4897c478bd9Sstevel@tonic-gate struct ipscan *fr_isc; 4907c478bd9Sstevel@tonic-gate void *fr_ifas[4]; 4917c478bd9Sstevel@tonic-gate void *fr_ptr; /* for use with fr_arg */ 4927c478bd9Sstevel@tonic-gate char *fr_comment; /* text comment for rule */ 4937c478bd9Sstevel@tonic-gate int fr_ref; /* reference count - for grouping */ 4947c478bd9Sstevel@tonic-gate int fr_statecnt; /* state count - for limit rules */ 4957c478bd9Sstevel@tonic-gate /* 4967c478bd9Sstevel@tonic-gate * These are only incremented when a packet matches this rule and 4977c478bd9Sstevel@tonic-gate * it is the last match 4987c478bd9Sstevel@tonic-gate */ 4997c478bd9Sstevel@tonic-gate U_QUAD_T fr_hits; 5007c478bd9Sstevel@tonic-gate U_QUAD_T fr_bytes; 5017c478bd9Sstevel@tonic-gate 5027c478bd9Sstevel@tonic-gate /* 5037c478bd9Sstevel@tonic-gate * For PPS rate limiting 5047c478bd9Sstevel@tonic-gate */ 5057c478bd9Sstevel@tonic-gate struct timeval fr_lastpkt; 5067c478bd9Sstevel@tonic-gate int fr_curpps; 5077c478bd9Sstevel@tonic-gate 5087c478bd9Sstevel@tonic-gate union { 5097c478bd9Sstevel@tonic-gate void *fru_data; 5107c478bd9Sstevel@tonic-gate caddr_t fru_caddr; 5117c478bd9Sstevel@tonic-gate fripf_t *fru_ipf; 5127c478bd9Sstevel@tonic-gate frentfunc_t fru_func; 5137c478bd9Sstevel@tonic-gate } fr_dun; 5147c478bd9Sstevel@tonic-gate 5157c478bd9Sstevel@tonic-gate /* 5167c478bd9Sstevel@tonic-gate * Fields after this may not change whilst in the kernel. 5177c478bd9Sstevel@tonic-gate */ 5187c478bd9Sstevel@tonic-gate ipfunc_t fr_func; /* call this function */ 5197c478bd9Sstevel@tonic-gate int fr_dsize; 5207c478bd9Sstevel@tonic-gate int fr_pps; 5217c478bd9Sstevel@tonic-gate int fr_statemax; /* max reference count */ 5227c478bd9Sstevel@tonic-gate int fr_flineno; /* line number from conf file */ 5237c478bd9Sstevel@tonic-gate u_32_t fr_type; 5247c478bd9Sstevel@tonic-gate u_32_t fr_flags; /* per-rule flags && options (see below) */ 5257c478bd9Sstevel@tonic-gate u_32_t fr_logtag; /* user defined log tag # */ 5267c478bd9Sstevel@tonic-gate u_32_t fr_collect; /* collection number */ 5277c478bd9Sstevel@tonic-gate u_int fr_arg; /* misc. numeric arg for rule */ 5287c478bd9Sstevel@tonic-gate u_int fr_loglevel; /* syslog log facility + priority */ 5297c478bd9Sstevel@tonic-gate u_int fr_age[2]; /* non-TCP timeouts */ 5307c478bd9Sstevel@tonic-gate u_char fr_v; 5317c478bd9Sstevel@tonic-gate u_char fr_icode; /* return ICMP code */ 5327c478bd9Sstevel@tonic-gate char fr_group[FR_GROUPLEN]; /* group to which this rule belongs */ 5337c478bd9Sstevel@tonic-gate char fr_grhead[FR_GROUPLEN]; /* group # which this rule starts */ 534ab25eeb5Syz ipftag_t fr_nattag; 5357c478bd9Sstevel@tonic-gate char fr_ifnames[4][LIFNAMSIZ]; 5367c478bd9Sstevel@tonic-gate char fr_isctag[16]; 537ab25eeb5Syz frdest_t fr_tifs[2]; /* "to"/"reply-to" interface */ 538ab25eeb5Syz frdest_t fr_dif; /* duplicate packet interface */ 5397c478bd9Sstevel@tonic-gate /* 5407c478bd9Sstevel@tonic-gate * This must be last and will change after loaded into the kernel. 5417c478bd9Sstevel@tonic-gate */ 5427c478bd9Sstevel@tonic-gate u_int fr_cksum; /* checksum on filter rules for performance */ 5437c478bd9Sstevel@tonic-gate } frentry_t; 5447c478bd9Sstevel@tonic-gate 5457c478bd9Sstevel@tonic-gate #define fr_caddr fr_dun.fru_caddr 5467c478bd9Sstevel@tonic-gate #define fr_data fr_dun.fru_data 5477c478bd9Sstevel@tonic-gate #define fr_dfunc fr_dun.fru_func 5487c478bd9Sstevel@tonic-gate #define fr_ipf fr_dun.fru_ipf 5497c478bd9Sstevel@tonic-gate #define fr_ip fr_ipf->fri_ip 5507c478bd9Sstevel@tonic-gate #define fr_mip fr_ipf->fri_mip 5517c478bd9Sstevel@tonic-gate #define fr_icmpm fr_ipf->fri_icmpm 5527c478bd9Sstevel@tonic-gate #define fr_icmp fr_ipf->fri_icmp 5537c478bd9Sstevel@tonic-gate #define fr_tuc fr_ipf->fri_tuc 5547c478bd9Sstevel@tonic-gate #define fr_satype fr_ipf->fri_satype 5557c478bd9Sstevel@tonic-gate #define fr_datype fr_ipf->fri_datype 5567c478bd9Sstevel@tonic-gate #define fr_sifpidx fr_ipf->fri_sifpidx 5577c478bd9Sstevel@tonic-gate #define fr_difpidx fr_ipf->fri_difpidx 5587c478bd9Sstevel@tonic-gate #define fr_proto fr_ip.fi_p 5597c478bd9Sstevel@tonic-gate #define fr_mproto fr_mip.fi_p 5607c478bd9Sstevel@tonic-gate #define fr_ttl fr_ip.fi_ttl 5617c478bd9Sstevel@tonic-gate #define fr_mttl fr_mip.fi_ttl 5627c478bd9Sstevel@tonic-gate #define fr_tos fr_ip.fi_tos 5637c478bd9Sstevel@tonic-gate #define fr_mtos fr_mip.fi_tos 5647c478bd9Sstevel@tonic-gate #define fr_tcpfm fr_tuc.ftu_tcpfm 5657c478bd9Sstevel@tonic-gate #define fr_tcpf fr_tuc.ftu_tcpf 5667c478bd9Sstevel@tonic-gate #define fr_scmp fr_tuc.ftu_scmp 5677c478bd9Sstevel@tonic-gate #define fr_dcmp fr_tuc.ftu_dcmp 5687c478bd9Sstevel@tonic-gate #define fr_dport fr_tuc.ftu_dport 5697c478bd9Sstevel@tonic-gate #define fr_sport fr_tuc.ftu_sport 5707c478bd9Sstevel@tonic-gate #define fr_stop fr_tuc.ftu_stop 5717c478bd9Sstevel@tonic-gate #define fr_dtop fr_tuc.ftu_dtop 5727c478bd9Sstevel@tonic-gate #define fr_dst fr_ip.fi_dst.in4 5737c478bd9Sstevel@tonic-gate #define fr_daddr fr_ip.fi_dst.in4.s_addr 5747c478bd9Sstevel@tonic-gate #define fr_src fr_ip.fi_src.in4 5757c478bd9Sstevel@tonic-gate #define fr_saddr fr_ip.fi_src.in4.s_addr 5767c478bd9Sstevel@tonic-gate #define fr_dmsk fr_mip.fi_dst.in4 5777c478bd9Sstevel@tonic-gate #define fr_dmask fr_mip.fi_dst.in4.s_addr 5787c478bd9Sstevel@tonic-gate #define fr_smsk fr_mip.fi_src.in4 5797c478bd9Sstevel@tonic-gate #define fr_smask fr_mip.fi_src.in4.s_addr 5807c478bd9Sstevel@tonic-gate #define fr_dstnum fr_ip.fi_dstnum 5817c478bd9Sstevel@tonic-gate #define fr_srcnum fr_ip.fi_srcnum 5827c478bd9Sstevel@tonic-gate #define fr_dsttype fr_ip.fi_dsttype 5837c478bd9Sstevel@tonic-gate #define fr_srctype fr_ip.fi_srctype 5847c478bd9Sstevel@tonic-gate #define fr_dstptr fr_mip.fi_dstptr 5857c478bd9Sstevel@tonic-gate #define fr_srcptr fr_mip.fi_srcptr 5867c478bd9Sstevel@tonic-gate #define fr_dstfunc fr_mip.fi_dstfunc 5877c478bd9Sstevel@tonic-gate #define fr_srcfunc fr_mip.fi_srcfunc 5887c478bd9Sstevel@tonic-gate #define fr_optbits fr_ip.fi_optmsk 5897c478bd9Sstevel@tonic-gate #define fr_optmask fr_mip.fi_optmsk 5907c478bd9Sstevel@tonic-gate #define fr_secbits fr_ip.fi_secmsk 5917c478bd9Sstevel@tonic-gate #define fr_secmask fr_mip.fi_secmsk 5927c478bd9Sstevel@tonic-gate #define fr_authbits fr_ip.fi_auth 5937c478bd9Sstevel@tonic-gate #define fr_authmask fr_mip.fi_auth 5947c478bd9Sstevel@tonic-gate #define fr_flx fr_ip.fi_flx 5957c478bd9Sstevel@tonic-gate #define fr_mflx fr_mip.fi_flx 5967c478bd9Sstevel@tonic-gate #define fr_ifname fr_ifnames[0] 5977c478bd9Sstevel@tonic-gate #define fr_oifname fr_ifnames[2] 5987c478bd9Sstevel@tonic-gate #define fr_ifa fr_ifas[0] 5997c478bd9Sstevel@tonic-gate #define fr_oifa fr_ifas[2] 6007c478bd9Sstevel@tonic-gate #define fr_tif fr_tifs[0] 6017c478bd9Sstevel@tonic-gate #define fr_rif fr_tifs[1] 6027c478bd9Sstevel@tonic-gate 6037c478bd9Sstevel@tonic-gate #define FR_NOLOGTAG 0 6047c478bd9Sstevel@tonic-gate 6057c478bd9Sstevel@tonic-gate #ifndef offsetof 6067c478bd9Sstevel@tonic-gate #define offsetof(t,m) (int)((&((t *)0L)->m)) 6077c478bd9Sstevel@tonic-gate #endif 6087c478bd9Sstevel@tonic-gate #define FR_CMPSIZ (sizeof(struct frentry) - \ 609ab25eeb5Syz offsetof(struct frentry, fr_func)) 6107c478bd9Sstevel@tonic-gate 6117c478bd9Sstevel@tonic-gate /* 6127c478bd9Sstevel@tonic-gate * fr_type 6137c478bd9Sstevel@tonic-gate */ 6147c478bd9Sstevel@tonic-gate #define FR_T_NONE 0 6157c478bd9Sstevel@tonic-gate #define FR_T_IPF 1 /* IPF structures */ 6167c478bd9Sstevel@tonic-gate #define FR_T_BPFOPC 2 /* BPF opcode */ 6177c478bd9Sstevel@tonic-gate #define FR_T_CALLFUNC 3 /* callout to function in fr_func only */ 6187c478bd9Sstevel@tonic-gate #define FR_T_COMPIPF 4 /* compiled C code */ 6197c478bd9Sstevel@tonic-gate #define FR_T_BUILTIN 0x80000000 /* rule is in kernel space */ 6207c478bd9Sstevel@tonic-gate 6217c478bd9Sstevel@tonic-gate /* 6227c478bd9Sstevel@tonic-gate * fr_flags 6237c478bd9Sstevel@tonic-gate */ 6247c478bd9Sstevel@tonic-gate #define FR_CALL 0x00000 /* call rule */ 6257c478bd9Sstevel@tonic-gate #define FR_BLOCK 0x00001 /* do not allow packet to pass */ 6267c478bd9Sstevel@tonic-gate #define FR_PASS 0x00002 /* allow packet to pass */ 6277c478bd9Sstevel@tonic-gate #define FR_AUTH 0x00003 /* use authentication */ 6287c478bd9Sstevel@tonic-gate #define FR_PREAUTH 0x00004 /* require preauthentication */ 6297c478bd9Sstevel@tonic-gate #define FR_ACCOUNT 0x00005 /* Accounting rule */ 6307c478bd9Sstevel@tonic-gate #define FR_SKIP 0x00006 /* skip rule */ 6317c478bd9Sstevel@tonic-gate #define FR_DIVERT 0x00007 /* divert rule */ 6327c478bd9Sstevel@tonic-gate #define FR_CMDMASK 0x0000f 6337c478bd9Sstevel@tonic-gate #define FR_LOG 0x00010 /* Log */ 6347c478bd9Sstevel@tonic-gate #define FR_LOGB 0x00011 /* Log-fail */ 6357c478bd9Sstevel@tonic-gate #define FR_LOGP 0x00012 /* Log-pass */ 6367c478bd9Sstevel@tonic-gate #define FR_LOGMASK (FR_LOG|FR_CMDMASK) 6377c478bd9Sstevel@tonic-gate #define FR_CALLNOW 0x00020 /* call another function (fr_func) if matches */ 6387c478bd9Sstevel@tonic-gate #define FR_NOTSRCIP 0x00040 6397c478bd9Sstevel@tonic-gate #define FR_NOTDSTIP 0x00080 6407c478bd9Sstevel@tonic-gate #define FR_QUICK 0x00100 /* match & stop processing list */ 6417c478bd9Sstevel@tonic-gate #define FR_KEEPFRAG 0x00200 /* keep fragment information */ 6427c478bd9Sstevel@tonic-gate #define FR_KEEPSTATE 0x00400 /* keep `connection' state information */ 6437c478bd9Sstevel@tonic-gate #define FR_FASTROUTE 0x00800 /* bypass normal routing */ 6447c478bd9Sstevel@tonic-gate #define FR_RETRST 0x01000 /* Return TCP RST packet - reset connection */ 6457c478bd9Sstevel@tonic-gate #define FR_RETICMP 0x02000 /* Return ICMP unreachable packet */ 6467c478bd9Sstevel@tonic-gate #define FR_FAKEICMP 0x03000 /* Return ICMP unreachable with fake source */ 6477c478bd9Sstevel@tonic-gate #define FR_OUTQUE 0x04000 /* outgoing packets */ 6487c478bd9Sstevel@tonic-gate #define FR_INQUE 0x08000 /* ingoing packets */ 6497c478bd9Sstevel@tonic-gate #define FR_LOGBODY 0x10000 /* Log the body */ 6507c478bd9Sstevel@tonic-gate #define FR_LOGFIRST 0x20000 /* Log the first byte if state held */ 6517c478bd9Sstevel@tonic-gate #define FR_LOGORBLOCK 0x40000 /* block the packet if it can't be logged */ 6527c478bd9Sstevel@tonic-gate #define FR_DUP 0x80000 /* duplicate packet */ 6537c478bd9Sstevel@tonic-gate #define FR_FRSTRICT 0x100000 /* strict frag. cache */ 6547c478bd9Sstevel@tonic-gate #define FR_STSTRICT 0x200000 /* strict keep state */ 6557c478bd9Sstevel@tonic-gate #define FR_NEWISN 0x400000 /* new ISN for outgoing TCP */ 6567c478bd9Sstevel@tonic-gate #define FR_NOICMPERR 0x800000 /* do not match ICMP errors in state */ 657ab25eeb5Syz #define FR_STATESYNC 0x1000000 /* synchronize state to slave */ 6587c478bd9Sstevel@tonic-gate #define FR_NOMATCH 0x8000000 /* no match occured */ 6597c478bd9Sstevel@tonic-gate /* 0x10000000 FF_LOGPASS */ 6607c478bd9Sstevel@tonic-gate /* 0x20000000 FF_LOGBLOCK */ 6617c478bd9Sstevel@tonic-gate /* 0x40000000 FF_LOGNOMATCH */ 6627c478bd9Sstevel@tonic-gate /* 0x80000000 FF_BLOCKNONIP */ 6637c478bd9Sstevel@tonic-gate #define FR_COPIED 0x40000000 /* copied from user space */ 6647c478bd9Sstevel@tonic-gate #define FR_INACTIVE 0x80000000 /* only used when flush'ing rules */ 6657c478bd9Sstevel@tonic-gate 6667c478bd9Sstevel@tonic-gate #define FR_RETMASK (FR_RETICMP|FR_RETRST|FR_FAKEICMP) 6677c478bd9Sstevel@tonic-gate #define FR_ISBLOCK(x) (((x) & FR_CMDMASK) == FR_BLOCK) 6687c478bd9Sstevel@tonic-gate #define FR_ISPASS(x) (((x) & FR_CMDMASK) == FR_PASS) 6697c478bd9Sstevel@tonic-gate #define FR_ISAUTH(x) (((x) & FR_CMDMASK) == FR_AUTH) 6707c478bd9Sstevel@tonic-gate #define FR_ISPREAUTH(x) (((x) & FR_CMDMASK) == FR_PREAUTH) 6717c478bd9Sstevel@tonic-gate #define FR_ISACCOUNT(x) (((x) & FR_CMDMASK) == FR_ACCOUNT) 6727c478bd9Sstevel@tonic-gate #define FR_ISSKIP(x) (((x) & FR_CMDMASK) == FR_SKIP) 6737c478bd9Sstevel@tonic-gate #define FR_ISNOMATCH(x) ((x) & FR_NOMATCH) 6747c478bd9Sstevel@tonic-gate #define FR_INOUT (FR_INQUE|FR_OUTQUE) 6757c478bd9Sstevel@tonic-gate 6767c478bd9Sstevel@tonic-gate /* 6777c478bd9Sstevel@tonic-gate * recognized flags for SIOCGETFF and SIOCSETFF, and get put in fr_flags 6787c478bd9Sstevel@tonic-gate */ 6797c478bd9Sstevel@tonic-gate #define FF_LOGPASS 0x10000000 6807c478bd9Sstevel@tonic-gate #define FF_LOGBLOCK 0x20000000 6817c478bd9Sstevel@tonic-gate #define FF_LOGNOMATCH 0x40000000 6827c478bd9Sstevel@tonic-gate #define FF_LOGGING (FF_LOGPASS|FF_LOGBLOCK|FF_LOGNOMATCH) 6837c478bd9Sstevel@tonic-gate #define FF_BLOCKNONIP 0x80000000 /* Solaris2 Only */ 6847c478bd9Sstevel@tonic-gate 6857c478bd9Sstevel@tonic-gate 6867c478bd9Sstevel@tonic-gate /* 6877c478bd9Sstevel@tonic-gate * Structure that passes information on what/how to flush to the kernel. 6887c478bd9Sstevel@tonic-gate */ 6897c478bd9Sstevel@tonic-gate typedef struct ipfflush { 6907c478bd9Sstevel@tonic-gate int ipflu_how; 6917c478bd9Sstevel@tonic-gate int ipflu_arg; 6927c478bd9Sstevel@tonic-gate } ipfflush_t; 6937c478bd9Sstevel@tonic-gate 6947c478bd9Sstevel@tonic-gate 6957c478bd9Sstevel@tonic-gate /* 6967c478bd9Sstevel@tonic-gate * 6977c478bd9Sstevel@tonic-gate */ 6987c478bd9Sstevel@tonic-gate typedef struct ipfgetctl { 6997c478bd9Sstevel@tonic-gate u_int ipfg_min; /* min value */ 7007c478bd9Sstevel@tonic-gate u_int ipfg_current; /* current value */ 7017c478bd9Sstevel@tonic-gate u_int ipfg_max; /* max value */ 7027c478bd9Sstevel@tonic-gate u_int ipfg_default; /* default value */ 7037c478bd9Sstevel@tonic-gate u_int ipfg_steps; /* value increments */ 7047c478bd9Sstevel@tonic-gate char ipfg_name[40]; /* tag name for this control */ 7057c478bd9Sstevel@tonic-gate } ipfgetctl_t; 7067c478bd9Sstevel@tonic-gate 7077c478bd9Sstevel@tonic-gate typedef struct ipfsetctl { 7087c478bd9Sstevel@tonic-gate int ipfs_which; /* 0 = min 1 = current 2 = max 3 = default */ 7097c478bd9Sstevel@tonic-gate u_int ipfs_value; /* min value */ 7107c478bd9Sstevel@tonic-gate char ipfs_name[40]; /* tag name for this control */ 7117c478bd9Sstevel@tonic-gate } ipfsetctl_t; 7127c478bd9Sstevel@tonic-gate 7137c478bd9Sstevel@tonic-gate 7147c478bd9Sstevel@tonic-gate /* 7157c478bd9Sstevel@tonic-gate * Some of the statistics below are in their own counters, but most are kept 7167c478bd9Sstevel@tonic-gate * in this single structure so that they can all easily be collected and 7177c478bd9Sstevel@tonic-gate * copied back as required. 718e0b463afSschuster * 719e0b463afSschuster * NOTE: when changing, keep in sync with kstats (below). 7207c478bd9Sstevel@tonic-gate */ 7217c478bd9Sstevel@tonic-gate typedef struct filterstats { 7227c478bd9Sstevel@tonic-gate u_long fr_pass; /* packets allowed */ 7237c478bd9Sstevel@tonic-gate u_long fr_block; /* packets denied */ 7247c478bd9Sstevel@tonic-gate u_long fr_nom; /* packets which don't match any rule */ 7257c478bd9Sstevel@tonic-gate u_long fr_short; /* packets which are short */ 7267c478bd9Sstevel@tonic-gate u_long fr_ppkl; /* packets allowed and logged */ 7277c478bd9Sstevel@tonic-gate u_long fr_bpkl; /* packets denied and logged */ 7287c478bd9Sstevel@tonic-gate u_long fr_npkl; /* packets unmatched and logged */ 7297c478bd9Sstevel@tonic-gate u_long fr_pkl; /* packets logged */ 7307c478bd9Sstevel@tonic-gate u_long fr_skip; /* packets to be logged but buffer full */ 7317c478bd9Sstevel@tonic-gate u_long fr_ret; /* packets for which a return is sent */ 7327c478bd9Sstevel@tonic-gate u_long fr_acct; /* packets for which counting was performed */ 7337c478bd9Sstevel@tonic-gate u_long fr_bnfr; /* bad attempts to allocate fragment state */ 7347c478bd9Sstevel@tonic-gate u_long fr_nfr; /* new fragment state kept */ 7357c478bd9Sstevel@tonic-gate u_long fr_cfr; /* add new fragment state but complete pkt */ 7367c478bd9Sstevel@tonic-gate u_long fr_bads; /* bad attempts to allocate packet state */ 7377c478bd9Sstevel@tonic-gate u_long fr_ads; /* new packet state kept */ 7387c478bd9Sstevel@tonic-gate u_long fr_chit; /* cached hit */ 7397c478bd9Sstevel@tonic-gate u_long fr_tcpbad; /* TCP checksum check failures */ 7407c478bd9Sstevel@tonic-gate u_long fr_pull[2]; /* good and bad pullup attempts */ 7417c478bd9Sstevel@tonic-gate u_long fr_badsrc; /* source received doesn't match route */ 7427c478bd9Sstevel@tonic-gate u_long fr_badttl; /* TTL in packet doesn't reach minimum */ 7437c478bd9Sstevel@tonic-gate u_long fr_bad; /* bad IP packets to the filter */ 7447c478bd9Sstevel@tonic-gate u_long fr_ipv6; /* IPv6 packets in/out */ 7457c478bd9Sstevel@tonic-gate u_long fr_ppshit; /* dropped because of pps ceiling */ 7467c478bd9Sstevel@tonic-gate u_long fr_ipud; /* IP id update failures */ 7477c478bd9Sstevel@tonic-gate } filterstats_t; 7487c478bd9Sstevel@tonic-gate 749e0b463afSschuster /* 750e0b463afSschuster * kstat "copy" of the above - keep in sync! 751e0b463afSschuster * also keep in sync with initialisation code in solaris.c, ipf_kstat_init(). 752e0b463afSschuster */ 753e0b463afSschuster typedef struct filter_kstats { 754e0b463afSschuster kstat_named_t fks_pass; /* see above for comments */ 755e0b463afSschuster kstat_named_t fks_block; 756e0b463afSschuster kstat_named_t fks_nom; 757e0b463afSschuster kstat_named_t fks_short; 758e0b463afSschuster kstat_named_t fks_ppkl; 759e0b463afSschuster kstat_named_t fks_bpkl; 760e0b463afSschuster kstat_named_t fks_npkl; 761e0b463afSschuster kstat_named_t fks_pkl; 762e0b463afSschuster kstat_named_t fks_skip; 763e0b463afSschuster kstat_named_t fks_ret; 764e0b463afSschuster kstat_named_t fks_acct; 765e0b463afSschuster kstat_named_t fks_bnfr; 766e0b463afSschuster kstat_named_t fks_nfr; 767e0b463afSschuster kstat_named_t fks_cfr; 768e0b463afSschuster kstat_named_t fks_bads; 769e0b463afSschuster kstat_named_t fks_ads; 770e0b463afSschuster kstat_named_t fks_chit; 771e0b463afSschuster kstat_named_t fks_tcpbad; 772e0b463afSschuster kstat_named_t fks_pull[2]; 773e0b463afSschuster kstat_named_t fks_badsrc; 774e0b463afSschuster kstat_named_t fks_badttl; 775e0b463afSschuster kstat_named_t fks_bad; 776e0b463afSschuster kstat_named_t fks_ipv6; 777e0b463afSschuster kstat_named_t fks_ppshit; 778e0b463afSschuster kstat_named_t fks_ipud; 779e0b463afSschuster } filter_kstats_t; 780e0b463afSschuster 7817c478bd9Sstevel@tonic-gate /* 7827c478bd9Sstevel@tonic-gate * Log structure. Each packet header logged is prepended by one of these. 7837c478bd9Sstevel@tonic-gate * Following this in the log records read from the device will be an ipflog 7847c478bd9Sstevel@tonic-gate * structure which is then followed by any packet data. 7857c478bd9Sstevel@tonic-gate */ 7867c478bd9Sstevel@tonic-gate typedef struct iplog { 7877c478bd9Sstevel@tonic-gate u_32_t ipl_magic; 7887c478bd9Sstevel@tonic-gate u_int ipl_count; 789ab25eeb5Syz struct timeval ipl_time; 7907c478bd9Sstevel@tonic-gate size_t ipl_dsize; 7917c478bd9Sstevel@tonic-gate struct iplog *ipl_next; 7927c478bd9Sstevel@tonic-gate } iplog_t; 7937c478bd9Sstevel@tonic-gate 794ab25eeb5Syz #define ipl_sec ipl_time.tv_sec 795ab25eeb5Syz #define ipl_usec ipl_time.tv_usec 7967c478bd9Sstevel@tonic-gate 7977c478bd9Sstevel@tonic-gate #define IPL_MAGIC 0x49504c4d /* 'IPLM' */ 798ab25eeb5Syz #define IPL_MAGIC_NAT 0x49504c4e /* 'IPLN' */ 799ab25eeb5Syz #define IPL_MAGIC_STATE 0x49504c53 /* 'IPLS' */ 8007c478bd9Sstevel@tonic-gate #define IPLOG_SIZE sizeof(iplog_t) 8017c478bd9Sstevel@tonic-gate 8027c478bd9Sstevel@tonic-gate typedef struct ipflog { 8037c478bd9Sstevel@tonic-gate #if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \ 8047c478bd9Sstevel@tonic-gate (defined(OpenBSD) && (OpenBSD >= 199603)) 8057c478bd9Sstevel@tonic-gate #else 8067c478bd9Sstevel@tonic-gate u_int fl_unit; 8077c478bd9Sstevel@tonic-gate #endif 8087c478bd9Sstevel@tonic-gate u_32_t fl_rule; 8097c478bd9Sstevel@tonic-gate u_32_t fl_flags; 8107c478bd9Sstevel@tonic-gate u_32_t fl_lflags; 811ab25eeb5Syz u_32_t fl_logtag; 812ab25eeb5Syz ipftag_t fl_nattag; 8137c478bd9Sstevel@tonic-gate u_short fl_plen; /* extra data after hlen */ 8147c478bd9Sstevel@tonic-gate u_short fl_loglevel; /* syslog log level */ 8157c478bd9Sstevel@tonic-gate char fl_group[FR_GROUPLEN]; 8167c478bd9Sstevel@tonic-gate u_char fl_hlen; /* length of IP headers saved */ 8177c478bd9Sstevel@tonic-gate u_char fl_dir; 818ab25eeb5Syz u_char fl_xxx[2]; /* pad */ 8197c478bd9Sstevel@tonic-gate char fl_ifname[LIFNAMSIZ]; 8207c478bd9Sstevel@tonic-gate } ipflog_t; 8217c478bd9Sstevel@tonic-gate 8227c478bd9Sstevel@tonic-gate #ifndef IPF_LOGGING 8237c478bd9Sstevel@tonic-gate # define IPF_LOGGING 0 8247c478bd9Sstevel@tonic-gate #endif 8257c478bd9Sstevel@tonic-gate #ifndef IPF_DEFAULT_PASS 8267c478bd9Sstevel@tonic-gate # define IPF_DEFAULT_PASS FR_PASS 8277c478bd9Sstevel@tonic-gate #endif 8287c478bd9Sstevel@tonic-gate 8297c478bd9Sstevel@tonic-gate #define DEFAULT_IPFLOGSIZE 8192 8307c478bd9Sstevel@tonic-gate #ifndef IPFILTER_LOGSIZE 8317c478bd9Sstevel@tonic-gate # define IPFILTER_LOGSIZE DEFAULT_IPFLOGSIZE 8327c478bd9Sstevel@tonic-gate #else 833ab25eeb5Syz # if IPFILTER_LOGSIZE < DEFAULT_IPFLOGSIZE 834ab25eeb5Syz # error IPFILTER_LOGSIZE too small. Must be >= DEFAULT_IPFLOGSIZE 8357c478bd9Sstevel@tonic-gate # endif 8367c478bd9Sstevel@tonic-gate #endif 8377c478bd9Sstevel@tonic-gate 8387c478bd9Sstevel@tonic-gate #define IPF_OPTCOPY 0x07ff00 /* bit mask of copied options */ 8397c478bd9Sstevel@tonic-gate 8407c478bd9Sstevel@tonic-gate /* 8417c478bd9Sstevel@tonic-gate * Device filenames for reading log information. Use ipf on Solaris2 because 8427c478bd9Sstevel@tonic-gate * ipl is already a name used by something else. 8437c478bd9Sstevel@tonic-gate */ 8447c478bd9Sstevel@tonic-gate #ifndef IPL_NAME 8457c478bd9Sstevel@tonic-gate # if SOLARIS 8467c478bd9Sstevel@tonic-gate # define IPL_NAME "/dev/ipf" 8477c478bd9Sstevel@tonic-gate # else 8487c478bd9Sstevel@tonic-gate # define IPL_NAME "/dev/ipl" 8497c478bd9Sstevel@tonic-gate # endif 8507c478bd9Sstevel@tonic-gate #endif 8517c478bd9Sstevel@tonic-gate /* 8527c478bd9Sstevel@tonic-gate * Pathnames for various IP Filter control devices. Used by LKM 8537c478bd9Sstevel@tonic-gate * and userland, so defined here. 8547c478bd9Sstevel@tonic-gate */ 8557c478bd9Sstevel@tonic-gate #define IPNAT_NAME "/dev/ipnat" 8567c478bd9Sstevel@tonic-gate #define IPSTATE_NAME "/dev/ipstate" 8577c478bd9Sstevel@tonic-gate #define IPAUTH_NAME "/dev/ipauth" 8587c478bd9Sstevel@tonic-gate #define IPSYNC_NAME "/dev/ipsync" 8597c478bd9Sstevel@tonic-gate #define IPSCAN_NAME "/dev/ipscan" 8607c478bd9Sstevel@tonic-gate #define IPLOOKUP_NAME "/dev/iplookup" 8617c478bd9Sstevel@tonic-gate 8627c478bd9Sstevel@tonic-gate #define IPL_LOGIPF 0 /* Minor device #'s for accessing logs */ 8637c478bd9Sstevel@tonic-gate #define IPL_LOGNAT 1 8647c478bd9Sstevel@tonic-gate #define IPL_LOGSTATE 2 8657c478bd9Sstevel@tonic-gate #define IPL_LOGAUTH 3 8667c478bd9Sstevel@tonic-gate #define IPL_LOGSYNC 4 8677c478bd9Sstevel@tonic-gate #define IPL_LOGSCAN 5 8687c478bd9Sstevel@tonic-gate #define IPL_LOGLOOKUP 6 8697c478bd9Sstevel@tonic-gate #define IPL_LOGCOUNT 7 8707c478bd9Sstevel@tonic-gate #define IPL_LOGMAX 7 871*f4b3ec61Sdh #define IPL_LOGSIZE (IPL_LOGMAX + 1) 8727c478bd9Sstevel@tonic-gate #define IPL_LOGALL -1 8737c478bd9Sstevel@tonic-gate #define IPL_LOGNONE -2 8747c478bd9Sstevel@tonic-gate 8757c478bd9Sstevel@tonic-gate /* 8767c478bd9Sstevel@tonic-gate * For SIOCGETFS 8777c478bd9Sstevel@tonic-gate */ 8787c478bd9Sstevel@tonic-gate typedef struct friostat { 8797c478bd9Sstevel@tonic-gate struct filterstats f_st[2]; 8807c478bd9Sstevel@tonic-gate struct frentry *f_ipf[2][2]; 8817c478bd9Sstevel@tonic-gate struct frentry *f_acct[2][2]; 8827c478bd9Sstevel@tonic-gate struct frentry *f_ipf6[2][2]; 8837c478bd9Sstevel@tonic-gate struct frentry *f_acct6[2][2]; 8847c478bd9Sstevel@tonic-gate struct frentry *f_auth; 8857c478bd9Sstevel@tonic-gate struct frgroup *f_groups[IPL_LOGSIZE][2]; 8867c478bd9Sstevel@tonic-gate u_long f_froute[2]; 8877c478bd9Sstevel@tonic-gate u_long f_ticks; 8887c478bd9Sstevel@tonic-gate int f_locks[IPL_LOGMAX]; 8897c478bd9Sstevel@tonic-gate size_t f_kmutex_sz; 8907c478bd9Sstevel@tonic-gate size_t f_krwlock_sz; 8917c478bd9Sstevel@tonic-gate int f_defpass; /* default pass - from fr_pass */ 892ab25eeb5Syz int f_active; /* 1 or 0 - active rule set */ 893ab25eeb5Syz int f_running; /* 1 if running, else 0 */ 894ab25eeb5Syz int f_logging; /* 1 if enabled, else 0 */ 895ab25eeb5Syz int f_features; 8967c478bd9Sstevel@tonic-gate char f_version[32]; /* version string */ 8977c478bd9Sstevel@tonic-gate } friostat_t; 8987c478bd9Sstevel@tonic-gate 8997c478bd9Sstevel@tonic-gate #define f_fin f_ipf[0] 9007c478bd9Sstevel@tonic-gate #define f_fin6 f_ipf6[0] 9017c478bd9Sstevel@tonic-gate #define f_fout f_ipf[1] 9027c478bd9Sstevel@tonic-gate #define f_fout6 f_ipf6[1] 9037c478bd9Sstevel@tonic-gate #define f_acctin f_acct[0] 9047c478bd9Sstevel@tonic-gate #define f_acctin6 f_acct6[0] 9057c478bd9Sstevel@tonic-gate #define f_acctout f_acct[1] 9067c478bd9Sstevel@tonic-gate #define f_acctout6 f_acct6[1] 9077c478bd9Sstevel@tonic-gate 908ab25eeb5Syz #define IPF_FEAT_LKM 0x001 909ab25eeb5Syz #define IPF_FEAT_LOG 0x002 910ab25eeb5Syz #define IPF_FEAT_LOOKUP 0x004 911ab25eeb5Syz #define IPF_FEAT_BPF 0x008 912ab25eeb5Syz #define IPF_FEAT_COMPILED 0x010 913ab25eeb5Syz #define IPF_FEAT_CKSUM 0x020 914ab25eeb5Syz #define IPF_FEAT_SYNC 0x040 915ab25eeb5Syz #define IPF_FEAT_SCAN 0x080 916ab25eeb5Syz #define IPF_FEAT_IPV6 0x100 9177c478bd9Sstevel@tonic-gate 9187c478bd9Sstevel@tonic-gate typedef struct optlist { 9197c478bd9Sstevel@tonic-gate u_short ol_val; 9207c478bd9Sstevel@tonic-gate int ol_bit; 9217c478bd9Sstevel@tonic-gate } optlist_t; 9227c478bd9Sstevel@tonic-gate 9237c478bd9Sstevel@tonic-gate 9247c478bd9Sstevel@tonic-gate /* 9257c478bd9Sstevel@tonic-gate * Group list structure. 9267c478bd9Sstevel@tonic-gate */ 9277c478bd9Sstevel@tonic-gate typedef struct frgroup { 9287c478bd9Sstevel@tonic-gate struct frgroup *fg_next; 9297c478bd9Sstevel@tonic-gate struct frentry *fg_head; 9307c478bd9Sstevel@tonic-gate struct frentry *fg_start; 9317c478bd9Sstevel@tonic-gate u_32_t fg_flags; 9327c478bd9Sstevel@tonic-gate int fg_ref; 9337c478bd9Sstevel@tonic-gate char fg_name[FR_GROUPLEN]; 9347c478bd9Sstevel@tonic-gate } frgroup_t; 9357c478bd9Sstevel@tonic-gate 9367c478bd9Sstevel@tonic-gate #define FG_NAME(g) (*(g)->fg_name == '\0' ? "" : (g)->fg_name) 9377c478bd9Sstevel@tonic-gate 9387c478bd9Sstevel@tonic-gate 9397c478bd9Sstevel@tonic-gate /* 9407c478bd9Sstevel@tonic-gate * Used by state and NAT tables 9417c478bd9Sstevel@tonic-gate */ 9427c478bd9Sstevel@tonic-gate typedef struct icmpinfo { 9437c478bd9Sstevel@tonic-gate u_short ici_id; 9447c478bd9Sstevel@tonic-gate u_short ici_seq; 9457c478bd9Sstevel@tonic-gate u_char ici_type; 9467c478bd9Sstevel@tonic-gate } icmpinfo_t; 9477c478bd9Sstevel@tonic-gate 9487c478bd9Sstevel@tonic-gate typedef struct udpinfo { 9497c478bd9Sstevel@tonic-gate u_short us_sport; 9507c478bd9Sstevel@tonic-gate u_short us_dport; 9517c478bd9Sstevel@tonic-gate } udpinfo_t; 9527c478bd9Sstevel@tonic-gate 9537c478bd9Sstevel@tonic-gate 9547c478bd9Sstevel@tonic-gate typedef struct tcpdata { 9557c478bd9Sstevel@tonic-gate u_32_t td_end; 9567c478bd9Sstevel@tonic-gate u_32_t td_maxend; 9577c478bd9Sstevel@tonic-gate u_32_t td_maxwin; 9587c478bd9Sstevel@tonic-gate u_32_t td_winscale; 9597c478bd9Sstevel@tonic-gate u_32_t td_maxseg; 9607c478bd9Sstevel@tonic-gate int td_winflags; 9617c478bd9Sstevel@tonic-gate } tcpdata_t; 9627c478bd9Sstevel@tonic-gate 9637c478bd9Sstevel@tonic-gate #define TCP_WSCALE_MAX 14 9647c478bd9Sstevel@tonic-gate 9657c478bd9Sstevel@tonic-gate #define TCP_WSCALE_SEEN 0x00000001 9667c478bd9Sstevel@tonic-gate #define TCP_WSCALE_FIRST 0x00000002 9677c478bd9Sstevel@tonic-gate 9687c478bd9Sstevel@tonic-gate 9697c478bd9Sstevel@tonic-gate typedef struct tcpinfo { 9707c478bd9Sstevel@tonic-gate u_short ts_sport; 9717c478bd9Sstevel@tonic-gate u_short ts_dport; 9727c478bd9Sstevel@tonic-gate tcpdata_t ts_data[2]; 9737c478bd9Sstevel@tonic-gate } tcpinfo_t; 9747c478bd9Sstevel@tonic-gate 975ab25eeb5Syz 976ab25eeb5Syz /* 977ab25eeb5Syz * Structures to define a GRE header as seen in a packet. 978ab25eeb5Syz */ 979ab25eeb5Syz struct grebits { 980ab25eeb5Syz u_32_t grb_C:1; 981ab25eeb5Syz u_32_t grb_R:1; 982ab25eeb5Syz u_32_t grb_K:1; 983ab25eeb5Syz u_32_t grb_S:1; 984ab25eeb5Syz u_32_t grb_s:1; 985ab25eeb5Syz u_32_t grb_recur:1; 986ab25eeb5Syz u_32_t grb_A:1; 987ab25eeb5Syz u_32_t grb_flags:3; 988ab25eeb5Syz u_32_t grb_ver:3; 989ab25eeb5Syz u_short grb_ptype; 990ab25eeb5Syz }; 9917c478bd9Sstevel@tonic-gate 9927c478bd9Sstevel@tonic-gate typedef struct grehdr { 9937c478bd9Sstevel@tonic-gate union { 994ab25eeb5Syz struct grebits gru_bits; 9957c478bd9Sstevel@tonic-gate u_short gru_flags; 9967c478bd9Sstevel@tonic-gate } gr_un; 9977c478bd9Sstevel@tonic-gate u_short gr_len; 9987c478bd9Sstevel@tonic-gate u_short gr_call; 9997c478bd9Sstevel@tonic-gate } grehdr_t; 10007c478bd9Sstevel@tonic-gate 1001ab25eeb5Syz #define gr_flags gr_un.gru_flags 10027c478bd9Sstevel@tonic-gate #define gr_bits gr_un.gru_bits 1003ab25eeb5Syz #define gr_ptype gr_bits.grb_ptype 1004ab25eeb5Syz #define gr_C gr_bits.grb_C 1005ab25eeb5Syz #define gr_R gr_bits.grb_R 1006ab25eeb5Syz #define gr_K gr_bits.grb_K 1007ab25eeb5Syz #define gr_S gr_bits.grb_S 1008ab25eeb5Syz #define gr_s gr_bits.grb_s 1009ab25eeb5Syz #define gr_recur gr_bits.grb_recur 1010ab25eeb5Syz #define gr_A gr_bits.grb_A 1011ab25eeb5Syz #define gr_ver gr_bits.grb_ver 1012ab25eeb5Syz 1013ab25eeb5Syz /* 1014ab25eeb5Syz * GRE information tracked by "keep state" 1015ab25eeb5Syz */ 1016ab25eeb5Syz typedef struct greinfo { 1017ab25eeb5Syz u_short gs_call[2]; 1018ab25eeb5Syz u_short gs_flags; 1019ab25eeb5Syz u_short gs_ptype; 1020ab25eeb5Syz } greinfo_t; 1021ab25eeb5Syz 1022ab25eeb5Syz #define GRE_REV(x) ((ntohs(x) >> 13) & 7) 1023ab25eeb5Syz 1024ab25eeb5Syz 1025ab25eeb5Syz /* 1026ab25eeb5Syz * Format of an Authentication header 1027ab25eeb5Syz */ 1028ab25eeb5Syz typedef struct authhdr { 1029ab25eeb5Syz u_char ah_next; 1030ab25eeb5Syz u_char ah_plen; 1031ab25eeb5Syz u_short ah_reserved; 1032ab25eeb5Syz u_32_t ah_spi; 1033ab25eeb5Syz u_32_t ah_seq; 1034ab25eeb5Syz /* Following the sequence number field is 0 or more bytes of */ 1035ab25eeb5Syz /* authentication data, as specified by ah_plen - RFC 2402. */ 1036ab25eeb5Syz } authhdr_t; 10377c478bd9Sstevel@tonic-gate 10387c478bd9Sstevel@tonic-gate 10397c478bd9Sstevel@tonic-gate /* 10407c478bd9Sstevel@tonic-gate * Timeout tail queue list member 10417c478bd9Sstevel@tonic-gate */ 10427c478bd9Sstevel@tonic-gate typedef struct ipftqent { 10437c478bd9Sstevel@tonic-gate struct ipftqent **tqe_pnext; 10447c478bd9Sstevel@tonic-gate struct ipftqent *tqe_next; 10457c478bd9Sstevel@tonic-gate struct ipftq *tqe_ifq; 10467c478bd9Sstevel@tonic-gate void *tqe_parent; /* pointer back to NAT/state struct */ 10477c478bd9Sstevel@tonic-gate u_long tqe_die; /* when this entriy is to die */ 10487c478bd9Sstevel@tonic-gate u_long tqe_touched; 10497c478bd9Sstevel@tonic-gate int tqe_flags; 10507c478bd9Sstevel@tonic-gate int tqe_state[2]; /* current state of this entry */ 10517c478bd9Sstevel@tonic-gate } ipftqent_t; 10527c478bd9Sstevel@tonic-gate 10537c478bd9Sstevel@tonic-gate #define TQE_RULEBASED 0x00000001 10547c478bd9Sstevel@tonic-gate 10557c478bd9Sstevel@tonic-gate 10567c478bd9Sstevel@tonic-gate /* 10577c478bd9Sstevel@tonic-gate * Timeout tail queue head for IPFilter 10587c478bd9Sstevel@tonic-gate */ 10597c478bd9Sstevel@tonic-gate typedef struct ipftq { 10607c478bd9Sstevel@tonic-gate ipfmutex_t ifq_lock; 10617c478bd9Sstevel@tonic-gate u_int ifq_ttl; 10627c478bd9Sstevel@tonic-gate ipftqent_t *ifq_head; 10637c478bd9Sstevel@tonic-gate ipftqent_t **ifq_tail; 10647c478bd9Sstevel@tonic-gate struct ipftq *ifq_next; 10657c478bd9Sstevel@tonic-gate struct ipftq **ifq_pnext; 10667c478bd9Sstevel@tonic-gate int ifq_ref; 10677c478bd9Sstevel@tonic-gate u_int ifq_flags; 10687c478bd9Sstevel@tonic-gate } ipftq_t; 10697c478bd9Sstevel@tonic-gate 10707c478bd9Sstevel@tonic-gate #define IFQF_USER 0x01 /* User defined aging */ 1071ab25eeb5Syz #define IFQF_DELETE 0x02 /* Marked for deletion */ 1072ab25eeb5Syz #define IFQF_PROXY 0x04 /* Timeout queue in use by a proxy */ 10737c478bd9Sstevel@tonic-gate 10747c478bd9Sstevel@tonic-gate #define IPF_HZ_MULT 1 10757c478bd9Sstevel@tonic-gate #define IPF_HZ_DIVIDE 2 /* How many times a second ipfilter */ 10767c478bd9Sstevel@tonic-gate /* checks its timeout queues. */ 10777c478bd9Sstevel@tonic-gate #define IPF_TTLVAL(x) (((x) / IPF_HZ_MULT) * IPF_HZ_DIVIDE) 10787c478bd9Sstevel@tonic-gate 10797c478bd9Sstevel@tonic-gate /* 10807c478bd9Sstevel@tonic-gate * Structure to define address for pool lookups. 10817c478bd9Sstevel@tonic-gate */ 10827c478bd9Sstevel@tonic-gate typedef struct { 10837c478bd9Sstevel@tonic-gate u_char adf_len; 10847663b816Sml sa_family_t adf_family; 10857c478bd9Sstevel@tonic-gate i6addr_t adf_addr; 10867c478bd9Sstevel@tonic-gate } addrfamily_t; 10877c478bd9Sstevel@tonic-gate 10887c478bd9Sstevel@tonic-gate 10897c478bd9Sstevel@tonic-gate /* 10907c478bd9Sstevel@tonic-gate * Object structure description. For passing through in ioctls. 10917c478bd9Sstevel@tonic-gate */ 10927c478bd9Sstevel@tonic-gate typedef struct ipfobj { 10937c478bd9Sstevel@tonic-gate u_32_t ipfo_rev; /* IPFilter version number */ 10947c478bd9Sstevel@tonic-gate u_32_t ipfo_size; /* size of object at ipfo_ptr */ 10957c478bd9Sstevel@tonic-gate void *ipfo_ptr; /* pointer to object */ 10967c478bd9Sstevel@tonic-gate int ipfo_type; /* type of object being pointed to */ 10977c478bd9Sstevel@tonic-gate int ipfo_offset; /* bytes from ipfo_ptr where to start */ 10987c478bd9Sstevel@tonic-gate u_char ipfo_xxxpad[32]; /* reserved for future use */ 10997c478bd9Sstevel@tonic-gate } ipfobj_t; 11007c478bd9Sstevel@tonic-gate 11017c478bd9Sstevel@tonic-gate #define IPFOBJ_FRENTRY 0 /* struct frentry */ 11027c478bd9Sstevel@tonic-gate #define IPFOBJ_IPFSTAT 1 /* struct friostat */ 11037c478bd9Sstevel@tonic-gate #define IPFOBJ_IPFINFO 2 /* struct fr_info */ 11047c478bd9Sstevel@tonic-gate #define IPFOBJ_AUTHSTAT 3 /* struct fr_authstat */ 11057c478bd9Sstevel@tonic-gate #define IPFOBJ_FRAGSTAT 4 /* struct ipfrstat */ 11067c478bd9Sstevel@tonic-gate #define IPFOBJ_IPNAT 5 /* struct ipnat */ 11077c478bd9Sstevel@tonic-gate #define IPFOBJ_NATSTAT 6 /* struct natstat */ 11087c478bd9Sstevel@tonic-gate #define IPFOBJ_STATESAVE 7 /* struct ipstate_save */ 11097c478bd9Sstevel@tonic-gate #define IPFOBJ_NATSAVE 8 /* struct nat_save */ 11107c478bd9Sstevel@tonic-gate #define IPFOBJ_NATLOOKUP 9 /* struct natlookup */ 11117c478bd9Sstevel@tonic-gate #define IPFOBJ_IPSTATE 10 /* struct ipstate */ 11127c478bd9Sstevel@tonic-gate #define IPFOBJ_STATESTAT 11 /* struct ips_stat */ 11137c478bd9Sstevel@tonic-gate #define IPFOBJ_FRAUTH 12 /* struct frauth */ 11147c478bd9Sstevel@tonic-gate #define IPFOBJ_TUNEABLE 13 /* struct ipftune */ 1115*f4b3ec61Sdh #define IPFOBJ_NAT 14 /* struct nat */ 1116*f4b3ec61Sdh #define IPFOBJ_IPFITER 15 /* struct ipfruleiter */ 1117*f4b3ec61Sdh #define IPFOBJ_GENITER 16 /* struct ipfgeniter */ 1118*f4b3ec61Sdh #define IPFOBJ_GTABLE 17 /* struct ipftable */ 1119*f4b3ec61Sdh #define IPFOBJ_LOOKUPITER 18 /* struct ipflookupiter */ 1120*f4b3ec61Sdh #define IPFOBJ_COUNT 19 /* How many #defines are above this? */ 11217c478bd9Sstevel@tonic-gate 11227c478bd9Sstevel@tonic-gate 11237c478bd9Sstevel@tonic-gate typedef union ipftunevalptr { 11247c478bd9Sstevel@tonic-gate void *ipftp_void; 11257c478bd9Sstevel@tonic-gate u_long *ipftp_long; 11267c478bd9Sstevel@tonic-gate u_int *ipftp_int; 11277c478bd9Sstevel@tonic-gate u_short *ipftp_short; 11287c478bd9Sstevel@tonic-gate u_char *ipftp_char; 11297c478bd9Sstevel@tonic-gate } ipftunevalptr_t; 11307c478bd9Sstevel@tonic-gate 11317c478bd9Sstevel@tonic-gate typedef struct ipftuneable { 11327c478bd9Sstevel@tonic-gate ipftunevalptr_t ipft_una; 11337c478bd9Sstevel@tonic-gate char *ipft_name; 11347c478bd9Sstevel@tonic-gate u_long ipft_min; 11357c478bd9Sstevel@tonic-gate u_long ipft_max; 11367c478bd9Sstevel@tonic-gate int ipft_sz; 11377c478bd9Sstevel@tonic-gate int ipft_flags; 1138ab25eeb5Syz struct ipftuneable *ipft_next; 11397c478bd9Sstevel@tonic-gate } ipftuneable_t; 11407c478bd9Sstevel@tonic-gate 11417c478bd9Sstevel@tonic-gate #define ipft_addr ipft_una.ipftp_void 11427c478bd9Sstevel@tonic-gate #define ipft_plong ipft_una.ipftp_long 11437c478bd9Sstevel@tonic-gate #define ipft_pint ipft_una.ipftp_int 11447c478bd9Sstevel@tonic-gate #define ipft_pshort ipft_una.ipftp_short 11457c478bd9Sstevel@tonic-gate #define ipft_pchar ipft_una.ipftp_char 11467c478bd9Sstevel@tonic-gate 11477c478bd9Sstevel@tonic-gate #define IPFT_RDONLY 1 /* read-only */ 11487c478bd9Sstevel@tonic-gate #define IPFT_WRDISABLED 2 /* write when disabled only */ 11497c478bd9Sstevel@tonic-gate 11507c478bd9Sstevel@tonic-gate typedef union ipftuneval { 11517c478bd9Sstevel@tonic-gate u_long ipftu_long; 11527c478bd9Sstevel@tonic-gate u_int ipftu_int; 11537c478bd9Sstevel@tonic-gate u_short ipftu_short; 11547c478bd9Sstevel@tonic-gate u_char ipftu_char; 11557c478bd9Sstevel@tonic-gate } ipftuneval_t; 11567c478bd9Sstevel@tonic-gate 11577c478bd9Sstevel@tonic-gate typedef struct ipftune { 11587c478bd9Sstevel@tonic-gate void *ipft_cookie; 11597c478bd9Sstevel@tonic-gate ipftuneval_t ipft_un; 11607c478bd9Sstevel@tonic-gate u_long ipft_min; 11617c478bd9Sstevel@tonic-gate u_long ipft_max; 11627c478bd9Sstevel@tonic-gate int ipft_sz; 11637c478bd9Sstevel@tonic-gate int ipft_flags; 11647c478bd9Sstevel@tonic-gate char ipft_name[80]; 11657c478bd9Sstevel@tonic-gate } ipftune_t; 11667c478bd9Sstevel@tonic-gate 11677c478bd9Sstevel@tonic-gate #define ipft_vlong ipft_un.ipftu_long 11687c478bd9Sstevel@tonic-gate #define ipft_vint ipft_un.ipftu_int 11697c478bd9Sstevel@tonic-gate #define ipft_vshort ipft_un.ipftu_short 11707c478bd9Sstevel@tonic-gate #define ipft_vchar ipft_un.ipftu_char 11717c478bd9Sstevel@tonic-gate 11727c478bd9Sstevel@tonic-gate 1173*f4b3ec61Sdh typedef struct ipfruleiter { 1174*f4b3ec61Sdh int iri_ver; 1175*f4b3ec61Sdh int iri_inout; 1176*f4b3ec61Sdh char iri_group[FR_GROUPLEN]; 1177*f4b3ec61Sdh int iri_active; 1178*f4b3ec61Sdh frentry_t *iri_rule; 1179*f4b3ec61Sdh } ipfruleiter_t; 1180*f4b3ec61Sdh 1181*f4b3ec61Sdh typedef struct ipfgeniter { 1182*f4b3ec61Sdh int igi_type; 1183*f4b3ec61Sdh void *igi_data; 1184*f4b3ec61Sdh } ipfgeniter_t; 1185*f4b3ec61Sdh 1186*f4b3ec61Sdh #define IPFGENITER_IPF 0 1187*f4b3ec61Sdh #define IPFGENITER_NAT 1 1188*f4b3ec61Sdh #define IPFGENITER_IPNAT 2 1189*f4b3ec61Sdh #define IPFGENITER_FRAG 3 1190*f4b3ec61Sdh #define IPFGENITER_AUTH 4 1191*f4b3ec61Sdh #define IPFGENITER_STATE 5 1192*f4b3ec61Sdh #define IPFGENITER_NATFRAG 6 1193*f4b3ec61Sdh #define IPFGENITER_HOSTMAP 7 1194*f4b3ec61Sdh #define IPFGENITER_LOOKUP 8 1195*f4b3ec61Sdh 1196*f4b3ec61Sdh typedef struct ipftable { 1197*f4b3ec61Sdh int ita_type; 1198*f4b3ec61Sdh void *ita_table; 1199*f4b3ec61Sdh } ipftable_t; 1200*f4b3ec61Sdh 1201*f4b3ec61Sdh typedef struct ipftoken { 1202*f4b3ec61Sdh struct ipftoken *ipt_next; 1203*f4b3ec61Sdh struct ipftoken **ipt_pnext; 1204*f4b3ec61Sdh void *ipt_ctx; 1205*f4b3ec61Sdh void *ipt_data; 1206*f4b3ec61Sdh u_long ipt_die; 1207*f4b3ec61Sdh int ipt_type; 1208*f4b3ec61Sdh int ipt_uid; 1209*f4b3ec61Sdh int ipt_subtype; 1210*f4b3ec61Sdh int ipt_alive; 1211*f4b3ec61Sdh } ipftoken_t; 1212*f4b3ec61Sdh 1213*f4b3ec61Sdh 1214381a2a9aSdr /* 1215381a2a9aSdr * sync commands 1216381a2a9aSdr */ 1217381a2a9aSdr #define IPFSYNC_RESYNC 0 1218381a2a9aSdr #define IPFSYNC_NEWIFP 1 1219381a2a9aSdr #define IPFSYNC_OLDIFP 2 1220381a2a9aSdr 1221381a2a9aSdr 12227c478bd9Sstevel@tonic-gate /* 12237c478bd9Sstevel@tonic-gate ** HPUX Port 12247c478bd9Sstevel@tonic-gate */ 12257c478bd9Sstevel@tonic-gate #ifdef __hpux 12267c478bd9Sstevel@tonic-gate /* HP-UX locking sequence deadlock detection module lock MAJOR ID */ 12277c478bd9Sstevel@tonic-gate # define IPF_SMAJ 0 /* temp assignment XXX, not critical */ 12287c478bd9Sstevel@tonic-gate #endif 12297c478bd9Sstevel@tonic-gate 12307c478bd9Sstevel@tonic-gate #if !defined(CDEV_MAJOR) && defined (__FreeBSD_version) && \ 12317c478bd9Sstevel@tonic-gate (__FreeBSD_version >= 220000) 12327c478bd9Sstevel@tonic-gate # define CDEV_MAJOR 79 12337c478bd9Sstevel@tonic-gate #endif 12347c478bd9Sstevel@tonic-gate 12357c478bd9Sstevel@tonic-gate /* 12367c478bd9Sstevel@tonic-gate * Post NetBSD 1.2 has the PFIL interface for packet filters. This turns 12377c478bd9Sstevel@tonic-gate * on those hooks. We don't need any special mods in non-IP Filter code 12387c478bd9Sstevel@tonic-gate * with this! 12397c478bd9Sstevel@tonic-gate */ 12407c478bd9Sstevel@tonic-gate #if (defined(NetBSD) && (NetBSD > 199609) && (NetBSD <= 1991011)) || \ 12417c478bd9Sstevel@tonic-gate (defined(NetBSD1_2) && NetBSD1_2 > 1) || \ 12427c478bd9Sstevel@tonic-gate (defined(__FreeBSD__) && (__FreeBSD_version >= 500043)) 12437c478bd9Sstevel@tonic-gate # if (NetBSD >= 199905) 12447c478bd9Sstevel@tonic-gate # define PFIL_HOOKS 12457c478bd9Sstevel@tonic-gate # endif 12467c478bd9Sstevel@tonic-gate # ifdef PFIL_HOOKS 12477c478bd9Sstevel@tonic-gate # define NETBSD_PF 12487c478bd9Sstevel@tonic-gate # endif 12497c478bd9Sstevel@tonic-gate #endif 12507c478bd9Sstevel@tonic-gate 12517c478bd9Sstevel@tonic-gate #ifndef _KERNEL 1252*f4b3ec61Sdh extern int fr_check __P((struct ip *, int, void *, int, mb_t **, ipf_stack_t *)); 1253*f4b3ec61Sdh extern int (*fr_checkp) __P((ip_t *, int, void *, int, mb_t **, ipf_stack_t *)); 12547c478bd9Sstevel@tonic-gate extern int ipf_log __P((void)); 1255*f4b3ec61Sdh extern struct ifnet *get_unit __P((char *, int, ipf_stack_t *)); 12567c478bd9Sstevel@tonic-gate extern char *get_ifname __P((struct ifnet *)); 12577c478bd9Sstevel@tonic-gate # if defined(__NetBSD__) || defined(__OpenBSD__) || \ 12587c478bd9Sstevel@tonic-gate (_BSDI_VERSION >= 199701) || (__FreeBSD_version >= 300000) 1259*f4b3ec61Sdh extern int frrequest __P((int, u_long, caddr_t, int, int, ipf_stack_t *)); 12607c478bd9Sstevel@tonic-gate # else 1261ab25eeb5Syz extern int iplioctl __P((int, ioctlcmd_t, caddr_t, int)); 12627c478bd9Sstevel@tonic-gate # endif 12637c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int)); 12647c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int)); 12657c478bd9Sstevel@tonic-gate extern void m_freem __P((mb_t *)); 12667c478bd9Sstevel@tonic-gate #else /* #ifndef _KERNEL */ 1267*f4b3ec61Sdh extern phy_if_t get_unit __P((char *, int, ipf_stack_t *)); 12687c478bd9Sstevel@tonic-gate # if defined(__NetBSD__) && defined(PFIL_HOOKS) 12697c478bd9Sstevel@tonic-gate extern void ipfilterattach __P((int)); 12707c478bd9Sstevel@tonic-gate # endif 12717c478bd9Sstevel@tonic-gate extern int ipl_enable __P((void)); 12727c478bd9Sstevel@tonic-gate extern int ipl_disable __P((void)); 12737c478bd9Sstevel@tonic-gate # ifdef MENTAT 1274ab25eeb5Syz extern int fr_check __P((struct ip *, int, void *, int, void *, 1275*f4b3ec61Sdh mblk_t **, ipf_stack_t *)); 12767c478bd9Sstevel@tonic-gate # if SOLARIS 12777c478bd9Sstevel@tonic-gate # if SOLARIS2 >= 7 12787c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, intptr_t, int, cred_t *, int *)); 12797c478bd9Sstevel@tonic-gate # else 12807c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, int *, int, cred_t *, int *)); 12817c478bd9Sstevel@tonic-gate # endif 12827c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t *, int, int, cred_t *)); 12837c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, cred_t *)); 1284ab25eeb5Syz extern int iplread __P((dev_t, uio_t *, cred_t *)); 1285ab25eeb5Syz extern int iplwrite __P((dev_t, uio_t *, cred_t *)); 12867c478bd9Sstevel@tonic-gate # endif 12877c478bd9Sstevel@tonic-gate # ifdef __hpux 12887c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int, intptr_t, int)); 12897c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int)); 12907c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int)); 1291ab25eeb5Syz extern int iplread __P((dev_t, uio_t *)); 1292ab25eeb5Syz extern int iplwrite __P((dev_t, uio_t *)); 12937c478bd9Sstevel@tonic-gate extern int iplselect __P((dev_t, int)); 12947c478bd9Sstevel@tonic-gate # endif 1295*f4b3ec61Sdh extern int ipfsync __P((ipf_stack_t *)); 12967c478bd9Sstevel@tonic-gate extern int fr_qout __P((queue_t *, mblk_t *)); 12977c478bd9Sstevel@tonic-gate # else /* MENTAT */ 1298*f4b3ec61Sdh extern int fr_check __P((struct ip *, int, void *, int, mb_t **, ipf_stack_t *)); 1299*f4b3ec61Sdh extern int (*fr_checkp) __P((ip_t *, int, void *, int, mb_t **, ipf_stack_t *)); 13007c478bd9Sstevel@tonic-gate extern size_t mbufchainlen __P((mb_t *)); 13017c478bd9Sstevel@tonic-gate # ifdef __sgi 13027c478bd9Sstevel@tonic-gate # include <sys/cred.h> 13037c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int, cred_t *, int *)); 13047c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t *, int, int, cred_t *)); 13057c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, cred_t *)); 1306ab25eeb5Syz extern int iplread __P((dev_t, uio_t *, cred_t *)); 1307ab25eeb5Syz extern int iplwrite __P((dev_t, uio_t *, cred_t *)); 1308*f4b3ec61Sdh extern int ipfsync __P((ipf_stack_t *)); 13097c478bd9Sstevel@tonic-gate extern int ipfilter_sgi_attach __P((void)); 13107c478bd9Sstevel@tonic-gate extern void ipfilter_sgi_detach __P((void)); 13117c478bd9Sstevel@tonic-gate extern void ipfilter_sgi_intfsync __P((void)); 13127c478bd9Sstevel@tonic-gate # else 13137c478bd9Sstevel@tonic-gate # ifdef IPFILTER_LKM 13147c478bd9Sstevel@tonic-gate extern int iplidentify __P((char *)); 13157c478bd9Sstevel@tonic-gate # endif 13167c478bd9Sstevel@tonic-gate # if (_BSDI_VERSION >= 199510) || (__FreeBSD_version >= 220000) || \ 13177c478bd9Sstevel@tonic-gate (NetBSD >= 199511) || defined(__OpenBSD__) 13187c478bd9Sstevel@tonic-gate # if defined(__NetBSD__) || (_BSDI_VERSION >= 199701) || \ 13197c478bd9Sstevel@tonic-gate defined(__OpenBSD__) || (__FreeBSD_version >= 300000) 13207c478bd9Sstevel@tonic-gate # if (__FreeBSD_version >= 500024) 1321ab25eeb5Syz # if (__FreeBSD_version >= 502116) 1322ab25eeb5Syz extern int iplioctl __P((struct cdev*, u_long, caddr_t, int, struct thread *)); 1323ab25eeb5Syz # else 13247c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, u_long, caddr_t, int, struct thread *)); 1325ab25eeb5Syz # endif /* __FreeBSD_version >= 502116 */ 13267c478bd9Sstevel@tonic-gate # else 13277c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); 13287c478bd9Sstevel@tonic-gate # endif /* __FreeBSD_version >= 500024 */ 13297c478bd9Sstevel@tonic-gate # else 13307c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int, struct proc *)); 13317c478bd9Sstevel@tonic-gate # endif 13327c478bd9Sstevel@tonic-gate # if (__FreeBSD_version >= 500024) 1333ab25eeb5Syz # if (__FreeBSD_version >= 502116) 1334ab25eeb5Syz extern int iplopen __P((struct cdev*, int, int, struct thread *)); 1335ab25eeb5Syz extern int iplclose __P((struct cdev*, int, int, struct thread *)); 1336ab25eeb5Syz # else 13377c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int, int, struct thread *)); 13387c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, struct thread *)); 1339ab25eeb5Syz # endif /* __FreeBSD_version >= 502116 */ 13407c478bd9Sstevel@tonic-gate # else 13417c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int, int, struct proc *)); 13427c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, struct proc *)); 13437c478bd9Sstevel@tonic-gate # endif /* __FreeBSD_version >= 500024 */ 13447c478bd9Sstevel@tonic-gate # else 1345ab25eeb5Syz # ifdef linux 1346ab25eeb5Syz extern int iplioctl __P((struct inode *, struct file *, u_int, u_long)); 1347ab25eeb5Syz # else 13487c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int)); 13497c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int)); 13507c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int)); 1351ab25eeb5Syz # endif 13527c478bd9Sstevel@tonic-gate # endif /* (_BSDI_VERSION >= 199510) */ 13537c478bd9Sstevel@tonic-gate # if BSD >= 199306 1354ab25eeb5Syz # if (__FreeBSD_version >= 502116) 1355ab25eeb5Syz extern int iplread __P((struct cdev*, struct uio *, int)); 1356ab25eeb5Syz extern int iplwrite __P((struct cdev*, struct uio *, int)); 1357ab25eeb5Syz # else 13587c478bd9Sstevel@tonic-gate extern int iplread __P((dev_t, struct uio *, int)); 1359ab25eeb5Syz extern int iplwrite __P((dev_t, struct uio *, int)); 1360ab25eeb5Syz # endif /* __FreeBSD_version >= 502116 */ 13617c478bd9Sstevel@tonic-gate # else 1362ab25eeb5Syz # ifndef linux 13637c478bd9Sstevel@tonic-gate extern int iplread __P((dev_t, struct uio *)); 1364ab25eeb5Syz extern int iplwrite __P((dev_t, struct uio *)); 1365ab25eeb5Syz # endif 13667c478bd9Sstevel@tonic-gate # endif /* BSD >= 199306 */ 13677c478bd9Sstevel@tonic-gate # endif /* __ sgi */ 13687c478bd9Sstevel@tonic-gate # endif /* MENTAT */ 13697c478bd9Sstevel@tonic-gate 13707c478bd9Sstevel@tonic-gate #endif /* #ifndef _KERNEL */ 13717c478bd9Sstevel@tonic-gate 13727c478bd9Sstevel@tonic-gate extern char *memstr __P((char *, char *, int, int)); 13737c478bd9Sstevel@tonic-gate extern int count4bits __P((u_32_t)); 13747663b816Sml extern int count6bits __P((u_32_t *)); 1375*f4b3ec61Sdh extern int frrequest __P((int, ioctlcmd_t, caddr_t, int, int, ipf_stack_t *)); 13767c478bd9Sstevel@tonic-gate extern char *getifname __P((struct ifnet *)); 1377*f4b3ec61Sdh extern int iplattach __P((ipf_stack_t *, netstack_t *)); 1378*f4b3ec61Sdh extern int ipldetach __P((ipf_stack_t *)); 13797c478bd9Sstevel@tonic-gate extern u_short ipf_cksum __P((u_short *, int)); 13807c478bd9Sstevel@tonic-gate extern int copyinptr __P((void *, void *, size_t)); 13817c478bd9Sstevel@tonic-gate extern int copyoutptr __P((void *, void *, size_t)); 1382ab25eeb5Syz extern int fr_fastroute __P((mb_t *, mb_t **, fr_info_t *, frdest_t *)); 13837c478bd9Sstevel@tonic-gate extern int fr_inobj __P((void *, void *, int)); 1384ab25eeb5Syz extern int fr_inobjsz __P((void *, void *, int, int)); 1385*f4b3ec61Sdh extern int fr_ioctlswitch __P((int, void *, ioctlcmd_t, int, int, void *, ipf_stack_t *)); 1386*f4b3ec61Sdh extern int fr_ipftune __P((ioctlcmd_t, void *, ipf_stack_t *)); 13877c478bd9Sstevel@tonic-gate extern int fr_outobj __P((void *, void *, int)); 1388ab25eeb5Syz extern int fr_outobjsz __P((void *, void *, int, int)); 1389ab25eeb5Syz extern void *fr_pullup __P((mb_t *, fr_info_t *, int)); 1390*f4b3ec61Sdh extern void fr_resolvedest __P((struct frdest *, int, ipf_stack_t *)); 13917c478bd9Sstevel@tonic-gate extern int fr_resolvefunc __P((void *)); 1392*f4b3ec61Sdh extern void *fr_resolvenic __P((char *, int, ipf_stack_t *)); 1393ab25eeb5Syz extern int fr_send_icmp_err __P((int, fr_info_t *, int)); 1394ab25eeb5Syz extern int fr_send_reset __P((fr_info_t *)); 1395ab25eeb5Syz #if (__FreeBSD_version < 490000) || !defined(_KERNEL) 13967c478bd9Sstevel@tonic-gate extern int ppsratecheck __P((struct timeval *, int *, int)); 1397ab25eeb5Syz #endif 1398*f4b3ec61Sdh extern ipftq_t *fr_addtimeoutqueue __P((ipftq_t **, u_int, ipf_stack_t *)); 1399ab25eeb5Syz extern void fr_deletequeueentry __P((ipftqent_t *)); 1400ab25eeb5Syz extern int fr_deletetimeoutqueue __P((ipftq_t *)); 1401*f4b3ec61Sdh extern void fr_freetimeoutqueue __P((ipftq_t *, ipf_stack_t *)); 1402*f4b3ec61Sdh extern void fr_movequeue __P((ipftqent_t *, ipftq_t *, ipftq_t *, ipf_stack_t *)); 1403*f4b3ec61Sdh extern void fr_queueappend __P((ipftqent_t *, ipftq_t *, void *, ipf_stack_t *)); 1404*f4b3ec61Sdh extern void fr_queueback __P((ipftqent_t *, ipf_stack_t *)); 1405ab25eeb5Syz extern void fr_queuefront __P((ipftqent_t *)); 14067c478bd9Sstevel@tonic-gate extern void fr_checkv4sum __P((fr_info_t *)); 14077c478bd9Sstevel@tonic-gate extern int fr_checkl4sum __P((fr_info_t *)); 14087c478bd9Sstevel@tonic-gate extern int fr_ifpfillv4addr __P((int, struct sockaddr_in *, 14097c478bd9Sstevel@tonic-gate struct sockaddr_in *, struct in_addr *, 14107c478bd9Sstevel@tonic-gate struct in_addr *)); 14117c478bd9Sstevel@tonic-gate extern int fr_coalesce __P((fr_info_t *)); 14127c478bd9Sstevel@tonic-gate #ifdef USE_INET6 14137c478bd9Sstevel@tonic-gate extern void fr_checkv6sum __P((fr_info_t *)); 14147c478bd9Sstevel@tonic-gate extern int fr_ifpfillv6addr __P((int, struct sockaddr_in6 *, 14157c478bd9Sstevel@tonic-gate struct sockaddr_in6 *, struct in_addr *, 14167c478bd9Sstevel@tonic-gate struct in_addr *)); 14177c478bd9Sstevel@tonic-gate #endif 14187c478bd9Sstevel@tonic-gate 1419*f4b3ec61Sdh extern int fr_addipftune __P((ipftuneable_t *, ipf_stack_t *)); 1420*f4b3ec61Sdh extern int fr_delipftune __P((ipftuneable_t *, ipf_stack_t *)); 1421*f4b3ec61Sdh 1422*f4b3ec61Sdh extern int frflush __P((minor_t, int, int, ipf_stack_t *)); 1423*f4b3ec61Sdh extern void frsync __P((int, int, void *, char *, ipf_stack_t *)); 1424*f4b3ec61Sdh extern frgroup_t *fr_addgroup __P((char *, void *, u_32_t, minor_t, int, 1425*f4b3ec61Sdh ipf_stack_t *)); 1426*f4b3ec61Sdh extern int fr_derefrule __P((frentry_t **, ipf_stack_t *)); 1427*f4b3ec61Sdh extern void fr_delgroup __P((char *, minor_t, int, ipf_stack_t *)); 1428*f4b3ec61Sdh extern frgroup_t *fr_findgroup __P((char *, minor_t, int, frgroup_t ***, 1429*f4b3ec61Sdh ipf_stack_t *)); 1430*f4b3ec61Sdh 1431*f4b3ec61Sdh extern int fr_loginit __P((ipf_stack_t *)); 1432*f4b3ec61Sdh extern int ipflog_clear __P((minor_t, ipf_stack_t *)); 1433*f4b3ec61Sdh extern int ipflog_read __P((minor_t, struct uio *, ipf_stack_t *)); 14347c478bd9Sstevel@tonic-gate extern int ipflog __P((fr_info_t *, u_int)); 1435*f4b3ec61Sdh extern int ipllog __P((int, fr_info_t *, void **, size_t *, int *, int, 1436*f4b3ec61Sdh ipf_stack_t *)); 1437*f4b3ec61Sdh extern void fr_logunload __P((ipf_stack_t *)); 14387c478bd9Sstevel@tonic-gate 14397c478bd9Sstevel@tonic-gate extern frentry_t *fr_acctpkt __P((fr_info_t *, u_32_t *)); 14407c478bd9Sstevel@tonic-gate extern int fr_copytolog __P((int, char *, int)); 14417c478bd9Sstevel@tonic-gate extern u_short fr_cksum __P((mb_t *, ip_t *, int, void *)); 1442*f4b3ec61Sdh extern void fr_deinitialise __P((ipf_stack_t *)); 14437c478bd9Sstevel@tonic-gate extern frentry_t *fr_dolog __P((fr_info_t *, u_32_t *)); 14447c478bd9Sstevel@tonic-gate extern frentry_t *fr_dstgrpmap __P((fr_info_t *, u_32_t *)); 14457c478bd9Sstevel@tonic-gate extern void fr_fixskip __P((frentry_t **, frentry_t *, int)); 1446*f4b3ec61Sdh extern void fr_forgetifp __P((void *, ipf_stack_t *)); 1447*f4b3ec61Sdh extern frentry_t *fr_getrulen __P((int, char *, u_32_t, 1448*f4b3ec61Sdh ipf_stack_t *)); 1449*f4b3ec61Sdh extern void fr_getstat __P((struct friostat *, ipf_stack_t *)); 14507c478bd9Sstevel@tonic-gate extern int fr_ifpaddr __P((int, int, void *, 1451*f4b3ec61Sdh struct in_addr *, struct in_addr *, 1452*f4b3ec61Sdh ipf_stack_t *)); 1453*f4b3ec61Sdh extern int fr_initialise __P((ipf_stack_t *)); 1454ab25eeb5Syz extern void fr_lock __P((caddr_t, int *)); 14557c478bd9Sstevel@tonic-gate extern int fr_makefrip __P((int, ip_t *, fr_info_t *)); 14567c478bd9Sstevel@tonic-gate extern int fr_matchtag __P((ipftag_t *, ipftag_t *)); 14577c478bd9Sstevel@tonic-gate extern int fr_matchicmpqueryreply __P((int, icmpinfo_t *, 14587c478bd9Sstevel@tonic-gate struct icmp *, int)); 14597c478bd9Sstevel@tonic-gate extern u_32_t fr_newisn __P((fr_info_t *)); 1460ab25eeb5Syz extern u_short fr_nextipid __P((fr_info_t *)); 1461*f4b3ec61Sdh extern int fr_rulen __P((int, frentry_t *, ipf_stack_t *)); 14627c478bd9Sstevel@tonic-gate extern int fr_scanlist __P((fr_info_t *, u_32_t)); 14637c478bd9Sstevel@tonic-gate extern frentry_t *fr_srcgrpmap __P((fr_info_t *, u_32_t *)); 14647c478bd9Sstevel@tonic-gate extern int fr_tcpudpchk __P((fr_info_t *, frtuc_t *)); 14657c478bd9Sstevel@tonic-gate extern int fr_verifysrc __P((fr_info_t *fin)); 1466*f4b3ec61Sdh extern int fr_zerostats __P((char *, ipf_stack_t *)); 1467*f4b3ec61Sdh extern ipftoken_t *ipf_findtoken __P((int, int, void *, ipf_stack_t *)); 1468*f4b3ec61Sdh extern int ipf_getnextrule __P((ipftoken_t *, void *, ipf_stack_t *)); 1469*f4b3ec61Sdh extern void ipf_expiretokens __P((ipf_stack_t *)); 1470*f4b3ec61Sdh extern void ipf_freetoken __P((ipftoken_t *, ipf_stack_t *)); 1471*f4b3ec61Sdh extern int ipf_deltoken __P((int,int, void *, ipf_stack_t *)); 1472*f4b3ec61Sdh extern int ipf_genericiter __P((void *, int, void *, ipf_stack_t *)); 1473*f4b3ec61Sdh 14747c478bd9Sstevel@tonic-gate extern char ipfilter_version[]; 14757c478bd9Sstevel@tonic-gate #ifdef USE_INET6 14767c478bd9Sstevel@tonic-gate extern int icmptoicmp6types[ICMP_MAXTYPE+1]; 14777c478bd9Sstevel@tonic-gate extern int icmptoicmp6unreach[ICMP_MAX_UNREACH]; 14787c478bd9Sstevel@tonic-gate extern int icmpreplytype6[ICMP6_MAXTYPE + 1]; 14797c478bd9Sstevel@tonic-gate #endif 14807c478bd9Sstevel@tonic-gate extern int icmpreplytype4[ICMP_MAXTYPE + 1]; 14817c478bd9Sstevel@tonic-gate extern frentry_t *ipfrule_match __P((fr_info_t *)); 1482*f4b3ec61Sdh 1483*f4b3ec61Sdh extern void ipftuneable_alloc(ipf_stack_t *); 1484*f4b3ec61Sdh extern void ipftuneable_free(ipf_stack_t *); 14857c478bd9Sstevel@tonic-gate 14867c478bd9Sstevel@tonic-gate #endif /* __IP_FIL_H__ */ 1487