LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-14-2014, 02:06 PM   #1
kikilinux
Member
 
Registered: Sep 2012
Posts: 125

Rep: Reputation: Disabled
Question modify ip option field by netfilter loadable kernel module


Hi
I want to modify IP option field by netfilter loadable kernel module.
I extract the IP header by the the bellow code :

struct iphdr * ip_header = (struct iphdr *)skb_network_header(skb);

and i want to modify IP option field, for example applying "AND" operator to a specific byte of IP option field, then i think after modifying i have to run bellow command to correct checksum too:

ip_header->check = 0;
ip_send_check(ip_header);

How can i perform Modifying;

The complete code is as bellow:

static unsigned int hook_func(unsigned int hooknum,
struct sk_buff *skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
struct iphdr *ip_header;
struct tcphdr *tcp_header;

//ip_header = ip_hdr(skb);

ip_header = (struct iphdr *)skb_network_header(skb);
skb_set_transport_header(skb, ip_header->ihl * 4);
tcp_header = (struct tcphdr *)skb_transport_header(skb);


ip_header->check = 0; // after modifying IP option field
ip_send_check(ip_header);

return NF_ACCEPT;
}
 
  


Reply

Tags
netfilter, netfilter modules



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Optimizing the Kernel - Loadable Module Support Option? boler Linux - Software 1 01-02-2009 03:02 PM
Use of -Wall option in CFLAGS while make for a loadable module Ashok_mittal Linux - Newbie 1 01-18-2008 06:32 AM
Help, loadable kernel module . ERBRMN Linux - General 3 10-13-2006 07:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration