Mangling IP Options
Hi
I'm trying to write a target to mangle IP options fields, but I'm new to netfilter (and linux, for that matter) and am struggling to understand some of the kernel data structures. In particular I need to know where to insert/overwrite IP options fields. I'm using Fabrice's ipt_IPV4OPTSTRIP.c as a starting point, as it clears the fields I'm wanting to alter.
What I don't quite understand is the difference between the ip_options structure in:
(unsigned char *)(skb.nh.iph) + sizeof (struct iphdr) /* skb is a (struct sk_buff *) */
and the one in:
IPCB(skb)->opt
which is a macro that expands to:
((struct inet_skb_parm)(skb->cb))-opt
Why two copies of the ip_options in two different places? The one appears to be a compiled version of the other?
The other thing I don't get is where the actual IP options fields reside, and in what format? I have RFC791, and know the structure of the options in the IP packet, but clearly this is not identical to the structure of struct ip_options, which has a mysterious
unsigned char __data[0]
field at the end. I assume the stuff is in there, but how do I decode this?
Any help much appreciated.
Q