Hi all.
I'm writing a module using netfilter that is supposed to show the
contents of the IPv6 header (if you wonder why, its an excercise in
order to wirte more useful modules later). I have registered a hook that
looks like this :
static unsigned int ip6hsniff_hook(unsigned int hook,
struct
sk_buff **pskb,
const struct
net_device *in,
const struct
net_device *out,
int
(*okfn)(struct sk_buff *)){
struct ipv6hdr *ip6;
u_int32_t flow;
unsigned int version, class, flowlabel;
ip6 = (*pskb)->nh.ipv6h;
flow = (u_int32_t) (*pskb)->nh.ipv6h;
flow = ntohl(flow);
flowlabel = flow & 0x000FFFFF;
class = (flow & 0x0FF00000) >> 20;
version = (flow & 0xF0000000) >> 28;
printk("15: payload_len: %d nexthdr: %d Version: %x Class: %x
FlowLabel: %x hop_limit: %d ", ip6->payload_len, ip6->nexthdr,
version,class,flowlabel,ip6->hop_limit);
return NF_ACCEPT;
}
To try my brand new module a issue this:
# ping6 -c 100 fec0::192.168.2.2 -F 00000
PING fec0::192.168.2.2(fec0::c0a8:202) , flow 0x59baa, from
fec0::c0a8:102 : 56 data bytes
64 bytes from fec0::c0a8:202: icmp_seq=0 hops=63 time=14.343 msec
etc etc etc
on another machine. The module prints out things (I see the result with
dmesg) but the flowlabel (as far as I can tell) is'nt right.
15: payload_len: 16384 nexthdr: 58 Version: 7 Class: 1 FlowLabel: 68ea0
hop_limit: 64
I must be interpreting the header in the wrong way. I've been staring
myself blind at this problem for 2 days now.
Does anyone have a clue what I'm doing wrong in the code-snippet above?
|