Changeset View
Changeset View
Standalone View
Standalone View
sys/net/bpf.h
Show First 20 Lines • Show All 363 Lines • ▼ Show 20 Lines | |||||
struct bpf_insn { | struct bpf_insn { | ||||
u_short code; | u_short code; | ||||
u_char jt; | u_char jt; | ||||
u_char jf; | u_char jf; | ||||
bpf_u_int32 k; | bpf_u_int32 k; | ||||
}; | }; | ||||
/* | /* | ||||
* Load operations for _bpf_filter to use against the packet pointer. | |||||
*/ | |||||
struct bpf_ops { | |||||
u_int32_t (*ldw)(const void *, u_int32_t, int *); | |||||
u_int32_t (*ldh)(const void *, u_int32_t, int *); | |||||
u_int32_t (*ldb)(const void *, u_int32_t, int *); | |||||
}; | |||||
/* | |||||
* Macros for insn array initializers. | * Macros for insn array initializers. | ||||
*/ | */ | ||||
#define BPF_STMT(code, k) { (u_short)(code), 0, 0, k } | #define BPF_STMT(code, k) { (u_short)(code), 0, 0, k } | ||||
#define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k } | #define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k } | ||||
__BEGIN_DECLS | |||||
u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int); | |||||
u_int _bpf_filter(const struct bpf_insn *, const struct bpf_ops *, | |||||
const void *, u_int); | |||||
int bpf_validate(const struct bpf_insn *, int); | |||||
__END_DECLS | |||||
/* | /* | ||||
* Structure to retrieve available DLTs for the interface. | * Structure to retrieve available DLTs for the interface. | ||||
*/ | */ | ||||
struct bpf_dltlist { | struct bpf_dltlist { | ||||
u_int bfl_len; /* number of bfd_list array */ | u_int bfl_len; /* number of bfd_list array */ | ||||
u_int *bfl_list; /* array of DLTs */ | u_int *bfl_list; /* array of DLTs */ | ||||
}; | }; | ||||
Show All 15 Lines | #define ROTATE_BUFFERS(d) do { \ | ||||
(d)->bd_hbuf = (d)->bd_sbuf; \ | (d)->bd_hbuf = (d)->bd_sbuf; \ | ||||
(d)->bd_hlen = (d)->bd_slen; \ | (d)->bd_hlen = (d)->bd_slen; \ | ||||
(d)->bd_sbuf = (d)->bd_fbuf; \ | (d)->bd_sbuf = (d)->bd_fbuf; \ | ||||
(d)->bd_slen = 0; \ | (d)->bd_slen = 0; \ | ||||
(d)->bd_fbuf = NULL; \ | (d)->bd_fbuf = NULL; \ | ||||
bpf_bufheld(d); \ | bpf_bufheld(d); \ | ||||
} while (0) | } while (0) | ||||
struct ifnet; | |||||
struct mbuf; | |||||
/* | /* | ||||
* Descriptor associated with each attached hardware interface. | * Descriptor associated with each attached hardware interface. | ||||
* Part of this structure is exposed to external callers to speed up | * Part of this structure is exposed to external callers to speed up | ||||
* bpf_peers_present() calls. | * bpf_peers_present() calls. | ||||
*/ | */ | ||||
struct bpf_if; | struct bpf_if; | ||||
CK_LIST_HEAD(bpfd_list, bpf_d); | CK_LIST_HEAD(bpfd_list, bpf_d); | ||||
struct bpf_if_ext { | struct bpf_if_ext { | ||||
CK_LIST_ENTRY(bpf_if) bif_next; /* list of all interfaces */ | CK_LIST_ENTRY(bpf_if) bif_next; /* list of all interfaces */ | ||||
struct bpfd_list bif_dlist; /* descriptor list */ | struct bpfd_list bif_dlist; /* descriptor list */ | ||||
}; | }; | ||||
void bpf_bufheld(struct bpf_d *d); | void bpf_bufheld(struct bpf_d *d); | ||||
int bpf_validate(const struct bpf_insn *, int); | |||||
void bpf_tap(struct bpf_if *, u_char *, u_int); | void bpf_tap(struct bpf_if *, u_char *, u_int); | ||||
void bpf_mtap(struct bpf_if *, struct mbuf *); | void bpf_mtap(struct bpf_if *, struct mbuf *); | ||||
void bpf_mtap2(struct bpf_if *, void *, u_int, struct mbuf *); | void bpf_mtap2(struct bpf_if *, void *, u_int, struct mbuf *); | ||||
void bpfattach(struct ifnet *, u_int, u_int); | void bpfattach(struct ifnet *, u_int, u_int); | ||||
void bpfattach2(struct ifnet *, u_int, u_int, struct bpf_if **); | void bpfattach2(struct ifnet *, u_int, u_int, struct bpf_if **); | ||||
void bpfdetach(struct ifnet *); | void bpfdetach(struct ifnet *); | ||||
#ifdef VIMAGE | #ifdef VIMAGE | ||||
int bpf_get_bp_params(struct bpf_if *, u_int *, u_int *); | int bpf_get_bp_params(struct bpf_if *, u_int *, u_int *); | ||||
#endif | #endif | ||||
void bpfilterattach(int); | void bpfilterattach(int); | ||||
u_int bpf_filter(const struct bpf_insn *, u_char *, u_int, u_int); | u_int bpf_mfilter(const struct bpf_insn *, const struct mbuf *, u_int); | ||||
static __inline int | static __inline int | ||||
bpf_peers_present(struct bpf_if *bpf) | bpf_peers_present(struct bpf_if *bpf) | ||||
{ | { | ||||
struct bpf_if_ext *ext; | struct bpf_if_ext *ext; | ||||
ext = (struct bpf_if_ext *)bpf; | ext = (struct bpf_if_ext *)bpf; | ||||
if (!CK_LIST_EMPTY(&ext->bif_dlist)) | if (!CK_LIST_EMPTY(&ext->bif_dlist)) | ||||
Show All 12 Lines | #define BPF_MTAP(_ifp,_m) do { \ | ||||
} \ | } \ | ||||
} while (0) | } while (0) | ||||
#define BPF_MTAP2(_ifp,_data,_dlen,_m) do { \ | #define BPF_MTAP2(_ifp,_data,_dlen,_m) do { \ | ||||
if (bpf_peers_present((_ifp)->if_bpf)) { \ | if (bpf_peers_present((_ifp)->if_bpf)) { \ | ||||
M_ASSERTVALID(_m); \ | M_ASSERTVALID(_m); \ | ||||
bpf_mtap2((_ifp)->if_bpf,(_data),(_dlen),(_m)); \ | bpf_mtap2((_ifp)->if_bpf,(_data),(_dlen),(_m)); \ | ||||
} \ | } \ | ||||
} while (0) | } while (0) | ||||
#endif | #endif /* _KERNEL */ | ||||
/* | /* | ||||
* Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST). | * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST). | ||||
*/ | */ | ||||
#define BPF_MEMWORDS 16 | #define BPF_MEMWORDS 16 | ||||
/* BPF attach/detach events */ | /* BPF attach/detach events */ | ||||
struct ifnet; | struct ifnet; | ||||
typedef void (*bpf_track_fn)(void *, struct ifnet *, int /* dlt */, | typedef void (*bpf_track_fn)(void *, struct ifnet *, int /* dlt */, | ||||
int /* 1 =>'s attach */); | int /* 1 =>'s attach */); | ||||
EVENTHANDLER_DECLARE(bpf_track, bpf_track_fn); | EVENTHANDLER_DECLARE(bpf_track, bpf_track_fn); | ||||
#endif /* _NET_BPF_H_ */ | #endif /* _NET_BPF_H_ */ |