BPF code generation for radiotap
Can I help someone with BPF know-how to write a radiotap code generator? It would be great if we could use BPF to filter out packets with, say, an RSSI below a certain threshold.
Dave
Signature · 2 lines
David Young OJC Technologies [email protected] Urbana, IL * (217) 278-3933
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 3 lines · David Young
Can I help someone with BPF know-how to write a radiotap code generator? It would be great if we could use BPF to filter out packets with, say, an RSSI below a certain threshold.
That will be possible only if the RSSI can be found without a loop, or if you're willing to have all the filtering done in userland. The kernel BPF interpreter doesn't support backwards branches; the userland one does, to support chasing IPv6 protocol headers, but backward branches completely screw up the optimizer (so it gets turned off).
A message that is not in the archive (sent off-list or not yet received): 46450124.1010809-FrUbXkNCsVf2fBVCVOL8/[email protected]
Quoted 7 lines · Guy Harris
Quoted 3 lines · David Young
Can I help someone with BPF know-how to write a radiotap code generator? It would be great if we could use BPF to filter out packets with, say, an RSSI below a certain threshold.
That will be possible only if the RSSI can be found without a loop, or if you're willing to have all the filtering done in userland. The
Right now, all radiotap fields can be found without a loop.
Dave
Signature · 2 lines
David Young OJC Technologies [email protected] Urbana, IL * (217) 278-3933
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 1 line · David Young
Right now, all radiotap fields can be found without a loop.
I.e., can be found with a completely unrolled loop.
I might have to work on the optimizer to handle code such as
if (field XXX is present) add AAA to the offset into the packet; if (field YYY is present) add BBB to the offset into the packet;
etc. - I remember seeing problems such as that when trying to handle either the token ring header (which is variable-length, with source routing stuff) or the 802.11 header in full generality (some frames have 4 MAC addresses - those are frames being sent from one access point to another access point, right?).
A message that is not in the archive (sent off-list or not yet received): 46451D83.2070003-FrUbXkNCsVf2fBVCVOL8/[email protected]
Quoted 5 lines · Guy Harris
Quoted 1 line · David Young
Right now, all radiotap fields can be found without a loop.
I.e., can be found with a completely unrolled loop.
Correct.
*snip snip*
Quoted 3 lines
or the 802.11 header in full generality (some frames have
4 MAC addresses - those are frames being sent from one access point to another access point, right?).
Right.
Dave
Signature · 2 lines
David Young OJC Technologies [email protected] Urbana, IL * (217) 278-3933
Quoted 6 lines · Guy Harris
I might have to work on the optimizer to handle code such as
if (field XXX is present) add AAA to the offset into the packet; if (field YYY is present) add BBB to the offset into the packet;
I don't think that is completely correct, the radiotap header says that fields are naturally aligned and this code doesn't handle that. In many scenarios alignment will not be needed but I wouldn't want to rely on that.
It'd have to look something like
if (field XXX is present)
add A-1 to the offset
mask offset with ~A
/* do whatever with field XXX */
add AAA to the offset into the packet
...
where A is the alignment of the field XXX.
This should be correct, but I can't seem to find an authoritative statement on how exactly alignment is to be treated and whether it is with respect to the beginning of the header (as it must be!)
Out of curiosity; what could be optimised with above code, and what does that optimiser do?
johannes