skb-> data_len,skb-> len,skb-> mac_len值是0是否正确?

时间:2016-11-12 08:06:36

标签: c netfilter

当我使用netfilter API时,

iph = ip_hdr(skb);
saddr = iph->saddr;        //unsigned long
daddr = iph->daddr;        //unsigned long

saddrdaddr的值不正确。

所以我测试了

printk("len = %u , data_len = %u , mac_len = %u , hdr_len = %u\n",skb->len , skb->data_len , skb->mac_len , skb->hdr_len);
printk("truesize = %u , data = %x\n",skb->truesize , &skb->data);

结果是:

enter image description here

这是正确的吗?

1 个答案:

答案 0 :(得分:2)

尝试以这种方式提取:

struct iphdr *ip_hdr = (struct iphdr *)skb_network_header(skb);

并以这种方式访问​​:

printk("source address = %u  destination address = %u\n", ip_hdr->saddr, ip_hdr->daddr);