ip_fil.h revision 80482
1/* 2 * Copyright (C) 1993-2001 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 * 6 * @(#)ip_fil.h 1.35 6/5/96 7 * $Id: ip_fil.h,v 2.29.2.4 2000/11/12 11:54:53 darrenr Exp $ 8 * $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_fil.h 80482 2001-07-28 11:58:26Z darrenr $ 9 */ 10 11#ifndef __IP_FIL_H__ 12#define __IP_FIL_H__ 13 14/* 15 * Pathnames for various IP Filter control devices. Used by LKM 16 * and userland, so defined here. 17 */ 18#define IPNAT_NAME "/dev/ipnat" 19#define IPSTATE_NAME "/dev/ipstate" 20#define IPAUTH_NAME "/dev/ipauth" 21 22#ifndef SOLARIS 23# define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4))) 24#endif 25 26#if defined(KERNEL) && !defined(_KERNEL) 27# define _KERNEL 28#endif 29 30#ifndef __P 31# ifdef __STDC__ 32# define __P(x) x 33# else 34# define __P(x) () 35# endif 36#endif 37 38#if defined(__STDC__) || defined(__GNUC__) 39# define SIOCADAFR _IOW('r', 60, struct frentry *) 40# define SIOCRMAFR _IOW('r', 61, struct frentry *) 41# define SIOCSETFF _IOW('r', 62, u_int) 42# define SIOCGETFF _IOR('r', 63, u_int) 43# define SIOCGETFS _IOWR('r', 64, struct friostat *) 44# define SIOCIPFFL _IOWR('r', 65, int) 45# define SIOCIPFFB _IOR('r', 66, int) 46# define SIOCADIFR _IOW('r', 67, struct frentry *) 47# define SIOCRMIFR _IOW('r', 68, struct frentry *) 48# define SIOCSWAPA _IOR('r', 69, u_int) 49# define SIOCINAFR _IOW('r', 70, struct frentry *) 50# define SIOCINIFR _IOW('r', 71, struct frentry *) 51# define SIOCFRENB _IOW('r', 72, u_int) 52# define SIOCFRSYN _IOW('r', 73, u_int) 53# define SIOCFRZST _IOWR('r', 74, struct friostat *) 54# define SIOCZRLST _IOWR('r', 75, struct frentry *) 55# define SIOCAUTHW _IOWR('r', 76, struct fr_info *) 56# define SIOCAUTHR _IOWR('r', 77, struct fr_info *) 57# define SIOCATHST _IOWR('r', 78, struct fr_authstat *) 58# define SIOCSTLCK _IOWR('r', 79, u_int) 59# define SIOCSTPUT _IOWR('r', 80, struct ipstate_save *) 60# define SIOCSTGET _IOWR('r', 81, struct ipstate_save *) 61# define SIOCSTGSZ _IOWR('r', 82, struct natget) 62# define SIOCGFRST _IOWR('r', 83, struct ipfrstat *) 63#else 64# define SIOCADAFR _IOW(r, 60, struct frentry *) 65# define SIOCRMAFR _IOW(r, 61, struct frentry *) 66# define SIOCSETFF _IOW(r, 62, u_int) 67# define SIOCGETFF _IOR(r, 63, u_int) 68# define SIOCGETFS _IOWR(r, 64, struct friostat *) 69# define SIOCIPFFL _IOWR(r, 65, int) 70# define SIOCIPFFB _IOR(r, 66, int) 71# define SIOCADIFR _IOW(r, 67, struct frentry *) 72# define SIOCRMIFR _IOW(r, 68, struct frentry *) 73# define SIOCSWAPA _IOR(r, 69, u_int) 74# define SIOCINAFR _IOW(r, 70, struct frentry *) 75# define SIOCINIFR _IOW(r, 71, struct frentry *) 76# define SIOCFRENB _IOW(r, 72, u_int) 77# define SIOCFRSYN _IOW(r, 73, u_int) 78# define SIOCFRZST _IOWR(r, 74, struct friostat *) 79# define SIOCZRLST _IOWR(r, 75, struct frentry *) 80# define SIOCAUTHW _IOWR(r, 76, struct fr_info *) 81# define SIOCAUTHR _IOWR(r, 77, struct fr_info *) 82# define SIOCATHST _IOWR(r, 78, struct fr_authstat *) 83# define SIOCSTLCK _IOWR(r, 79, u_int) 84# define SIOCSTPUT _IOWR(r, 80, struct ipstate_save *) 85# define SIOCSTGET _IOWR(r, 81, struct ipstate_save *) 86# define SIOCSTGSZ _IOWR(r, 82, struct natget) 87# define SIOCGFRST _IOWR(r, 83, struct ipfrstat *) 88#endif 89#define SIOCADDFR SIOCADAFR 90#define SIOCDELFR SIOCRMAFR 91#define SIOCINSFR SIOCINAFR 92 93 94typedef struct fr_ip { 95 u_32_t fi_v:4; /* IP version */ 96 u_32_t fi_fl:4; /* packet flags */ 97 u_32_t fi_tos:8; /* IP packet TOS */ 98 u_32_t fi_ttl:8; /* IP packet TTL */ 99 u_32_t fi_p:8; /* IP packet protocol */ 100 union i6addr fi_src; /* source address from packet */ 101 union i6addr fi_dst; /* destination address from packet */ 102 u_32_t fi_optmsk; /* bitmask composed from IP options */ 103 u_short fi_secmsk; /* bitmask composed from IP security options */ 104 u_short fi_auth; /* authentication code from IP sec. options */ 105} fr_ip_t; 106 107#define FI_OPTIONS (FF_OPTIONS >> 24) 108#define FI_TCPUDP (FF_TCPUDP >> 24) /* TCP/UCP implied comparison*/ 109#define FI_FRAG (FF_FRAG >> 24) 110#define FI_SHORT (FF_SHORT >> 24) 111#define FI_CMP (FI_OPTIONS|FI_TCPUDP|FI_SHORT) 112 113#define fi_saddr fi_src.in4.s_addr 114#define fi_daddr fi_dst.in4.s_addr 115 116 117/* 118 * These are both used by the state and NAT code to indicate that one port or 119 * the other should be treated as a wildcard. 120 */ 121#define FI_W_SPORT 0x00000100 122#define FI_W_DPORT 0x00000200 123#define FI_WILDP (FI_W_SPORT|FI_W_DPORT) 124#define FI_W_SADDR 0x00000400 125#define FI_W_DADDR 0x00000800 126#define FI_WILDA (FI_W_SADDR|FI_W_DADDR) 127#define FI_NEWFR 0x00001000 128 129typedef struct fr_info { 130 void *fin_ifp; /* interface packet is `on' */ 131 struct fr_ip fin_fi; /* IP Packet summary */ 132 u_short fin_data[2]; /* TCP/UDP ports, ICMP code/type */ 133 u_char fin_out; /* in or out ? 1 == out, 0 == in */ 134 u_char fin_rev; /* state only: 1 = reverse */ 135 u_short fin_hlen; /* length of IP header in bytes */ 136 u_char fin_tcpf; /* TCP header flags (SYN, ACK, etc) */ 137 /* From here on is packet specific */ 138 u_char fin_icode; /* ICMP error to return */ 139 u_short fin_rule; /* rule # last matched */ 140 u_32_t fin_group; /* group number, -1 for none */ 141 struct frentry *fin_fr; /* last matching rule */ 142 char *fin_dp; /* start of data past IP header */ 143 u_short fin_dlen; /* length of data portion of packet */ 144 u_short fin_id; /* IP packet id field */ 145 void *fin_mp; /* pointer to pointer to mbuf */ 146#if SOLARIS 147 void *fin_qfm; /* pointer to mblk where pkt starts */ 148 void *fin_qif; 149#endif 150 u_short fin_plen; 151 u_short fin_off; 152} fr_info_t; 153 154#define fin_v fin_fi.fi_v 155#define fin_saddr fin_fi.fi_saddr 156#define fin_daddr fin_fi.fi_daddr 157#define fin_fl fin_fi.fi_fl 158 159/* 160 * Size for compares on fr_info structures 161 */ 162#define FI_CSIZE offsetof(fr_info_t, fin_icode) 163 164/* 165 * Size for copying cache fr_info structure 166 */ 167#define FI_COPYSIZE offsetof(fr_info_t, fin_dp) 168 169typedef struct frdest { 170 void *fd_ifp; 171 struct in_addr fd_ip; 172 char fd_ifname[IFNAMSIZ]; 173#if SOLARIS 174 mb_t *fd_mp; /* cache resolver for to/dup-to */ 175#endif 176} frdest_t; 177 178typedef struct frpcmp { 179 int frp_cmp; /* data for port comparisons */ 180 u_short frp_port; /* top port for <> and >< */ 181 u_short frp_top; /* top port for <> and >< */ 182} frpcmp_t; 183 184typedef struct frtuc { 185 u_char ftu_tcpfm; /* tcp flags mask */ 186 u_char ftu_tcpf; /* tcp flags */ 187 frpcmp_t ftu_src; 188 frpcmp_t ftu_dst; 189} frtuc_t; 190 191#define ftu_scmp ftu_src.frp_cmp 192#define ftu_dcmp ftu_dst.frp_cmp 193#define ftu_sport ftu_src.frp_port 194#define ftu_dport ftu_dst.frp_port 195#define ftu_stop ftu_src.frp_top 196#define ftu_dtop ftu_dst.frp_top 197 198typedef struct frentry { 199 struct frentry *fr_next; 200 struct frentry *fr_grp; 201 int fr_ref; /* reference count - for grouping */ 202 void *fr_ifa; 203#if BSD >= 199306 204 void *fr_oifa; 205#endif 206 /* 207 * These are only incremented when a packet matches this rule and 208 * it is the last match 209 */ 210 U_QUAD_T fr_hits; 211 U_QUAD_T fr_bytes; 212 /* 213 * Fields after this may not change whilst in the kernel. 214 */ 215 struct fr_ip fr_ip; 216 struct fr_ip fr_mip; /* mask structure */ 217 218 219 u_short fr_icmpm; /* data for ICMP packets (mask) */ 220 u_short fr_icmp; 221 222 frtuc_t fr_tuc; 223 u_32_t fr_group; /* group to which this rule belongs */ 224 u_32_t fr_grhead; /* group # which this rule starts */ 225 u_32_t fr_flags; /* per-rule flags && options (see below) */ 226 u_int fr_skip; /* # of rules to skip */ 227 u_int fr_loglevel; /* syslog log facility + priority */ 228 int (*fr_func) __P((int, ip_t *, fr_info_t *)); /* call this function */ 229 int fr_sap; /* For solaris only */ 230 u_char fr_icode; /* return ICMP code */ 231 char fr_ifname[IFNAMSIZ]; 232#if BSD >= 199306 233 char fr_oifname[IFNAMSIZ]; 234#endif 235 struct frdest fr_tif; /* "to" interface */ 236 struct frdest fr_dif; /* duplicate packet interfaces */ 237 u_int fr_cksum; /* checksum on filter rules for performance */ 238} frentry_t; 239 240#define fr_v fr_ip.fi_v 241#define fr_proto fr_ip.fi_p 242#define fr_ttl fr_ip.fi_ttl 243#define fr_tos fr_ip.fi_tos 244#define fr_tcpfm fr_tuc.ftu_tcpfm 245#define fr_tcpf fr_tuc.ftu_tcpf 246#define fr_scmp fr_tuc.ftu_scmp 247#define fr_dcmp fr_tuc.ftu_dcmp 248#define fr_dport fr_tuc.ftu_dport 249#define fr_sport fr_tuc.ftu_sport 250#define fr_stop fr_tuc.ftu_stop 251#define fr_dtop fr_tuc.ftu_dtop 252#define fr_dst fr_ip.fi_dst.in4 253#define fr_src fr_ip.fi_src.in4 254#define fr_dmsk fr_mip.fi_dst.in4 255#define fr_smsk fr_mip.fi_src.in4 256 257#ifndef offsetof 258#define offsetof(t,m) (int)((&((t *)0L)->m)) 259#endif 260#define FR_CMPSIZ (sizeof(struct frentry) - offsetof(frentry_t, fr_ip)) 261 262/* 263 * fr_flags 264 */ 265#define FR_BLOCK 0x00001 /* do not allow packet to pass */ 266#define FR_PASS 0x00002 /* allow packet to pass */ 267#define FR_OUTQUE 0x00004 /* outgoing packets */ 268#define FR_INQUE 0x00008 /* ingoing packets */ 269#define FR_LOG 0x00010 /* Log */ 270#define FR_LOGB 0x00011 /* Log-fail */ 271#define FR_LOGP 0x00012 /* Log-pass */ 272#define FR_LOGBODY 0x00020 /* Log the body */ 273#define FR_LOGFIRST 0x00040 /* Log the first byte if state held */ 274#define FR_RETRST 0x00080 /* Return TCP RST packet - reset connection */ 275#define FR_RETICMP 0x00100 /* Return ICMP unreachable packet */ 276#define FR_FAKEICMP 0x00180 /* Return ICMP unreachable with fake source */ 277#define FR_NOMATCH 0x00200 /* no match occured */ 278#define FR_ACCOUNT 0x00400 /* count packet bytes */ 279#define FR_KEEPFRAG 0x00800 /* keep fragment information */ 280#define FR_KEEPSTATE 0x01000 /* keep `connection' state information */ 281#define FR_INACTIVE 0x02000 282#define FR_QUICK 0x04000 /* match & stop processing list */ 283#define FR_FASTROUTE 0x08000 /* bypass normal routing */ 284#define FR_CALLNOW 0x10000 /* call another function (fr_func) if matches */ 285#define FR_DUP 0x20000 /* duplicate packet */ 286#define FR_LOGORBLOCK 0x40000 /* block the packet if it can't be logged */ 287#define FR_NOTSRCIP 0x80000 /* not the src IP# */ 288#define FR_NOTDSTIP 0x100000 /* not the dst IP# */ 289#define FR_AUTH 0x200000 /* use authentication */ 290#define FR_PREAUTH 0x400000 /* require preauthentication */ 291#define FR_DONTCACHE 0x800000 /* don't cache the result */ 292 293#define FR_LOGMASK (FR_LOG|FR_LOGP|FR_LOGB) 294#define FR_RETMASK (FR_RETICMP|FR_RETRST|FR_FAKEICMP) 295 296/* 297 * These correspond to #define's for FI_* and are stored in fr_flags 298 */ 299#define FF_OPTIONS 0x01000000 300#define FF_TCPUDP 0x02000000 301#define FF_FRAG 0x04000000 302#define FF_SHORT 0x08000000 303/* 304 * recognized flags for SIOCGETFF and SIOCSETFF, and get put in fr_flags 305 */ 306#define FF_LOGPASS 0x10000000 307#define FF_LOGBLOCK 0x20000000 308#define FF_LOGNOMATCH 0x40000000 309#define FF_LOGGING (FF_LOGPASS|FF_LOGBLOCK|FF_LOGNOMATCH) 310#define FF_BLOCKNONIP 0x80000000 /* Solaris2 Only */ 311 312#define FR_NONE 0 313#define FR_EQUAL 1 314#define FR_NEQUAL 2 315#define FR_LESST 3 316#define FR_GREATERT 4 317#define FR_LESSTE 5 318#define FR_GREATERTE 6 319#define FR_OUTRANGE 7 320#define FR_INRANGE 8 321 322typedef struct filterstats { 323 u_long fr_pass; /* packets allowed */ 324 u_long fr_block; /* packets denied */ 325 u_long fr_nom; /* packets which don't match any rule */ 326 u_long fr_short; /* packets which are short */ 327 u_long fr_ppkl; /* packets allowed and logged */ 328 u_long fr_bpkl; /* packets denied and logged */ 329 u_long fr_npkl; /* packets unmatched and logged */ 330 u_long fr_pkl; /* packets logged */ 331 u_long fr_skip; /* packets to be logged but buffer full */ 332 u_long fr_ret; /* packets for which a return is sent */ 333 u_long fr_acct; /* packets for which counting was performed */ 334 u_long fr_bnfr; /* bad attempts to allocate fragment state */ 335 u_long fr_nfr; /* new fragment state kept */ 336 u_long fr_cfr; /* add new fragment state but complete pkt */ 337 u_long fr_bads; /* bad attempts to allocate packet state */ 338 u_long fr_ads; /* new packet state kept */ 339 u_long fr_chit; /* cached hit */ 340 u_long fr_tcpbad; /* TCP checksum check failures */ 341 u_long fr_pull[2]; /* good and bad pullup attempts */ 342 u_long fr_badsrc; /* source received doesn't match route */ 343 u_long fr_badttl; /* TTL in packet doesn't reach minimum */ 344#if SOLARIS 345 u_long fr_notdata; /* PROTO/PCPROTO that have no data */ 346 u_long fr_nodata; /* mblks that have no data */ 347 u_long fr_bad; /* bad IP packets to the filter */ 348 u_long fr_notip; /* packets passed through no on ip queue */ 349 u_long fr_drop; /* packets dropped - no info for them! */ 350 u_long fr_copy; /* messages copied due to db_ref > 1 */ 351#endif 352 u_long fr_ipv6[2]; /* IPv6 packets in/out */ 353} filterstats_t; 354 355/* 356 * For SIOCGETFS 357 */ 358typedef struct friostat { 359 struct filterstats f_st[2]; 360 struct frentry *f_fin[2]; 361 struct frentry *f_fout[2]; 362 struct frentry *f_acctin[2]; 363 struct frentry *f_acctout[2]; 364 struct frentry *f_fin6[2]; 365 struct frentry *f_fout6[2]; 366 struct frentry *f_acctin6[2]; 367 struct frentry *f_acctout6[2]; 368 struct frentry *f_auth; 369 struct frgroup *f_groups[3][2]; 370 u_long f_froute[2]; 371 int f_defpass; /* default pass - from fr_pass */ 372 char f_active; /* 1 or 0 - active rule set */ 373 char f_running; /* 1 if running, else 0 */ 374 char f_logging; /* 1 if enabled, else 0 */ 375 char f_version[32]; /* version string */ 376 int f_locks[4]; 377} friostat_t; 378 379typedef struct optlist { 380 u_short ol_val; 381 int ol_bit; 382} optlist_t; 383 384 385/* 386 * Group list structure. 387 */ 388typedef struct frgroup { 389 u_32_t fg_num; 390 struct frgroup *fg_next; 391 struct frentry *fg_head; 392 struct frentry **fg_start; 393} frgroup_t; 394 395 396/* 397 * Log structure. Each packet header logged is prepended by one of these. 398 * Following this in the log records read from the device will be an ipflog 399 * structure which is then followed by any packet data. 400 */ 401typedef struct iplog { 402 u_32_t ipl_magic; 403 u_int ipl_count; 404 u_long ipl_sec; 405 u_long ipl_usec; 406 size_t ipl_dsize; 407 struct iplog *ipl_next; 408} iplog_t; 409 410#define IPL_MAGIC 0x49504c4d /* 'IPLM' */ 411 412typedef struct ipflog { 413#if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \ 414 (defined(OpenBSD) && (OpenBSD >= 199603)) 415 u_char fl_ifname[IFNAMSIZ]; 416#else 417 u_int fl_unit; 418 u_char fl_ifname[4]; 419#endif 420 u_char fl_plen; /* extra data after hlen */ 421 u_char fl_hlen; /* length of IP headers saved */ 422 u_short fl_loglevel; /* syslog log level */ 423 u_32_t fl_rule; 424 u_32_t fl_group; 425 u_32_t fl_flags; 426 u_32_t fl_lflags; 427} ipflog_t; 428 429 430#ifndef ICMP_UNREACH_FILTER 431# define ICMP_UNREACH_FILTER 13 432#endif 433 434#ifndef IPF_LOGGING 435# define IPF_LOGGING 0 436#endif 437#ifndef IPF_DEFAULT_PASS 438# define IPF_DEFAULT_PASS FR_PASS 439#endif 440 441#define IPMINLEN(i, h) ((i)->ip_len >= ((i)->ip_hl * 4 + sizeof(struct h))) 442#define IPLLOGSIZE 8192 443 444#define IPF_OPTCOPY 0x07ff00 /* bit mask of copied options */ 445 446/* 447 * Device filenames for reading log information. Use ipf on Solaris2 because 448 * ipl is already a name used by something else. 449 */ 450#ifndef IPL_NAME 451# if SOLARIS 452# define IPL_NAME "/dev/ipf" 453# else 454# define IPL_NAME "/dev/ipl" 455# endif 456#endif 457#define IPL_NAT IPNAT_NAME 458#define IPL_STATE IPSTATE_NAME 459#define IPL_AUTH IPAUTH_NAME 460 461#define IPL_LOGIPF 0 /* Minor device #'s for accessing logs */ 462#define IPL_LOGNAT 1 463#define IPL_LOGSTATE 2 464#define IPL_LOGAUTH 3 465#define IPL_LOGMAX 3 466 467#if !defined(CDEV_MAJOR) && defined (__FreeBSD_version) && \ 468 (__FreeBSD_version >= 220000) 469# define CDEV_MAJOR 79 470#endif 471 472/* 473 * Post NetBSD 1.2 has the PFIL interface for packet filters. This turns 474 * on those hooks. We don't need any special mods in non-IP Filter code 475 * with this! 476 */ 477#if (defined(NetBSD) && (NetBSD > 199609) && (NetBSD <= 1991011)) || \ 478 (defined(NetBSD1_2) && NetBSD1_2 > 1) || (defined(__FreeBSD_version) && \ 479 (__FreeBSD_version >= 500011)) 480# if (NetBSD >= 199905) 481# define PFIL_HOOKS 482# endif 483# ifdef PFIL_HOOKS 484# define NETBSD_PF 485# endif 486#endif 487 488 489#ifndef _KERNEL 490struct ifnet; 491extern int fr_check __P((ip_t *, int, void *, int, mb_t **)); 492extern int (*fr_checkp) __P((ip_t *, int, void *, int, mb_t **)); 493extern int send_reset __P((ip_t *, struct ifnet *)); 494extern int icmp_error __P((ip_t *, struct ifnet *)); 495extern int ipf_log __P((void)); 496extern struct ifnet *get_unit __P((char *, int)); 497# if defined(__NetBSD__) || defined(__OpenBSD__) || \ 498 (_BSDI_VERSION >= 199701) || (__FreeBSD_version >= 300000) 499extern int iplioctl __P((dev_t, u_long, caddr_t, int)); 500# else 501extern int iplioctl __P((dev_t, int, caddr_t, int)); 502# endif 503extern int iplopen __P((dev_t, int)); 504extern int iplclose __P((dev_t, int)); 505#else /* #ifndef _KERNEL */ 506# if defined(__NetBSD__) && defined(PFIL_HOOKS) 507extern void ipfilterattach __P((int)); 508# endif 509extern int iplattach __P((void)); 510extern int ipl_enable __P((void)); 511extern int ipl_disable __P((void)); 512extern void ipflog_init __P((void)); 513extern int ipflog_clear __P((minor_t)); 514extern int ipflog_read __P((minor_t, struct uio *)); 515extern int ipflog __P((u_int, ip_t *, fr_info_t *, mb_t *)); 516extern int ipllog __P((int, fr_info_t *, void **, size_t *, int *, int)); 517extern int send_icmp_err __P((ip_t *, int, fr_info_t *, int)); 518extern int send_reset __P((ip_t *, fr_info_t *)); 519# if SOLARIS 520extern int fr_check __P((ip_t *, int, void *, int, qif_t *, mb_t **)); 521extern int (*fr_checkp) __P((ip_t *, int, void *, 522 int, qif_t *, mb_t **)); 523# if SOLARIS2 >= 7 524extern int iplioctl __P((dev_t, int, intptr_t, int, cred_t *, int *)); 525# else 526extern int iplioctl __P((dev_t, int, int *, int, cred_t *, int *)); 527# endif 528extern int iplopen __P((dev_t *, int, int, cred_t *)); 529extern int iplclose __P((dev_t, int, int, cred_t *)); 530extern int ipfsync __P((void)); 531extern int ipfr_fastroute __P((ip_t *, mblk_t *, mblk_t **, 532 fr_info_t *, frdest_t *)); 533extern void copyin_mblk __P((mblk_t *, size_t, size_t, char *)); 534extern void copyout_mblk __P((mblk_t *, size_t, size_t, char *)); 535extern int fr_qin __P((queue_t *, mblk_t *)); 536extern int fr_qout __P((queue_t *, mblk_t *)); 537extern int iplread __P((dev_t, struct uio *, cred_t *)); 538# else /* SOLARIS */ 539extern int fr_check __P((ip_t *, int, void *, int, mb_t **)); 540extern int (*fr_checkp) __P((ip_t *, int, void *, int, mb_t **)); 541extern int ipfr_fastroute __P((mb_t *, mb_t **, fr_info_t *, frdest_t *)); 542extern size_t mbufchainlen __P((mb_t *)); 543# ifdef __sgi 544# include <sys/cred.h> 545extern int iplioctl __P((dev_t, int, caddr_t, int, cred_t *, int *)); 546extern int iplopen __P((dev_t *, int, int, cred_t *)); 547extern int iplclose __P((dev_t, int, int, cred_t *)); 548extern int iplread __P((dev_t, struct uio *, cred_t *)); 549extern int ipfsync __P((void)); 550extern int ipfilter_sgi_attach __P((void)); 551extern void ipfilter_sgi_detach __P((void)); 552extern void ipfilter_sgi_intfsync __P((void)); 553# else 554# ifdef IPFILTER_LKM 555extern int iplidentify __P((char *)); 556# endif 557# if (_BSDI_VERSION >= 199510) || (__FreeBSD_version >= 220000) || \ 558 (NetBSD >= 199511) || defined(__OpenBSD__) 559# if defined(__NetBSD__) || (_BSDI_VERSION >= 199701) || \ 560 defined(__OpenBSD__) || (__FreeBSD_version >= 300000) 561extern int iplioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); 562# else 563extern int iplioctl __P((dev_t, int, caddr_t, int, struct proc *)); 564# endif 565extern int iplopen __P((dev_t, int, int, struct proc *)); 566extern int iplclose __P((dev_t, int, int, struct proc *)); 567# else 568# ifndef linux 569extern int iplopen __P((dev_t, int)); 570extern int iplclose __P((dev_t, int)); 571extern int iplioctl __P((dev_t, int, caddr_t, int)); 572# else 573extern int iplioctl(struct inode *, struct file *, u_int, u_long); 574extern int iplopen __P((struct inode *, struct file *)); 575extern void iplclose __P((struct inode *, struct file *)); 576# endif /* !linux */ 577# endif /* (_BSDI_VERSION >= 199510) */ 578# if BSD >= 199306 579extern int iplread __P((dev_t, struct uio *, int)); 580# else 581# ifndef linux 582extern int iplread __P((dev_t, struct uio *)); 583# else 584extern int iplread(struct inode *, struct file *, char *, int); 585# endif /* !linux */ 586# endif /* BSD >= 199306 */ 587# endif /* __ sgi */ 588# endif /* SOLARIS */ 589#endif /* #ifndef _KERNEL */ 590 591extern char *memstr __P((char *, char *, int, int)); 592extern void fixskip __P((frentry_t **, frentry_t *, int)); 593extern int countbits __P((u_32_t)); 594extern int ipldetach __P((void)); 595extern u_short ipf_cksum __P((u_short *, int)); 596extern int ircopyptr __P((void *, void *, size_t)); 597extern int iwcopyptr __P((void *, void *, size_t)); 598 599extern int frflush __P((minor_t, int)); 600extern void frsync __P((void)); 601extern frgroup_t *fr_addgroup __P((u_32_t, frentry_t *, minor_t, int)); 602extern void fr_delgroup __P((u_32_t, u_32_t, minor_t, int)); 603extern frgroup_t *fr_findgroup __P((u_32_t, u_32_t, minor_t, int, 604 frgroup_t ***)); 605 606extern int fr_copytolog __P((int, char *, int)); 607extern void fr_forgetifp __P((void *)); 608extern void fr_getstat __P((struct friostat *)); 609extern int fr_ifpaddr __P((int, void *, struct in_addr *)); 610extern int fr_lock __P((caddr_t, int *)); 611extern void fr_makefrip __P((int, ip_t *, fr_info_t *)); 612extern u_short fr_tcpsum __P((mb_t *, ip_t *, tcphdr_t *)); 613extern int fr_scanlist __P((u_32_t, ip_t *, fr_info_t *, void *)); 614extern int fr_tcpudpchk __P((frtuc_t *, fr_info_t *)); 615extern int fr_verifysrc __P((struct in_addr, void *)); 616 617extern int ipl_unreach; 618extern int fr_running; 619extern u_long ipl_frouteok[2]; 620extern int fr_pass; 621extern int fr_flags; 622extern int fr_active; 623extern int fr_chksrc; 624extern int fr_minttl; 625extern int fr_minttllog; 626extern fr_info_t frcache[2]; 627extern char ipfilter_version[]; 628extern iplog_t **iplh[IPL_LOGMAX+1], *iplt[IPL_LOGMAX+1]; 629extern size_t iplused[IPL_LOGMAX + 1]; 630extern struct frentry *ipfilter[2][2], *ipacct[2][2]; 631#ifdef USE_INET6 632extern struct frentry *ipfilter6[2][2], *ipacct6[2][2]; 633extern int icmptoicmp6types[ICMP_MAXTYPE+1]; 634extern int icmptoicmp6unreach[ICMP_MAX_UNREACH]; 635#endif 636extern struct frgroup *ipfgroups[3][2]; 637extern struct filterstats frstats[]; 638 639#endif /* __IP_FIL_H__ */ 640