为了更方便的调试报文,需要对sk_buff的真正数据载荷进行调试输出,只需要在驱动中加入如下代码就可以调试了
static void qdmalib_dump_skb(struct sk_buff *skb, struct net_device *dev){
int i = 0;
if(!skb || !dev){
pr_err("%s: bad param\n",__FUNCTION__);
goto out;
}
netdev_printk(KERN_INFO, dev, "TX loopback packets(data_len = %d): \n",skb->len);
for (i = 0; i < skb->len; i++){
if(0 == i % 8){
printk("\t");
}
if(0 == i % 2){
printk(" ");
}
printk("%02x", *(skb->data + i));
if(7 == i % 8){
printk("\n");
}
}
printk("\n");
out:
return;
}
调用者
int qdmalib_tx(struct sk_buff *skb, struct net_device *dev)
{
................
qdmalib_dump_skb(skb, dev);
................
return 0;
}
输出效果