- 论坛徽章:
- 0
|
条件:已有从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就死机了呢? |
|