On Tue, Aug 03, 2010 at 03:11:10PM +0100, Paul LeoNerd Evans wrote:
Of course, I completely forgot about finding also the offset of the
'next header' from the current header. That results in some code which,
in C, would look like:
int hdrtype = b[IPv6_nexthdr];
int x = size_of_IPv6_header;
while(hdrtype != hdr_wanted) {
int len;
switch(hdrtype) {
case 1:
len = someconst;
hdrtype = someotherconst;
break;
case 2:
len = b[x+someoffs];
hdrtype = b[x+someotheroffs];
break;
/* other IPv6 header types here */
}
x += len;
}
You can't compile that idea into BPF without using a scratch memory
cell, because you can't have both 'len' and 'hdrtype' live in A at the
same time, nor can you atomically x += b[x+someoffs].
In short, much much easier if the C code did this part...
--
Paul "LeoNerd" Evans
leonerd@leonerd.org.uk
ICQ# 4135350 | Registered Linux# 179460
http://www.leonerd.org.uk/