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*de22af4eSJohn Ojemann * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 107c478bd9Sstevel@tonic-gate */ 117c478bd9Sstevel@tonic-gate 127c478bd9Sstevel@tonic-gate #ifndef __IP_FIL_H__ 137c478bd9Sstevel@tonic-gate #define __IP_FIL_H__ 147c478bd9Sstevel@tonic-gate 15ab25eeb5Syz #include "netinet/ip_compat.h" 16ab25eeb5Syz 177c478bd9Sstevel@tonic-gate #ifndef SOLARIS 187c478bd9Sstevel@tonic-gate # define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4))) 197c478bd9Sstevel@tonic-gate #endif 207c478bd9Sstevel@tonic-gate 217c478bd9Sstevel@tonic-gate #ifndef __P 227c478bd9Sstevel@tonic-gate # ifdef __STDC__ 237c478bd9Sstevel@tonic-gate # define __P(x) x 247c478bd9Sstevel@tonic-gate # else 257c478bd9Sstevel@tonic-gate # define __P(x) () 267c478bd9Sstevel@tonic-gate # endif 277c478bd9Sstevel@tonic-gate #endif 287c478bd9Sstevel@tonic-gate 29ab25eeb5Syz #if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51) 307c478bd9Sstevel@tonic-gate # define SIOCADAFR _IOW('r', 60, struct ipfobj) 317c478bd9Sstevel@tonic-gate # define SIOCRMAFR _IOW('r', 61, struct ipfobj) 327c478bd9Sstevel@tonic-gate # define SIOCSETFF _IOW('r', 62, u_int) 337c478bd9Sstevel@tonic-gate # define SIOCGETFF _IOR('r', 63, u_int) 347c478bd9Sstevel@tonic-gate # define SIOCGETFS _IOWR('r', 64, struct ipfobj) 357c478bd9Sstevel@tonic-gate # define SIOCIPFFL _IOWR('r', 65, int) 367c478bd9Sstevel@tonic-gate # define SIOCIPFFB _IOR('r', 66, int) 377c478bd9Sstevel@tonic-gate # define SIOCADIFR _IOW('r', 67, struct ipfobj) 387c478bd9Sstevel@tonic-gate # define SIOCRMIFR _IOW('r', 68, struct ipfobj) 397c478bd9Sstevel@tonic-gate # define SIOCSWAPA _IOR('r', 69, u_int) 407c478bd9Sstevel@tonic-gate # define SIOCINAFR _IOW('r', 70, struct ipfobj) 417c478bd9Sstevel@tonic-gate # define SIOCINIFR _IOW('r', 71, struct ipfobj) 427c478bd9Sstevel@tonic-gate # define SIOCFRENB _IOW('r', 72, u_int) 437c478bd9Sstevel@tonic-gate # define SIOCFRSYN _IOW('r', 73, u_int) 447c478bd9Sstevel@tonic-gate # define SIOCFRZST _IOWR('r', 74, struct ipfobj) 457c478bd9Sstevel@tonic-gate # define SIOCZRLST _IOWR('r', 75, struct ipfobj) 467c478bd9Sstevel@tonic-gate # define SIOCAUTHW _IOWR('r', 76, struct ipfobj) 477c478bd9Sstevel@tonic-gate # define SIOCAUTHR _IOWR('r', 77, struct ipfobj) 487c478bd9Sstevel@tonic-gate # define SIOCATHST _IOWR('r', 78, struct ipfobj) 497c478bd9Sstevel@tonic-gate # define SIOCSTLCK _IOWR('r', 79, u_int) 507c478bd9Sstevel@tonic-gate # define SIOCSTPUT _IOWR('r', 80, struct ipfobj) 517c478bd9Sstevel@tonic-gate # define SIOCSTGET _IOWR('r', 81, struct ipfobj) 527c478bd9Sstevel@tonic-gate # define SIOCSTGSZ _IOWR('r', 82, struct ipfobj) 537c478bd9Sstevel@tonic-gate # define SIOCGFRST _IOWR('r', 83, struct ipfobj) 547c478bd9Sstevel@tonic-gate # define SIOCSETLG _IOWR('r', 84, int) 557c478bd9Sstevel@tonic-gate # define SIOCGETLG _IOWR('r', 85, int) 567c478bd9Sstevel@tonic-gate # define SIOCFUNCL _IOWR('r', 86, struct ipfunc_resolve) 577c478bd9Sstevel@tonic-gate # define SIOCIPFGETNEXT _IOWR('r', 87, struct ipfobj) 587c478bd9Sstevel@tonic-gate # define SIOCIPFGET _IOWR('r', 88, struct ipfobj) 597c478bd9Sstevel@tonic-gate # define SIOCIPFSET _IOWR('r', 89, struct ipfobj) 607663b816Sml # define SIOCIPFL6 _IOWR('r', 90, int) 61381a2a9aSdr # define SIOCIPFLP _IOWR('r', 91, int) 62f4b3ec61Sdh # define SIOCIPFITER _IOWR('r', 92, struct ipfobj) 63f4b3ec61Sdh # define SIOCGENITER _IOWR('r', 93, struct ipfobj) 64f4b3ec61Sdh # define SIOCGTABL _IOWR('r', 94, struct ipfobj) 65f4b3ec61Sdh # define SIOCIPFDELTOK _IOWR('r', 95, int) 66f4b3ec61Sdh # define SIOCLOOKUPITER _IOWR('r', 96, struct ipfobj) 677c478bd9Sstevel@tonic-gate #else 687c478bd9Sstevel@tonic-gate # define SIOCADAFR _IOW(r, 60, struct ipfobj) 697c478bd9Sstevel@tonic-gate # define SIOCRMAFR _IOW(r, 61, struct ipfobj) 707c478bd9Sstevel@tonic-gate # define SIOCSETFF _IOW(r, 62, u_int) 717c478bd9Sstevel@tonic-gate # define SIOCGETFF _IOR(r, 63, u_int) 727c478bd9Sstevel@tonic-gate # define SIOCGETFS _IOWR(r, 64, struct ipfobj) 737c478bd9Sstevel@tonic-gate # define SIOCIPFFL _IOWR(r, 65, int) 747c478bd9Sstevel@tonic-gate # define SIOCIPFFB _IOR(r, 66, int) 757c478bd9Sstevel@tonic-gate # define SIOCADIFR _IOW(r, 67, struct ipfobj) 767c478bd9Sstevel@tonic-gate # define SIOCRMIFR _IOW(r, 68, struct ipfobj) 777c478bd9Sstevel@tonic-gate # define SIOCSWAPA _IOR(r, 69, u_int) 787c478bd9Sstevel@tonic-gate # define SIOCINAFR _IOW(r, 70, struct ipfobj) 797c478bd9Sstevel@tonic-gate # define SIOCINIFR _IOW(r, 71, struct ipfobj) 807c478bd9Sstevel@tonic-gate # define SIOCFRENB _IOW(r, 72, u_int) 817c478bd9Sstevel@tonic-gate # define SIOCFRSYN _IOW(r, 73, u_int) 827c478bd9Sstevel@tonic-gate # define SIOCFRZST _IOWR(r, 74, struct ipfobj) 837c478bd9Sstevel@tonic-gate # define SIOCZRLST _IOWR(r, 75, struct ipfobj) 847c478bd9Sstevel@tonic-gate # define SIOCAUTHW _IOWR(r, 76, struct ipfobj) 857c478bd9Sstevel@tonic-gate # define SIOCAUTHR _IOWR(r, 77, struct ipfobj) 867c478bd9Sstevel@tonic-gate # define SIOCATHST _IOWR(r, 78, struct ipfobj) 877c478bd9Sstevel@tonic-gate # define SIOCSTLCK _IOWR(r, 79, u_int) 887c478bd9Sstevel@tonic-gate # define SIOCSTPUT _IOWR(r, 80, struct ipfobj) 897c478bd9Sstevel@tonic-gate # define SIOCSTGET _IOWR(r, 81, struct ipfobj) 907c478bd9Sstevel@tonic-gate # define SIOCSTGSZ _IOWR(r, 82, struct ipfobj) 917c478bd9Sstevel@tonic-gate # define SIOCGFRST _IOWR(r, 83, struct ipfobj) 927c478bd9Sstevel@tonic-gate # define SIOCSETLG _IOWR(r, 84, int) 937c478bd9Sstevel@tonic-gate # define SIOCGETLG _IOWR(r, 85, int) 947c478bd9Sstevel@tonic-gate # define SIOCFUNCL _IOWR(r, 86, struct ipfunc_resolve) 957c478bd9Sstevel@tonic-gate # define SIOCIPFGETNEXT _IOWR(r, 87, struct ipfobj) 967c478bd9Sstevel@tonic-gate # define SIOCIPFGET _IOWR(r, 88, struct ipfobj) 977c478bd9Sstevel@tonic-gate # define SIOCIPFSET _IOWR(r, 89, struct ipfobj) 987663b816Sml # define SIOCIPFL6 _IOWR(r, 90, int) 99381a2a9aSdr # define SIOCIPFLP _IOWR(r, 91, int) 100f4b3ec61Sdh # define SIOCIPFITER _IOWR(r, 92, struct ipfobj) 101f4b3ec61Sdh # define SIOCGENITER _IOWR(r, 93, struct ipfobj) 102f4b3ec61Sdh # define SIOCGTABL _IOWR(r, 94, struct ipfobj) 103f4b3ec61Sdh # define SIOCIPFDELTOK _IOWR(r, 95, int) 104f4b3ec61Sdh # define SIOCLOOKUPITER _IOWR(r, 96, struct ipfobj) 1057c478bd9Sstevel@tonic-gate #endif 1067c478bd9Sstevel@tonic-gate #define SIOCADDFR SIOCADAFR 1077c478bd9Sstevel@tonic-gate #define SIOCDELFR SIOCRMAFR 1087c478bd9Sstevel@tonic-gate #define SIOCINSFR SIOCINAFR 1097c478bd9Sstevel@tonic-gate 110ea8244dcSJohn Ojemann /* 111ea8244dcSJohn Ojemann * What type of table is getting flushed? 112ea8244dcSJohn Ojemann */ 113ea8244dcSJohn Ojemann 114ea8244dcSJohn Ojemann #define NAT_FLUSH 1 115ea8244dcSJohn Ojemann #define STATE_FLUSH 2 116ea8244dcSJohn Ojemann 117ea8244dcSJohn Ojemann /* 118ea8244dcSJohn Ojemann * What table flush options are available? 119ea8244dcSJohn Ojemann */ 120ea8244dcSJohn Ojemann 121ea8244dcSJohn Ojemann #define FLUSH_LIST 0 122ea8244dcSJohn Ojemann #define FLUSH_TABLE_ALL 1 /* Flush entire table */ 123ea8244dcSJohn Ojemann #define FLUSH_TABLE_CLOSING 2 /* Flush "closing" entries" */ 124ea8244dcSJohn Ojemann #define FLUSH_TABLE_EXTRA 3 /* Targetted flush: almost closed, long idle */ 125ea8244dcSJohn Ojemann 126ea8244dcSJohn Ojemann #define VALID_TABLE_FLUSH_OPT(x) ((x) >= 1 && (x) <= 3) 127ea8244dcSJohn Ojemann 128ea8244dcSJohn Ojemann /* 129ea8244dcSJohn Ojemann * Define the default hi and lo watermarks used when flushing the 130ea8244dcSJohn Ojemann * tables. The values represent percent full of respective tables. 131ea8244dcSJohn Ojemann */ 132ea8244dcSJohn Ojemann 133ea8244dcSJohn Ojemann #define NAT_FLUSH_HI 95 134ea8244dcSJohn Ojemann #define NAT_FLUSH_LO 75 135ea8244dcSJohn Ojemann 136ea8244dcSJohn Ojemann #define ST_FLUSH_HI 95 137ea8244dcSJohn Ojemann #define ST_FLUSH_LO 75 138ea8244dcSJohn Ojemann 139ea8244dcSJohn Ojemann /* 140ea8244dcSJohn Ojemann * How full are the tables? 141ea8244dcSJohn Ojemann */ 142ea8244dcSJohn Ojemann 143ea8244dcSJohn Ojemann #define NAT_TAB_WATER_LEVEL(x) ((x)->ifs_nat_stats.ns_inuse * 100 \ 144ea8244dcSJohn Ojemann / (x)->ifs_ipf_nattable_max) 145ea8244dcSJohn Ojemann 146ea8244dcSJohn Ojemann #define ST_TAB_WATER_LEVEL(x) ((x)->ifs_ips_num * 100 \ 147ea8244dcSJohn Ojemann / (x)->ifs_fr_statemax) 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate struct ipscan; 1507c478bd9Sstevel@tonic-gate struct ifnet; 1517c478bd9Sstevel@tonic-gate 152f4b3ec61Sdh typedef struct ipf_stack ipf_stack_t; 153*de22af4eSJohn Ojemann typedef struct fr_info fr_info_t; 154f4b3ec61Sdh 155*de22af4eSJohn Ojemann typedef int (* lookupfunc_t) __P((void *, int, void *, fr_info_t *, ipf_stack_t *)); 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate /* 1587c478bd9Sstevel@tonic-gate * i6addr is used as a container for both IPv4 and IPv6 addresses, as well 1597c478bd9Sstevel@tonic-gate * as other types of objects, depending on its qualifier. 1607c478bd9Sstevel@tonic-gate */ 1617c478bd9Sstevel@tonic-gate #ifdef USE_INET6 1627c478bd9Sstevel@tonic-gate typedef union i6addr { 1637c478bd9Sstevel@tonic-gate u_32_t i6[4]; 1647c478bd9Sstevel@tonic-gate struct in_addr in4; 1657c478bd9Sstevel@tonic-gate struct in6_addr in6; 1667c478bd9Sstevel@tonic-gate void *vptr[2]; 1677c478bd9Sstevel@tonic-gate lookupfunc_t lptr[2]; 1687c478bd9Sstevel@tonic-gate } i6addr_t; 169d6c23f6fSyx #define in6_addr8 in6.s6_addr 1707c478bd9Sstevel@tonic-gate #else 1717c478bd9Sstevel@tonic-gate typedef union i6addr { 1727c478bd9Sstevel@tonic-gate u_32_t i6[4]; 1737c478bd9Sstevel@tonic-gate struct in_addr in4; 1747c478bd9Sstevel@tonic-gate void *vptr[2]; 1757c478bd9Sstevel@tonic-gate lookupfunc_t lptr[2]; 1767c478bd9Sstevel@tonic-gate } i6addr_t; 1777c478bd9Sstevel@tonic-gate #endif 178ab25eeb5Syz 179d6c23f6fSyx #define in4_addr in4.s_addr 1807c478bd9Sstevel@tonic-gate #define iplookupnum i6[0] 1817c478bd9Sstevel@tonic-gate #define iplookuptype i6[1] 1827c478bd9Sstevel@tonic-gate /* 1837c478bd9Sstevel@tonic-gate * NOTE: These DO overlap the above on 64bit systems and this IS recognised. 1847c478bd9Sstevel@tonic-gate */ 1857c478bd9Sstevel@tonic-gate #define iplookupptr vptr[0] 1867c478bd9Sstevel@tonic-gate #define iplookupfunc lptr[1] 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate #define I60(x) (((i6addr_t *)(x))->i6[0]) 1897c478bd9Sstevel@tonic-gate #define I61(x) (((i6addr_t *)(x))->i6[1]) 1907c478bd9Sstevel@tonic-gate #define I62(x) (((i6addr_t *)(x))->i6[2]) 1917c478bd9Sstevel@tonic-gate #define I63(x) (((i6addr_t *)(x))->i6[3]) 1927c478bd9Sstevel@tonic-gate #define HI60(x) ntohl(((i6addr_t *)(x))->i6[0]) 1937c478bd9Sstevel@tonic-gate #define HI61(x) ntohl(((i6addr_t *)(x))->i6[1]) 1947c478bd9Sstevel@tonic-gate #define HI62(x) ntohl(((i6addr_t *)(x))->i6[2]) 1957c478bd9Sstevel@tonic-gate #define HI63(x) ntohl(((i6addr_t *)(x))->i6[3]) 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate #define IP6_EQ(a,b) ((I63(a) == I63(b)) && (I62(a) == I62(b)) && \ 1987c478bd9Sstevel@tonic-gate (I61(a) == I61(b)) && (I60(a) == I60(b))) 1997c478bd9Sstevel@tonic-gate #define IP6_NEQ(a,b) ((I63(a) != I63(b)) || (I62(a) != I62(b)) || \ 2007c478bd9Sstevel@tonic-gate (I61(a) != I61(b)) || (I60(a) != I60(b))) 201d6c23f6fSyx #define IP6_ISZERO(a) ((I60(a) | I61(a) | I62(a) | I63(a)) == 0) 2027c478bd9Sstevel@tonic-gate #define IP6_NOTZERO(a) ((I60(a) | I61(a) | I62(a) | I63(a)) != 0) 203d6c23f6fSyx #define IP6_ISONES(a) ((I63(a) == 0xffffffff) && (I62(a) == 0xffffffff) && \ 204d6c23f6fSyx (I61(a) == 0xffffffff) && (I60(a) == 0xffffffff)) 205d6c23f6fSyx #define IP6_GT(a,b) (ntohl(HI60(a)) > ntohl(HI60(b)) || \ 206d6c23f6fSyx (HI60(a) == HI60(b) && \ 207d6c23f6fSyx (ntohl(HI61(a)) > ntohl(HI61(b)) || \ 208d6c23f6fSyx (HI61(a) == HI61(b) && \ 209d6c23f6fSyx (ntohl(HI62(a)) > ntohl(HI62(b)) || \ 210d6c23f6fSyx (HI62(a) == HI62(b) && \ 211d6c23f6fSyx ntohl(HI63(a)) > ntohl(HI63(b)))))))) 212d6c23f6fSyx #define IP6_LT(a,b) (ntohl(HI60(a)) < ntohl(HI60(b)) || \ 213d6c23f6fSyx (HI60(a) == HI60(b) && \ 214d6c23f6fSyx (ntohl(HI61(a)) < ntohl(HI61(b)) || \ 215d6c23f6fSyx (HI61(a) == HI61(b) && \ 216d6c23f6fSyx (ntohl(HI62(a)) < ntohl(HI62(b)) || \ 217d6c23f6fSyx (HI62(a) == HI62(b) && \ 218d6c23f6fSyx ntohl(HI63(a)) < ntohl(HI63(b)))))))) 2197c478bd9Sstevel@tonic-gate #define NLADD(n,x) htonl(ntohl(n) + (x)) 2207c478bd9Sstevel@tonic-gate #define IP6_INC(a) \ 2217c478bd9Sstevel@tonic-gate { i6addr_t *_i6 = (i6addr_t *)(a); \ 222d6c23f6fSyx _i6->i6[3] = NLADD(_i6->i6[3], 1); \ 223d6c23f6fSyx if (_i6->i6[3] == 0) { \ 224d6c23f6fSyx _i6->i6[2] = NLADD(_i6->i6[2], 1); \ 225d6c23f6fSyx if (_i6->i6[2] == 0) { \ 226d6c23f6fSyx _i6->i6[1] = NLADD(_i6->i6[1], 1); \ 227d6c23f6fSyx if (_i6->i6[1] == 0) { \ 228d6c23f6fSyx _i6->i6[0] = NLADD(_i6->i6[0], 1); \ 2297c478bd9Sstevel@tonic-gate } \ 2307c478bd9Sstevel@tonic-gate } \ 2317c478bd9Sstevel@tonic-gate } \ 2327c478bd9Sstevel@tonic-gate } 2337c478bd9Sstevel@tonic-gate #define IP6_ADD(a,x,d) \ 2347c478bd9Sstevel@tonic-gate { i6addr_t *_s = (i6addr_t *)(a); \ 2357c478bd9Sstevel@tonic-gate i6addr_t *_d = (i6addr_t *)(d); \ 236d6c23f6fSyx _d->i6[3] = NLADD(_s->i6[3], x); \ 237d6c23f6fSyx if (ntohl(_d->i6[3]) < ntohl(_s->i6[3])) { \ 238d6c23f6fSyx _d->i6[2] = NLADD(_d->i6[2], 1); \ 239d6c23f6fSyx if (ntohl(_d->i6[2]) < ntohl(_s->i6[2])) { \ 240d6c23f6fSyx _d->i6[1] = NLADD(_d->i6[1], 1); \ 241d6c23f6fSyx if (ntohl(_d->i6[1]) < ntohl(_s->i6[1])) { \ 242d6c23f6fSyx _d->i6[0] = NLADD(_d->i6[0], 1); \ 2437c478bd9Sstevel@tonic-gate } \ 2447c478bd9Sstevel@tonic-gate } \ 2457c478bd9Sstevel@tonic-gate } \ 2467c478bd9Sstevel@tonic-gate } 2477c478bd9Sstevel@tonic-gate #define IP6_AND(a,b,d) { i6addr_t *_s1 = (i6addr_t *)(a); \ 248d6c23f6fSyx i6addr_t *_s2 = (i6addr_t *)(b); \ 2497c478bd9Sstevel@tonic-gate i6addr_t *_d = (i6addr_t *)(d); \ 2507c478bd9Sstevel@tonic-gate _d->i6[0] = _s1->i6[0] & _s2->i6[0]; \ 2517c478bd9Sstevel@tonic-gate _d->i6[1] = _s1->i6[1] & _s2->i6[1]; \ 2527c478bd9Sstevel@tonic-gate _d->i6[2] = _s1->i6[2] & _s2->i6[2]; \ 2537c478bd9Sstevel@tonic-gate _d->i6[3] = _s1->i6[3] & _s2->i6[3]; \ 2547c478bd9Sstevel@tonic-gate } 255d6c23f6fSyx #define IP6_MASKEQ(a,m,b) \ 256d6c23f6fSyx (((I60(a) & I60(m)) == I60(b)) && \ 257d6c23f6fSyx ((I61(a) & I61(m)) == I61(b)) && \ 258d6c23f6fSyx ((I62(a) & I62(m)) == I62(b)) && \ 259d6c23f6fSyx ((I63(a) & I63(m)) == I63(b))) 260d6c23f6fSyx #define IP6_MASKNEQ(a,m,b) \ 261d6c23f6fSyx (((I60(a) & I60(m)) != I60(b)) || \ 262d6c23f6fSyx ((I61(a) & I61(m)) != I61(b)) || \ 263d6c23f6fSyx ((I62(a) & I62(m)) != I62(b)) || \ 264d6c23f6fSyx ((I63(a) & I63(m)) != I63(b))) 2657c478bd9Sstevel@tonic-gate #define IP6_MERGE(a,b,c) \ 2667c478bd9Sstevel@tonic-gate { i6addr_t *_d, *_s1, *_s2; \ 2677c478bd9Sstevel@tonic-gate _d = (i6addr_t *)(a); \ 2687c478bd9Sstevel@tonic-gate _s1 = (i6addr_t *)(b); \ 2697c478bd9Sstevel@tonic-gate _s2 = (i6addr_t *)(c); \ 2707c478bd9Sstevel@tonic-gate _d->i6[0] |= _s1->i6[0] & ~_s2->i6[0]; \ 2717c478bd9Sstevel@tonic-gate _d->i6[1] |= _s1->i6[1] & ~_s2->i6[1]; \ 2727c478bd9Sstevel@tonic-gate _d->i6[2] |= _s1->i6[2] & ~_s2->i6[2]; \ 273d6c23f6fSyx _d->i6[3] |= _s1->i6[3] & ~_s2->i6[3]; \ 2747c478bd9Sstevel@tonic-gate } 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate 2777c478bd9Sstevel@tonic-gate typedef struct fr_ip { 2787c478bd9Sstevel@tonic-gate u_32_t fi_v:4; /* IP version */ 2797c478bd9Sstevel@tonic-gate u_32_t fi_xx:4; /* spare */ 2807c478bd9Sstevel@tonic-gate u_32_t fi_tos:8; /* IP packet TOS */ 2817c478bd9Sstevel@tonic-gate u_32_t fi_ttl:8; /* IP packet TTL */ 2827c478bd9Sstevel@tonic-gate u_32_t fi_p:8; /* IP packet protocol */ 2837c478bd9Sstevel@tonic-gate u_32_t fi_optmsk; /* bitmask composed from IP options */ 2847c478bd9Sstevel@tonic-gate i6addr_t fi_src; /* source address from packet */ 2857c478bd9Sstevel@tonic-gate i6addr_t fi_dst; /* destination address from packet */ 2867c478bd9Sstevel@tonic-gate u_short fi_secmsk; /* bitmask composed from IP security options */ 2877c478bd9Sstevel@tonic-gate u_short fi_auth; /* authentication code from IP sec. options */ 2887c478bd9Sstevel@tonic-gate u_32_t fi_flx; /* packet flags */ 2897c478bd9Sstevel@tonic-gate u_32_t fi_tcpmsk; /* TCP options set/reset */ 2907c478bd9Sstevel@tonic-gate u_32_t fi_res1; /* RESERVED */ 2917c478bd9Sstevel@tonic-gate } fr_ip_t; 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate /* 2947c478bd9Sstevel@tonic-gate * For use in fi_flx 2957c478bd9Sstevel@tonic-gate */ 29643412a42SDarren Reed #define FI_TCPUDP 0x0001 /* TCP/UCP implied comparison*/ 29743412a42SDarren Reed #define FI_OPTIONS 0x0002 2987c478bd9Sstevel@tonic-gate #define FI_FRAG 0x0004 2997c478bd9Sstevel@tonic-gate #define FI_SHORT 0x0008 3007c478bd9Sstevel@tonic-gate #define FI_NATED 0x0010 30143412a42SDarren Reed #define FI_MULTICAST 0x0020 30243412a42SDarren Reed #define FI_BROADCAST 0x0040 3037c478bd9Sstevel@tonic-gate #define FI_MBCAST 0x0080 3047c478bd9Sstevel@tonic-gate #define FI_STATE 0x0100 3057c478bd9Sstevel@tonic-gate #define FI_BADNAT 0x0200 3067c478bd9Sstevel@tonic-gate #define FI_BAD 0x0400 3077c478bd9Sstevel@tonic-gate #define FI_OOW 0x0800 /* Out of state window, else match */ 3087c478bd9Sstevel@tonic-gate #define FI_ICMPERR 0x1000 309ab25eeb5Syz #define FI_FRAGBODY 0x2000 3107c478bd9Sstevel@tonic-gate #define FI_BADSRC 0x4000 3117c478bd9Sstevel@tonic-gate #define FI_LOWTTL 0x8000 312bb1d9de5SJohn Ojemann #define FI_CMP 0xcf03 /* Not FI_FRAG,FI_NATED,FI_FRAGTAIL,broadcast */ 313ab25eeb5Syz #define FI_ICMPCMP 0x0003 /* Flags we can check for ICMP error packets */ 3147c478bd9Sstevel@tonic-gate #define FI_WITH 0xeffe /* Not FI_TCPUDP */ 3157c478bd9Sstevel@tonic-gate #define FI_V6EXTHDR 0x10000 3167c478bd9Sstevel@tonic-gate #define FI_COALESCE 0x20000 317d6c23f6fSyx #define FI_ICMPQUERY 0x40000 3185b48165cSJohn Ojemann #define FI_NEWNAT 0x80000 31972680cf5SDarren Reed #define FI_MOREFRAG 0x100000 32040cdc2e8SAlexandr Nedvedicky #define FI_NEG_OOW 0x10000000 /* packet underflows TCP window */ 3217c478bd9Sstevel@tonic-gate #define FI_NOCKSUM 0x20000000 /* don't do a L4 checksum validation */ 3227c478bd9Sstevel@tonic-gate #define FI_DONTCACHE 0x40000000 /* don't cache the result */ 3237c478bd9Sstevel@tonic-gate #define FI_IGNORE 0x80000000 3247c478bd9Sstevel@tonic-gate 3257c478bd9Sstevel@tonic-gate #define fi_saddr fi_src.in4.s_addr 3267c478bd9Sstevel@tonic-gate #define fi_daddr fi_dst.in4.s_addr 3277c478bd9Sstevel@tonic-gate #define fi_srcnum fi_src.iplookupnum 3287c478bd9Sstevel@tonic-gate #define fi_dstnum fi_dst.iplookupnum 3297c478bd9Sstevel@tonic-gate #define fi_srctype fi_src.iplookuptype 3307c478bd9Sstevel@tonic-gate #define fi_dsttype fi_dst.iplookuptype 3317c478bd9Sstevel@tonic-gate #define fi_srcptr fi_src.iplookupptr 3327c478bd9Sstevel@tonic-gate #define fi_dstptr fi_dst.iplookupptr 3337c478bd9Sstevel@tonic-gate #define fi_srcfunc fi_src.iplookupfunc 3347c478bd9Sstevel@tonic-gate #define fi_dstfunc fi_dst.iplookupfunc 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate /* 3387c478bd9Sstevel@tonic-gate * These are both used by the state and NAT code to indicate that one port or 3397c478bd9Sstevel@tonic-gate * the other should be treated as a wildcard. 3407c478bd9Sstevel@tonic-gate * NOTE: When updating, check bit masks in ip_state.h and update there too. 3417c478bd9Sstevel@tonic-gate */ 3427c478bd9Sstevel@tonic-gate #define SI_W_SPORT 0x00000100 3437c478bd9Sstevel@tonic-gate #define SI_W_DPORT 0x00000200 3447c478bd9Sstevel@tonic-gate #define SI_WILDP (SI_W_SPORT|SI_W_DPORT) 3457c478bd9Sstevel@tonic-gate #define SI_W_SADDR 0x00000400 3467c478bd9Sstevel@tonic-gate #define SI_W_DADDR 0x00000800 3477c478bd9Sstevel@tonic-gate #define SI_WILDA (SI_W_SADDR|SI_W_DADDR) 3487c478bd9Sstevel@tonic-gate #define SI_NEWFR 0x00001000 3497c478bd9Sstevel@tonic-gate #define SI_CLONE 0x00002000 3507c478bd9Sstevel@tonic-gate #define SI_CLONED 0x00004000 3517c478bd9Sstevel@tonic-gate 3527c478bd9Sstevel@tonic-gate 353f4b3ec61Sdh 354f4b3ec61Sdh 355*de22af4eSJohn Ojemann struct fr_info { 3567c478bd9Sstevel@tonic-gate void *fin_ifp; /* interface packet is `on' */ 357ab25eeb5Syz fr_ip_t fin_fi; /* IP Packet summary */ 3587c478bd9Sstevel@tonic-gate union { 3597c478bd9Sstevel@tonic-gate u_short fid_16[2]; /* TCP/UDP ports, ICMP code/type */ 3607c478bd9Sstevel@tonic-gate u_32_t fid_32; 3617c478bd9Sstevel@tonic-gate } fin_dat; 3627c478bd9Sstevel@tonic-gate int fin_out; /* in or out ? 1 == out, 0 == in */ 3637c478bd9Sstevel@tonic-gate int fin_rev; /* state only: 1 = reverse */ 3647c478bd9Sstevel@tonic-gate u_short fin_hlen; /* length of IP header in bytes */ 3657c478bd9Sstevel@tonic-gate u_char fin_tcpf; /* TCP header flags (SYN, ACK, etc) */ 3667c478bd9Sstevel@tonic-gate u_char fin_icode; /* ICMP error to return */ 3677c478bd9Sstevel@tonic-gate u_32_t fin_rule; /* rule # last matched */ 3687c478bd9Sstevel@tonic-gate char fin_group[FR_GROUPLEN]; /* group number, -1 for none */ 3697c478bd9Sstevel@tonic-gate struct frentry *fin_fr; /* last matching rule */ 3707c478bd9Sstevel@tonic-gate void *fin_dp; /* start of data past IP header */ 3717c478bd9Sstevel@tonic-gate int fin_dlen; /* length of data portion of packet */ 3727c478bd9Sstevel@tonic-gate int fin_plen; 373ab25eeb5Syz int fin_ipoff; /* # bytes from buffer start to hdr */ 3747663b816Sml u_32_t fin_id; /* IP packet id field */ 3757c478bd9Sstevel@tonic-gate u_short fin_off; 3767c478bd9Sstevel@tonic-gate int fin_depth; /* Group nesting depth */ 3777c478bd9Sstevel@tonic-gate int fin_error; /* Error code to return */ 37833f2fefdSDarren Reed u_int fin_pktnum; 3797c478bd9Sstevel@tonic-gate void *fin_nattag; 380d6c23f6fSyx union { 381d6c23f6fSyx ip_t *fip_ip; 382d6c23f6fSyx #ifdef USE_INET6 383d6c23f6fSyx ip6_t *fip_ip6; 384d6c23f6fSyx #endif 385d6c23f6fSyx } fin_ipu; 3867c478bd9Sstevel@tonic-gate mb_t **fin_mp; /* pointer to pointer to mbuf */ 3877c478bd9Sstevel@tonic-gate mb_t *fin_m; /* pointer to mbuf */ 3887c478bd9Sstevel@tonic-gate #ifdef MENTAT 3897c478bd9Sstevel@tonic-gate mb_t *fin_qfm; /* pointer to mblk where pkt starts */ 390ab25eeb5Syz void *fin_qpi; 391f4b3ec61Sdh ipf_stack_t *fin_ifs; 392ab25eeb5Syz #endif 393ab25eeb5Syz #ifdef __sgi 394ab25eeb5Syz void *fin_hbuf; 3957c478bd9Sstevel@tonic-gate #endif 396*de22af4eSJohn Ojemann }; 3977c478bd9Sstevel@tonic-gate 398d6c23f6fSyx #define fin_ip fin_ipu.fip_ip 399d6c23f6fSyx #define fin_ip6 fin_ipu.fip_ip6 4007c478bd9Sstevel@tonic-gate #define fin_v fin_fi.fi_v 4017c478bd9Sstevel@tonic-gate #define fin_p fin_fi.fi_p 4027c478bd9Sstevel@tonic-gate #define fin_flx fin_fi.fi_flx 4037c478bd9Sstevel@tonic-gate #define fin_optmsk fin_fi.fi_optmsk 4047c478bd9Sstevel@tonic-gate #define fin_secmsk fin_fi.fi_secmsk 4057c478bd9Sstevel@tonic-gate #define fin_auth fin_fi.fi_auth 4067c478bd9Sstevel@tonic-gate #define fin_src fin_fi.fi_src.in4 4077c478bd9Sstevel@tonic-gate #define fin_saddr fin_fi.fi_saddr 4087c478bd9Sstevel@tonic-gate #define fin_dst fin_fi.fi_dst.in4 4097c478bd9Sstevel@tonic-gate #define fin_daddr fin_fi.fi_daddr 4107c478bd9Sstevel@tonic-gate #define fin_data fin_dat.fid_16 4117c478bd9Sstevel@tonic-gate #define fin_sport fin_dat.fid_16[0] 4127c478bd9Sstevel@tonic-gate #define fin_dport fin_dat.fid_16[1] 4137c478bd9Sstevel@tonic-gate #define fin_ports fin_dat.fid_32 4147c478bd9Sstevel@tonic-gate 415d6c23f6fSyx #ifdef USE_INET6 416d6c23f6fSyx # define fin_src6 fin_fi.fi_src 417d6c23f6fSyx # define fin_dst6 fin_fi.fi_dst 418d6c23f6fSyx # define fin_dstip6 fin_fi.fi_dst.in6 419d6c23f6fSyx # define fin_srcip6 fin_fi.fi_src.in6 420d6c23f6fSyx #endif 421d6c23f6fSyx 4227c478bd9Sstevel@tonic-gate #define IPF_IN 0 4237c478bd9Sstevel@tonic-gate #define IPF_OUT 1 4247c478bd9Sstevel@tonic-gate 4257c478bd9Sstevel@tonic-gate typedef struct frentry *(*ipfunc_t) __P((fr_info_t *, u_32_t *)); 426f4b3ec61Sdh typedef int (*ipfuncinit_t) __P((struct frentry *, 427f4b3ec61Sdh ipf_stack_t *)); 4287c478bd9Sstevel@tonic-gate 4297c478bd9Sstevel@tonic-gate typedef struct ipfunc_resolve { 4307c478bd9Sstevel@tonic-gate char ipfu_name[32]; 4317c478bd9Sstevel@tonic-gate ipfunc_t ipfu_addr; 4327c478bd9Sstevel@tonic-gate ipfuncinit_t ipfu_init; 4337c478bd9Sstevel@tonic-gate } ipfunc_resolve_t; 4347c478bd9Sstevel@tonic-gate 4357c478bd9Sstevel@tonic-gate /* 4367c478bd9Sstevel@tonic-gate * Size for compares on fr_info structures 4377c478bd9Sstevel@tonic-gate */ 4387c478bd9Sstevel@tonic-gate #define FI_CSIZE offsetof(fr_info_t, fin_icode) 4397c478bd9Sstevel@tonic-gate #define FI_LCSIZE offsetof(fr_info_t, fin_dp) 4407c478bd9Sstevel@tonic-gate 4417c478bd9Sstevel@tonic-gate /* 4427c478bd9Sstevel@tonic-gate * Size for copying cache fr_info structure 4437c478bd9Sstevel@tonic-gate */ 4447c478bd9Sstevel@tonic-gate #define FI_COPYSIZE offsetof(fr_info_t, fin_dp) 4457c478bd9Sstevel@tonic-gate 4467c478bd9Sstevel@tonic-gate /* 447ab25eeb5Syz * Structure for holding IPFilter's tag information 4487c478bd9Sstevel@tonic-gate */ 449ab25eeb5Syz #define IPFTAG_LEN 16 4507c478bd9Sstevel@tonic-gate typedef struct { 4517c478bd9Sstevel@tonic-gate union { 4527c478bd9Sstevel@tonic-gate u_32_t iptu_num[4]; 453ab25eeb5Syz char iptu_tag[IPFTAG_LEN]; 4547c478bd9Sstevel@tonic-gate } ipt_un; 4557c478bd9Sstevel@tonic-gate int ipt_not; 4567c478bd9Sstevel@tonic-gate } ipftag_t; 4577c478bd9Sstevel@tonic-gate 4587c478bd9Sstevel@tonic-gate #define ipt_tag ipt_un.iptu_tag 4597c478bd9Sstevel@tonic-gate #define ipt_num ipt_un.iptu_num 4607c478bd9Sstevel@tonic-gate 4617c478bd9Sstevel@tonic-gate 4627c478bd9Sstevel@tonic-gate /* 4637c478bd9Sstevel@tonic-gate * This structure is used to hold information about the next hop for where 4647c478bd9Sstevel@tonic-gate * to forward a packet. 4657c478bd9Sstevel@tonic-gate */ 4667c478bd9Sstevel@tonic-gate typedef struct frdest { 4677c478bd9Sstevel@tonic-gate void *fd_ifp; 4687c478bd9Sstevel@tonic-gate i6addr_t fd_ip6; 4697c478bd9Sstevel@tonic-gate char fd_ifname[LIFNAMSIZ]; 4707c478bd9Sstevel@tonic-gate } frdest_t; 4717c478bd9Sstevel@tonic-gate 4727c478bd9Sstevel@tonic-gate #define fd_ip fd_ip6.in4 4737c478bd9Sstevel@tonic-gate 4747c478bd9Sstevel@tonic-gate 4757c478bd9Sstevel@tonic-gate /* 4767c478bd9Sstevel@tonic-gate * This structure holds information about a port comparison. 4777c478bd9Sstevel@tonic-gate */ 4787c478bd9Sstevel@tonic-gate typedef struct frpcmp { 4797c478bd9Sstevel@tonic-gate int frp_cmp; /* data for port comparisons */ 4807c478bd9Sstevel@tonic-gate u_short frp_port; /* top port for <> and >< */ 4817c478bd9Sstevel@tonic-gate u_short frp_top; /* top port for <> and >< */ 4827c478bd9Sstevel@tonic-gate } frpcmp_t; 4837c478bd9Sstevel@tonic-gate 4847c478bd9Sstevel@tonic-gate #define FR_NONE 0 4857c478bd9Sstevel@tonic-gate #define FR_EQUAL 1 4867c478bd9Sstevel@tonic-gate #define FR_NEQUAL 2 4877c478bd9Sstevel@tonic-gate #define FR_LESST 3 4887c478bd9Sstevel@tonic-gate #define FR_GREATERT 4 4897c478bd9Sstevel@tonic-gate #define FR_LESSTE 5 4907c478bd9Sstevel@tonic-gate #define FR_GREATERTE 6 4917c478bd9Sstevel@tonic-gate #define FR_OUTRANGE 7 4927c478bd9Sstevel@tonic-gate #define FR_INRANGE 8 4937c478bd9Sstevel@tonic-gate #define FR_INCRANGE 9 4947c478bd9Sstevel@tonic-gate 4957c478bd9Sstevel@tonic-gate /* 4967c478bd9Sstevel@tonic-gate * Structure containing all the relevant TCP things that can be checked in 4977c478bd9Sstevel@tonic-gate * a filter rule. 4987c478bd9Sstevel@tonic-gate */ 4997c478bd9Sstevel@tonic-gate typedef struct frtuc { 5007c478bd9Sstevel@tonic-gate u_char ftu_tcpfm; /* tcp flags mask */ 5017c478bd9Sstevel@tonic-gate u_char ftu_tcpf; /* tcp flags */ 5027c478bd9Sstevel@tonic-gate frpcmp_t ftu_src; 5037c478bd9Sstevel@tonic-gate frpcmp_t ftu_dst; 5047c478bd9Sstevel@tonic-gate } frtuc_t; 5057c478bd9Sstevel@tonic-gate 5067c478bd9Sstevel@tonic-gate #define ftu_scmp ftu_src.frp_cmp 5077c478bd9Sstevel@tonic-gate #define ftu_dcmp ftu_dst.frp_cmp 5087c478bd9Sstevel@tonic-gate #define ftu_sport ftu_src.frp_port 5097c478bd9Sstevel@tonic-gate #define ftu_dport ftu_dst.frp_port 5107c478bd9Sstevel@tonic-gate #define ftu_stop ftu_src.frp_top 5117c478bd9Sstevel@tonic-gate #define ftu_dtop ftu_dst.frp_top 5127c478bd9Sstevel@tonic-gate 5137c478bd9Sstevel@tonic-gate #define FR_TCPFMAX 0x3f 5147c478bd9Sstevel@tonic-gate 5157c478bd9Sstevel@tonic-gate /* 5167c478bd9Sstevel@tonic-gate * This structure makes up what is considered to be the IPFilter specific 5177c478bd9Sstevel@tonic-gate * matching components of a filter rule, as opposed to the data structures 5187c478bd9Sstevel@tonic-gate * used to define the result which are in frentry_t and not here. 5197c478bd9Sstevel@tonic-gate */ 5207c478bd9Sstevel@tonic-gate typedef struct fripf { 521ab25eeb5Syz fr_ip_t fri_ip; 522ab25eeb5Syz fr_ip_t fri_mip; /* mask structure */ 5237c478bd9Sstevel@tonic-gate 5247c478bd9Sstevel@tonic-gate u_short fri_icmpm; /* data for ICMP packets (mask) */ 5257c478bd9Sstevel@tonic-gate u_short fri_icmp; 5267c478bd9Sstevel@tonic-gate 5277c478bd9Sstevel@tonic-gate frtuc_t fri_tuc; 5287c478bd9Sstevel@tonic-gate int fri_satype; /* addres type */ 5297c478bd9Sstevel@tonic-gate int fri_datype; /* addres type */ 5307c478bd9Sstevel@tonic-gate int fri_sifpidx; /* doing dynamic addressing */ 5317c478bd9Sstevel@tonic-gate int fri_difpidx; /* index into fr_ifps[] to use when */ 5327c478bd9Sstevel@tonic-gate } fripf_t; 5337c478bd9Sstevel@tonic-gate 5347c478bd9Sstevel@tonic-gate #define fri_dstnum fri_ip.fi_dstnum 5357c478bd9Sstevel@tonic-gate #define fri_srcnum fri_mip.fi_srcnum 5367c478bd9Sstevel@tonic-gate #define fri_dstptr fri_ip.fi_dstptr 5377c478bd9Sstevel@tonic-gate #define fri_srcptr fri_mip.fi_srcptr 5387c478bd9Sstevel@tonic-gate 5397c478bd9Sstevel@tonic-gate #define FRI_NORMAL 0 /* Normal address */ 5407c478bd9Sstevel@tonic-gate #define FRI_DYNAMIC 1 /* dynamic address */ 5417c478bd9Sstevel@tonic-gate #define FRI_LOOKUP 2 /* address is a pool # */ 5427c478bd9Sstevel@tonic-gate #define FRI_RANGE 3 /* address/mask is a range */ 5437c478bd9Sstevel@tonic-gate #define FRI_NETWORK 4 /* network address from if */ 5447c478bd9Sstevel@tonic-gate #define FRI_BROADCAST 5 /* broadcast address from if */ 5457c478bd9Sstevel@tonic-gate #define FRI_PEERADDR 6 /* Peer address for P-to-P */ 5467c478bd9Sstevel@tonic-gate #define FRI_NETMASKED 7 /* network address with netmask from if */ 5477c478bd9Sstevel@tonic-gate 5487c478bd9Sstevel@tonic-gate 5497c478bd9Sstevel@tonic-gate typedef struct frentry * (* frentfunc_t) __P((fr_info_t *)); 5507c478bd9Sstevel@tonic-gate 5517c478bd9Sstevel@tonic-gate typedef struct frentry { 5527c478bd9Sstevel@tonic-gate ipfmutex_t fr_lock; 5537c478bd9Sstevel@tonic-gate struct frentry *fr_next; 5547c478bd9Sstevel@tonic-gate struct frentry **fr_grp; 5557c478bd9Sstevel@tonic-gate struct ipscan *fr_isc; 5567c478bd9Sstevel@tonic-gate void *fr_ifas[4]; 5577c478bd9Sstevel@tonic-gate void *fr_ptr; /* for use with fr_arg */ 5587c478bd9Sstevel@tonic-gate char *fr_comment; /* text comment for rule */ 5597c478bd9Sstevel@tonic-gate int fr_ref; /* reference count - for grouping */ 5607c478bd9Sstevel@tonic-gate int fr_statecnt; /* state count - for limit rules */ 5617c478bd9Sstevel@tonic-gate /* 5627c478bd9Sstevel@tonic-gate * These are only incremented when a packet matches this rule and 5637c478bd9Sstevel@tonic-gate * it is the last match 5647c478bd9Sstevel@tonic-gate */ 5657c478bd9Sstevel@tonic-gate U_QUAD_T fr_hits; 5667c478bd9Sstevel@tonic-gate U_QUAD_T fr_bytes; 5677c478bd9Sstevel@tonic-gate 5687c478bd9Sstevel@tonic-gate /* 5697c478bd9Sstevel@tonic-gate * For PPS rate limiting 5707c478bd9Sstevel@tonic-gate */ 5717c478bd9Sstevel@tonic-gate struct timeval fr_lastpkt; 5727c478bd9Sstevel@tonic-gate int fr_curpps; 5737c478bd9Sstevel@tonic-gate 5747c478bd9Sstevel@tonic-gate union { 5757c478bd9Sstevel@tonic-gate void *fru_data; 5767c478bd9Sstevel@tonic-gate caddr_t fru_caddr; 5777c478bd9Sstevel@tonic-gate fripf_t *fru_ipf; 5787c478bd9Sstevel@tonic-gate frentfunc_t fru_func; 5797c478bd9Sstevel@tonic-gate } fr_dun; 5807c478bd9Sstevel@tonic-gate 5817c478bd9Sstevel@tonic-gate /* 5827c478bd9Sstevel@tonic-gate * Fields after this may not change whilst in the kernel. 5837c478bd9Sstevel@tonic-gate */ 5847c478bd9Sstevel@tonic-gate ipfunc_t fr_func; /* call this function */ 5857c478bd9Sstevel@tonic-gate int fr_dsize; 5867c478bd9Sstevel@tonic-gate int fr_pps; 5877c478bd9Sstevel@tonic-gate int fr_statemax; /* max reference count */ 5887c478bd9Sstevel@tonic-gate int fr_flineno; /* line number from conf file */ 5897c478bd9Sstevel@tonic-gate u_32_t fr_type; 5907c478bd9Sstevel@tonic-gate u_32_t fr_flags; /* per-rule flags && options (see below) */ 5917c478bd9Sstevel@tonic-gate u_32_t fr_logtag; /* user defined log tag # */ 5927c478bd9Sstevel@tonic-gate u_32_t fr_collect; /* collection number */ 5937c478bd9Sstevel@tonic-gate u_int fr_arg; /* misc. numeric arg for rule */ 5947c478bd9Sstevel@tonic-gate u_int fr_loglevel; /* syslog log facility + priority */ 5957c478bd9Sstevel@tonic-gate u_int fr_age[2]; /* non-TCP timeouts */ 5967c478bd9Sstevel@tonic-gate u_char fr_v; 5977c478bd9Sstevel@tonic-gate u_char fr_icode; /* return ICMP code */ 5987c478bd9Sstevel@tonic-gate char fr_group[FR_GROUPLEN]; /* group to which this rule belongs */ 5997c478bd9Sstevel@tonic-gate char fr_grhead[FR_GROUPLEN]; /* group # which this rule starts */ 600ab25eeb5Syz ipftag_t fr_nattag; 6017c478bd9Sstevel@tonic-gate char fr_ifnames[4][LIFNAMSIZ]; 6027c478bd9Sstevel@tonic-gate char fr_isctag[16]; 603ab25eeb5Syz frdest_t fr_tifs[2]; /* "to"/"reply-to" interface */ 604ab25eeb5Syz frdest_t fr_dif; /* duplicate packet interface */ 6057c478bd9Sstevel@tonic-gate /* 6067c478bd9Sstevel@tonic-gate * This must be last and will change after loaded into the kernel. 6077c478bd9Sstevel@tonic-gate */ 6087c478bd9Sstevel@tonic-gate u_int fr_cksum; /* checksum on filter rules for performance */ 6097c478bd9Sstevel@tonic-gate } frentry_t; 6107c478bd9Sstevel@tonic-gate 6117c478bd9Sstevel@tonic-gate #define fr_caddr fr_dun.fru_caddr 6127c478bd9Sstevel@tonic-gate #define fr_data fr_dun.fru_data 6137c478bd9Sstevel@tonic-gate #define fr_dfunc fr_dun.fru_func 6147c478bd9Sstevel@tonic-gate #define fr_ipf fr_dun.fru_ipf 6157c478bd9Sstevel@tonic-gate #define fr_ip fr_ipf->fri_ip 6167c478bd9Sstevel@tonic-gate #define fr_mip fr_ipf->fri_mip 6177c478bd9Sstevel@tonic-gate #define fr_icmpm fr_ipf->fri_icmpm 6187c478bd9Sstevel@tonic-gate #define fr_icmp fr_ipf->fri_icmp 6197c478bd9Sstevel@tonic-gate #define fr_tuc fr_ipf->fri_tuc 6207c478bd9Sstevel@tonic-gate #define fr_satype fr_ipf->fri_satype 6217c478bd9Sstevel@tonic-gate #define fr_datype fr_ipf->fri_datype 6227c478bd9Sstevel@tonic-gate #define fr_sifpidx fr_ipf->fri_sifpidx 6237c478bd9Sstevel@tonic-gate #define fr_difpidx fr_ipf->fri_difpidx 6247c478bd9Sstevel@tonic-gate #define fr_proto fr_ip.fi_p 6257c478bd9Sstevel@tonic-gate #define fr_mproto fr_mip.fi_p 6267c478bd9Sstevel@tonic-gate #define fr_ttl fr_ip.fi_ttl 6277c478bd9Sstevel@tonic-gate #define fr_mttl fr_mip.fi_ttl 6287c478bd9Sstevel@tonic-gate #define fr_tos fr_ip.fi_tos 6297c478bd9Sstevel@tonic-gate #define fr_mtos fr_mip.fi_tos 6307c478bd9Sstevel@tonic-gate #define fr_tcpfm fr_tuc.ftu_tcpfm 6317c478bd9Sstevel@tonic-gate #define fr_tcpf fr_tuc.ftu_tcpf 6327c478bd9Sstevel@tonic-gate #define fr_scmp fr_tuc.ftu_scmp 6337c478bd9Sstevel@tonic-gate #define fr_dcmp fr_tuc.ftu_dcmp 6347c478bd9Sstevel@tonic-gate #define fr_dport fr_tuc.ftu_dport 6357c478bd9Sstevel@tonic-gate #define fr_sport fr_tuc.ftu_sport 6367c478bd9Sstevel@tonic-gate #define fr_stop fr_tuc.ftu_stop 6377c478bd9Sstevel@tonic-gate #define fr_dtop fr_tuc.ftu_dtop 6387c478bd9Sstevel@tonic-gate #define fr_dst fr_ip.fi_dst.in4 6397c478bd9Sstevel@tonic-gate #define fr_daddr fr_ip.fi_dst.in4.s_addr 6407c478bd9Sstevel@tonic-gate #define fr_src fr_ip.fi_src.in4 6417c478bd9Sstevel@tonic-gate #define fr_saddr fr_ip.fi_src.in4.s_addr 6427c478bd9Sstevel@tonic-gate #define fr_dmsk fr_mip.fi_dst.in4 6437c478bd9Sstevel@tonic-gate #define fr_dmask fr_mip.fi_dst.in4.s_addr 6447c478bd9Sstevel@tonic-gate #define fr_smsk fr_mip.fi_src.in4 6457c478bd9Sstevel@tonic-gate #define fr_smask fr_mip.fi_src.in4.s_addr 6467c478bd9Sstevel@tonic-gate #define fr_dstnum fr_ip.fi_dstnum 6477c478bd9Sstevel@tonic-gate #define fr_srcnum fr_ip.fi_srcnum 6487c478bd9Sstevel@tonic-gate #define fr_dsttype fr_ip.fi_dsttype 6497c478bd9Sstevel@tonic-gate #define fr_srctype fr_ip.fi_srctype 6507c478bd9Sstevel@tonic-gate #define fr_dstptr fr_mip.fi_dstptr 6517c478bd9Sstevel@tonic-gate #define fr_srcptr fr_mip.fi_srcptr 6527c478bd9Sstevel@tonic-gate #define fr_dstfunc fr_mip.fi_dstfunc 6537c478bd9Sstevel@tonic-gate #define fr_srcfunc fr_mip.fi_srcfunc 6547c478bd9Sstevel@tonic-gate #define fr_optbits fr_ip.fi_optmsk 6557c478bd9Sstevel@tonic-gate #define fr_optmask fr_mip.fi_optmsk 6567c478bd9Sstevel@tonic-gate #define fr_secbits fr_ip.fi_secmsk 6577c478bd9Sstevel@tonic-gate #define fr_secmask fr_mip.fi_secmsk 6587c478bd9Sstevel@tonic-gate #define fr_authbits fr_ip.fi_auth 6597c478bd9Sstevel@tonic-gate #define fr_authmask fr_mip.fi_auth 6607c478bd9Sstevel@tonic-gate #define fr_flx fr_ip.fi_flx 6617c478bd9Sstevel@tonic-gate #define fr_mflx fr_mip.fi_flx 6627c478bd9Sstevel@tonic-gate #define fr_ifname fr_ifnames[0] 6637c478bd9Sstevel@tonic-gate #define fr_oifname fr_ifnames[2] 6647c478bd9Sstevel@tonic-gate #define fr_ifa fr_ifas[0] 6657c478bd9Sstevel@tonic-gate #define fr_oifa fr_ifas[2] 6667c478bd9Sstevel@tonic-gate #define fr_tif fr_tifs[0] 6677c478bd9Sstevel@tonic-gate #define fr_rif fr_tifs[1] 6687c478bd9Sstevel@tonic-gate 6697c478bd9Sstevel@tonic-gate #define FR_NOLOGTAG 0 6707c478bd9Sstevel@tonic-gate 6717c478bd9Sstevel@tonic-gate #ifndef offsetof 6727c478bd9Sstevel@tonic-gate #define offsetof(t,m) (int)((&((t *)0L)->m)) 6737c478bd9Sstevel@tonic-gate #endif 6747c478bd9Sstevel@tonic-gate #define FR_CMPSIZ (sizeof(struct frentry) - \ 675ab25eeb5Syz offsetof(struct frentry, fr_func)) 6767c478bd9Sstevel@tonic-gate 6777c478bd9Sstevel@tonic-gate /* 6787c478bd9Sstevel@tonic-gate * fr_type 6797c478bd9Sstevel@tonic-gate */ 6807c478bd9Sstevel@tonic-gate #define FR_T_NONE 0 6817c478bd9Sstevel@tonic-gate #define FR_T_IPF 1 /* IPF structures */ 6827c478bd9Sstevel@tonic-gate #define FR_T_BPFOPC 2 /* BPF opcode */ 6837c478bd9Sstevel@tonic-gate #define FR_T_CALLFUNC 3 /* callout to function in fr_func only */ 6847c478bd9Sstevel@tonic-gate #define FR_T_COMPIPF 4 /* compiled C code */ 6857c478bd9Sstevel@tonic-gate #define FR_T_BUILTIN 0x80000000 /* rule is in kernel space */ 6867c478bd9Sstevel@tonic-gate 6877c478bd9Sstevel@tonic-gate /* 6887c478bd9Sstevel@tonic-gate * fr_flags 6897c478bd9Sstevel@tonic-gate */ 6907c478bd9Sstevel@tonic-gate #define FR_CALL 0x00000 /* call rule */ 6917c478bd9Sstevel@tonic-gate #define FR_BLOCK 0x00001 /* do not allow packet to pass */ 6927c478bd9Sstevel@tonic-gate #define FR_PASS 0x00002 /* allow packet to pass */ 6937c478bd9Sstevel@tonic-gate #define FR_AUTH 0x00003 /* use authentication */ 6947c478bd9Sstevel@tonic-gate #define FR_PREAUTH 0x00004 /* require preauthentication */ 6957c478bd9Sstevel@tonic-gate #define FR_ACCOUNT 0x00005 /* Accounting rule */ 6967c478bd9Sstevel@tonic-gate #define FR_SKIP 0x00006 /* skip rule */ 6977c478bd9Sstevel@tonic-gate #define FR_DIVERT 0x00007 /* divert rule */ 6987c478bd9Sstevel@tonic-gate #define FR_CMDMASK 0x0000f 6997c478bd9Sstevel@tonic-gate #define FR_LOG 0x00010 /* Log */ 7007c478bd9Sstevel@tonic-gate #define FR_LOGB 0x00011 /* Log-fail */ 7017c478bd9Sstevel@tonic-gate #define FR_LOGP 0x00012 /* Log-pass */ 7027c478bd9Sstevel@tonic-gate #define FR_LOGMASK (FR_LOG|FR_CMDMASK) 7037c478bd9Sstevel@tonic-gate #define FR_CALLNOW 0x00020 /* call another function (fr_func) if matches */ 7047c478bd9Sstevel@tonic-gate #define FR_NOTSRCIP 0x00040 7057c478bd9Sstevel@tonic-gate #define FR_NOTDSTIP 0x00080 7067c478bd9Sstevel@tonic-gate #define FR_QUICK 0x00100 /* match & stop processing list */ 7077c478bd9Sstevel@tonic-gate #define FR_KEEPFRAG 0x00200 /* keep fragment information */ 7087c478bd9Sstevel@tonic-gate #define FR_KEEPSTATE 0x00400 /* keep `connection' state information */ 7097c478bd9Sstevel@tonic-gate #define FR_FASTROUTE 0x00800 /* bypass normal routing */ 7107c478bd9Sstevel@tonic-gate #define FR_RETRST 0x01000 /* Return TCP RST packet - reset connection */ 7117c478bd9Sstevel@tonic-gate #define FR_RETICMP 0x02000 /* Return ICMP unreachable packet */ 7127c478bd9Sstevel@tonic-gate #define FR_FAKEICMP 0x03000 /* Return ICMP unreachable with fake source */ 7137c478bd9Sstevel@tonic-gate #define FR_OUTQUE 0x04000 /* outgoing packets */ 7147c478bd9Sstevel@tonic-gate #define FR_INQUE 0x08000 /* ingoing packets */ 7157c478bd9Sstevel@tonic-gate #define FR_LOGBODY 0x10000 /* Log the body */ 7167c478bd9Sstevel@tonic-gate #define FR_LOGFIRST 0x20000 /* Log the first byte if state held */ 7177c478bd9Sstevel@tonic-gate #define FR_LOGORBLOCK 0x40000 /* block the packet if it can't be logged */ 7187c478bd9Sstevel@tonic-gate #define FR_DUP 0x80000 /* duplicate packet */ 7197c478bd9Sstevel@tonic-gate #define FR_FRSTRICT 0x100000 /* strict frag. cache */ 7207c478bd9Sstevel@tonic-gate #define FR_STSTRICT 0x200000 /* strict keep state */ 7217c478bd9Sstevel@tonic-gate #define FR_NEWISN 0x400000 /* new ISN for outgoing TCP */ 7227c478bd9Sstevel@tonic-gate #define FR_NOICMPERR 0x800000 /* do not match ICMP errors in state */ 723ab25eeb5Syz #define FR_STATESYNC 0x1000000 /* synchronize state to slave */ 7247c478bd9Sstevel@tonic-gate #define FR_NOMATCH 0x8000000 /* no match occured */ 7257c478bd9Sstevel@tonic-gate /* 0x10000000 FF_LOGPASS */ 7267c478bd9Sstevel@tonic-gate /* 0x20000000 FF_LOGBLOCK */ 7277c478bd9Sstevel@tonic-gate /* 0x40000000 FF_LOGNOMATCH */ 7287c478bd9Sstevel@tonic-gate /* 0x80000000 FF_BLOCKNONIP */ 7297c478bd9Sstevel@tonic-gate #define FR_COPIED 0x40000000 /* copied from user space */ 7307c478bd9Sstevel@tonic-gate #define FR_INACTIVE 0x80000000 /* only used when flush'ing rules */ 7317c478bd9Sstevel@tonic-gate 7327c478bd9Sstevel@tonic-gate #define FR_RETMASK (FR_RETICMP|FR_RETRST|FR_FAKEICMP) 7337c478bd9Sstevel@tonic-gate #define FR_ISBLOCK(x) (((x) & FR_CMDMASK) == FR_BLOCK) 7347c478bd9Sstevel@tonic-gate #define FR_ISPASS(x) (((x) & FR_CMDMASK) == FR_PASS) 7357c478bd9Sstevel@tonic-gate #define FR_ISAUTH(x) (((x) & FR_CMDMASK) == FR_AUTH) 7367c478bd9Sstevel@tonic-gate #define FR_ISPREAUTH(x) (((x) & FR_CMDMASK) == FR_PREAUTH) 7377c478bd9Sstevel@tonic-gate #define FR_ISACCOUNT(x) (((x) & FR_CMDMASK) == FR_ACCOUNT) 7387c478bd9Sstevel@tonic-gate #define FR_ISSKIP(x) (((x) & FR_CMDMASK) == FR_SKIP) 7397c478bd9Sstevel@tonic-gate #define FR_ISNOMATCH(x) ((x) & FR_NOMATCH) 7407c478bd9Sstevel@tonic-gate #define FR_INOUT (FR_INQUE|FR_OUTQUE) 7417c478bd9Sstevel@tonic-gate 7427c478bd9Sstevel@tonic-gate /* 7437c478bd9Sstevel@tonic-gate * recognized flags for SIOCGETFF and SIOCSETFF, and get put in fr_flags 7447c478bd9Sstevel@tonic-gate */ 7457c478bd9Sstevel@tonic-gate #define FF_LOGPASS 0x10000000 7467c478bd9Sstevel@tonic-gate #define FF_LOGBLOCK 0x20000000 7477c478bd9Sstevel@tonic-gate #define FF_LOGNOMATCH 0x40000000 7487c478bd9Sstevel@tonic-gate #define FF_LOGGING (FF_LOGPASS|FF_LOGBLOCK|FF_LOGNOMATCH) 7497c478bd9Sstevel@tonic-gate #define FF_BLOCKNONIP 0x80000000 /* Solaris2 Only */ 7507c478bd9Sstevel@tonic-gate 7517c478bd9Sstevel@tonic-gate 7527c478bd9Sstevel@tonic-gate /* 7537c478bd9Sstevel@tonic-gate * Structure that passes information on what/how to flush to the kernel. 7547c478bd9Sstevel@tonic-gate */ 7557c478bd9Sstevel@tonic-gate typedef struct ipfflush { 7567c478bd9Sstevel@tonic-gate int ipflu_how; 7577c478bd9Sstevel@tonic-gate int ipflu_arg; 7587c478bd9Sstevel@tonic-gate } ipfflush_t; 7597c478bd9Sstevel@tonic-gate 7607c478bd9Sstevel@tonic-gate 7617c478bd9Sstevel@tonic-gate /* 7627c478bd9Sstevel@tonic-gate * 7637c478bd9Sstevel@tonic-gate */ 7647c478bd9Sstevel@tonic-gate typedef struct ipfgetctl { 7657c478bd9Sstevel@tonic-gate u_int ipfg_min; /* min value */ 7667c478bd9Sstevel@tonic-gate u_int ipfg_current; /* current value */ 7677c478bd9Sstevel@tonic-gate u_int ipfg_max; /* max value */ 7687c478bd9Sstevel@tonic-gate u_int ipfg_default; /* default value */ 7697c478bd9Sstevel@tonic-gate u_int ipfg_steps; /* value increments */ 7707c478bd9Sstevel@tonic-gate char ipfg_name[40]; /* tag name for this control */ 7717c478bd9Sstevel@tonic-gate } ipfgetctl_t; 7727c478bd9Sstevel@tonic-gate 7737c478bd9Sstevel@tonic-gate typedef struct ipfsetctl { 7747c478bd9Sstevel@tonic-gate int ipfs_which; /* 0 = min 1 = current 2 = max 3 = default */ 7757c478bd9Sstevel@tonic-gate u_int ipfs_value; /* min value */ 7767c478bd9Sstevel@tonic-gate char ipfs_name[40]; /* tag name for this control */ 7777c478bd9Sstevel@tonic-gate } ipfsetctl_t; 7787c478bd9Sstevel@tonic-gate 7797c478bd9Sstevel@tonic-gate 7807c478bd9Sstevel@tonic-gate /* 7817c478bd9Sstevel@tonic-gate * Some of the statistics below are in their own counters, but most are kept 7827c478bd9Sstevel@tonic-gate * in this single structure so that they can all easily be collected and 7837c478bd9Sstevel@tonic-gate * copied back as required. 784e0b463afSschuster * 785e0b463afSschuster * NOTE: when changing, keep in sync with kstats (below). 7867c478bd9Sstevel@tonic-gate */ 7877c478bd9Sstevel@tonic-gate typedef struct filterstats { 7887c478bd9Sstevel@tonic-gate u_long fr_pass; /* packets allowed */ 7897c478bd9Sstevel@tonic-gate u_long fr_block; /* packets denied */ 7907c478bd9Sstevel@tonic-gate u_long fr_nom; /* packets which don't match any rule */ 7917c478bd9Sstevel@tonic-gate u_long fr_short; /* packets which are short */ 7927c478bd9Sstevel@tonic-gate u_long fr_ppkl; /* packets allowed and logged */ 7937c478bd9Sstevel@tonic-gate u_long fr_bpkl; /* packets denied and logged */ 7947c478bd9Sstevel@tonic-gate u_long fr_npkl; /* packets unmatched and logged */ 7957c478bd9Sstevel@tonic-gate u_long fr_pkl; /* packets logged */ 7967c478bd9Sstevel@tonic-gate u_long fr_skip; /* packets to be logged but buffer full */ 7977c478bd9Sstevel@tonic-gate u_long fr_ret; /* packets for which a return is sent */ 7987c478bd9Sstevel@tonic-gate u_long fr_acct; /* packets for which counting was performed */ 7997c478bd9Sstevel@tonic-gate u_long fr_bnfr; /* bad attempts to allocate fragment state */ 8007c478bd9Sstevel@tonic-gate u_long fr_nfr; /* new fragment state kept */ 8017c478bd9Sstevel@tonic-gate u_long fr_cfr; /* add new fragment state but complete pkt */ 8027c478bd9Sstevel@tonic-gate u_long fr_bads; /* bad attempts to allocate packet state */ 8037c478bd9Sstevel@tonic-gate u_long fr_ads; /* new packet state kept */ 8047c478bd9Sstevel@tonic-gate u_long fr_chit; /* cached hit */ 8057c478bd9Sstevel@tonic-gate u_long fr_tcpbad; /* TCP checksum check failures */ 8067c478bd9Sstevel@tonic-gate u_long fr_pull[2]; /* good and bad pullup attempts */ 8077c478bd9Sstevel@tonic-gate u_long fr_badsrc; /* source received doesn't match route */ 8087c478bd9Sstevel@tonic-gate u_long fr_badttl; /* TTL in packet doesn't reach minimum */ 8097c478bd9Sstevel@tonic-gate u_long fr_bad; /* bad IP packets to the filter */ 8107c478bd9Sstevel@tonic-gate u_long fr_ipv6; /* IPv6 packets in/out */ 8117c478bd9Sstevel@tonic-gate u_long fr_ppshit; /* dropped because of pps ceiling */ 8127c478bd9Sstevel@tonic-gate u_long fr_ipud; /* IP id update failures */ 8137c478bd9Sstevel@tonic-gate } filterstats_t; 8147c478bd9Sstevel@tonic-gate 815e0b463afSschuster /* 816e0b463afSschuster * kstat "copy" of the above - keep in sync! 817e0b463afSschuster * also keep in sync with initialisation code in solaris.c, ipf_kstat_init(). 818e0b463afSschuster */ 819e0b463afSschuster typedef struct filter_kstats { 820e0b463afSschuster kstat_named_t fks_pass; /* see above for comments */ 821e0b463afSschuster kstat_named_t fks_block; 822e0b463afSschuster kstat_named_t fks_nom; 823e0b463afSschuster kstat_named_t fks_short; 824e0b463afSschuster kstat_named_t fks_ppkl; 825e0b463afSschuster kstat_named_t fks_bpkl; 826e0b463afSschuster kstat_named_t fks_npkl; 827e0b463afSschuster kstat_named_t fks_pkl; 828e0b463afSschuster kstat_named_t fks_skip; 829e0b463afSschuster kstat_named_t fks_ret; 830e0b463afSschuster kstat_named_t fks_acct; 831e0b463afSschuster kstat_named_t fks_bnfr; 832e0b463afSschuster kstat_named_t fks_nfr; 833e0b463afSschuster kstat_named_t fks_cfr; 834e0b463afSschuster kstat_named_t fks_bads; 835e0b463afSschuster kstat_named_t fks_ads; 836e0b463afSschuster kstat_named_t fks_chit; 837e0b463afSschuster kstat_named_t fks_tcpbad; 838e0b463afSschuster kstat_named_t fks_pull[2]; 839e0b463afSschuster kstat_named_t fks_badsrc; 840e0b463afSschuster kstat_named_t fks_badttl; 841e0b463afSschuster kstat_named_t fks_bad; 842e0b463afSschuster kstat_named_t fks_ipv6; 843e0b463afSschuster kstat_named_t fks_ppshit; 844e0b463afSschuster kstat_named_t fks_ipud; 845e0b463afSschuster } filter_kstats_t; 846e0b463afSschuster 8477c478bd9Sstevel@tonic-gate /* 8487c478bd9Sstevel@tonic-gate * Log structure. Each packet header logged is prepended by one of these. 8497c478bd9Sstevel@tonic-gate * Following this in the log records read from the device will be an ipflog 8507c478bd9Sstevel@tonic-gate * structure which is then followed by any packet data. 8517c478bd9Sstevel@tonic-gate */ 8527c478bd9Sstevel@tonic-gate typedef struct iplog { 8537c478bd9Sstevel@tonic-gate u_32_t ipl_magic; 8547c478bd9Sstevel@tonic-gate u_int ipl_count; 855ab25eeb5Syz struct timeval ipl_time; 8567c478bd9Sstevel@tonic-gate size_t ipl_dsize; 8577c478bd9Sstevel@tonic-gate struct iplog *ipl_next; 8587c478bd9Sstevel@tonic-gate } iplog_t; 8597c478bd9Sstevel@tonic-gate 860ab25eeb5Syz #define ipl_sec ipl_time.tv_sec 861ab25eeb5Syz #define ipl_usec ipl_time.tv_usec 8627c478bd9Sstevel@tonic-gate 8637c478bd9Sstevel@tonic-gate #define IPL_MAGIC 0x49504c4d /* 'IPLM' */ 864ab25eeb5Syz #define IPL_MAGIC_NAT 0x49504c4e /* 'IPLN' */ 865ab25eeb5Syz #define IPL_MAGIC_STATE 0x49504c53 /* 'IPLS' */ 8667c478bd9Sstevel@tonic-gate #define IPLOG_SIZE sizeof(iplog_t) 8677c478bd9Sstevel@tonic-gate 8687c478bd9Sstevel@tonic-gate typedef struct ipflog { 8697c478bd9Sstevel@tonic-gate #if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \ 8707c478bd9Sstevel@tonic-gate (defined(OpenBSD) && (OpenBSD >= 199603)) 8717c478bd9Sstevel@tonic-gate #else 8727c478bd9Sstevel@tonic-gate u_int fl_unit; 8737c478bd9Sstevel@tonic-gate #endif 8747c478bd9Sstevel@tonic-gate u_32_t fl_rule; 8757c478bd9Sstevel@tonic-gate u_32_t fl_flags; 8767c478bd9Sstevel@tonic-gate u_32_t fl_lflags; 877ab25eeb5Syz u_32_t fl_logtag; 878ab25eeb5Syz ipftag_t fl_nattag; 8797c478bd9Sstevel@tonic-gate u_short fl_plen; /* extra data after hlen */ 8807c478bd9Sstevel@tonic-gate u_short fl_loglevel; /* syslog log level */ 8817c478bd9Sstevel@tonic-gate char fl_group[FR_GROUPLEN]; 8827c478bd9Sstevel@tonic-gate u_char fl_hlen; /* length of IP headers saved */ 8837c478bd9Sstevel@tonic-gate u_char fl_dir; 884ab25eeb5Syz u_char fl_xxx[2]; /* pad */ 8857c478bd9Sstevel@tonic-gate char fl_ifname[LIFNAMSIZ]; 8867c478bd9Sstevel@tonic-gate } ipflog_t; 8877c478bd9Sstevel@tonic-gate 8887c478bd9Sstevel@tonic-gate #ifndef IPF_LOGGING 8897c478bd9Sstevel@tonic-gate # define IPF_LOGGING 0 8907c478bd9Sstevel@tonic-gate #endif 8917c478bd9Sstevel@tonic-gate #ifndef IPF_DEFAULT_PASS 8927c478bd9Sstevel@tonic-gate # define IPF_DEFAULT_PASS FR_PASS 8937c478bd9Sstevel@tonic-gate #endif 8947c478bd9Sstevel@tonic-gate 8957c478bd9Sstevel@tonic-gate #define DEFAULT_IPFLOGSIZE 8192 8967c478bd9Sstevel@tonic-gate #ifndef IPFILTER_LOGSIZE 8977c478bd9Sstevel@tonic-gate # define IPFILTER_LOGSIZE DEFAULT_IPFLOGSIZE 8987c478bd9Sstevel@tonic-gate #else 899ab25eeb5Syz # if IPFILTER_LOGSIZE < DEFAULT_IPFLOGSIZE 900ab25eeb5Syz # error IPFILTER_LOGSIZE too small. Must be >= DEFAULT_IPFLOGSIZE 9017c478bd9Sstevel@tonic-gate # endif 9027c478bd9Sstevel@tonic-gate #endif 9037c478bd9Sstevel@tonic-gate 9047c478bd9Sstevel@tonic-gate #define IPF_OPTCOPY 0x07ff00 /* bit mask of copied options */ 9057c478bd9Sstevel@tonic-gate 9067c478bd9Sstevel@tonic-gate /* 9077c478bd9Sstevel@tonic-gate * Device filenames for reading log information. Use ipf on Solaris2 because 9087c478bd9Sstevel@tonic-gate * ipl is already a name used by something else. 9097c478bd9Sstevel@tonic-gate */ 9107c478bd9Sstevel@tonic-gate #ifndef IPL_NAME 9117c478bd9Sstevel@tonic-gate # if SOLARIS 9127c478bd9Sstevel@tonic-gate # define IPL_NAME "/dev/ipf" 9137c478bd9Sstevel@tonic-gate # else 9147c478bd9Sstevel@tonic-gate # define IPL_NAME "/dev/ipl" 9157c478bd9Sstevel@tonic-gate # endif 9167c478bd9Sstevel@tonic-gate #endif 9177c478bd9Sstevel@tonic-gate /* 9187c478bd9Sstevel@tonic-gate * Pathnames for various IP Filter control devices. Used by LKM 9197c478bd9Sstevel@tonic-gate * and userland, so defined here. 9207c478bd9Sstevel@tonic-gate */ 9217c478bd9Sstevel@tonic-gate #define IPNAT_NAME "/dev/ipnat" 9227c478bd9Sstevel@tonic-gate #define IPSTATE_NAME "/dev/ipstate" 9237c478bd9Sstevel@tonic-gate #define IPAUTH_NAME "/dev/ipauth" 9247c478bd9Sstevel@tonic-gate #define IPSYNC_NAME "/dev/ipsync" 9257c478bd9Sstevel@tonic-gate #define IPSCAN_NAME "/dev/ipscan" 9267c478bd9Sstevel@tonic-gate #define IPLOOKUP_NAME "/dev/iplookup" 9277c478bd9Sstevel@tonic-gate 9287c478bd9Sstevel@tonic-gate #define IPL_LOGIPF 0 /* Minor device #'s for accessing logs */ 9297c478bd9Sstevel@tonic-gate #define IPL_LOGNAT 1 9307c478bd9Sstevel@tonic-gate #define IPL_LOGSTATE 2 9317c478bd9Sstevel@tonic-gate #define IPL_LOGAUTH 3 9327c478bd9Sstevel@tonic-gate #define IPL_LOGSYNC 4 9337c478bd9Sstevel@tonic-gate #define IPL_LOGSCAN 5 9347c478bd9Sstevel@tonic-gate #define IPL_LOGLOOKUP 6 9357c478bd9Sstevel@tonic-gate #define IPL_LOGCOUNT 7 9367c478bd9Sstevel@tonic-gate #define IPL_LOGMAX 7 937f4b3ec61Sdh #define IPL_LOGSIZE (IPL_LOGMAX + 1) 9387c478bd9Sstevel@tonic-gate #define IPL_LOGALL -1 9397c478bd9Sstevel@tonic-gate #define IPL_LOGNONE -2 9407c478bd9Sstevel@tonic-gate 9417c478bd9Sstevel@tonic-gate /* 9427c478bd9Sstevel@tonic-gate * For SIOCGETFS 9437c478bd9Sstevel@tonic-gate */ 9447c478bd9Sstevel@tonic-gate typedef struct friostat { 9457c478bd9Sstevel@tonic-gate struct filterstats f_st[2]; 9467c478bd9Sstevel@tonic-gate struct frentry *f_ipf[2][2]; 9477c478bd9Sstevel@tonic-gate struct frentry *f_acct[2][2]; 9487c478bd9Sstevel@tonic-gate struct frentry *f_ipf6[2][2]; 9497c478bd9Sstevel@tonic-gate struct frentry *f_acct6[2][2]; 9507c478bd9Sstevel@tonic-gate struct frentry *f_auth; 9517c478bd9Sstevel@tonic-gate struct frgroup *f_groups[IPL_LOGSIZE][2]; 9527c478bd9Sstevel@tonic-gate u_long f_froute[2]; 9537c478bd9Sstevel@tonic-gate u_long f_ticks; 9547c478bd9Sstevel@tonic-gate int f_locks[IPL_LOGMAX]; 9557c478bd9Sstevel@tonic-gate size_t f_kmutex_sz; 9567c478bd9Sstevel@tonic-gate size_t f_krwlock_sz; 9577c478bd9Sstevel@tonic-gate int f_defpass; /* default pass - from fr_pass */ 958ab25eeb5Syz int f_active; /* 1 or 0 - active rule set */ 959ab25eeb5Syz int f_running; /* 1 if running, else 0 */ 960ab25eeb5Syz int f_logging; /* 1 if enabled, else 0 */ 961ab25eeb5Syz int f_features; 9627c478bd9Sstevel@tonic-gate char f_version[32]; /* version string */ 9637c478bd9Sstevel@tonic-gate } friostat_t; 9647c478bd9Sstevel@tonic-gate 9657c478bd9Sstevel@tonic-gate #define f_fin f_ipf[0] 9667c478bd9Sstevel@tonic-gate #define f_fin6 f_ipf6[0] 9677c478bd9Sstevel@tonic-gate #define f_fout f_ipf[1] 9687c478bd9Sstevel@tonic-gate #define f_fout6 f_ipf6[1] 9697c478bd9Sstevel@tonic-gate #define f_acctin f_acct[0] 9707c478bd9Sstevel@tonic-gate #define f_acctin6 f_acct6[0] 9717c478bd9Sstevel@tonic-gate #define f_acctout f_acct[1] 9727c478bd9Sstevel@tonic-gate #define f_acctout6 f_acct6[1] 9737c478bd9Sstevel@tonic-gate 974ab25eeb5Syz #define IPF_FEAT_LKM 0x001 975ab25eeb5Syz #define IPF_FEAT_LOG 0x002 976ab25eeb5Syz #define IPF_FEAT_LOOKUP 0x004 977ab25eeb5Syz #define IPF_FEAT_BPF 0x008 978ab25eeb5Syz #define IPF_FEAT_COMPILED 0x010 979ab25eeb5Syz #define IPF_FEAT_CKSUM 0x020 980ab25eeb5Syz #define IPF_FEAT_SYNC 0x040 981ab25eeb5Syz #define IPF_FEAT_SCAN 0x080 982ab25eeb5Syz #define IPF_FEAT_IPV6 0x100 9837c478bd9Sstevel@tonic-gate 9847c478bd9Sstevel@tonic-gate typedef struct optlist { 9857c478bd9Sstevel@tonic-gate u_short ol_val; 9867c478bd9Sstevel@tonic-gate int ol_bit; 9877c478bd9Sstevel@tonic-gate } optlist_t; 9887c478bd9Sstevel@tonic-gate 9897c478bd9Sstevel@tonic-gate 9907c478bd9Sstevel@tonic-gate /* 9917c478bd9Sstevel@tonic-gate * Group list structure. 9927c478bd9Sstevel@tonic-gate */ 9937c478bd9Sstevel@tonic-gate typedef struct frgroup { 9947c478bd9Sstevel@tonic-gate struct frgroup *fg_next; 9957c478bd9Sstevel@tonic-gate struct frentry *fg_head; 9967c478bd9Sstevel@tonic-gate struct frentry *fg_start; 9977c478bd9Sstevel@tonic-gate u_32_t fg_flags; 9987c478bd9Sstevel@tonic-gate int fg_ref; 9997c478bd9Sstevel@tonic-gate char fg_name[FR_GROUPLEN]; 10007c478bd9Sstevel@tonic-gate } frgroup_t; 10017c478bd9Sstevel@tonic-gate 10027c478bd9Sstevel@tonic-gate #define FG_NAME(g) (*(g)->fg_name == '\0' ? "" : (g)->fg_name) 10037c478bd9Sstevel@tonic-gate 10047c478bd9Sstevel@tonic-gate 10057c478bd9Sstevel@tonic-gate /* 10067c478bd9Sstevel@tonic-gate * Used by state and NAT tables 10077c478bd9Sstevel@tonic-gate */ 10087c478bd9Sstevel@tonic-gate typedef struct icmpinfo { 10097c478bd9Sstevel@tonic-gate u_short ici_id; 10107c478bd9Sstevel@tonic-gate u_short ici_seq; 10117c478bd9Sstevel@tonic-gate u_char ici_type; 10127c478bd9Sstevel@tonic-gate } icmpinfo_t; 10137c478bd9Sstevel@tonic-gate 10147c478bd9Sstevel@tonic-gate typedef struct udpinfo { 10157c478bd9Sstevel@tonic-gate u_short us_sport; 10167c478bd9Sstevel@tonic-gate u_short us_dport; 10177c478bd9Sstevel@tonic-gate } udpinfo_t; 10187c478bd9Sstevel@tonic-gate 10197c478bd9Sstevel@tonic-gate 10207c478bd9Sstevel@tonic-gate typedef struct tcpdata { 10217c478bd9Sstevel@tonic-gate u_32_t td_end; 10227c478bd9Sstevel@tonic-gate u_32_t td_maxend; 10237c478bd9Sstevel@tonic-gate u_32_t td_maxwin; 10247c478bd9Sstevel@tonic-gate u_32_t td_winscale; 10257c478bd9Sstevel@tonic-gate u_32_t td_maxseg; 10267c478bd9Sstevel@tonic-gate int td_winflags; 10277c478bd9Sstevel@tonic-gate } tcpdata_t; 10287c478bd9Sstevel@tonic-gate 10297c478bd9Sstevel@tonic-gate #define TCP_WSCALE_MAX 14 10307c478bd9Sstevel@tonic-gate 10317c478bd9Sstevel@tonic-gate #define TCP_WSCALE_SEEN 0x00000001 10327c478bd9Sstevel@tonic-gate #define TCP_WSCALE_FIRST 0x00000002 1033f17d2b41San #define TCP_SACK_PERMIT 0x00000004 10347c478bd9Sstevel@tonic-gate 10357c478bd9Sstevel@tonic-gate 10367c478bd9Sstevel@tonic-gate typedef struct tcpinfo { 10377c478bd9Sstevel@tonic-gate u_short ts_sport; 10387c478bd9Sstevel@tonic-gate u_short ts_dport; 10397c478bd9Sstevel@tonic-gate tcpdata_t ts_data[2]; 10407c478bd9Sstevel@tonic-gate } tcpinfo_t; 10417c478bd9Sstevel@tonic-gate 1042ab25eeb5Syz 1043ab25eeb5Syz /* 1044ab25eeb5Syz * Structures to define a GRE header as seen in a packet. 1045ab25eeb5Syz */ 1046ab25eeb5Syz struct grebits { 1047ab25eeb5Syz u_32_t grb_C:1; 1048ab25eeb5Syz u_32_t grb_R:1; 1049ab25eeb5Syz u_32_t grb_K:1; 1050ab25eeb5Syz u_32_t grb_S:1; 1051ab25eeb5Syz u_32_t grb_s:1; 1052ab25eeb5Syz u_32_t grb_recur:1; 1053ab25eeb5Syz u_32_t grb_A:1; 1054ab25eeb5Syz u_32_t grb_flags:3; 1055ab25eeb5Syz u_32_t grb_ver:3; 1056ab25eeb5Syz u_short grb_ptype; 1057ab25eeb5Syz }; 10587c478bd9Sstevel@tonic-gate 10597c478bd9Sstevel@tonic-gate typedef struct grehdr { 10607c478bd9Sstevel@tonic-gate union { 1061ab25eeb5Syz struct grebits gru_bits; 10627c478bd9Sstevel@tonic-gate u_short gru_flags; 10637c478bd9Sstevel@tonic-gate } gr_un; 10647c478bd9Sstevel@tonic-gate u_short gr_len; 10657c478bd9Sstevel@tonic-gate u_short gr_call; 10667c478bd9Sstevel@tonic-gate } grehdr_t; 10677c478bd9Sstevel@tonic-gate 1068ab25eeb5Syz #define gr_flags gr_un.gru_flags 10697c478bd9Sstevel@tonic-gate #define gr_bits gr_un.gru_bits 1070ab25eeb5Syz #define gr_ptype gr_bits.grb_ptype 1071ab25eeb5Syz #define gr_C gr_bits.grb_C 1072ab25eeb5Syz #define gr_R gr_bits.grb_R 1073ab25eeb5Syz #define gr_K gr_bits.grb_K 1074ab25eeb5Syz #define gr_S gr_bits.grb_S 1075ab25eeb5Syz #define gr_s gr_bits.grb_s 1076ab25eeb5Syz #define gr_recur gr_bits.grb_recur 1077ab25eeb5Syz #define gr_A gr_bits.grb_A 1078ab25eeb5Syz #define gr_ver gr_bits.grb_ver 1079ab25eeb5Syz 1080ab25eeb5Syz /* 1081ab25eeb5Syz * GRE information tracked by "keep state" 1082ab25eeb5Syz */ 1083ab25eeb5Syz typedef struct greinfo { 1084ab25eeb5Syz u_short gs_call[2]; 1085ab25eeb5Syz u_short gs_flags; 1086ab25eeb5Syz u_short gs_ptype; 1087ab25eeb5Syz } greinfo_t; 1088ab25eeb5Syz 1089ab25eeb5Syz #define GRE_REV(x) ((ntohs(x) >> 13) & 7) 1090ab25eeb5Syz 1091ab25eeb5Syz 1092ab25eeb5Syz /* 1093ab25eeb5Syz * Format of an Authentication header 1094ab25eeb5Syz */ 1095ab25eeb5Syz typedef struct authhdr { 1096ab25eeb5Syz u_char ah_next; 1097ab25eeb5Syz u_char ah_plen; 1098ab25eeb5Syz u_short ah_reserved; 1099ab25eeb5Syz u_32_t ah_spi; 1100ab25eeb5Syz u_32_t ah_seq; 1101ab25eeb5Syz /* Following the sequence number field is 0 or more bytes of */ 1102ab25eeb5Syz /* authentication data, as specified by ah_plen - RFC 2402. */ 1103ab25eeb5Syz } authhdr_t; 11047c478bd9Sstevel@tonic-gate 11057c478bd9Sstevel@tonic-gate 11067c478bd9Sstevel@tonic-gate /* 11077c478bd9Sstevel@tonic-gate * Timeout tail queue list member 11087c478bd9Sstevel@tonic-gate */ 11097c478bd9Sstevel@tonic-gate typedef struct ipftqent { 11107c478bd9Sstevel@tonic-gate struct ipftqent **tqe_pnext; 11117c478bd9Sstevel@tonic-gate struct ipftqent *tqe_next; 11127c478bd9Sstevel@tonic-gate struct ipftq *tqe_ifq; 11137c478bd9Sstevel@tonic-gate void *tqe_parent; /* pointer back to NAT/state struct */ 11147c478bd9Sstevel@tonic-gate u_long tqe_die; /* when this entriy is to die */ 11157c478bd9Sstevel@tonic-gate u_long tqe_touched; 11167c478bd9Sstevel@tonic-gate int tqe_flags; 11177c478bd9Sstevel@tonic-gate int tqe_state[2]; /* current state of this entry */ 11187c478bd9Sstevel@tonic-gate } ipftqent_t; 11197c478bd9Sstevel@tonic-gate 11207c478bd9Sstevel@tonic-gate #define TQE_RULEBASED 0x00000001 11217c478bd9Sstevel@tonic-gate 11227c478bd9Sstevel@tonic-gate 11237c478bd9Sstevel@tonic-gate /* 11247c478bd9Sstevel@tonic-gate * Timeout tail queue head for IPFilter 11257c478bd9Sstevel@tonic-gate */ 11267c478bd9Sstevel@tonic-gate typedef struct ipftq { 11277c478bd9Sstevel@tonic-gate ipfmutex_t ifq_lock; 11287c478bd9Sstevel@tonic-gate u_int ifq_ttl; 11297c478bd9Sstevel@tonic-gate ipftqent_t *ifq_head; 11307c478bd9Sstevel@tonic-gate ipftqent_t **ifq_tail; 11317c478bd9Sstevel@tonic-gate struct ipftq *ifq_next; 11327c478bd9Sstevel@tonic-gate struct ipftq **ifq_pnext; 11337c478bd9Sstevel@tonic-gate int ifq_ref; 11347c478bd9Sstevel@tonic-gate u_int ifq_flags; 11357c478bd9Sstevel@tonic-gate } ipftq_t; 11367c478bd9Sstevel@tonic-gate 11377c478bd9Sstevel@tonic-gate #define IFQF_USER 0x01 /* User defined aging */ 1138ab25eeb5Syz #define IFQF_DELETE 0x02 /* Marked for deletion */ 1139ab25eeb5Syz #define IFQF_PROXY 0x04 /* Timeout queue in use by a proxy */ 11407c478bd9Sstevel@tonic-gate 11417c478bd9Sstevel@tonic-gate #define IPF_HZ_MULT 1 11427c478bd9Sstevel@tonic-gate #define IPF_HZ_DIVIDE 2 /* How many times a second ipfilter */ 11437c478bd9Sstevel@tonic-gate /* checks its timeout queues. */ 11447c478bd9Sstevel@tonic-gate #define IPF_TTLVAL(x) (((x) / IPF_HZ_MULT) * IPF_HZ_DIVIDE) 11457c478bd9Sstevel@tonic-gate 11467c478bd9Sstevel@tonic-gate /* 11477c478bd9Sstevel@tonic-gate * Structure to define address for pool lookups. 11487c478bd9Sstevel@tonic-gate */ 11497c478bd9Sstevel@tonic-gate typedef struct { 11507c478bd9Sstevel@tonic-gate u_char adf_len; 11517663b816Sml sa_family_t adf_family; 11527c478bd9Sstevel@tonic-gate i6addr_t adf_addr; 11537c478bd9Sstevel@tonic-gate } addrfamily_t; 11547c478bd9Sstevel@tonic-gate 11557c478bd9Sstevel@tonic-gate 11567c478bd9Sstevel@tonic-gate /* 11577c478bd9Sstevel@tonic-gate * Object structure description. For passing through in ioctls. 11587c478bd9Sstevel@tonic-gate */ 11597c478bd9Sstevel@tonic-gate typedef struct ipfobj { 11607c478bd9Sstevel@tonic-gate u_32_t ipfo_rev; /* IPFilter version number */ 11617c478bd9Sstevel@tonic-gate u_32_t ipfo_size; /* size of object at ipfo_ptr */ 11627c478bd9Sstevel@tonic-gate void *ipfo_ptr; /* pointer to object */ 11637c478bd9Sstevel@tonic-gate int ipfo_type; /* type of object being pointed to */ 11647c478bd9Sstevel@tonic-gate int ipfo_offset; /* bytes from ipfo_ptr where to start */ 11657c478bd9Sstevel@tonic-gate u_char ipfo_xxxpad[32]; /* reserved for future use */ 11667c478bd9Sstevel@tonic-gate } ipfobj_t; 11677c478bd9Sstevel@tonic-gate 11687c478bd9Sstevel@tonic-gate #define IPFOBJ_FRENTRY 0 /* struct frentry */ 11697c478bd9Sstevel@tonic-gate #define IPFOBJ_IPFSTAT 1 /* struct friostat */ 11707c478bd9Sstevel@tonic-gate #define IPFOBJ_IPFINFO 2 /* struct fr_info */ 11717c478bd9Sstevel@tonic-gate #define IPFOBJ_AUTHSTAT 3 /* struct fr_authstat */ 11727c478bd9Sstevel@tonic-gate #define IPFOBJ_FRAGSTAT 4 /* struct ipfrstat */ 11737c478bd9Sstevel@tonic-gate #define IPFOBJ_IPNAT 5 /* struct ipnat */ 11747c478bd9Sstevel@tonic-gate #define IPFOBJ_NATSTAT 6 /* struct natstat */ 11757c478bd9Sstevel@tonic-gate #define IPFOBJ_STATESAVE 7 /* struct ipstate_save */ 11767c478bd9Sstevel@tonic-gate #define IPFOBJ_NATSAVE 8 /* struct nat_save */ 11777c478bd9Sstevel@tonic-gate #define IPFOBJ_NATLOOKUP 9 /* struct natlookup */ 11787c478bd9Sstevel@tonic-gate #define IPFOBJ_IPSTATE 10 /* struct ipstate */ 11797c478bd9Sstevel@tonic-gate #define IPFOBJ_STATESTAT 11 /* struct ips_stat */ 11807c478bd9Sstevel@tonic-gate #define IPFOBJ_FRAUTH 12 /* struct frauth */ 11817c478bd9Sstevel@tonic-gate #define IPFOBJ_TUNEABLE 13 /* struct ipftune */ 1182f4b3ec61Sdh #define IPFOBJ_NAT 14 /* struct nat */ 1183f4b3ec61Sdh #define IPFOBJ_IPFITER 15 /* struct ipfruleiter */ 1184f4b3ec61Sdh #define IPFOBJ_GENITER 16 /* struct ipfgeniter */ 1185f4b3ec61Sdh #define IPFOBJ_GTABLE 17 /* struct ipftable */ 1186f4b3ec61Sdh #define IPFOBJ_LOOKUPITER 18 /* struct ipflookupiter */ 1187f4b3ec61Sdh #define IPFOBJ_COUNT 19 /* How many #defines are above this? */ 11887c478bd9Sstevel@tonic-gate 11897c478bd9Sstevel@tonic-gate 11907c478bd9Sstevel@tonic-gate typedef union ipftunevalptr { 11917c478bd9Sstevel@tonic-gate void *ipftp_void; 11927c478bd9Sstevel@tonic-gate u_long *ipftp_long; 11937c478bd9Sstevel@tonic-gate u_int *ipftp_int; 11947c478bd9Sstevel@tonic-gate u_short *ipftp_short; 11957c478bd9Sstevel@tonic-gate u_char *ipftp_char; 11967c478bd9Sstevel@tonic-gate } ipftunevalptr_t; 11977c478bd9Sstevel@tonic-gate 11987c478bd9Sstevel@tonic-gate typedef struct ipftuneable { 11997c478bd9Sstevel@tonic-gate ipftunevalptr_t ipft_una; 12007c478bd9Sstevel@tonic-gate char *ipft_name; 12017c478bd9Sstevel@tonic-gate u_long ipft_min; 12027c478bd9Sstevel@tonic-gate u_long ipft_max; 12037c478bd9Sstevel@tonic-gate int ipft_sz; 12047c478bd9Sstevel@tonic-gate int ipft_flags; 1205ab25eeb5Syz struct ipftuneable *ipft_next; 12067c478bd9Sstevel@tonic-gate } ipftuneable_t; 12077c478bd9Sstevel@tonic-gate 12087c478bd9Sstevel@tonic-gate #define ipft_addr ipft_una.ipftp_void 12097c478bd9Sstevel@tonic-gate #define ipft_plong ipft_una.ipftp_long 12107c478bd9Sstevel@tonic-gate #define ipft_pint ipft_una.ipftp_int 12117c478bd9Sstevel@tonic-gate #define ipft_pshort ipft_una.ipftp_short 12127c478bd9Sstevel@tonic-gate #define ipft_pchar ipft_una.ipftp_char 12137c478bd9Sstevel@tonic-gate 12147c478bd9Sstevel@tonic-gate #define IPFT_RDONLY 1 /* read-only */ 12157c478bd9Sstevel@tonic-gate #define IPFT_WRDISABLED 2 /* write when disabled only */ 12167c478bd9Sstevel@tonic-gate 12177c478bd9Sstevel@tonic-gate typedef union ipftuneval { 12187c478bd9Sstevel@tonic-gate u_long ipftu_long; 12197c478bd9Sstevel@tonic-gate u_int ipftu_int; 12207c478bd9Sstevel@tonic-gate u_short ipftu_short; 12217c478bd9Sstevel@tonic-gate u_char ipftu_char; 12227c478bd9Sstevel@tonic-gate } ipftuneval_t; 12237c478bd9Sstevel@tonic-gate 12247c478bd9Sstevel@tonic-gate typedef struct ipftune { 12257c478bd9Sstevel@tonic-gate void *ipft_cookie; 12267c478bd9Sstevel@tonic-gate ipftuneval_t ipft_un; 12277c478bd9Sstevel@tonic-gate u_long ipft_min; 12287c478bd9Sstevel@tonic-gate u_long ipft_max; 12297c478bd9Sstevel@tonic-gate int ipft_sz; 12307c478bd9Sstevel@tonic-gate int ipft_flags; 12317c478bd9Sstevel@tonic-gate char ipft_name[80]; 12327c478bd9Sstevel@tonic-gate } ipftune_t; 12337c478bd9Sstevel@tonic-gate 12347c478bd9Sstevel@tonic-gate #define ipft_vlong ipft_un.ipftu_long 12357c478bd9Sstevel@tonic-gate #define ipft_vint ipft_un.ipftu_int 12367c478bd9Sstevel@tonic-gate #define ipft_vshort ipft_un.ipftu_short 12377c478bd9Sstevel@tonic-gate #define ipft_vchar ipft_un.ipftu_char 12387c478bd9Sstevel@tonic-gate 123990b0a856Sjojemann /* 124090b0a856Sjojemann * ipfruleiter is iterator structure used for filter rules. 124190b0a856Sjojemann */ 1242f4b3ec61Sdh typedef struct ipfruleiter { 1243f4b3ec61Sdh int iri_ver; 1244f4b3ec61Sdh int iri_inout; 1245f4b3ec61Sdh char iri_group[FR_GROUPLEN]; 1246f4b3ec61Sdh int iri_active; 124790b0a856Sjojemann int iri_nrules; 1248f4b3ec61Sdh frentry_t *iri_rule; 1249f4b3ec61Sdh } ipfruleiter_t; 1250f4b3ec61Sdh 125190b0a856Sjojemann /* Values for iri_inout */ 125290b0a856Sjojemann #define F_IN 0 125390b0a856Sjojemann #define F_OUT 1 125490b0a856Sjojemann #define F_ACIN 2 125590b0a856Sjojemann #define F_ACOUT 3 125690b0a856Sjojemann 125790b0a856Sjojemann /* 125890b0a856Sjojemann * ipfgeniter is generic iterator structure used for nat rules, 125990b0a856Sjojemann * hostmap entries and nat table entries. 126090b0a856Sjojemann */ 1261f4b3ec61Sdh typedef struct ipfgeniter { 126290b0a856Sjojemann int igi_type; /* type of data we're looking at */ 126390b0a856Sjojemann int igi_nitems; 1264f4b3ec61Sdh void *igi_data; 1265f4b3ec61Sdh } ipfgeniter_t; 1266f4b3ec61Sdh 1267f4b3ec61Sdh #define IPFGENITER_IPF 0 1268f4b3ec61Sdh #define IPFGENITER_NAT 1 1269f4b3ec61Sdh #define IPFGENITER_IPNAT 2 1270f4b3ec61Sdh #define IPFGENITER_FRAG 3 1271f4b3ec61Sdh #define IPFGENITER_AUTH 4 1272f4b3ec61Sdh #define IPFGENITER_STATE 5 1273f4b3ec61Sdh #define IPFGENITER_NATFRAG 6 1274f4b3ec61Sdh #define IPFGENITER_HOSTMAP 7 1275f4b3ec61Sdh #define IPFGENITER_LOOKUP 8 1276f4b3ec61Sdh 1277f4b3ec61Sdh typedef struct ipftable { 1278f4b3ec61Sdh int ita_type; 1279f4b3ec61Sdh void *ita_table; 1280f4b3ec61Sdh } ipftable_t; 1281f4b3ec61Sdh 1282f4b3ec61Sdh typedef struct ipftoken { 1283f4b3ec61Sdh struct ipftoken *ipt_next; 1284f4b3ec61Sdh struct ipftoken **ipt_pnext; 1285f4b3ec61Sdh void *ipt_ctx; 1286f4b3ec61Sdh void *ipt_data; 1287f4b3ec61Sdh u_long ipt_die; 1288f4b3ec61Sdh int ipt_type; 1289f4b3ec61Sdh int ipt_uid; 1290f4b3ec61Sdh int ipt_subtype; 1291f4b3ec61Sdh int ipt_alive; 1292f4b3ec61Sdh } ipftoken_t; 1293f4b3ec61Sdh 1294f4b3ec61Sdh 1295381a2a9aSdr /* 1296381a2a9aSdr * sync commands 1297381a2a9aSdr */ 1298381a2a9aSdr #define IPFSYNC_RESYNC 0 1299381a2a9aSdr #define IPFSYNC_NEWIFP 1 1300381a2a9aSdr #define IPFSYNC_OLDIFP 2 1301381a2a9aSdr 1302381a2a9aSdr 13037c478bd9Sstevel@tonic-gate /* 13047c478bd9Sstevel@tonic-gate ** HPUX Port 13057c478bd9Sstevel@tonic-gate */ 13067c478bd9Sstevel@tonic-gate #ifdef __hpux 13077c478bd9Sstevel@tonic-gate /* HP-UX locking sequence deadlock detection module lock MAJOR ID */ 13087c478bd9Sstevel@tonic-gate # define IPF_SMAJ 0 /* temp assignment XXX, not critical */ 13097c478bd9Sstevel@tonic-gate #endif 13107c478bd9Sstevel@tonic-gate 13117c478bd9Sstevel@tonic-gate #if !defined(CDEV_MAJOR) && defined (__FreeBSD_version) && \ 13127c478bd9Sstevel@tonic-gate (__FreeBSD_version >= 220000) 13137c478bd9Sstevel@tonic-gate # define CDEV_MAJOR 79 13147c478bd9Sstevel@tonic-gate #endif 13157c478bd9Sstevel@tonic-gate 13167c478bd9Sstevel@tonic-gate /* 13177c478bd9Sstevel@tonic-gate * Post NetBSD 1.2 has the PFIL interface for packet filters. This turns 13187c478bd9Sstevel@tonic-gate * on those hooks. We don't need any special mods in non-IP Filter code 13197c478bd9Sstevel@tonic-gate * with this! 13207c478bd9Sstevel@tonic-gate */ 13217c478bd9Sstevel@tonic-gate #if (defined(NetBSD) && (NetBSD > 199609) && (NetBSD <= 1991011)) || \ 13227c478bd9Sstevel@tonic-gate (defined(NetBSD1_2) && NetBSD1_2 > 1) || \ 13237c478bd9Sstevel@tonic-gate (defined(__FreeBSD__) && (__FreeBSD_version >= 500043)) 13247c478bd9Sstevel@tonic-gate # if (NetBSD >= 199905) 13257c478bd9Sstevel@tonic-gate # define PFIL_HOOKS 13267c478bd9Sstevel@tonic-gate # endif 13277c478bd9Sstevel@tonic-gate # ifdef PFIL_HOOKS 13287c478bd9Sstevel@tonic-gate # define NETBSD_PF 13297c478bd9Sstevel@tonic-gate # endif 13307c478bd9Sstevel@tonic-gate #endif 13317c478bd9Sstevel@tonic-gate 13327c478bd9Sstevel@tonic-gate #ifndef _KERNEL 1333f4b3ec61Sdh extern int fr_check __P((struct ip *, int, void *, int, mb_t **, ipf_stack_t *)); 1334f4b3ec61Sdh extern int (*fr_checkp) __P((ip_t *, int, void *, int, mb_t **, ipf_stack_t *)); 13357c478bd9Sstevel@tonic-gate extern int ipf_log __P((void)); 1336f4b3ec61Sdh extern struct ifnet *get_unit __P((char *, int, ipf_stack_t *)); 13377c478bd9Sstevel@tonic-gate extern char *get_ifname __P((struct ifnet *)); 13387c478bd9Sstevel@tonic-gate # if defined(__NetBSD__) || defined(__OpenBSD__) || \ 13397c478bd9Sstevel@tonic-gate (_BSDI_VERSION >= 199701) || (__FreeBSD_version >= 300000) 1340f4b3ec61Sdh extern int frrequest __P((int, u_long, caddr_t, int, int, ipf_stack_t *)); 13417c478bd9Sstevel@tonic-gate # else 1342ab25eeb5Syz extern int iplioctl __P((int, ioctlcmd_t, caddr_t, int)); 13437c478bd9Sstevel@tonic-gate # endif 13447c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int)); 13457c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int)); 13467c478bd9Sstevel@tonic-gate extern void m_freem __P((mb_t *)); 13477c478bd9Sstevel@tonic-gate #else /* #ifndef _KERNEL */ 1348f4b3ec61Sdh extern phy_if_t get_unit __P((char *, int, ipf_stack_t *)); 13497c478bd9Sstevel@tonic-gate # if defined(__NetBSD__) && defined(PFIL_HOOKS) 13507c478bd9Sstevel@tonic-gate extern void ipfilterattach __P((int)); 13517c478bd9Sstevel@tonic-gate # endif 13527c478bd9Sstevel@tonic-gate extern int ipl_enable __P((void)); 13537c478bd9Sstevel@tonic-gate extern int ipl_disable __P((void)); 13547c478bd9Sstevel@tonic-gate # ifdef MENTAT 13557ddc9b1aSDarren Reed extern ipf_stack_t *ipf_find_stack(const zoneid_t zone); 1356ab25eeb5Syz extern int fr_check __P((struct ip *, int, void *, int, void *, 1357f4b3ec61Sdh mblk_t **, ipf_stack_t *)); 13587c478bd9Sstevel@tonic-gate # if SOLARIS 13597c478bd9Sstevel@tonic-gate # if SOLARIS2 >= 7 13607c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, intptr_t, int, cred_t *, int *)); 13617c478bd9Sstevel@tonic-gate # else 13627c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, int *, int, cred_t *, int *)); 13637c478bd9Sstevel@tonic-gate # endif 1364a1173273SAlexandr Nedvedicky # if SOLARIS2 >= 10 1365a1173273SAlexandr Nedvedicky extern int fr_make_rst __P((fr_info_t *)); 1366a1173273SAlexandr Nedvedicky extern int fr_make_icmp __P((fr_info_t *)); 1367a1173273SAlexandr Nedvedicky # endif 13687c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t *, int, int, cred_t *)); 13697c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, cred_t *)); 1370ab25eeb5Syz extern int iplread __P((dev_t, uio_t *, cred_t *)); 1371ab25eeb5Syz extern int iplwrite __P((dev_t, uio_t *, cred_t *)); 13727c478bd9Sstevel@tonic-gate # endif 13737c478bd9Sstevel@tonic-gate # ifdef __hpux 13747c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int, intptr_t, int)); 13757c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int)); 13767c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int)); 1377ab25eeb5Syz extern int iplread __P((dev_t, uio_t *)); 1378ab25eeb5Syz extern int iplwrite __P((dev_t, uio_t *)); 13797c478bd9Sstevel@tonic-gate extern int iplselect __P((dev_t, int)); 13807c478bd9Sstevel@tonic-gate # endif 1381f4b3ec61Sdh extern int ipfsync __P((ipf_stack_t *)); 13827c478bd9Sstevel@tonic-gate extern int fr_qout __P((queue_t *, mblk_t *)); 13837c478bd9Sstevel@tonic-gate # else /* MENTAT */ 1384f4b3ec61Sdh extern int fr_check __P((struct ip *, int, void *, int, mb_t **, ipf_stack_t *)); 1385f4b3ec61Sdh extern int (*fr_checkp) __P((ip_t *, int, void *, int, mb_t **, ipf_stack_t *)); 13867c478bd9Sstevel@tonic-gate extern size_t mbufchainlen __P((mb_t *)); 13877c478bd9Sstevel@tonic-gate # ifdef __sgi 13887c478bd9Sstevel@tonic-gate # include <sys/cred.h> 13897c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int, cred_t *, int *)); 13907c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t *, int, int, cred_t *)); 13917c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, cred_t *)); 1392ab25eeb5Syz extern int iplread __P((dev_t, uio_t *, cred_t *)); 1393ab25eeb5Syz extern int iplwrite __P((dev_t, uio_t *, cred_t *)); 1394f4b3ec61Sdh extern int ipfsync __P((ipf_stack_t *)); 13957c478bd9Sstevel@tonic-gate extern int ipfilter_sgi_attach __P((void)); 13967c478bd9Sstevel@tonic-gate extern void ipfilter_sgi_detach __P((void)); 13977c478bd9Sstevel@tonic-gate extern void ipfilter_sgi_intfsync __P((void)); 13987c478bd9Sstevel@tonic-gate # else 13997c478bd9Sstevel@tonic-gate # ifdef IPFILTER_LKM 14007c478bd9Sstevel@tonic-gate extern int iplidentify __P((char *)); 14017c478bd9Sstevel@tonic-gate # endif 14027c478bd9Sstevel@tonic-gate # if (_BSDI_VERSION >= 199510) || (__FreeBSD_version >= 220000) || \ 14037c478bd9Sstevel@tonic-gate (NetBSD >= 199511) || defined(__OpenBSD__) 14047c478bd9Sstevel@tonic-gate # if defined(__NetBSD__) || (_BSDI_VERSION >= 199701) || \ 14057c478bd9Sstevel@tonic-gate defined(__OpenBSD__) || (__FreeBSD_version >= 300000) 14067c478bd9Sstevel@tonic-gate # if (__FreeBSD_version >= 500024) 1407ab25eeb5Syz # if (__FreeBSD_version >= 502116) 1408ab25eeb5Syz extern int iplioctl __P((struct cdev*, u_long, caddr_t, int, struct thread *)); 1409ab25eeb5Syz # else 14107c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, u_long, caddr_t, int, struct thread *)); 1411ab25eeb5Syz # endif /* __FreeBSD_version >= 502116 */ 14127c478bd9Sstevel@tonic-gate # else 14137c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); 14147c478bd9Sstevel@tonic-gate # endif /* __FreeBSD_version >= 500024 */ 14157c478bd9Sstevel@tonic-gate # else 14167c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int, struct proc *)); 14177c478bd9Sstevel@tonic-gate # endif 14187c478bd9Sstevel@tonic-gate # if (__FreeBSD_version >= 500024) 1419ab25eeb5Syz # if (__FreeBSD_version >= 502116) 1420ab25eeb5Syz extern int iplopen __P((struct cdev*, int, int, struct thread *)); 1421ab25eeb5Syz extern int iplclose __P((struct cdev*, int, int, struct thread *)); 1422ab25eeb5Syz # else 14237c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int, int, struct thread *)); 14247c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, struct thread *)); 1425ab25eeb5Syz # endif /* __FreeBSD_version >= 502116 */ 14267c478bd9Sstevel@tonic-gate # else 14277c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int, int, struct proc *)); 14287c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int, int, struct proc *)); 14297c478bd9Sstevel@tonic-gate # endif /* __FreeBSD_version >= 500024 */ 14307c478bd9Sstevel@tonic-gate # else 1431ab25eeb5Syz # ifdef linux 1432ab25eeb5Syz extern int iplioctl __P((struct inode *, struct file *, u_int, u_long)); 1433ab25eeb5Syz # else 14347c478bd9Sstevel@tonic-gate extern int iplopen __P((dev_t, int)); 14357c478bd9Sstevel@tonic-gate extern int iplclose __P((dev_t, int)); 14367c478bd9Sstevel@tonic-gate extern int iplioctl __P((dev_t, int, caddr_t, int)); 1437ab25eeb5Syz # endif 14387c478bd9Sstevel@tonic-gate # endif /* (_BSDI_VERSION >= 199510) */ 14397c478bd9Sstevel@tonic-gate # if BSD >= 199306 1440ab25eeb5Syz # if (__FreeBSD_version >= 502116) 1441ab25eeb5Syz extern int iplread __P((struct cdev*, struct uio *, int)); 1442ab25eeb5Syz extern int iplwrite __P((struct cdev*, struct uio *, int)); 1443ab25eeb5Syz # else 14447c478bd9Sstevel@tonic-gate extern int iplread __P((dev_t, struct uio *, int)); 1445ab25eeb5Syz extern int iplwrite __P((dev_t, struct uio *, int)); 1446ab25eeb5Syz # endif /* __FreeBSD_version >= 502116 */ 14477c478bd9Sstevel@tonic-gate # else 1448ab25eeb5Syz # ifndef linux 14497c478bd9Sstevel@tonic-gate extern int iplread __P((dev_t, struct uio *)); 1450ab25eeb5Syz extern int iplwrite __P((dev_t, struct uio *)); 1451ab25eeb5Syz # endif 14527c478bd9Sstevel@tonic-gate # endif /* BSD >= 199306 */ 14537c478bd9Sstevel@tonic-gate # endif /* __ sgi */ 14547c478bd9Sstevel@tonic-gate # endif /* MENTAT */ 14557c478bd9Sstevel@tonic-gate 14567c478bd9Sstevel@tonic-gate #endif /* #ifndef _KERNEL */ 14577c478bd9Sstevel@tonic-gate 14587c478bd9Sstevel@tonic-gate extern char *memstr __P((char *, char *, int, int)); 14597c478bd9Sstevel@tonic-gate extern int count4bits __P((u_32_t)); 14607663b816Sml extern int count6bits __P((u_32_t *)); 1461f4b3ec61Sdh extern int frrequest __P((int, ioctlcmd_t, caddr_t, int, int, ipf_stack_t *)); 14627c478bd9Sstevel@tonic-gate extern char *getifname __P((struct ifnet *)); 14637ddc9b1aSDarren Reed extern int iplattach __P((ipf_stack_t *)); 1464f4b3ec61Sdh extern int ipldetach __P((ipf_stack_t *)); 14657c478bd9Sstevel@tonic-gate extern u_short ipf_cksum __P((u_short *, int)); 14667c478bd9Sstevel@tonic-gate extern int copyinptr __P((void *, void *, size_t)); 14677c478bd9Sstevel@tonic-gate extern int copyoutptr __P((void *, void *, size_t)); 1468ab25eeb5Syz extern int fr_fastroute __P((mb_t *, mb_t **, fr_info_t *, frdest_t *)); 14697c478bd9Sstevel@tonic-gate extern int fr_inobj __P((void *, void *, int)); 1470ab25eeb5Syz extern int fr_inobjsz __P((void *, void *, int, int)); 1471d6c23f6fSyx extern int fr_ioctlswitch __P((int, void *, ioctlcmd_t, int, int, void *, 1472d6c23f6fSyx ipf_stack_t *)); 1473f4b3ec61Sdh extern int fr_ipftune __P((ioctlcmd_t, void *, ipf_stack_t *)); 14747c478bd9Sstevel@tonic-gate extern int fr_outobj __P((void *, void *, int)); 1475ab25eeb5Syz extern int fr_outobjsz __P((void *, void *, int, int)); 1476ab25eeb5Syz extern void *fr_pullup __P((mb_t *, fr_info_t *, int)); 1477f4b3ec61Sdh extern void fr_resolvedest __P((struct frdest *, int, ipf_stack_t *)); 14787c478bd9Sstevel@tonic-gate extern int fr_resolvefunc __P((void *)); 1479f4b3ec61Sdh extern void *fr_resolvenic __P((char *, int, ipf_stack_t *)); 1480ab25eeb5Syz extern int fr_send_icmp_err __P((int, fr_info_t *, int)); 1481ab25eeb5Syz extern int fr_send_reset __P((fr_info_t *)); 1482ab25eeb5Syz #if (__FreeBSD_version < 490000) || !defined(_KERNEL) 14837c478bd9Sstevel@tonic-gate extern int ppsratecheck __P((struct timeval *, int *, int)); 1484ab25eeb5Syz #endif 1485f4b3ec61Sdh extern ipftq_t *fr_addtimeoutqueue __P((ipftq_t **, u_int, ipf_stack_t *)); 1486ab25eeb5Syz extern void fr_deletequeueentry __P((ipftqent_t *)); 1487ab25eeb5Syz extern int fr_deletetimeoutqueue __P((ipftq_t *)); 1488f4b3ec61Sdh extern void fr_freetimeoutqueue __P((ipftq_t *, ipf_stack_t *)); 1489d6c23f6fSyx extern void fr_movequeue __P((ipftqent_t *, ipftq_t *, ipftq_t *, 1490d6c23f6fSyx ipf_stack_t *)); 1491d6c23f6fSyx extern void fr_queueappend __P((ipftqent_t *, ipftq_t *, void *, 1492d6c23f6fSyx ipf_stack_t *)); 1493f4b3ec61Sdh extern void fr_queueback __P((ipftqent_t *, ipf_stack_t *)); 1494ab25eeb5Syz extern void fr_queuefront __P((ipftqent_t *)); 14957c478bd9Sstevel@tonic-gate extern void fr_checkv4sum __P((fr_info_t *)); 14967c478bd9Sstevel@tonic-gate extern int fr_checkl4sum __P((fr_info_t *)); 14977c478bd9Sstevel@tonic-gate extern int fr_ifpfillv4addr __P((int, struct sockaddr_in *, 14987c478bd9Sstevel@tonic-gate struct sockaddr_in *, struct in_addr *, 14997c478bd9Sstevel@tonic-gate struct in_addr *)); 15007c478bd9Sstevel@tonic-gate extern int fr_coalesce __P((fr_info_t *)); 15017c478bd9Sstevel@tonic-gate #ifdef USE_INET6 15027c478bd9Sstevel@tonic-gate extern void fr_checkv6sum __P((fr_info_t *)); 15037c478bd9Sstevel@tonic-gate extern int fr_ifpfillv6addr __P((int, struct sockaddr_in6 *, 15047c478bd9Sstevel@tonic-gate struct sockaddr_in6 *, struct in_addr *, 15057c478bd9Sstevel@tonic-gate struct in_addr *)); 15067c478bd9Sstevel@tonic-gate #endif 15077c478bd9Sstevel@tonic-gate 1508d6c23f6fSyx #define IPFILTER_COMPAT 1509d6c23f6fSyx extern int fr_incomptrans __P((ipfobj_t *, void *)); 1510d6c23f6fSyx extern int fr_outcomptrans __P((ipfobj_t *, void *)); 1511d6c23f6fSyx 1512f4b3ec61Sdh extern int fr_addipftune __P((ipftuneable_t *, ipf_stack_t *)); 1513f4b3ec61Sdh extern int fr_delipftune __P((ipftuneable_t *, ipf_stack_t *)); 1514f4b3ec61Sdh 1515f4b3ec61Sdh extern int frflush __P((minor_t, int, int, ipf_stack_t *)); 1516f4b3ec61Sdh extern void frsync __P((int, int, void *, char *, ipf_stack_t *)); 1517e8d569f4SAlexandr Nedvedicky #if SOLARIS2 >= 10 1518e8d569f4SAlexandr Nedvedicky extern void fr_ifindexsync __P((void *, void *, ipf_stack_t *)); 1519e8d569f4SAlexandr Nedvedicky #endif 1520f4b3ec61Sdh extern frgroup_t *fr_addgroup __P((char *, void *, u_32_t, minor_t, int, 1521f4b3ec61Sdh ipf_stack_t *)); 1522f4b3ec61Sdh extern int fr_derefrule __P((frentry_t **, ipf_stack_t *)); 1523f4b3ec61Sdh extern void fr_delgroup __P((char *, minor_t, int, ipf_stack_t *)); 1524f4b3ec61Sdh extern frgroup_t *fr_findgroup __P((char *, minor_t, int, frgroup_t ***, 1525f4b3ec61Sdh ipf_stack_t *)); 1526f4b3ec61Sdh 1527f4b3ec61Sdh extern int fr_loginit __P((ipf_stack_t *)); 1528f4b3ec61Sdh extern int ipflog_clear __P((minor_t, ipf_stack_t *)); 1529f4b3ec61Sdh extern int ipflog_read __P((minor_t, struct uio *, ipf_stack_t *)); 15307c478bd9Sstevel@tonic-gate extern int ipflog __P((fr_info_t *, u_int)); 1531f4b3ec61Sdh extern int ipllog __P((int, fr_info_t *, void **, size_t *, int *, int, 1532f4b3ec61Sdh ipf_stack_t *)); 1533f4b3ec61Sdh extern void fr_logunload __P((ipf_stack_t *)); 15347c478bd9Sstevel@tonic-gate 15357c478bd9Sstevel@tonic-gate extern frentry_t *fr_acctpkt __P((fr_info_t *, u_32_t *)); 15367c478bd9Sstevel@tonic-gate extern int fr_copytolog __P((int, char *, int)); 15377c478bd9Sstevel@tonic-gate extern u_short fr_cksum __P((mb_t *, ip_t *, int, void *)); 1538f4b3ec61Sdh extern void fr_deinitialise __P((ipf_stack_t *)); 15397c478bd9Sstevel@tonic-gate extern frentry_t *fr_dolog __P((fr_info_t *, u_32_t *)); 15407c478bd9Sstevel@tonic-gate extern frentry_t *fr_dstgrpmap __P((fr_info_t *, u_32_t *)); 15417c478bd9Sstevel@tonic-gate extern void fr_fixskip __P((frentry_t **, frentry_t *, int)); 1542f4b3ec61Sdh extern void fr_forgetifp __P((void *, ipf_stack_t *)); 1543f4b3ec61Sdh extern frentry_t *fr_getrulen __P((int, char *, u_32_t, 1544f4b3ec61Sdh ipf_stack_t *)); 1545f4b3ec61Sdh extern void fr_getstat __P((struct friostat *, ipf_stack_t *)); 15467c478bd9Sstevel@tonic-gate extern int fr_ifpaddr __P((int, int, void *, 1547f4b3ec61Sdh struct in_addr *, struct in_addr *, 1548f4b3ec61Sdh ipf_stack_t *)); 1549f4b3ec61Sdh extern int fr_initialise __P((ipf_stack_t *)); 1550bb1d9de5SJohn Ojemann extern int fr_lock __P((caddr_t, int *)); 1551bb1d9de5SJohn Ojemann extern int fr_makefrip __P((int, ip_t *, fr_info_t *)); 15527c478bd9Sstevel@tonic-gate extern int fr_matchtag __P((ipftag_t *, ipftag_t *)); 15537c478bd9Sstevel@tonic-gate extern int fr_matchicmpqueryreply __P((int, icmpinfo_t *, 1554d6c23f6fSyx struct icmp *, int)); 15557c478bd9Sstevel@tonic-gate extern u_32_t fr_newisn __P((fr_info_t *)); 1556ab25eeb5Syz extern u_short fr_nextipid __P((fr_info_t *)); 1557f4b3ec61Sdh extern int fr_rulen __P((int, frentry_t *, ipf_stack_t *)); 15587c478bd9Sstevel@tonic-gate extern int fr_scanlist __P((fr_info_t *, u_32_t)); 15597c478bd9Sstevel@tonic-gate extern frentry_t *fr_srcgrpmap __P((fr_info_t *, u_32_t *)); 15607c478bd9Sstevel@tonic-gate extern int fr_tcpudpchk __P((fr_info_t *, frtuc_t *)); 15617c478bd9Sstevel@tonic-gate extern int fr_verifysrc __P((fr_info_t *fin)); 1562f4b3ec61Sdh extern int fr_zerostats __P((char *, ipf_stack_t *)); 1563d6c23f6fSyx extern ipftoken_t *ipf_findtoken __P((int, int, void *, ipf_stack_t *)); 1564d6c23f6fSyx extern int ipf_getnextrule __P((ipftoken_t *, void *, 1565d6c23f6fSyx ipf_stack_t *)); 1566f4b3ec61Sdh extern void ipf_expiretokens __P((ipf_stack_t *)); 1567ea8244dcSJohn Ojemann extern void ipf_freetoken __P((ipftoken_t *, ipf_stack_t *)); 1568ea8244dcSJohn Ojemann extern int ipf_deltoken __P((int, int, void *, ipf_stack_t *)); 1569ea8244dcSJohn Ojemann extern int ipf_genericiter __P((void *, int, void *, ipf_stack_t *)); 1570ea8244dcSJohn Ojemann extern int ipf_extraflush __P((int, ipftq_t *, ipftq_t *, ipf_stack_t *)); 1571ea8244dcSJohn Ojemann extern int ipf_flushclosing __P((int, int, ipftq_t *, ipftq_t *, ipf_stack_t *)); 1572ea8244dcSJohn Ojemann extern int ipf_earlydrop __P((int, ipftq_t *, int, ipf_stack_t *)); 1573ea8244dcSJohn Ojemann 1574ea8244dcSJohn Ojemann #ifndef ipf_random 1575ab073b32Sdr extern u_32_t ipf_random __P((void)); 1576ab073b32Sdr #endif 1577f4b3ec61Sdh 15787c478bd9Sstevel@tonic-gate extern char ipfilter_version[]; 15797c478bd9Sstevel@tonic-gate #ifdef USE_INET6 15807c478bd9Sstevel@tonic-gate extern int icmptoicmp6types[ICMP_MAXTYPE+1]; 15817c478bd9Sstevel@tonic-gate extern int icmptoicmp6unreach[ICMP_MAX_UNREACH]; 15827c478bd9Sstevel@tonic-gate extern int icmpreplytype6[ICMP6_MAXTYPE + 1]; 15837c478bd9Sstevel@tonic-gate #endif 15847c478bd9Sstevel@tonic-gate extern int icmpreplytype4[ICMP_MAXTYPE + 1]; 15857c478bd9Sstevel@tonic-gate extern frentry_t *ipfrule_match __P((fr_info_t *)); 1586f4b3ec61Sdh 1587f4b3ec61Sdh extern void ipftuneable_alloc(ipf_stack_t *); 1588f4b3ec61Sdh extern void ipftuneable_free(ipf_stack_t *); 15897c478bd9Sstevel@tonic-gate 15907c478bd9Sstevel@tonic-gate #endif /* __IP_FIL_H__ */ 1591