有这样两个宏可以方便地打印mac地址:
#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
使用样例如下:
struct ethhdr *eh = (struct ethhdr *)skb->mac.raw;
printk(KERN_INFO "SOURCE:" MAC_FMT "\n", MAC_ARG(eh->h_source));
printk(KERN_INFO "DEST:" MAC_FMT "\n", MAC_ARG(eh->h_dest));
阅读(1468) | 评论(0) | 转发(0) |