【发布时间】:2013-06-22 17:52:01
【问题描述】:
我正在尝试将来自机器的所有数据包的源 IP 修改为我在此内核模块中指定的内容,但每次我尝试访问 nh.iph->saddr 时都会收到错误消息在 编译 的时候,说 Struct sk_buff 没有名为 nh 的成员
我在这里做错了什么?
我错过了一些标题吗??
#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> /* For IP header */
#include <linux/inet.h> /* For in_aton(); htonl(); and other related Network utility functions */
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 sk_buff *sb = *skb;
struct in_addr masterIP;
masterIP.s_addr = htonl (in_aton("192.168.1.10"));
sb->nh.iph->saddr = masterIP.s_addr;
return NF_ACCEPT;
}
请注意,我运行的是 Ubuntu 10.04 LTS 64 位
内核 2.6.32-33
【问题讨论】:
标签: linux-kernel kernel-module