1 .\" Copyright (c) 2004 FreeBSD Inc.
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL [your name] OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .Nd "Berkeley Packet Filter"
39 .Fn bpfattach "struct ifnet *ifp" "u_int dlt" "u_int hdrlen"
42 .Fa "struct ifnet *ifp" "u_int dlt" "u_int hdrlen" "struct bpf_if **driverp"
45 .Fn bpfdetach "struct ifnet *ifp"
47 .Fn bpf_tap "struct ifnet *ifp" "u_char *pkt" "u_int *pktlen"
49 .Fn bpf_mtap "struct ifnet *ifp" "struct mbuf *m"
51 .Fn bpf_mtap2 "struct bpf_if *bp" "void *data" "u_int dlen" "struct mbuf *m"
54 .Fa "const struct bpf_insn *pc " "u_char *pkt" "u_int wirelen" "u_int buflen"
57 .Fn bpf_validate "const struct bpf_insn *fcode" "int flen"
60 The Berkeley Packet Filter provides a raw interface,
61 that is protocol independent,
63 It allows all packets on the network,
64 even those destined for other hosts,
65 to be passed from a network interface to user programs.
66 Each program may specify a filter,
69 filter machine program.
73 describes the interface used by user programs.
74 This manual page describes the functions used by interfaces to pass packets to
76 and the functions for testing and running
78 filter machine programs.
83 attaches a network interface to
88 is a pointer to the structure that defines the interface to be
89 attached to an interface.
93 is the data link-layer type:
95 (no link-layer encapsulation),
99 (802.11 wireless networks),
101 The rest of the link layer types can be found in
106 is the fixed size of the link header;
107 variable length headers are not yet supported.
110 system will hold a pointer to
112 This variable will set to a
116 requires packets from this interface to be tapped using the functions below.
123 instances to be attached to a single interface,
124 by registering an explicit
128 It is then possible to run
130 on the interface for any data link-layer types attached.
136 instance from an interface,
142 should be called once for each
149 is used by an interface to pass the packet to
151 The packet data (including link-header),
156 which must be a contiguous buffer.
160 is a pointer to the structure that defines the interface to be tapped.
161 The packet is parsed by each processes filter,
163 it is buffered for the process to read.
169 except that it is used to tap packets that are in an
176 is a pointer to the structure that defines the interface to be tapped.
180 requires a link-header for whatever data link layer type is specified.
186 it does not free it or keep a pointer to it.
189 containing the link-header
190 can be prepended to the chain if necessary.
191 A cleaner interface to achieve this is provided by
197 allows the user to pass a link-header
204 containing the packet.
205 This simplifies the passing of some link-headers.
210 executes the filter program starting at
217 is the length of the original packet and
219 is the amount of data present.
222 value of 0 is special; it indicates that the
224 is actually a pointer to an mbuf chain
225 .Pq Vt "struct mbuf *" .
230 checks that the filter code
240 (cast to an unsigned integer)
241 if there is no filter.
242 Otherwise, it returns the result of the filter program.
247 returns 0 when the program is not a valid filter program.
254 The Enet packet filter was created in 1980 by Mike Accetta and
255 Rick Rashid at Carnegie-Mellon University.
260 and continued its development from 1983 on.
262 it has evolved into the Ultrix Packet Filter at
275 of Lawrence Berkeley Laboratory, implemented BPF in Summer 1990.
276 Much of the design is due to
278 This manpage was written by