Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Dec 2015 16:46:39 +0800
From:      Julian Elischer <julian@freebsd.org>
To:        Juan Herrera <mybsdmailing@gmail.com>, freebsd-net@freebsd.org
Subject:   Re: BPF Berkeley Packet Filter
Message-ID:  <568399EF.2090409@freebsd.org>
In-Reply-To: <CAAN2wCCpbivX6B3xCt4wFCw_6eOQ40nquVJf%2Bz-8RRVyUFa7mA@mail.gmail.com>
References:  <CAAN2wCCpbivX6B3xCt4wFCw_6eOQ40nquVJf%2Bz-8RRVyUFa7mA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 30/12/2015 12:22 PM, Juan Herrera wrote:
> Hello BSD folks,
>
> 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).
>
> So my question is, Can I use BPF to read the packet length to do what I
> want?
you mean can you use a bpf filter to act upon a trailer?
yes you can
look at the man page for BPF_LD and BPF_LEN


>
> Thank you in advance!
>
> Happy Holidays!
> _______________________________________________
> freebsd-net@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-net
> To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"
>




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?568399EF.2090409>