Networking 使用netfilter模块将IP选项字段附加到IP标头

Networking 使用netfilter模块将IP选项字段附加到IP标头,networking,linux-kernel,c,Networking,Linux Kernel,C,根据以下代码: #include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/netfilter.h> #include <linux/netfilter_ipv4.h> #include <linux/skbuff.h> #include <linu

根据以下代码:

#include <linux/module.h>       
#include <linux/kernel.h>       
#include <linux/init.h>         

#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
#include <linux/skbuff.h>
#include <linux/ip.h>    
#include <linux/inet.h>   

static struct nf_hook_ops nfho;


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);
     ...
     ...


     return NF_ACCEPT;
}
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
静态结构nf_hook_ops nfho;
unsigned int hook_func(unsigned int hooknum,
结构sk_buff*skb,
const struct net_device*in,
const结构网络设备*out,
int(*okfn)(结构sk_buff*))
{    
结构iphdr*ip_头;
结构tcphdr*tcp_头;
ip_头=ip_hdr(skb);
ip_头=(结构iphdr*)skb_网络_头(skb);
skb_设置_传输_头(skb,ip_头->ihl*4);
tcp_头=(结构tcphdr*)skb_传输_头(skb);
...
...
返回NF_接受;
}
我们可以访问数据包, 现在我想知道我可以在这里把IP选项字段附加到IP头吗

 struct iphdr *ip_header;
 bind(hooknum,(sk_buff *) &ip_header,sizeof(ip_header));
 struct tcphdr *tcp_header;
 bind(hooknum,(sk_buff *) &tcp_header,sizeof(tcp_header));