Changeset View
Changeset View
Standalone View
Standalone View
sys/net/bpf.h
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
/* BSD style release date */ | /* BSD style release date */ | ||||
#define BPF_RELEASE 199606 | #define BPF_RELEASE 199606 | ||||
typedef int32_t bpf_int32; | typedef int32_t bpf_int32; | ||||
typedef u_int32_t bpf_u_int32; | typedef u_int32_t bpf_u_int32; | ||||
typedef int64_t bpf_int64; | typedef int64_t bpf_int64; | ||||
typedef u_int64_t bpf_u_int64; | typedef u_int64_t bpf_u_int64; | ||||
struct ifnet; | |||||
/* | /* | ||||
* Alignment macros. BPF_WORDALIGN rounds up to the next multiple of | * Alignment macros. BPF_WORDALIGN rounds up to the next multiple of | ||||
* BPF_ALIGNMENT. | * BPF_ALIGNMENT. | ||||
*/ | */ | ||||
#define BPF_ALIGNMENT sizeof(long) | #define BPF_ALIGNMENT sizeof(long) | ||||
#define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1)) | #define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1)) | ||||
▲ Show 20 Lines • Show All 352 Lines • ▼ Show 20 Lines | |||||
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); | 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_tap_if(struct ifnet *, u_char *, u_int); | |||||
void bpf_mtap(struct bpf_if *, struct mbuf *); | void bpf_mtap(struct bpf_if *, struct mbuf *); | ||||
void bpf_mtap_if(struct ifnet *, 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 bpf_mtap2_if(struct ifnet *, 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_filter(const struct bpf_insn *, u_char *, u_int, 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)) | ||||
return (1); | return (1); | ||||
return (0); | return (0); | ||||
} | } | ||||
#define BPF_TAP(_ifp,_pkt,_pktlen) do { \ | #define BPF_TAP(_ifp,_pkt,_pktlen) \ | ||||
if (bpf_peers_present((_ifp)->if_bpf)) \ | bpf_tap_if((_ifp), (_pkt), (_pktlen)) | ||||
bpf_tap((_ifp)->if_bpf, (_pkt), (_pktlen)); \ | #define BPF_MTAP(_ifp,_m) \ | ||||
} while (0) | bpf_mtap_if((_ifp), (_m)) | ||||
#define BPF_MTAP(_ifp,_m) do { \ | #define BPF_MTAP2(_ifp,_data,_dlen,_m) \ | ||||
if (bpf_peers_present((_ifp)->if_bpf)) { \ | bpf_mtap2_if((_ifp), (_data), (_dlen), (_m)) | ||||
M_ASSERTVALID(_m); \ | |||||
bpf_mtap((_ifp)->if_bpf, (_m)); \ | |||||
} \ | |||||
} while (0) | |||||
#define BPF_MTAP2(_ifp,_data,_dlen,_m) do { \ | |||||
if (bpf_peers_present((_ifp)->if_bpf)) { \ | |||||
M_ASSERTVALID(_m); \ | |||||
bpf_mtap2((_ifp)->if_bpf,(_data),(_dlen),(_m)); \ | |||||
} \ | |||||
} while (0) | |||||
#endif | #endif | ||||
/* | /* | ||||
* 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; | |||||
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_ */ |