Ejemplo n.º 1
0
static struct sk_buff *cdc_mbim_process_dgram(struct usbnet *dev, u8 *buf, size_t len, u16 tci)
{
	__be16 proto = htons(ETH_P_802_3);
	struct sk_buff *skb = NULL;

	if (tci < 256) { /* IPS session? */
		if (len < sizeof(struct iphdr))
			goto err;

		switch (*buf & 0xf0) {
		case 0x40:
			proto = htons(ETH_P_IP);
			break;
		case 0x60:
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
			if (is_neigh_solicit(buf, len))
				do_neigh_solicit(dev, buf, tci);
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0) */
			proto = htons(ETH_P_IPV6);
			break;
		default:
			goto err;
		}
	}

	skb = netdev_alloc_skb_ip_align(dev->net,  len + ETH_HLEN);
	if (!skb)
		goto err;

	/* add an ethernet header */
	skb_put(skb, ETH_HLEN);
	skb_reset_mac_header(skb);
	eth_hdr(skb)->h_proto = proto;
	memset(eth_hdr(skb)->h_source, 0, ETH_ALEN);
	memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN);

	/* add datagram */
	memcpy(skb_put(skb, len), buf, len);

	/* map MBIM session to VLAN */
	if (tci)
		vlan_put_tag(skb, htons(ETH_P_8021Q), tci);
err:
	return skb;
}
Ejemplo n.º 2
0
/*******************************************************************************
 函数名称  :    sub_if_dev_hard_start_xmit
 功能描述  :    子接口发送函数
 输入参数  :    skb/net_device
 输出参数  :    无
 返回值    :    
                0               设置成功
 --------------------------------------------------------------------------------
 最近一次修改记录 :
 修改作者   :       王松波
 修改目的   :       新增函数
 修改日期   :       2010-09-16
********************************************************************************/
static int sub_if_dev_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
{
    struct sub_interface_priv *sub_if_priv;


    sub_if_priv = (struct sub_interface_priv *)dev->priv;

	skb->mac.raw = skb->data;
    skb = vlan_put_tag(skb, sub_if_priv->tag);
    if(!skb)
    {
        return -EINVAL;
    }

    skb->dev = sub_if_priv->real_dev;
    dev_queue_xmit(skb);
    
    return 0;
}