Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Jun 2004 14:27:19 -0700
From:      Guy Harris <guy@alum.mit.edu>
To:        Roman Kurakin <rik@cronyx.ru>
Cc:        net@FreeBSD.org
Subject:   Re: cvs commit: src/sys/net bpf.h
Message-ID:  <C9710634-BA5B-11D8-B046-000A958097E4@alum.mit.edu>

next in thread | raw e-mail | index | archive | help
> 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;
}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C9710634-BA5B-11D8-B046-000A958097E4>