编译模块时出现'struct skbuff’ 没有名为'nh'的成员的错误

interlc 2009-10-26 09:18:21
编译模块时出现‘struct sk_buff’ 没有名为 ‘nh’ 的成员的错误
从网上找了一段关于netfilter下hook的代码,实验一下,代码如下:
#include <linux/init.h>
#include <linux/types.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/netfilter_ipv4.h>
#include <linux/inet.h>
#include <linux/in.h>
#include <linux/ip.h>

static unsigned int icmp_srv(unsigned int hook,
struct sk_buff **pskb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *)
)
{
//printk(KERN_INFO"hook_icmp::icmp_srv()\n");
struct iphdr *iph = (*pskb)->nh.iph;

if(iph->protocol == IPPROTO_ICMP)
{
printk(KERN_INFO"hook_icmp::icmp_srv: receive ICMP packet\n");
printk(KERN_INFO"src: ");
}

return NF_ACCEPT;
}

static struct nf_hook_ops icmpsrv_ops =
{
.hook = icmp_srv,
.pf = PF_INET,
.hooknum = NF_IP_PRE_ROUTING,
.priority = NF_IP_PRI_FILTER -1,
};

static int __init init_hook_icmp(void)
{
return nf_register_hook(&icmpsrv_ops);
}

static void __exit fini_hook_icmp(void)
{
nf_unregister_hook(&icmpsrv_ops);
}

MODULE_LICENSE("GPL");

module_init(init_hook_icmp);
module_exit(fini_hook_icmp);

然后就出现了上面讲得错误,请问怎么解决
...全文
407 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hefuhua 2009-10-30
  • 打赏
  • 举报
回复
去网上找找,和看看内核的修改日志文件
interlc 2009-10-30
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 elfirex 的回复:]
源程序对应的内核版本跟你用的版本不一样。
内核更新基本不考虑内核代码的兼容性。
[/Quote]
如果想要成功应该怎么做呢
zkuang82 2009-10-26
  • 打赏
  • 举报
回复
源程序对应的内核版本跟你用的版本不一样。
内核更新基本不考虑内核代码的兼容性。

4,469

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧