FreeBSD/sys/net/bpf.c
/*
 * Set the data link type of a BPF instance.
 */
Set the data link type of a BPF instance.
Set the data link type of a BPF instance .
static int
bpf_setdlt(struct bpf_d *d, u_int dlt)
{
	int error, opromisc;
	struct ifnet *ifp;
	struct bpf_if *bp;
	BPF_LOCK_ASSERT();
	if (d->bd_bif->bif_dlt == dlt)
		return (0);
	ifp = d->bd_bif->bif_ifp;
	LIST_FOREACH(bp, &bpf_iflist, bif_next) {
		if (bp->bif_ifp == ifp && bp->bif_dlt == dlt)
			break;
	}
	if (bp != NULL) {
		opromisc = d->bd_promisc;
		bpf_attachd(d, bp);
		BPFD_LOCK(d);
		reset_d(d);
		BPFD_UNLOCK(d);
		if (opromisc) {
			error = ifpromisc(bp->bif_ifp, 1);
			if (error)
				if_printf(bp->bif_ifp,
					"bpf_setdlt: ifpromisc failed (%d)\n",
					error);
			else
				d->bd_promisc = 1;
		}
	}
	return (bp == NULL ? EINVAL : 0);
}
static int bpf_setdlt ( struct bpf_d * d , u_int dlt ) { int error , opromisc ; struct ifnet * ifp ; struct bpf_if * bp ; BPF_LOCK_ASSERT ( ) ; if ( d -> bd_bif -> bif_dlt == dlt ) return ( 0 ) ; ifp = d -> bd_bif -> bif_ifp ; LIST_FOREACH ( bp , & bpf_iflist , bif_next ) { if ( bp -> bif_ifp == ifp && bp -> bif_dlt == dlt ) break ; } if ( bp != NULL ) { opromisc = d -> bd_promisc ; bpf_attachd ( d , bp ) ; BPFD_LOCK ( d ) ; reset_d ( d ) ; BPFD_UNLOCK ( d ) ; if ( opromisc ) { error = ifpromisc ( bp -> bif_ifp , 1 ) ; if ( error ) if_printf ( bp -> bif_ifp , " \n " , error ) ; else d -> bd_promisc = 1 ; } } return ( bp == NULL ? EINVAL : 0 ) ; }
Set the data link type of a BPF instance.
Set the data link type of a BPF instance .