关于构造skb 的问题,高手来谈谈看法吧!
条件:已有从eth0来的skb, 数据拷贝入以太网桢缓冲区framebuff, 且有记录桢长度frame_len,释放此skb
目的:把此缓冲区数据组成新的skb,从eth1发送出去
以下发送函数
static int br_assemble_outgoing_skb(unsigned char * framebuff,
unsigned long int frame_len,
struct net_device *todev)
{
struct sk_buff *skb;
int res =0;
//unsigned short protocol = 0;
//unsigned char *smac ;
//unsigned char *dmac;
//unsigned char* netlayer_hdr;
printk(KERN_ALERT "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~n");
printk("Will Assemble packet n");
skb = dev_alloc_skb(frame_len+2);
if (skb != NULL)
{
skb_put(skb,frame_len);
memcpy(skb->data, framebuff,frame_len);
skb->protocol = ( (struct ethhdr *)framebuff)->h_proto;
skb->dev = todev;
//skb ->ip_summed = 0;
//CHECKSUM_UNNECESSARY;
skb->pkt_type = PACKET_OUTGOING;
skb->mac.raw = skb->data;;
skb->nh.raw = skb->data+sizeof(struct ethhdr);
printk("Assemble packet 0x%.4x to todev %s frame_len:%ld succ n",
ntohs(skb->protocol),
todev->name,
frame_len);
res= dev_queue_xmit(skb);
if (res < 0) {
dev_kfree_skb(skb);
dev_put(todev);
}
printk("dev xmit send 0x%.4x packet to %s succ n",ntohs(skb->protocol ),skb->dev->name);
printk(KERN_ALERT "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~n");
}
return 0;
}
为何发送几个.10几个frame就死机了呢?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论