```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 *iph = NULL;
struct ethhdr *eth = NULL;
if(!skb)
return NF_ACCEPT;
iph = ip_hdr(skb);
eth = eth_hdr(skb);
if(!eth || !iph)
return NF_ACCEPT;
printk(“skb->len===%u\n",skb->len);
}
/* 初始化程序 /
int init_module()
{
/ 填充我们的hook数据结构 /
nfho.hook = hook_func; / 处理函数 /
nfho.hooknum = NF_IP_PRE_ROUTING; / 使用IPv4的第一个hook /
nfho.pf = PF_INET;
nfho.priority = NF_IP_PRI_FIRST; / 让我们的函数首先执行 */
nf_register_hook(&nfho);
return 0;
}
/* 清除程序 */
void cleanup_module()
{
nf_unregister_hook(&nfho);
}
为甚么 skb->len总是等于0;