From a3d0b8a79a432820dee80b1583f1acf86d256e97 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 10 Dec 1998 19:42:29 +0000 Subject: Patch from Ian Lance Taylor : From: Eric Norum Date: Sat, 5 Dec 98 13:20:51 -0600 What do you think of this patch? It implements your `tap' suggestion in a way that adds support for all ethernet devices with no driver modifications. I also added a return value from the tap function. If the return value is zero, the packet will be passed up the chain as usual. If the return value is non-zero the mbuf holding the packet will be freed and the packet will be dropped. If you like it, please submit it to Joel. I guess there needs to be an addition to the network documentation describing the additional ioctl's -- and a big warning that the tap function is called from a context that holds the network semaphore. Here is Eric's patch. I've tested it a bit, and made a couple of trivial changes. This is certainly better than mine: it should work for all Ethernet drivers. ================================================== The only concern I have about this patch is that the tap function may want to fiddle with the mbuf, calling functions like m_pullup and the like. If those force the networking code to rearrange the mbuf structure, then the caller's call to m_freem may crash. I don't know if this is a realistic concern--I don't know enough about the mbuf layer. --- cpukit/libnetworking/net/if_ethersubr.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'cpukit/libnetworking/net/if_ethersubr.c') diff --git a/cpukit/libnetworking/net/if_ethersubr.c b/cpukit/libnetworking/net/if_ethersubr.c index 4d1675ca3c..2a6446ebb6 100644 --- a/cpukit/libnetworking/net/if_ethersubr.c +++ b/cpukit/libnetworking/net/if_ethersubr.c @@ -483,6 +483,15 @@ ether_input(ifp, eh, m) if (m->m_flags & (M_BCAST|M_MCAST)) ifp->if_imcasts++; + /* + * RTEMS addition -- allow application to `tap into' + * the incoming packet stream. + */ + if (ifp->if_tap && (*ifp->if_tap)(ifp, eh, m)) { + m_freem(m); + return; + } + ether_type = ntohs(eh->ether_type); switch (ether_type) { -- cgit v1.2.3