bpf.h (149376) | bpf.h (159180) |
---|---|
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. --- 20 unchanged lines hidden (view full) --- 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 * | 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. --- 20 unchanged lines hidden (view full) --- 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: head/sys/net/bpf.h 149376 2005-08-22 19:35:48Z csjp $ | 37 * $FreeBSD: head/sys/net/bpf.h 159180 2006-06-02 19:59:33Z csjp $ |
38 */ 39 40#ifndef _NET_BPF_H_ 41#define _NET_BPF_H_ 42 43/* BSD style release date */ 44#define BPF_RELEASE 199606 45 --- 552 unchanged lines hidden (view full) --- 598 * Structure to retrieve available DLTs for the interface. 599 */ 600struct 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 | 38 */ 39 40#ifndef _NET_BPF_H_ 41#define _NET_BPF_H_ 42 43/* BSD style release date */ 44#define BPF_RELEASE 199606 45 --- 552 unchanged lines hidden (view full) --- 598 * Structure to retrieve available DLTs for the interface. 599 */ 600struct 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 |
606struct bpf_if; | 606/* 607 * Descriptor associated with each attached hardware interface. 608 */ 609struct bpf_if { 610 LIST_ENTRY(bpf_if) bif_next; /* list of all interfaces */ 611 LIST_HEAD(, bpf_d) bif_dlist; /* descriptor list */ 612 u_int bif_dlt; /* link layer type */ 613 u_int bif_hdrlen; /* length of header (with padding) */ 614 struct ifnet *bif_ifp; /* corresponding interface */ 615 struct mtx bif_mtx; /* mutex for interface */ 616}; 617 |
607int bpf_validate(const struct bpf_insn *, int); 608void bpf_tap(struct bpf_if *, u_char *, u_int); 609void bpf_mtap(struct bpf_if *, struct mbuf *); 610void bpf_mtap2(struct bpf_if *, void *, u_int, struct mbuf *); 611void bpfattach(struct ifnet *, u_int, u_int); 612void bpfattach2(struct ifnet *, u_int, u_int, struct bpf_if **); 613void bpfdetach(struct ifnet *); 614 615void bpfilterattach(int); 616u_int bpf_filter(const struct bpf_insn *, u_char *, u_int, u_int); 617 | 618int bpf_validate(const struct bpf_insn *, int); 619void bpf_tap(struct bpf_if *, u_char *, u_int); 620void bpf_mtap(struct bpf_if *, struct mbuf *); 621void bpf_mtap2(struct bpf_if *, void *, u_int, struct mbuf *); 622void bpfattach(struct ifnet *, u_int, u_int); 623void bpfattach2(struct ifnet *, u_int, u_int, struct bpf_if **); 624void bpfdetach(struct ifnet *); 625 626void bpfilterattach(int); 627u_int bpf_filter(const struct bpf_insn *, u_char *, u_int, u_int); 628 |
629static __inline int 630bpf_peers_present(struct bpf_if *bpf) 631{ 632 633 return !LIST_EMPTY(&bpf->bif_dlist); 634} 635 |
|
618#define BPF_TAP(_ifp,_pkt,_pktlen) do { \ | 636#define BPF_TAP(_ifp,_pkt,_pktlen) do { \ |
619 if ((_ifp)->if_bpf) \ | 637 if (bpf_peers_present((_ifp)->if_bpf)) \ |
620 bpf_tap((_ifp)->if_bpf, (_pkt), (_pktlen)); \ 621} while (0) 622#define BPF_MTAP(_ifp,_m) do { \ | 638 bpf_tap((_ifp)->if_bpf, (_pkt), (_pktlen)); \ 639} while (0) 640#define BPF_MTAP(_ifp,_m) do { \ |
623 if ((_ifp)->if_bpf) { \ | 641 if (bpf_peers_present((_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 { \ | 642 M_ASSERTVALID(_m); \ 643 bpf_mtap((_ifp)->if_bpf, (_m)); \ 644 } \ 645} while (0) 646#define BPF_MTAP2(_ifp,_data,_dlen,_m) do { \ |
629 if ((_ifp)->if_bpf) { \ | 647 if (bpf_peers_present((_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_ */ | 648 M_ASSERTVALID(_m); \ 649 bpf_mtap2((_ifp)->if_bpf,(_data),(_dlen),(_m)); \ 650 } \ 651} while (0) 652#endif 653 654/* 655 * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST). 656 */ 657#define BPF_MEMWORDS 16 658 659#endif /* _NET_BPF_H_ */ |