1 /*- 2 * Copyright (c) 1990, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from the Stanford/CMU enet packet filter, 6 * (net/enet.c) distributed as part of 4.3BSD, and code contributed 7 * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 8 * Berkeley Laboratory. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 4. Neither the name of the University nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)bpf.h 8.1 (Berkeley) 6/10/93 35 * @(#)bpf.h 1.34 (LBL) 6/16/96 36 * 37 * $FreeBSD$ 38 */ 39 40 #ifndef _NET_BPF_H_ 41 #define _NET_BPF_H_ 42 43 /* BSD style release date */ 44 #define BPF_RELEASE 199606 45 46 typedef int32_t bpf_int32; 47 typedef u_int32_t bpf_u_int32; 48 49 /* 50 * Alignment macros. BPF_WORDALIGN rounds up to the next 51 * even multiple of BPF_ALIGNMENT. 52 */ 53 #define BPF_ALIGNMENT sizeof(long) 54 #define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1)) 55 56 #define BPF_MAXINSNS 512 57 #define BPF_MAXBUFSIZE 0x80000 58 #define BPF_MINBUFSIZE 32 59 60 /* 61 * Structure for BIOCSETF. 62 */ 63 struct bpf_program { 64 u_int bf_len; 65 struct bpf_insn *bf_insns; 66 }; 67 68 /* 69 * Struct returned by BIOCGSTATS. 70 */ 71 struct bpf_stat { 72 u_int bs_recv; /* number of packets received */ 73 u_int bs_drop; /* number of packets dropped */ 74 }; 75 76 /* 77 * Struct return by BIOCVERSION. This represents the version number of 78 * the filter language described by the instruction encodings below. 79 * bpf understands a program iff kernel_major == filter_major && 80 * kernel_minor >= filter_minor, that is, if the value returned by the 81 * running kernel has the same major number and a minor number equal 82 * equal to or less than the filter being downloaded. Otherwise, the 83 * results are undefined, meaning an error may be returned or packets 84 * may be accepted haphazardly. 85 * It has nothing to do with the source code version. 86 */ 87 struct bpf_version { 88 u_short bv_major; 89 u_short bv_minor; 90 }; 91 /* Current version number of filter architecture. */ 92 #define BPF_MAJOR_VERSION 1 93 #define BPF_MINOR_VERSION 1 94 95 #define BIOCGBLEN _IOR('B',102, u_int) 96 #define BIOCSBLEN _IOWR('B',102, u_int) 97 #define BIOCSETF _IOW('B',103, struct bpf_program) 98 #define BIOCFLUSH _IO('B',104) 99 #define BIOCPROMISC _IO('B',105) 100 #define BIOCGDLT _IOR('B',106, u_int) 101 #define BIOCGETIF _IOR('B',107, struct ifreq) 102 #define BIOCSETIF _IOW('B',108, struct ifreq) 103 #define BIOCSRTIMEOUT _IOW('B',109, struct timeval) 104 #define BIOCGRTIMEOUT _IOR('B',110, struct timeval) 105 #define BIOCGSTATS _IOR('B',111, struct bpf_stat) 106 #define BIOCIMMEDIATE _IOW('B',112, u_int) 107 #define BIOCVERSION _IOR('B',113, struct bpf_version) 108 #define BIOCGRSIG _IOR('B',114, u_int) 109 #define BIOCSRSIG _IOW('B',115, u_int) 110 #define BIOCGHDRCMPLT _IOR('B',116, u_int) 111 #define BIOCSHDRCMPLT _IOW('B',117, u_int) 112 #define BIOCGSEESENT _IOR('B',118, u_int) 113 #define BIOCSSEESENT _IOW('B',119, u_int) 114 #define BIOCSDLT _IOW('B',120, u_int) 115 #define BIOCGDLTLIST _IOWR('B',121, struct bpf_dltlist) 116 #define BIOCLOCK _IO('B', 122) 117 #define BIOCSETWF _IOW('B',123, struct bpf_program) 118 119 /* 120 * Structure prepended to each packet. 121 */ 122 struct bpf_hdr { 123 struct timeval bh_tstamp; /* time stamp */ 124 bpf_u_int32 bh_caplen; /* length of captured portion */ 125 bpf_u_int32 bh_datalen; /* original length of packet */ 126 u_short bh_hdrlen; /* length of bpf header (this struct 127 plus alignment padding) */ 128 }; 129 /* 130 * Because the structure above is not a multiple of 4 bytes, some compilers 131 * will insist on inserting padding; hence, sizeof(struct bpf_hdr) won't work. 132 * Only the kernel needs to know about it; applications use bh_hdrlen. 133 */ 134 #ifdef _KERNEL 135 #define SIZEOF_BPF_HDR (sizeof(struct bpf_hdr) <= 20 ? 18 : \ 136 sizeof(struct bpf_hdr)) 137 #endif 138 139 /* 140 * Data-link level type codes. 141 */ 142 #define DLT_NULL 0 /* BSD loopback encapsulation */ 143 #define DLT_EN10MB 1 /* Ethernet (10Mb) */ 144 #define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */ 145 #define DLT_AX25 3 /* Amateur Radio AX.25 */ 146 #define DLT_PRONET 4 /* Proteon ProNET Token Ring */ 147 #define DLT_CHAOS 5 /* Chaos */ 148 #define DLT_IEEE802 6 /* IEEE 802 Networks */ 149 #define DLT_ARCNET 7 /* ARCNET */ 150 #define DLT_SLIP 8 /* Serial Line IP */ 151 #define DLT_PPP 9 /* Point-to-point Protocol */ 152 #define DLT_FDDI 10 /* FDDI */ 153 #define DLT_ATM_RFC1483 11 /* LLC/SNAP encapsulated atm */ 154 #define DLT_RAW 12 /* raw IP */ 155 156 /* 157 * These are values from BSD/OS's "bpf.h". 158 * These are not the same as the values from the traditional libpcap 159 * "bpf.h"; however, these values shouldn't be generated by any 160 * OS other than BSD/OS, so the correct values to use here are the 161 * BSD/OS values. 162 * 163 * Platforms that have already assigned these values to other 164 * DLT_ codes, however, should give these codes the values 165 * from that platform, so that programs that use these codes will 166 * continue to compile - even though they won't correctly read 167 * files of these types. 168 */ 169 #define DLT_SLIP_BSDOS 15 /* BSD/OS Serial Line IP */ 170 #define DLT_PPP_BSDOS 16 /* BSD/OS Point-to-point Protocol */ 171 172 #define DLT_ATM_CLIP 19 /* Linux Classical-IP over ATM */ 173 174 /* 175 * These values are defined by NetBSD; other platforms should refrain from 176 * using them for other purposes, so that NetBSD savefiles with link 177 * types of 50 or 51 can be read as this type on all platforms. 178 */ 179 #define DLT_PPP_SERIAL 50 /* PPP over serial with HDLC encapsulation */ 180 #define DLT_PPP_ETHER 51 /* PPP over Ethernet */ 181 182 /* 183 * Reserved for the Symantec Enterprise Firewall. 184 */ 185 #define DLT_SYMANTEC_FIREWALL 99 186 187 188 /* 189 * This value was defined by libpcap 0.5; platforms that have defined 190 * it with a different value should define it here with that value - 191 * a link type of 104 in a save file will be mapped to DLT_C_HDLC, 192 * whatever value that happens to be, so programs will correctly 193 * handle files with that link type regardless of the value of 194 * DLT_C_HDLC. 195 * 196 * The name DLT_C_HDLC was used by BSD/OS; we use that name for source 197 * compatibility with programs written for BSD/OS. 198 * 199 * libpcap 0.5 defined it as DLT_CHDLC; we define DLT_CHDLC as well, 200 * for source compatibility with programs written for libpcap 0.5. 201 */ 202 #define DLT_C_HDLC 104 /* Cisco HDLC */ 203 #define DLT_CHDLC DLT_C_HDLC 204 205 #define DLT_IEEE802_11 105 /* IEEE 802.11 wireless */ 206 207 /* 208 * Values between 106 and 107 are used in capture file headers as 209 * link-layer types corresponding to DLT_ types that might differ 210 * between platforms; don't use those values for new DLT_ new types. 211 */ 212 213 /* 214 * Frame Relay; BSD/OS has a DLT_FR with a value of 11, but that collides 215 * with other values. 216 * DLT_FR and DLT_FRELAY packets start with the Q.922 Frame Relay header 217 * (DLCI, etc.). 218 */ 219 #define DLT_FRELAY 107 220 221 /* 222 * OpenBSD DLT_LOOP, for loopback devices; it's like DLT_NULL, except 223 * that the AF_ type in the link-layer header is in network byte order. 224 * 225 * OpenBSD defines it as 12, but that collides with DLT_RAW, so we 226 * define it as 108 here. If OpenBSD picks up this file, it should 227 * define DLT_LOOP as 12 in its version, as per the comment above - 228 * and should not use 108 as a DLT_ value. 229 */ 230 #define DLT_LOOP 108 231 232 /* 233 * Values between 109 and 112 are used in capture file headers as 234 * link-layer types corresponding to DLT_ types that might differ 235 * between platforms; don't use those values for new DLT_ new types. 236 */ 237 238 /* 239 * Encapsulated packets for IPsec; DLT_ENC is 13 in OpenBSD, but that's 240 * DLT_SLIP_BSDOS in NetBSD, so we don't use 13 for it in OSes other 241 * than OpenBSD. 242 */ 243 #define DLT_ENC 109 244 245 /* 246 * This is for Linux cooked sockets. 247 */ 248 #define DLT_LINUX_SLL 113 249 250 /* 251 * Apple LocalTalk hardware. 252 */ 253 #define DLT_LTALK 114 254 255 /* 256 * Acorn Econet. 257 */ 258 #define DLT_ECONET 115 259 260 /* 261 * Reserved for use with OpenBSD ipfilter. 262 */ 263 #define DLT_IPFILTER 116 264 265 /* 266 * Reserved for use in capture-file headers as a link-layer type 267 * corresponding to OpenBSD DLT_PFLOG; DLT_PFLOG is 17 in OpenBSD, 268 * but that's DLT_LANE8023 in SuSE 6.3, so we can't use 17 for it 269 * in capture-file headers. 270 */ 271 #define DLT_PFLOG 117 272 273 /* 274 * Registered for Cisco-internal use. 275 */ 276 #define DLT_CISCO_IOS 118 277 278 /* 279 * Reserved for 802.11 cards using the Prism II chips, with a link-layer 280 * header including Prism monitor mode information plus an 802.11 281 * header. 282 */ 283 #define DLT_PRISM_HEADER 119 284 285 /* 286 * Reserved for Aironet 802.11 cards, with an Aironet link-layer header 287 * (see Doug Ambrisko's FreeBSD patches). 288 */ 289 #define DLT_AIRONET_HEADER 120 290 291 /* 292 * Reserved for use by OpenBSD's pfsync device. 293 */ 294 #define DLT_PFSYNC 121 295 296 /* 297 * Reserved for Siemens HiPath HDLC. XXX 298 */ 299 #define DLT_HHDLC 121 300 301 /* 302 * Reserved for RFC 2625 IP-over-Fibre Channel. 303 */ 304 #define DLT_IP_OVER_FC 122 305 306 /* 307 * Reserved for Full Frontal ATM on Solaris. 308 */ 309 #define DLT_SUNATM 123 310 311 /* 312 * Reserved as per request from Kent Dahlgren <kent@praesum.com> 313 * for private use. 314 */ 315 #define DLT_RIO 124 /* RapidIO */ 316 #define DLT_PCI_EXP 125 /* PCI Express */ 317 #define DLT_AURORA 126 /* Xilinx Aurora link layer */ 318 319 /* 320 * BSD header for 802.11 plus a number of bits of link-layer information 321 * including radio information. 322 */ 323 #ifndef DLT_IEEE802_11_RADIO 324 #define DLT_IEEE802_11_RADIO 127 325 #endif 326 327 /* 328 * Reserved for TZSP encapsulation. 329 */ 330 #define DLT_TZSP 128 /* Tazmen Sniffer Protocol */ 331 332 /* 333 * Reserved for Linux ARCNET. 334 */ 335 #define DLT_ARCNET_LINUX 129 336 337 /* 338 * Juniper-private data link types. 339 */ 340 #define DLT_JUNIPER_MLPPP 130 341 #define DLT_JUNIPER_MLFR 131 342 #define DLT_JUNIPER_ES 132 343 #define DLT_JUNIPER_GGSN 133 344 #define DLT_JUNIPER_MFR 134 345 #define DLT_JUNIPER_ATM2 135 346 #define DLT_JUNIPER_SERVICES 136 347 #define DLT_JUNIPER_ATM1 137 348 349 /* 350 * Apple IP-over-IEEE 1394, as per a request from Dieter Siegmund 351 * <dieter@apple.com>. The header that's presented is an Ethernet-like 352 * header: 353 * 354 * #define FIREWIRE_EUI64_LEN 8 355 * struct firewire_header { 356 * u_char firewire_dhost[FIREWIRE_EUI64_LEN]; 357 * u_char firewire_shost[FIREWIRE_EUI64_LEN]; 358 * u_short firewire_type; 359 * }; 360 * 361 * with "firewire_type" being an Ethernet type value, rather than, 362 * for example, raw GASP frames being handed up. 363 */ 364 #define DLT_APPLE_IP_OVER_IEEE1394 138 365 366 /* 367 * Various SS7 encapsulations, as per a request from Jeff Morriss 368 * <jeff.morriss[AT]ulticom.com> and subsequent discussions. 369 */ 370 #define DLT_MTP2_WITH_PHDR 139 /* pseudo-header with various info, followed by MTP2 */ 371 #define DLT_MTP2 140 /* MTP2, without pseudo-header */ 372 #define DLT_MTP3 141 /* MTP3, without pseudo-header or MTP2 */ 373 #define DLT_SCCP 142 /* SCCP, without pseudo-header or MTP2 or MTP3 */ 374 375 /* 376 * Reserved for DOCSIS. 377 */ 378 #define DLT_DOCSIS 143 379 380 /* 381 * Reserved for Linux IrDA. 382 */ 383 #define DLT_LINUX_IRDA 144 384 385 /* 386 * Reserved for IBM SP switch and IBM Next Federation switch. 387 */ 388 #define DLT_IBM_SP 145 389 #define DLT_IBM_SN 146 390 391 /* 392 * Reserved for private use. If you have some link-layer header type 393 * that you want to use within your organization, with the capture files 394 * using that link-layer header type not ever be sent outside your 395 * organization, you can use these values. 396 * 397 * No libpcap release will use these for any purpose, nor will any 398 * tcpdump release use them, either. 399 * 400 * Do *NOT* use these in capture files that you expect anybody not using 401 * your private versions of capture-file-reading tools to read; in 402 * particular, do *NOT* use them in products, otherwise you may find that 403 * people won't be able to use tcpdump, or snort, or Ethereal, or... to 404 * read capture files from your firewall/intrusion detection/traffic 405 * monitoring/etc. appliance, or whatever product uses that DLT_ value, 406 * and you may also find that the developers of those applications will 407 * not accept patches to let them read those files. 408 * 409 * Also, do not use them if somebody might send you a capture using them 410 * for *their* private type and tools using them for *your* private type 411 * would have to read them. 412 * 413 * Instead, ask "tcpdump-workers@tcpdump.org" for a new DLT_ value, 414 * as per the comment above, and use the type you're given. 415 */ 416 #define DLT_USER0 147 417 #define DLT_USER1 148 418 #define DLT_USER2 149 419 #define DLT_USER3 150 420 #define DLT_USER4 151 421 #define DLT_USER5 152 422 #define DLT_USER6 153 423 #define DLT_USER7 154 424 #define DLT_USER8 155 425 #define DLT_USER9 156 426 #define DLT_USER10 157 427 #define DLT_USER11 158 428 #define DLT_USER12 159 429 #define DLT_USER13 160 430 #define DLT_USER14 161 431 #define DLT_USER15 162 432 433 /* 434 * For future use with 802.11 captures - defined by AbsoluteValue 435 * Systems to store a number of bits of link-layer information 436 * including radio information: 437 * 438 * http://www.shaftnet.org/~pizza/software/capturefrm.txt 439 * 440 * but it might be used by some non-AVS drivers now or in the 441 * future. 442 */ 443 #define DLT_IEEE802_11_RADIO_AVS 163 /* 802.11 plus AVS radio header */ 444 445 /* 446 * Juniper-private data link type, as per request from 447 * Hannes Gredler <hannes@juniper.net>. The DLT_s are used 448 * for passing on chassis-internal metainformation such as 449 * QOS profiles, etc.. 450 */ 451 #define DLT_JUNIPER_MONITOR 164 452 453 /* 454 * Reserved for BACnet MS/TP. 455 */ 456 #define DLT_BACNET_MS_TP 165 457 458 /* 459 * Another PPP variant as per request from Karsten Keil <kkeil@suse.de>. 460 * 461 * This is used in some OSes to allow a kernel socket filter to distinguish 462 * between incoming and outgoing packets, on a socket intended to 463 * supply pppd with outgoing packets so it can do dial-on-demand and 464 * hangup-on-lack-of-demand; incoming packets are filtered out so they 465 * don't cause pppd to hold the connection up (you don't want random 466 * input packets such as port scans, packets from old lost connections, 467 * etc. to force the connection to stay up). 468 * 469 * The first byte of the PPP header (0xff03) is modified to accomodate 470 * the direction - 0x00 = IN, 0x01 = OUT. 471 */ 472 #define DLT_PPP_PPPD 166 473 474 /* 475 * Names for backwards compatibility with older versions of some PPP 476 * software; new software should use DLT_PPP_PPPD. 477 */ 478 #define DLT_PPP_WITH_DIRECTION DLT_PPP_PPPD 479 #define DLT_LINUX_PPP_WITHDIRECTION DLT_PPP_PPPD 480 481 /* 482 * Juniper-private data link type, as per request from 483 * Hannes Gredler <hannes@juniper.net>. The DLT_s are used 484 * for passing on chassis-internal metainformation such as 485 * QOS profiles, cookies, etc.. 486 */ 487 #define DLT_JUNIPER_PPPOE 167 488 #define DLT_JUNIPER_PPPOE_ATM 168 489 490 #define DLT_GPRS_LLC 169 /* GPRS LLC */ 491 #define DLT_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */ 492 #define DLT_GPF_F 171 /* GPF-F (ITU-T G.7041/Y.1303) */ 493 494 /* 495 * Requested by Oolan Zimmer <oz@gcom.com> for use in Gcom's T1/E1 line 496 * monitoring equipment. 497 */ 498 #define DLT_GCOM_T1E1 172 499 #define DLT_GCOM_SERIAL 173 500 501 /* 502 * Juniper-private data link type, as per request from 503 * Hannes Gredler <hannes@juniper.net>. The DLT_ is used 504 * for internal communication to Physical Interface Cards (PIC) 505 */ 506 #define DLT_JUNIPER_PIC_PEER 174 507 508 /* 509 * Link types requested by Gregor Maier <gregor@endace.com> of Endace 510 * Measurement Systems. They add an ERF header (see 511 * http://www.endace.com/support/EndaceRecordFormat.pdf) in front of 512 * the link-layer header. 513 */ 514 #define DLT_ERF_ETH 175 /* Ethernet */ 515 #define DLT_ERF_POS 176 /* Packet-over-SONET */ 516 517 /* 518 * Requested by Daniele Orlandi <daniele@orlandi.com> for raw LAPD 519 * for vISDN (http://www.orlandi.com/visdn/). Its link-layer header 520 * includes additional information before the LAPD header, so it's 521 * not necessarily a generic LAPD header. 522 */ 523 #define DLT_LINUX_LAPD 177 524 525 /* 526 * The instruction encodings. 527 */ 528 /* instruction classes */ 529 #define BPF_CLASS(code) ((code) & 0x07) 530 #define BPF_LD 0x00 531 #define BPF_LDX 0x01 532 #define BPF_ST 0x02 533 #define BPF_STX 0x03 534 #define BPF_ALU 0x04 535 #define BPF_JMP 0x05 536 #define BPF_RET 0x06 537 #define BPF_MISC 0x07 538 539 /* ld/ldx fields */ 540 #define BPF_SIZE(code) ((code) & 0x18) 541 #define BPF_W 0x00 542 #define BPF_H 0x08 543 #define BPF_B 0x10 544 #define BPF_MODE(code) ((code) & 0xe0) 545 #define BPF_IMM 0x00 546 #define BPF_ABS 0x20 547 #define BPF_IND 0x40 548 #define BPF_MEM 0x60 549 #define BPF_LEN 0x80 550 #define BPF_MSH 0xa0 551 552 /* alu/jmp fields */ 553 #define BPF_OP(code) ((code) & 0xf0) 554 #define BPF_ADD 0x00 555 #define BPF_SUB 0x10 556 #define BPF_MUL 0x20 557 #define BPF_DIV 0x30 558 #define BPF_OR 0x40 559 #define BPF_AND 0x50 560 #define BPF_LSH 0x60 561 #define BPF_RSH 0x70 562 #define BPF_NEG 0x80 563 #define BPF_JA 0x00 564 #define BPF_JEQ 0x10 565 #define BPF_JGT 0x20 566 #define BPF_JGE 0x30 567 #define BPF_JSET 0x40 568 #define BPF_SRC(code) ((code) & 0x08) 569 #define BPF_K 0x00 570 #define BPF_X 0x08 571 572 /* ret - BPF_K and BPF_X also apply */ 573 #define BPF_RVAL(code) ((code) & 0x18) 574 #define BPF_A 0x10 575 576 /* misc */ 577 #define BPF_MISCOP(code) ((code) & 0xf8) 578 #define BPF_TAX 0x00 579 #define BPF_TXA 0x80 580 581 /* 582 * The instruction data structure. 583 */ 584 struct bpf_insn { 585 u_short code; 586 u_char jt; 587 u_char jf; 588 bpf_u_int32 k; 589 }; 590 591 /* 592 * Macros for insn array initializers. 593 */ 594 #define BPF_STMT(code, k) { (u_short)(code), 0, 0, k } 595 #define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k } 596 597 /* 598 * Structure to retrieve available DLTs for the interface. 599 */ 600 struct bpf_dltlist { 601 u_int bfl_len; /* number of bfd_list array */ 602 u_int *bfl_list; /* array of DLTs */ 603 }; 604 605 #ifdef _KERNEL 606 struct bpf_if; 607 int bpf_validate(const struct bpf_insn *, int); 608 void bpf_tap(struct bpf_if *, u_char *, u_int); 609 void bpf_mtap(struct bpf_if *, struct mbuf *); 610 void bpf_mtap2(struct bpf_if *, void *, u_int, struct mbuf *); 611 void bpfattach(struct ifnet *, u_int, u_int); 612 void bpfattach2(struct ifnet *, u_int, u_int, struct bpf_if **); 613 void bpfdetach(struct ifnet *); 614 615 void bpfilterattach(int); 616 u_int bpf_filter(const struct bpf_insn *, u_char *, u_int, u_int); 617 618 #define BPF_TAP(_ifp,_pkt,_pktlen) do { \ 619 if ((_ifp)->if_bpf) \ 620 bpf_tap((_ifp)->if_bpf, (_pkt), (_pktlen)); \ 621 } while (0) 622 #define BPF_MTAP(_ifp,_m) do { \ 623 if ((_ifp)->if_bpf) { \ 624 M_ASSERTVALID(_m); \ 625 bpf_mtap((_ifp)->if_bpf, (_m)); \ 626 } \ 627 } while (0) 628 #define BPF_MTAP2(_ifp,_data,_dlen,_m) do { \ 629 if ((_ifp)->if_bpf) { \ 630 M_ASSERTVALID(_m); \ 631 bpf_mtap2((_ifp)->if_bpf,(_data),(_dlen),(_m)); \ 632 } \ 633 } while (0) 634 #endif 635 636 /* 637 * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST). 638 */ 639 #define BPF_MEMWORDS 16 640 641 #endif /* _NET_BPF_H_ */ 642