<div dir="ltr"><div>ip [2:2] is the packet length. So ip [2:2] > 650 would filter for packets greater than length 650.<br><br></div><div>If you google ip [2:2] you should find various bpf resources explaining how to look at other ip fields.<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 29, 2015 at 11:45 PM, Juan Herrera <span dir="ltr"><<a href="mailto:mybsdmailing@gmail.com" target="_blank">mybsdmailing@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello BSD folks,<br><br>I am developing a networking application in C and I have a question regarding BPF (Berkeley Packet Filters), I will give you an idea of the app first,  I need to send a packet from machine A to machine B (any kind of packet) so for this I wrote a packet generator application which will send a packet to machine B, but before sending the packet I need to append some metadata values at the end of the packet, already done, so in machine B I have a raw socket listener app ready to receive incoming packets from machine A, however I want to implement filtering with BPF on machine B, but as my metadata was appended at the end of the packet (have to be at the end), I need to read the packet length with(using) Berkeley Packet Filter to match a specific field to filter one of the bytes at the end of my packet (metadata appended), in other words I need to know the incoming packet length to filtered against one of the metadatas fields and be able to drop the packet before reaching user space applications(drop it in kernel space).<br><br>So my question is, Can I use BPF to read the packet length ?<br><br>TIA!<br><br><br><br></div>
<br>_______________________________________________<br>
CDBUG-talk mailing list<br>
<a href="mailto:CDBUG-talk@lists.nycbug.org">CDBUG-talk@lists.nycbug.org</a><br>
<a href="http://lists.nycbug.org/mailman/listinfo/cdbug-talk" rel="noreferrer" target="_blank">http://lists.nycbug.org/mailman/listinfo/cdbug-talk</a><br></blockquote></div><br></div>