kernel 调试 打印IP地址

 

#define NIPQUAD(addr) \
((unsigned char *)&addr)[0], \
((unsigned char *)&addr)[1], \
((unsigned char *)&addr)[2], \
((unsigned char *)&addr)[3]

 

struct iphdr *nh;

struct sk_buff *skb;

nh = ip_hdr(skb);

printk(KERN_INFO "src: %u.%u.%u.%u, dst: %u.%u.%u.%u\n", NIPQUAD(nh->saddr), NIPQUAD(nh->daddr));

posted @ 2019-01-28 17:31  salami_china  阅读(829)  评论(0编辑  收藏  举报