ip_fil.h revision 95418
152284Sobrien/* 2169689Skan * Copyright (C) 1993-2002 by Darren Reed. 3117395Skan * 452284Sobrien * See the IPFILTER.LICENCE file for details on licencing. 5132718Skan * 652284Sobrien * @(#)ip_fil.h 1.35 6/5/96 7132718Skan * $Id: ip_fil.h,v 2.29.2.4 2000/11/12 11:54:53 darrenr Exp $ 852284Sobrien * $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_fil.h 95418 2002-04-25 03:31:39Z darrenr $ 952284Sobrien */ 1052284Sobrien 1152284Sobrien#ifndef __IP_FIL_H__ 12132718Skan#define __IP_FIL_H__ 1352284Sobrien 1452284Sobrien/* 1552284Sobrien * Pathnames for various IP Filter control devices. Used by LKM 1652284Sobrien * and userland, so defined here. 1752284Sobrien */ 18132718Skan#define IPNAT_NAME "/dev/ipnat" 19169689Skan#define IPSTATE_NAME "/dev/ipstate" 20169689Skan#define IPAUTH_NAME "/dev/ipauth" 2152284Sobrien 2290075Sobrien#ifndef SOLARIS 23117395Skan# define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4))) 2490075Sobrien#endif 2590075Sobrien 2652284Sobrien#if defined(KERNEL) && !defined(_KERNEL) 2752284Sobrien# define _KERNEL 28117395Skan#endif 2952284Sobrien 3052284Sobrien#ifndef __P 3152284Sobrien# ifdef __STDC__ 3252284Sobrien# define __P(x) x 3390075Sobrien# else 3490075Sobrien# define __P(x) () 3590075Sobrien# endif 3690075Sobrien#endif 3790075Sobrien 3890075Sobrien#ifndef offsetof 3990075Sobrien# define offsetof(t,m) (int)((&((t *)0L)->m)) 4090075Sobrien#endif 4190075Sobrien 4290075Sobrien#if defined(__STDC__) || defined(__GNUC__) 4390075Sobrien# define SIOCADAFR _IOW('r', 60, struct frentry *) 4490075Sobrien# define SIOCRMAFR _IOW('r', 61, struct frentry *) 4590075Sobrien# define SIOCSETFF _IOW('r', 62, u_int) 4690075Sobrien# define SIOCGETFF _IOR('r', 63, u_int) 4790075Sobrien# define SIOCGETFS _IOWR('r', 64, struct friostat *) 4890075Sobrien# define SIOCIPFFL _IOWR('r', 65, int) 4990075Sobrien# define SIOCIPFFB _IOR('r', 66, int) 5090075Sobrien# define SIOCADIFR _IOW('r', 67, struct frentry *) 5152284Sobrien# define SIOCRMIFR _IOW('r', 68, struct frentry *) 5252284Sobrien# define SIOCSWAPA _IOR('r', 69, u_int) 5390075Sobrien# define SIOCINAFR _IOW('r', 70, struct frentry *) 5452284Sobrien# define SIOCINIFR _IOW('r', 71, struct frentry *) 5552284Sobrien# define SIOCFRENB _IOW('r', 72, u_int) 5690075Sobrien# define SIOCFRSYN _IOW('r', 73, u_int) 5790075Sobrien# define SIOCFRZST _IOWR('r', 74, struct friostat *) 5890075Sobrien# define SIOCZRLST _IOWR('r', 75, struct frentry *) 5952284Sobrien# define SIOCAUTHW _IOWR('r', 76, struct frauth *) 60132718Skan# define SIOCAUTHR _IOWR('r', 77, struct frauth *) 6190075Sobrien# define SIOCATHST _IOWR('r', 78, struct fr_authstat *) 62132718Skan# define SIOCSTLCK _IOWR('r', 79, u_int) 6390075Sobrien# define SIOCSTPUT _IOWR('r', 80, struct ipstate_save *) 6490075Sobrien# define SIOCSTGET _IOWR('r', 81, struct ipstate_save *) 6590075Sobrien# define SIOCSTGSZ _IOWR('r', 82, struct natget) 6690075Sobrien# define SIOCGFRST _IOWR('r', 83, struct ipfrstat *) 6790075Sobrien#else 6890075Sobrien# define SIOCADAFR _IOW(r, 60, struct frentry *) 6990075Sobrien# define SIOCRMAFR _IOW(r, 61, struct frentry *) 7090075Sobrien# define SIOCSETFF _IOW(r, 62, u_int) 7190075Sobrien# define SIOCGETFF _IOR(r, 63, u_int) 7290075Sobrien# define SIOCGETFS _IOWR(r, 64, struct friostat *) 7390075Sobrien# define SIOCIPFFL _IOWR(r, 65, int) 7490075Sobrien# define SIOCIPFFB _IOR(r, 66, int) 7590075Sobrien# define SIOCADIFR _IOW(r, 67, struct frentry *) 7652284Sobrien# define SIOCRMIFR _IOW(r, 68, struct frentry *) 7752284Sobrien# define SIOCSWAPA _IOR(r, 69, u_int) 7852284Sobrien# define SIOCINAFR _IOW(r, 70, struct frentry *) 7952284Sobrien# define SIOCINIFR _IOW(r, 71, struct frentry *) 8052284Sobrien# define SIOCFRENB _IOW(r, 72, u_int) 81117395Skan# define SIOCFRSYN _IOW(r, 73, u_int) 82117395Skan# define SIOCFRZST _IOWR(r, 74, struct friostat *) 83117395Skan# define SIOCZRLST _IOWR(r, 75, struct frentry *) 84117395Skan# define SIOCAUTHW _IOWR(r, 76, struct frauth *) 85117395Skan# define SIOCAUTHR _IOWR(r, 77, struct frauth *) 86117395Skan# define SIOCATHST _IOWR(r, 78, struct fr_authstat *) 87117395Skan# define SIOCSTLCK _IOWR(r, 79, u_int) 88117395Skan# define SIOCSTPUT _IOWR(r, 80, struct ipstate_save *) 8952284Sobrien# define SIOCSTGET _IOWR(r, 81, struct ipstate_save *) 9090075Sobrien# define SIOCSTGSZ _IOWR(r, 82, struct natget) 9190075Sobrien# define SIOCGFRST _IOWR(r, 83, struct ipfrstat *) 92117395Skan#endif 9390075Sobrien#define SIOCADDFR SIOCADAFR 9490075Sobrien#define SIOCDELFR SIOCRMAFR 9552284Sobrien#define SIOCINSFR SIOCINAFR 9652284Sobrien 9752284Sobrien 9852284Sobrientypedef struct fr_ip { 9952284Sobrien u_32_t fi_v:4; /* IP version */ 10052284Sobrien u_32_t fi_fl:4; /* packet flags */ 10152284Sobrien u_32_t fi_tos:8; /* IP packet TOS */ 10252284Sobrien u_32_t fi_ttl:8; /* IP packet TTL */ 10352284Sobrien u_32_t fi_p:8; /* IP packet protocol */ 10452284Sobrien union i6addr fi_src; /* source address from packet */ 10552284Sobrien union i6addr fi_dst; /* destination address from packet */ 10652284Sobrien u_32_t fi_optmsk; /* bitmask composed from IP options */ 10752284Sobrien u_short fi_secmsk; /* bitmask composed from IP security options */ 10852284Sobrien u_short fi_auth; /* authentication code from IP sec. options */ 10952284Sobrien} fr_ip_t; 11052284Sobrien 11152284Sobrien#define FI_OPTIONS (FF_OPTIONS >> 24) 11252284Sobrien#define FI_TCPUDP (FF_TCPUDP >> 24) /* TCP/UCP implied comparison*/ 11352284Sobrien#define FI_FRAG (FF_FRAG >> 24) 11452284Sobrien#define FI_SHORT (FF_SHORT >> 24) 11552284Sobrien#define FI_CMP (FI_OPTIONS|FI_TCPUDP|FI_SHORT) 11652284Sobrien 11752284Sobrien#define fi_saddr fi_src.in4.s_addr 11852284Sobrien#define fi_daddr fi_dst.in4.s_addr 11952284Sobrien 12052284Sobrien 12152284Sobrien/* 12252284Sobrien * These are both used by the state and NAT code to indicate that one port or 12352284Sobrien * the other should be treated as a wildcard. 12452284Sobrien */ 12552284Sobrien#define FI_W_SPORT 0x00000100 12690075Sobrien#define FI_W_DPORT 0x00000200 12790075Sobrien#define FI_WILDP (FI_W_SPORT|FI_W_DPORT) 12852284Sobrien#define FI_W_SADDR 0x00000400 12952284Sobrien#define FI_W_DADDR 0x00000800 13052284Sobrien#define FI_WILDA (FI_W_SADDR|FI_W_DADDR) 13152284Sobrien#define FI_NEWFR 0x00001000 /* Create a filter rule */ 13252284Sobrien#define FI_IGNOREPKT 0x00002000 /* Do not treat as a real packet */ 13352284Sobrien#define FI_NORULE 0x00004000 /* Not direct a result of a rule */ 13452284Sobrien 13552284Sobrientypedef struct fr_info { 13652284Sobrien void *fin_ifp; /* interface packet is `on' */ 13790075Sobrien struct fr_ip fin_fi; /* IP Packet summary */ 13890075Sobrien u_short fin_data[2]; /* TCP/UDP ports, ICMP code/type */ 13990075Sobrien u_int fin_out; /* in or out ? 1 == out, 0 == in */ 14090075Sobrien u_short fin_hlen; /* length of IP header in bytes */ 14152284Sobrien u_char fin_rev; /* state only: 1 = reverse */ 14290075Sobrien u_char fin_tcpf; /* TCP header flags (SYN, ACK, etc) */ 14390075Sobrien u_int fin_icode; /* ICMP error to return */ 14490075Sobrien u_32_t fin_rule; /* rule # last matched */ 14590075Sobrien u_32_t fin_group; /* group number, -1 for none */ 14690075Sobrien struct frentry *fin_fr; /* last matching rule */ 14790075Sobrien char *fin_dp; /* start of data past IP header */ 14852284Sobrien u_short fin_plen; 14952284Sobrien u_short fin_off; 15052284Sobrien u_short fin_dlen; /* length of data portion of packet */ 15190075Sobrien u_short fin_id; /* IP packet id field */ 15290075Sobrien u_int fin_misc; 15390075Sobrien void *fin_mp; /* pointer to pointer to mbuf */ 15490075Sobrien#if SOLARIS 15590075Sobrien void *fin_qfm; /* pointer to mblk where pkt starts */ 15690075Sobrien void *fin_qif; 15790075Sobrien#endif 15890075Sobrien} fr_info_t; 15990075Sobrien 16090075Sobrien#define fin_v fin_fi.fi_v 16190075Sobrien#define fin_p fin_fi.fi_p 16290075Sobrien#define fin_saddr fin_fi.fi_saddr 16390075Sobrien#define fin_src fin_fi.fi_src.in4 16490075Sobrien#define fin_daddr fin_fi.fi_daddr 16590075Sobrien#define fin_dst fin_fi.fi_dst.in4 16690075Sobrien#define fin_fl fin_fi.fi_fl 16790075Sobrien 16890075Sobrien/* 16990075Sobrien * Size for compares on fr_info structures 17090075Sobrien */ 17190075Sobrien#define FI_CSIZE offsetof(fr_info_t, fin_icode) 172117395Skan#define FI_LCSIZE offsetof(fr_info_t, fin_dp) 173117395Skan 17490075Sobrien/* 17590075Sobrien * For fin_misc 17690075Sobrien */ 17790075Sobrien#define FM_BADSTATE 0x00000001 17890075Sobrien 179169689Skan/* 18090075Sobrien * Size for copying cache fr_info structure 181169689Skan */ 18290075Sobrien#define FI_COPYSIZE offsetof(fr_info_t, fin_dp) 18390075Sobrien 18490075Sobrientypedef struct frdest { 18590075Sobrien void *fd_ifp; 18690075Sobrien union i6addr fd_ip6; 18790075Sobrien char fd_ifname[LIFNAMSIZ]; 18890075Sobrien#if SOLARIS 189 mb_t *fd_mp; /* cache resolver for to/dup-to */ 190#endif 191} frdest_t; 192 193#define fd_ip fd_ip6.in4 194 195 196typedef struct frpcmp { 197 int frp_cmp; /* data for port comparisons */ 198 u_short frp_port; /* top port for <> and >< */ 199 u_short frp_top; /* top port for <> and >< */ 200} frpcmp_t; 201 202typedef struct frtuc { 203 u_char ftu_tcpfm; /* tcp flags mask */ 204 u_char ftu_tcpf; /* tcp flags */ 205 frpcmp_t ftu_src; 206 frpcmp_t ftu_dst; 207} frtuc_t; 208 209#define ftu_scmp ftu_src.frp_cmp 210#define ftu_dcmp ftu_dst.frp_cmp 211#define ftu_sport ftu_src.frp_port 212#define ftu_dport ftu_dst.frp_port 213#define ftu_stop ftu_src.frp_top 214#define ftu_dtop ftu_dst.frp_top 215 216typedef struct frentry { 217 struct frentry *fr_next; 218 struct frentry *fr_grp; 219 int fr_ref; /* reference count - for grouping */ 220 void *fr_ifas[4]; 221 /* 222 * These are only incremented when a packet matches this rule and 223 * it is the last match 224 */ 225 U_QUAD_T fr_hits; 226 U_QUAD_T fr_bytes; 227 /* 228 * Fields after this may not change whilst in the kernel. 229 */ 230 struct fr_ip fr_ip; 231 struct fr_ip fr_mip; /* mask structure */ 232 233 234 u_short fr_icmpm; /* data for ICMP packets (mask) */ 235 u_short fr_icmp; 236 237 u_int fr_age[2]; /* aging for state */ 238 frtuc_t fr_tuc; 239 u_32_t fr_group; /* group to which this rule belongs */ 240 u_32_t fr_grhead; /* group # which this rule starts */ 241 u_32_t fr_flags; /* per-rule flags && options (see below) */ 242 u_int fr_skip; /* # of rules to skip */ 243 u_int fr_loglevel; /* syslog log facility + priority */ 244 int (*fr_func) __P((int, ip_t *, fr_info_t *)); /* call this function */ 245 int fr_sap; /* For solaris only */ 246 u_char fr_icode; /* return ICMP code */ 247 char fr_ifnames[4][LIFNAMSIZ]; 248 struct frdest fr_tif; /* "to" interface */ 249 struct frdest fr_dif; /* duplicate packet interfaces */ 250 u_int fr_cksum; /* checksum on filter rules for performance */ 251} frentry_t; 252 253#define fr_v fr_ip.fi_v 254#define fr_proto fr_ip.fi_p 255#define fr_ttl fr_ip.fi_ttl 256#define fr_tos fr_ip.fi_tos 257#define fr_tcpfm fr_tuc.ftu_tcpfm 258#define fr_tcpf fr_tuc.ftu_tcpf 259#define fr_scmp fr_tuc.ftu_scmp 260#define fr_dcmp fr_tuc.ftu_dcmp 261#define fr_dport fr_tuc.ftu_dport 262#define fr_sport fr_tuc.ftu_sport 263#define fr_stop fr_tuc.ftu_stop 264#define fr_dtop fr_tuc.ftu_dtop 265#define fr_dst fr_ip.fi_dst.in4 266#define fr_src fr_ip.fi_src.in4 267#define fr_dmsk fr_mip.fi_dst.in4 268#define fr_smsk fr_mip.fi_src.in4 269#define fr_ifname fr_ifnames[0] 270#define fr_oifname fr_ifnames[2] 271#define fr_ifa fr_ifas[0] 272#define fr_oifa fr_ifas[2] 273 274#define FR_CMPSIZ (sizeof(struct frentry) - offsetof(frentry_t, fr_ip)) 275 276/* 277 * fr_flags 278 */ 279#define FR_BLOCK 0x00001 /* do not allow packet to pass */ 280#define FR_PASS 0x00002 /* allow packet to pass */ 281#define FR_OUTQUE 0x00004 /* outgoing packets */ 282#define FR_INQUE 0x00008 /* ingoing packets */ 283#define FR_LOG 0x00010 /* Log */ 284#define FR_LOGB 0x00011 /* Log-fail */ 285#define FR_LOGP 0x00012 /* Log-pass */ 286#define FR_NOTSRCIP 0x00020 /* not the src IP# */ 287#define FR_NOTDSTIP 0x00040 /* not the dst IP# */ 288#define FR_RETRST 0x00080 /* Return TCP RST packet - reset connection */ 289#define FR_RETICMP 0x00100 /* Return ICMP unreachable packet */ 290#define FR_FAKEICMP 0x00180 /* Return ICMP unreachable with fake source */ 291#define FR_NOMATCH 0x00200 /* no match occured */ 292#define FR_ACCOUNT 0x00400 /* count packet bytes */ 293#define FR_KEEPFRAG 0x00800 /* keep fragment information */ 294#define FR_KEEPSTATE 0x01000 /* keep `connection' state information */ 295#define FR_INACTIVE 0x02000 296#define FR_QUICK 0x04000 /* match & stop processing list */ 297#define FR_FASTROUTE 0x08000 /* bypass normal routing */ 298#define FR_CALLNOW 0x10000 /* call another function (fr_func) if matches */ 299#define FR_DUP 0x20000 /* duplicate packet */ 300#define FR_LOGORBLOCK 0x40000 /* block the packet if it can't be logged */ 301#define FR_LOGBODY 0x80000 /* Log the body */ 302#define FR_LOGFIRST 0x100000 /* Log the first byte if state held */ 303#define FR_AUTH 0x200000 /* use authentication */ 304#define FR_PREAUTH 0x400000 /* require preauthentication */ 305#define FR_DONTCACHE 0x800000 /* don't cache the result */ 306 307#define FR_LOGMASK (FR_LOG|FR_LOGP|FR_LOGB) 308#define FR_RETMASK (FR_RETICMP|FR_RETRST|FR_FAKEICMP) 309 310/* 311 * These correspond to #define's for FI_* and are stored in fr_flags 312 */ 313#define FF_OPTIONS 0x01000000 314#define FF_TCPUDP 0x02000000 315#define FF_FRAG 0x04000000 316#define FF_SHORT 0x08000000 317/* 318 * recognized flags for SIOCGETFF and SIOCSETFF, and get put in fr_flags 319 */ 320#define FF_LOGPASS 0x10000000 321#define FF_LOGBLOCK 0x20000000 322#define FF_LOGNOMATCH 0x40000000 323#define FF_LOGGING (FF_LOGPASS|FF_LOGBLOCK|FF_LOGNOMATCH) 324#define FF_BLOCKNONIP 0x80000000 /* Solaris2 Only */ 325 326#define FR_NONE 0 327#define FR_EQUAL 1 328#define FR_NEQUAL 2 329#define FR_LESST 3 330#define FR_GREATERT 4 331#define FR_LESSTE 5 332#define FR_GREATERTE 6 333#define FR_OUTRANGE 7 334#define FR_INRANGE 8 335 336typedef struct filterstats { 337 u_long fr_pass; /* packets allowed */ 338 u_long fr_block; /* packets denied */ 339 u_long fr_nom; /* packets which don't match any rule */ 340 u_long fr_short; /* packets which are short */ 341 u_long fr_ppkl; /* packets allowed and logged */ 342 u_long fr_bpkl; /* packets denied and logged */ 343 u_long fr_npkl; /* packets unmatched and logged */ 344 u_long fr_pkl; /* packets logged */ 345 u_long fr_skip; /* packets to be logged but buffer full */ 346 u_long fr_ret; /* packets for which a return is sent */ 347 u_long fr_acct; /* packets for which counting was performed */ 348 u_long fr_bnfr; /* bad attempts to allocate fragment state */ 349 u_long fr_nfr; /* new fragment state kept */ 350 u_long fr_cfr; /* add new fragment state but complete pkt */ 351 u_long fr_bads; /* bad attempts to allocate packet state */ 352 u_long fr_ads; /* new packet state kept */ 353 u_long fr_chit; /* cached hit */ 354 u_long fr_tcpbad; /* TCP checksum check failures */ 355 u_long fr_pull[2]; /* good and bad pullup attempts */ 356 u_long fr_badsrc; /* source received doesn't match route */ 357 u_long fr_badttl; /* TTL in packet doesn't reach minimum */ 358#if SOLARIS 359 u_long fr_notdata; /* PROTO/PCPROTO that have no data */ 360 u_long fr_nodata; /* mblks that have no data */ 361 u_long fr_bad; /* bad IP packets to the filter */ 362 u_long fr_notip; /* packets passed through no on ip queue */ 363 u_long fr_drop; /* packets dropped - no info for them! */ 364 u_long fr_copy; /* messages copied due to db_ref > 1 */ 365#endif 366 u_long fr_ipv6[2]; /* IPv6 packets in/out */ 367} filterstats_t; 368 369/* 370 * For SIOCGETFS 371 */ 372typedef struct friostat { 373 struct filterstats f_st[2]; 374 struct frentry *f_fin[2]; 375 struct frentry *f_fout[2]; 376 struct frentry *f_acctin[2]; 377 struct frentry *f_acctout[2]; 378 struct frentry *f_fin6[2]; 379 struct frentry *f_fout6[2]; 380 struct frentry *f_acctin6[2]; 381 struct frentry *f_acctout6[2]; 382 struct frentry *f_auth; 383 struct frgroup *f_groups[3][2]; 384 u_long f_froute[2]; 385 int f_defpass; /* default pass - from fr_pass */ 386 char f_active; /* 1 or 0 - active rule set */ 387 char f_running; /* 1 if running, else 0 */ 388 char f_logging; /* 1 if enabled, else 0 */ 389 char f_version[32]; /* version string */ 390 int f_locks[4]; 391} friostat_t; 392 393typedef struct optlist { 394 u_short ol_val; 395 int ol_bit; 396} optlist_t; 397 398 399/* 400 * Group list structure. 401 */ 402typedef struct frgroup { 403 u_32_t fg_num; 404 struct frgroup *fg_next; 405 struct frentry *fg_head; 406 struct frentry **fg_start; 407} frgroup_t; 408 409 410/* 411 * Log structure. Each packet header logged is prepended by one of these. 412 * Following this in the log records read from the device will be an ipflog 413 * structure which is then followed by any packet data. 414 */ 415typedef struct iplog { 416 u_32_t ipl_magic; 417 u_int ipl_count; 418 u_long ipl_sec; 419 u_long ipl_usec; 420 size_t ipl_dsize; 421 struct iplog *ipl_next; 422} iplog_t; 423 424#define IPL_MAGIC 0x49504c4d /* 'IPLM' */ 425#define IPLOG_SIZE sizeof(iplog_t) 426 427typedef struct ipflog { 428#if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \ 429 (defined(OpenBSD) && (OpenBSD >= 199603)) 430 char fl_ifname[LIFNAMSIZ]; 431#else 432 u_int fl_unit; 433 char fl_ifname[LIFNAMSIZ]; 434#endif 435 u_char fl_plen; /* extra data after hlen */ 436 u_char fl_hlen; /* length of IP headers saved */ 437 u_short fl_loglevel; /* syslog log level */ 438 u_32_t fl_rule; 439 u_32_t fl_group; 440 u_32_t fl_flags; 441 u_char fl_dir; 442 u_char fl_pad[3]; 443} ipflog_t; 444 445 446#ifndef ICMP_UNREACH_FILTER 447# define ICMP_UNREACH_FILTER 13 448#endif 449 450#ifndef IPF_LOGGING 451# define IPF_LOGGING 0 452#endif 453#ifndef IPF_DEFAULT_PASS 454# define IPF_DEFAULT_PASS FR_PASS 455#endif 456 457#define IPMINLEN(i, h) ((i)->ip_len >= ((i)->ip_hl * 4 + sizeof(struct h))) 458#define IPLLOGSIZE 8192 459 460#define IPF_OPTCOPY 0x07ff00 /* bit mask of copied options */ 461 462/* 463 * Device filenames for reading log information. Use ipf on Solaris2 because 464 * ipl is already a name used by something else. 465 */ 466#ifndef IPL_NAME 467# if SOLARIS 468# define IPL_NAME "/dev/ipf" 469# else 470# define IPL_NAME "/dev/ipl" 471# endif 472#endif 473#define IPL_NAT IPNAT_NAME 474#define IPL_STATE IPSTATE_NAME 475#define IPL_AUTH IPAUTH_NAME 476 477#define IPL_LOGIPF 0 /* Minor device #'s for accessing logs */ 478#define IPL_LOGNAT 1 479#define IPL_LOGSTATE 2 480#define IPL_LOGAUTH 3 481#define IPL_LOGMAX 3 482 483#if !defined(CDEV_MAJOR) && defined (__FreeBSD_version) && \ 484 (__FreeBSD_version >= 220000) 485# define CDEV_MAJOR 79 486#endif 487 488/* 489 * Post NetBSD 1.2 has the PFIL interface for packet filters. This turns 490 * on those hooks. We don't need any special mods in non-IP Filter code 491 * with this! 492 */ 493#if (defined(NetBSD) && (NetBSD > 199609) && (NetBSD <= 1991011)) || \ 494 (defined(NetBSD1_2) && NetBSD1_2 > 1) || (defined(__FreeBSD_version) && \ 495 (__FreeBSD_version >= 500011)) 496# if (NetBSD >= 199905) 497# define PFIL_HOOKS 498# endif 499# ifdef PFIL_HOOKS 500# define NETBSD_PF 501# endif 502#endif 503 504 505#ifndef _KERNEL 506extern char *get_ifname __P((struct ifnet *)); 507extern int fr_check __P((ip_t *, int, void *, int, mb_t **)); 508extern int (*fr_checkp) __P((ip_t *, int, void *, int, mb_t **)); 509extern int send_reset __P((ip_t *, fr_info_t *)); 510extern int send_icmp_err __P((ip_t *, int, fr_info_t *, int)); 511extern int ipf_log __P((void)); 512extern struct ifnet *get_unit __P((char *, int)); 513# if defined(__NetBSD__) || defined(__OpenBSD__) || \ 514 (_BSDI_VERSION >= 199701) || (__FreeBSD_version >= 300000) 515extern int iplioctl __P((dev_t, u_long, caddr_t, int)); 516# else 517extern int iplioctl __P((dev_t, int, caddr_t, int)); 518# endif 519extern int iplopen __P((dev_t, int)); 520extern int iplclose __P((dev_t, int)); 521#else /* #ifndef _KERNEL */ 522# if defined(__NetBSD__) && defined(PFIL_HOOKS) 523extern void ipfilterattach __P((int)); 524# endif 525extern int iplattach __P((void)); 526extern int ipl_enable __P((void)); 527extern int ipl_disable __P((void)); 528extern int send_icmp_err __P((ip_t *, int, fr_info_t *, int)); 529extern int send_reset __P((ip_t *, fr_info_t *)); 530# if SOLARIS 531extern int fr_check __P((ip_t *, int, void *, int, qif_t *, mb_t **)); 532extern int (*fr_checkp) __P((ip_t *, int, void *, 533 int, qif_t *, mb_t **)); 534# if SOLARIS2 >= 7 535extern int iplioctl __P((dev_t, int, intptr_t, int, cred_t *, int *)); 536# else 537extern int iplioctl __P((dev_t, int, int *, int, cred_t *, int *)); 538# endif 539extern int iplopen __P((dev_t *, int, int, cred_t *)); 540extern int iplclose __P((dev_t, int, int, cred_t *)); 541extern int ipfsync __P((void)); 542extern int ipfr_fastroute __P((ip_t *, mblk_t *, mblk_t **, 543 fr_info_t *, frdest_t *)); 544extern void copyin_mblk __P((mblk_t *, size_t, size_t, char *)); 545extern void copyout_mblk __P((mblk_t *, size_t, size_t, char *)); 546extern int fr_qin __P((queue_t *, mblk_t *)); 547extern int fr_qout __P((queue_t *, mblk_t *)); 548extern int iplread __P((dev_t, struct uio *, cred_t *)); 549# else /* SOLARIS */ 550extern int fr_check __P((ip_t *, int, void *, int, mb_t **)); 551extern int (*fr_checkp) __P((ip_t *, int, void *, int, mb_t **)); 552extern int ipfr_fastroute __P((mb_t *, mb_t **, fr_info_t *, frdest_t *)); 553extern size_t mbufchainlen __P((mb_t *)); 554# ifdef __sgi 555# include <sys/cred.h> 556extern int iplioctl __P((dev_t, int, caddr_t, int, cred_t *, int *)); 557extern int iplopen __P((dev_t *, int, int, cred_t *)); 558extern int iplclose __P((dev_t, int, int, cred_t *)); 559extern int iplread __P((dev_t, struct uio *, cred_t *)); 560extern int ipfsync __P((void)); 561extern int ipfilter_sgi_attach __P((void)); 562extern void ipfilter_sgi_detach __P((void)); 563extern void ipfilter_sgi_intfsync __P((void)); 564# else 565# ifdef IPFILTER_LKM 566extern int iplidentify __P((char *)); 567# endif 568# if (_BSDI_VERSION >= 199510) || (__FreeBSD_version >= 220000) || \ 569 (NetBSD >= 199511) || defined(__OpenBSD__) 570# if defined(__NetBSD__) || (_BSDI_VERSION >= 199701) || \ 571 defined(__OpenBSD__) || (__FreeBSD_version >= 300000) 572extern int iplioctl __P((dev_t, u_long, caddr_t, int, struct thread *)); 573# else 574extern int iplioctl __P((dev_t, int, caddr_t, int, struct thread *)); 575# endif 576extern int iplopen __P((dev_t, int, int, struct thread *)); 577extern int iplclose __P((dev_t, int, int, struct thread *)); 578# else 579# ifndef linux 580extern int iplopen __P((dev_t, int)); 581extern int iplclose __P((dev_t, int)); 582extern int iplioctl __P((dev_t, int, caddr_t, int)); 583# else 584extern int iplioctl(struct inode *, struct file *, u_int, u_long); 585extern int iplopen __P((struct inode *, struct file *)); 586extern void iplclose __P((struct inode *, struct file *)); 587# endif /* !linux */ 588# endif /* (_BSDI_VERSION >= 199510) */ 589# if BSD >= 199306 590extern int iplread __P((dev_t, struct uio *, int)); 591# else 592# ifndef linux 593extern int iplread __P((dev_t, struct uio *)); 594# else 595extern int iplread(struct inode *, struct file *, char *, int); 596# endif /* !linux */ 597# endif /* BSD >= 199306 */ 598# endif /* __ sgi */ 599# endif /* SOLARIS */ 600#endif /* #ifndef _KERNEL */ 601 602extern char *memstr __P((char *, char *, int, int)); 603extern void fixskip __P((frentry_t **, frentry_t *, int)); 604extern int countbits __P((u_32_t)); 605extern int ipldetach __P((void)); 606extern u_short ipf_cksum __P((u_short *, int)); 607extern int ircopyptr __P((void *, void *, size_t)); 608extern int iwcopyptr __P((void *, void *, size_t)); 609 610extern void ipflog_init __P((void)); 611extern int ipflog_clear __P((minor_t)); 612extern int ipflog __P((u_int, ip_t *, fr_info_t *, mb_t *)); 613extern int ipllog __P((int, fr_info_t *, void **, size_t *, int *, int)); 614extern int ipflog_read __P((minor_t, struct uio *)); 615 616extern int frflush __P((minor_t, int)); 617extern void frsync __P((void)); 618extern frgroup_t *fr_addgroup __P((u_32_t, frentry_t *, minor_t, int)); 619extern void fr_delgroup __P((u_32_t, u_32_t, minor_t, int)); 620extern frgroup_t *fr_findgroup __P((u_32_t, u_32_t, minor_t, int, 621 frgroup_t ***)); 622 623extern int fr_copytolog __P((int, char *, int)); 624extern void fr_forgetifp __P((void *)); 625extern void fr_getstat __P((struct friostat *)); 626extern int fr_ifpaddr __P((int, void *, struct in_addr *)); 627extern int fr_lock __P((caddr_t, int *)); 628extern void fr_makefrip __P((int, ip_t *, fr_info_t *)); 629extern u_short fr_tcpsum __P((mb_t *, ip_t *, tcphdr_t *)); 630extern int fr_scanlist __P((u_32_t, ip_t *, fr_info_t *, void *)); 631extern int fr_tcpudpchk __P((frtuc_t *, fr_info_t *)); 632extern int fr_verifysrc __P((struct in_addr, void *)); 633 634extern int ipl_unreach; 635extern int fr_running; 636extern u_long ipl_frouteok[2]; 637extern int fr_pass; 638extern int fr_flags; 639extern int fr_active; 640extern int fr_chksrc; 641extern int fr_minttl; 642extern int fr_minttllog; 643extern fr_info_t frcache[2]; 644extern char ipfilter_version[]; 645extern iplog_t **iplh[IPL_LOGMAX+1], *iplt[IPL_LOGMAX+1]; 646extern size_t iplused[IPL_LOGMAX + 1]; 647extern struct frentry *ipfilter[2][2], *ipacct[2][2]; 648#ifdef USE_INET6 649extern struct frentry *ipfilter6[2][2], *ipacct6[2][2]; 650extern int icmptoicmp6types[ICMP_MAXTYPE+1]; 651extern int icmptoicmp6unreach[ICMP_MAX_UNREACH]; 652#endif 653extern struct frgroup *ipfgroups[3][2]; 654extern struct filterstats frstats[]; 655 656#endif /* __IP_FIL_H__ */ 657