我试图修改从机器输出的所有数据包的源IP到我在这个内核模块中指定的东西,但每次我尝试访问nh.iph-> saddr我在编译时得到一个错误说Struct sk_buff没有任何成员命名为nh
我在做什么错在这里? 我错过了一些标题或东西?如何到达struct sk_buff成员?
#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
非常感谢= D解决^^ 编辑:IP校验,好吧... 但为什么传输数据包校验和? – Fingolfin 2012-04-05 12:36:59
例如,UDP校验和占所谓的“ip伪头”,这意味着UDP校验和使用IP头的某些字段,例如源地址和目标地址。我不太记得,但我认为TCP也是这样做的。 – Fred 2012-04-05 13:00:36