FreeBSD/sys/net/bpf.c
/*
 * Attach an interface to bpf.  ifp is a pointer to the structure
 * defining the interface to be attached, dlt is the link layer type,
 * and hdrlen is the fixed size of the link header (variable length
 * headers are not yet supporrted).
 */
Attach an interface to bpf.  ifp is a pointer to the structure
defining the interface to be attached, dlt is the link layer type,
and hdrlen is the fixed size of the link header (variable length
headers are not yet supporrted).
Attach an interface to bpf . ifp is a pointer to the structure defining the interface to be attached dlt is the link layer type and hdrlen is the fixed size of the link header ( variable length headers are not yet supporrted ) .
void
bpfattach2(struct ifnet *ifp, u_int dlt, u_int hdrlen, struct bpf_if **driverp)
{
	struct bpf_if *bp;
	bp = malloc(sizeof(*bp), M_BPF, M_NOWAIT | M_ZERO);
	if (bp == NULL)
		panic("bpfattach");
	LIST_INIT(&bp->bif_dlist);
	LIST_INIT(&bp->bif_wlist);
	bp->bif_ifp = ifp;
	bp->bif_dlt = dlt;
	rw_init(&bp->bif_lock, "bpf interface lock");
	KASSERT(*driverp == NULL, ("bpfattach2: driverp already initialized"));
	*driverp = bp;
	BPF_LOCK();
	LIST_INSERT_HEAD(&bpf_iflist, bp, bif_next);
	BPF_UNLOCK();
	bp->bif_hdrlen = hdrlen;
	if (bootverbose && IS_DEFAULT_VNET(curvnet))
		if_printf(ifp, "bpf attached\n");
}
void bpfattach2 ( struct ifnet * ifp , u_int dlt , u_int hdrlen , struct bpf_if * * driverp ) { struct bpf_if * bp ; bp = malloc ( sizeof ( * bp ) , M_BPF , M_NOWAIT | M_ZERO ) ; if ( bp == NULL ) panic ( " " ) ; LIST_INIT ( & bp -> bif_dlist ) ; LIST_INIT ( & bp -> bif_wlist ) ; bp -> bif_ifp = ifp ; bp -> bif_dlt = dlt ; rw_init ( & bp -> bif_lock , " " ) ; KASSERT ( * driverp == NULL , ( " " ) ) ; * driverp = bp ; BPF_LOCK ( ) ; LIST_INSERT_HEAD ( & bpf_iflist , bp , bif_next ) ; BPF_UNLOCK ( ) ; bp -> bif_hdrlen = hdrlen ; if ( bootverbose && IS_DEFAULT_VNET ( curvnet ) ) if_printf ( ifp , " \n " ) ; }
Attach an interface to bpf.
Attach an interface to bpf .