Projects…interjects…Part Deux!
Yesterday was a fantastic day trying to get the IP data field to be pointed to by in the skbuff structure. The documentation in the files did not help make things clearer.
The situation was where I was supposed to use the
unsigned char* data field in the skbuff structure to point to the IP data starting point.
Tried a lot of pointer math and the following finally worked:
IP Data pointer location:
unsigned char * ptr = sb->data +
sb->nh.iph->ihl*4;
int byte_size = ntohs(sb->nh.iph->tot_len) –
sb->nh.iph->ihl*4;
In fact, Vinay Reddy (vinayvinay@gmail.com) suggested something which I think was even better than the stuff that was working for me. He said the pointer value should be:
unsigned char * ptr = sb->nh.iph->raw + sb->nh.iph->ihl*4;
I think this actually grabs the gist of what I exactly want to do.
I *really* want to point with respect to the IP Header. I do not really care about where sb->data really points to so I guess Vinay’s method is much better. Haven’t implemented it so I really don’t know but sounds the most logical!
– Rajat
http://www-scf.usc.edu/~swarup/
uh-huh.. jholu.. kyaaaaeeeeeee ye kyaeeeeee ye kyaeeeee… woh kyaaaaeee.. kisiki yaad aye? 🙂
Was this answer helpful?
LikeDislikekaka…yaad aane ke liye kuchh bacha hi nahin hai!
totally sapped because of this project man!
-Rajat
Was this answer helpful?
LikeDislikeHi,
Hope you are having fun with your project. Google for the piconet code, by alex song, that could give you a few pointers on how to write kernel networking code. In fact, we have used it to make our own protocol, using the netfilter hooks.
-Devesh