cvs commit: src/sys/net bpf.h
Guy Harris
guy at alum.mit.edu
Wed Jun 9 21:27:25 GMT 2004
> This commit reminded me one of my old ideas. Why not to make some
> function that allow to change DLT on the fly?
Such as NetBSD's "bpf_change_type()"?
/*
* Change the data link type of a interface.
*/
void
bpf_change_type(ifp, dlt, hdrlen)
struct ifnet *ifp;
u_int dlt, hdrlen;
{
struct bpf_if *bp;
for (bp = bpf_iflist; bp != NULL; bp = bp->bif_next) {
if (bp->bif_driverp == (struct bpf_if **)&ifp->if_bpf)
break;
}
if (bp == NULL)
panic("bpf_change_type");
bp->bif_dlt = dlt;
/*
* Compute the length of the bpf header. This is not
necessarily
* equal to SIZEOF_BPF_HDR because we want to insert spacing
such
* that the network layer header begins on a longword boundary
(for
* performance reasons and to alleviate alignment restrictions).
*/
bp->bif_hdrlen = BPF_WORDALIGN(hdrlen + SIZEOF_BPF_HDR) -
hdrlen;
}
More information about the freebsd-net
mailing list