首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用netfilter模块将IP选项字段附加到IP报头

使用netfilter模块将IP选项字段附加到IP报头
EN

Stack Overflow用户
提问于 2014-05-11 02:22:08
回答 1查看 477关注 0票数 0

根据下面的代码:

代码语言:javascript
复制
#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;
}

我们可以访问数据包,现在我想知道我是否可以在此处将IP选项字段附加到IP报头?

EN

回答 1

Stack Overflow用户

发布于 2014-05-11 04:57:49

代码语言:javascript
复制
 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));
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23586517

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档