Is it true that this tap interface only allows inspection of incoming packets, but does not allow generation of outgoing packets?<div><br></div><div>I did a little nosing around in the networking code.  bpf.h is present, but bpf.c is not.  I'm assuming that this file would need to be ported from FreeBSD to allow generation of and operation on the device nodes.  Additionally bpf support would need to be added to the ethernet drivers, as Daron supposed.</div>
<div><br></div><div>I'm torn between diving into this and making it happen, or just rewriting my peripheral to generate UDP packets for communication on this interface.  Does anyone see a need for this in the future?</div>
<div><br></div><div>Thanks,</div><div><br></div><div>Brett<br><br><div class="gmail_quote">On Thu, Apr 14, 2011 at 3:35 PM, Eric Norum <span dir="ltr"><<a href="mailto:wenorum@lbl.gov">wenorum@lbl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word">The documentation for this is in the networking suplement:<div><br></div><div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
3.4.2 Tapping Into an Interface</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">RTEMS add two new ioctls to the BSD networking code: SIOCSIFTAP and SIOCGIFTAP. These may be used to set and get a <span style="font:10.9px Helvetica">tap function</span>. The tap function will be called for every Ethernet packet received by the interface.</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">These are called like other interface ioctls, such as SIOCSIFADDR. When setting the tap function with SIOCSIFTAP, set the ifr tap field of the ifreq struct to the tap function. When retrieving the tap function with SIOCGIFTAP, the current tap function will be returned in the ifr tap field. To stop tapping packets, call SIOCSIFTAP with a ifr tap field of 0.</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">The tap function is called like this:</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">int tap (struct ifnet *, struct ether_header *, struct mbuf *)</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">The tap function should return 1 if the packet was fully handled, in which case the caller will simply discard the mbuf. The tap function should return 0 if the packet should be passed up to the higher networking layers.</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">The tap function is called with the network semaphore locked. It must not make any calls on the application levels of the networking level itself. It is safe to call other non-networking RTEMS functions.</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><br></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><br></div><div><div class="im"><div>On Apr 14, 2011, at 2:21 PM, Daron Chabot wrote:</div>
<br></div><blockquote type="cite"><div><div></div><div class="h5"><br><br><div class="gmail_quote">On Thu, Apr 14, 2011 at 5:16 PM, Brett Swimley <span dir="ltr"><<a href="mailto:brett.swimley@aedbozeman.com" target="_blank">brett.swimley@aedbozeman.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Thanks Daron,<div><br></div><div>I had found this reference, and it appears that libpcap uses this API, so I will continue looking. I'm hoping that the RTEMS stack does support bpf.</div></blockquote><div><br>I had a brief grep through the source tree and noted that there were only 3 NIC drivers that had the bpf_mtap( ) interface (all ported from FreeBSD!):<br>


<br>dchabot@dev32new--> git grep -n bpf c/src/libchip/network <br>c/src/libchip/network/i82586.c:1280:  if (sc->arpcom.ac_if.if_bpf != 0)<br>c/src/libchip/network/i82586.c:1282:    bpf_mtap(sc->arpcom.ac_if.if_bpf, m);<br>


c/src/libchip/network/i82586.c:1378:    if (ifp->if_bpf)<br>c/src/libchip/network/i82586.c:1379:      bpf_mtap(ifp->if_bpf, m0);<br>c/src/libchip/network/if_dc.c:159:#include <net/bpf.h><br>c/src/libchip/network/if_dc.c:3372:             if (ifp->if_bpf)<br>


c/src/libchip/network/if_dc.c:3373:                     bpf_mtap(ifp, m_head);<br>c/src/libchip/network/if_fxp.c:87:#include <net/bpf.h><br>c/src/libchip/network/if_fxp.c:1262:             * Pass packet to bpf if there i<br>


c/src/libchip/network/if_fxp.c:1264:            if (ifp->if_bpf)<br>c/src/libchip/network/if_fxp.c:1265:                    bpf_mtap(ifp, mb_head);<br><br>But, on further inspection, the bpf_mtaps( ) were "#if 0"'d out of commission.<br>


<br>Then there's the issue of creating /dev/bpfX device nodes...<br><br>I would be surprised if someone out there doesn't have something already, perhaps created to support message passing between nodes of a distributed, multi-processing system?<br>


<br>I'm looking at you Till... ;-)<br><br><br>-- dc<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div><br></div><font color="#888888"><div>


Brett</div></font><div><div></div><div>
<div><br><br><div class="gmail_quote">On Thu, Apr 14, 2011 at 2:30 PM, Daron Chabot <span dir="ltr"><<a href="mailto:daron.chabot@gmail.com" target="_blank">daron.chabot@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



Hi Brett,<br><br>I have not looked into this in much detail, but since RTEMS' network stack is ported from FreeBSD, you may be able to use the Berkley Packet Filter (bpf) API for this.<br><br><br><br>-- dc<br><br><br>



<div class="gmail_quote"><div><div></div><div><br></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div><div class="im">
_______________________________________________<br>rtems-users mailing list<br><a href="mailto:rtems-users@rtems.org" target="_blank">rtems-users@rtems.org</a><br><a href="http://www.rtems.org/mailman/listinfo/rtems-users" target="_blank">http://www.rtems.org/mailman/listinfo/rtems-users</a><br>
</div></blockquote></div><br><div class="im"><div>
<div>-- <br>Eric Norum<br><a href="mailto:wenorum@lbl.gov" target="_blank">wenorum@lbl.gov</a></div>
</div>
<br></div></div></div></blockquote></div><br></div>