xref: /netbsd-src/share/man/man9/bpf.9 (revision 7f21db1c0118155e0dd40b75182e30c589d9f63e)
1.\"     $NetBSD: bpf.9,v 1.1 2010/01/20 12:09:39 pooka Exp $
2.\"
3.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25.\" POSSIBILITY OF SUCH DAMAGE.
26.\"
27.Dd January 20, 2010
28.Dt BPF 9
29.Os
30.Sh NAME
31.Nm bpf
32.Nd Berkeley Packet Filter kernel interface
33.Sh SYNOPSIS
34.In sys/mbuf.h
35.In net/bpf.h
36.Sh DESCRIPTION
37.Nm
38is called via an operations vector described by the following struct:
39.Pp
40.Bd -literal
41struct bpf_ops {
42        void (*bpf_attach)(struct ifnet *, u_int, u_int, struct bpf_if **);
43        void (*bpf_detach)(struct ifnet *);
44        void (*bpf_change_type)(struct ifnet *, u_int, u_int);
45
46        void (*bpf_tap)(struct bpf_if *, u_char *, u_int);
47        void (*bpf_mtap)(struct bpf_if *, struct mbuf *);
48        void (*bpf_mtap2)(struct bpf_if *, void *, u_int, struct mbuf *);
49        void (*bpf_mtap_af)(struct bpf_if *, uint32_t, struct mbuf *);
50        void (*bpf_mtap_et)(struct bpf_if *, uint16_t, struct mbuf *);
51        void (*bpf_mtap_sl_in)(struct bpf_if *, u_char *, struct mbuf **);
52        void (*bpf_mtap_sl_out)(struct bpf_if *, u_char *, struct mbuf *);
53};
54.Ed
55.Pp
56This vector is found from
57.Vt struct bpf_ops *
58.Va bpf_ops ,
59and is either a stub implementation or a real implementation depending
60on if bpf is absent or present in the kernel, respectively.
61.Sh CODE REFERENCES
62This section describes places within the
63.Nx
64source tree where the implementation can be found.
65All pathnames are relative to
66.Pa /usr/src .
67.Pp
68The
69.Nm
70implementation is located in
71.Pa sys/net/bpf.c ,
72the stub implementation is in
73.Pa sys/net/bpf_stub.c
74and the interface is defined in
75.Pa sys/net/bpf.h .
76