本文整理汇总了C++中dev_hard_header函数的典型用法代码示例。如果您正苦于以下问题:C++ dev_hard_header函数的具体用法?C++ dev_hard_header怎么用?C++ dev_hard_header使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dev_hard_header函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: dsr_hw_header_create
int dsr_hw_header_create(struct dsr_pkt *dp, struct sk_buff *skb)
{
struct sockaddr broadcast =
{ AF_UNSPEC, {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} };
struct neighbor_info neigh_info;
if (dp->dst.s_addr == DSR_BROADCAST)
memcpy(neigh_info.hw_addr.sa_data, broadcast.sa_data, ETH_ALEN);
else {
/* Get hardware destination address */
if (neigh_tbl_query(dp->nxt_hop, &neigh_info) < 0) {
DEBUG
("Could not get hardware address for next hop %s\n",
print_ip(dp->nxt_hop));
return -1;
}
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
if (skb->dev->hard_header) {
skb->dev->hard_header(skb, skb->dev, ETH_P_IP,
neigh_info.hw_addr.sa_data, 0, skb->len);
} else {
DEBUG("Missing hard_header\n");
return -1;
}
#else
dev_hard_header(skb, skb->dev, ETH_P_IP,
neigh_info.hw_addr.sa_data, 0, skb->len);
#endif
return 0;
}
开发者ID:chyileon,项目名称:iie_leon,代码行数:33,代码来源:dsr-dev.c
示例2: mhost_finish_output
/* DOWNSTACK: MASTER FUNCTION CALLED BY L3
* analagous to ip_output and ip_finish_output{2}
* they then call the equivalent of neigh_connected_output
* A LOT of arp shit happens here too!
* for reference: Figure 27.13
*/
int mhost_finish_output(struct sk_buff *skb, struct net_device *dev, const void *daddr)
{
int err = 0;
// printk(KERN_INFO "mhost_finish_output called\n");
/* set device-specific header here... */
skb->protocol = htons(ETH_P_MHOST);
skb->dev = dev;
err = dev_hard_header(skb, dev, ntohs(skb->protocol),
daddr, NULL, skb->len);
/* ...and ship off to the device driver! */
if (err >= 0) {
err = dev_queue_xmit(skb);
if (err < 0) {
printk(KERN_INFO "error: dev_queue_xmit!\n");
}
}
else {
printk(KERN_INFO "error: dev_hard_header returned %d\n", err);
err = -EINVAL;
kfree_skb(skb);
}
return err;
}
开发者ID:spencersevilla,项目名称:mnet,代码行数:32,代码来源:mhost_l3_wrapper.c
示例3: tipc_l2_send_msg
/**
* tipc_l2_send_msg - send a TIPC packet out over an L2 interface
* @buf: the packet to be sent
* @b_ptr: the bearer through which the packet is to be sent
* @dest: peer destination address
*/
int tipc_l2_send_msg(struct sk_buff *buf, struct tipc_bearer *b,
struct tipc_media_addr *dest)
{
struct sk_buff *clone;
struct net_device *dev;
int delta;
dev = (struct net_device *)rcu_dereference_rtnl(b->media_ptr);
if (!dev)
return 0;
clone = skb_clone(buf, GFP_ATOMIC);
if (!clone)
return 0;
delta = dev->hard_header_len - skb_headroom(buf);
if ((delta > 0) &&
pskb_expand_head(clone, SKB_DATA_ALIGN(delta), 0, GFP_ATOMIC)) {
kfree_skb(clone);
return 0;
}
skb_reset_network_header(clone);
clone->dev = dev;
clone->protocol = htons(ETH_P_TIPC);
dev_hard_header(clone, dev, ETH_P_TIPC, dest->value,
dev->dev_addr, clone->len);
dev_queue_xmit(clone);
return 0;
}
开发者ID:3null,项目名称:linux,代码行数:36,代码来源:bearer.c
示例4: tipc_l2_send_msg
/**
* tipc_l2_send_msg - send a TIPC packet out over an L2 interface
* @skb: the packet to be sent
* @b: the bearer through which the packet is to be sent
* @dest: peer destination address
*/
int tipc_l2_send_msg(struct net *net, struct sk_buff *skb,
struct tipc_bearer *b, struct tipc_media_addr *dest)
{
struct net_device *dev;
int delta;
void *tipc_ptr;
dev = (struct net_device *)rcu_dereference_rtnl(b->media_ptr);
if (!dev)
return 0;
/* Send RESET message even if bearer is detached from device */
tipc_ptr = rcu_dereference_rtnl(dev->tipc_ptr);
if (unlikely(!tipc_ptr && !msg_is_reset(buf_msg(skb))))
goto drop;
delta = dev->hard_header_len - skb_headroom(skb);
if ((delta > 0) &&
pskb_expand_head(skb, SKB_DATA_ALIGN(delta), 0, GFP_ATOMIC))
goto drop;
skb_reset_network_header(skb);
skb->dev = dev;
skb->protocol = htons(ETH_P_TIPC);
dev_hard_header(skb, dev, ETH_P_TIPC, dest->value,
dev->dev_addr, skb->len);
dev_queue_xmit(skb);
return 0;
drop:
kfree_skb(skb);
return 0;
}
开发者ID:ironbox360,项目名称:linux-ubifs,代码行数:38,代码来源:bearer.c
示例5: send_msg
/**
* send_msg - send a TIPC message out over an InfiniBand interface
*/
static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
struct tipc_media_addr *dest)
{
struct sk_buff *clone;
struct net_device *dev;
int delta;
clone = skb_clone(buf, GFP_ATOMIC);
if (!clone)
return 0;
dev = ((struct ib_bearer *)(tb_ptr->usr_handle))->dev;
delta = dev->hard_header_len - skb_headroom(buf);
if ((delta > 0) &&
pskb_expand_head(clone, SKB_DATA_ALIGN(delta), 0, GFP_ATOMIC)) {
kfree_skb(clone);
return 0;
}
skb_reset_network_header(clone);
clone->dev = dev;
clone->protocol = htons(ETH_P_TIPC);
dev_hard_header(clone, dev, ETH_P_TIPC, dest->value,
dev->dev_addr, clone->len);
dev_queue_xmit(clone);
return 0;
}
开发者ID:yuwgit,项目名称:pmfs,代码行数:31,代码来源:ib_media.c
示例6: p8023_request
static int p8023_request(struct datalink_proto *dl,
struct sk_buff *skb, unsigned char *dest_node)
{
struct net_device *dev = skb->dev;
dev_hard_header(skb, dev, ETH_P_802_3, dest_node, NULL, skb->len);
return dev_queue_xmit(skb);
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:8,代码来源:p8023.c
示例7: pn_send
/*
* Prepends an ISI header and sends a datagram.
*/
static int pn_send(struct sk_buff *skb, struct net_device *dev,
u16 dst, u16 src, u8 res, u8 irq)
{
struct phonethdr *ph;
int err;
if (skb->len + 2 > 0xffff /* Phonet length field limit */ ||
skb->len + sizeof(struct phonethdr) > dev->mtu) {
err = -EMSGSIZE;
goto drop;
}
/* Broadcast sending is not implemented */
if (pn_addr(dst) == PNADDR_BROADCAST) {
err = -EOPNOTSUPP;
goto drop;
}
skb_reset_transport_header(skb);
WARN_ON(skb_headroom(skb) & 1); /* HW assumes word alignment */
skb_push(skb, sizeof(struct phonethdr));
skb_reset_network_header(skb);
ph = pn_hdr(skb);
ph->pn_rdev = pn_dev(dst);
ph->pn_sdev = pn_dev(src);
ph->pn_res = res;
ph->pn_length = __cpu_to_be16(skb->len + 2 - sizeof(*ph));
ph->pn_robj = pn_obj(dst);
ph->pn_sobj = pn_obj(src);
skb->protocol = htons(ETH_P_PHONET);
skb->priority = 0;
skb->dev = dev;
if (pn_addr(src) == pn_addr(dst)) {
skb_reset_mac_header(skb);
skb->pkt_type = PACKET_LOOPBACK;
skb_orphan(skb);
if (irq)
netif_rx(skb);
else
netif_rx_ni(skb);
err = 0;
} else {
err = dev_hard_header(skb, dev, ntohs(skb->protocol),
NULL, NULL, skb->len);
if (err < 0) {
err = -EHOSTUNREACH;
goto drop;
}
err = dev_queue_xmit(skb);
}
return err;
drop:
kfree_skb(skb);
return err;
}
开发者ID:jiacc0110,项目名称:Android-Froyo-Kernel-Source-v2.6.32.9,代码行数:61,代码来源:af_phonet.c
示例8: pEII_request
static int pEII_request(struct datalink_proto *dl,
struct sk_buff *skb, unsigned char *dest_node)
{
struct net_device *dev = skb->dev;
skb->protocol = htons(ETH_P_IPX);
dev_hard_header(skb, dev, ETH_P_IPX, dest_node, NULL, skb->len);
return dev_queue_xmit(skb);
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:9,代码来源:pe2.c
示例9: send_hsr_supervision_frame
static void send_hsr_supervision_frame(struct net_device *hsr_dev, u8 type)
{
struct hsr_priv *hsr_priv;
struct sk_buff *skb;
int hlen, tlen;
struct hsr_sup_tag *hsr_stag;
struct hsr_sup_payload *hsr_sp;
unsigned long irqflags;
hlen = LL_RESERVED_SPACE(hsr_dev);
tlen = hsr_dev->needed_tailroom;
skb = alloc_skb(hsr_pad(sizeof(struct hsr_sup_payload)) + hlen + tlen,
GFP_ATOMIC);
if (skb == NULL)
return;
hsr_priv = netdev_priv(hsr_dev);
skb_reserve(skb, hlen);
skb->dev = hsr_dev;
skb->protocol = htons(ETH_P_PRP);
skb->priority = TC_PRIO_CONTROL;
if (dev_hard_header(skb, skb->dev, ETH_P_PRP,
hsr_priv->sup_multicast_addr,
skb->dev->dev_addr, skb->len) < 0)
goto out;
skb_pull(skb, sizeof(struct ethhdr));
hsr_stag = (typeof(hsr_stag)) skb->data;
set_hsr_stag_path(hsr_stag, 0xf);
set_hsr_stag_HSR_Ver(hsr_stag, 0);
spin_lock_irqsave(&hsr_priv->seqnr_lock, irqflags);
hsr_stag->sequence_nr = htons(hsr_priv->sequence_nr);
hsr_priv->sequence_nr++;
spin_unlock_irqrestore(&hsr_priv->seqnr_lock, irqflags);
hsr_stag->HSR_TLV_Type = type;
hsr_stag->HSR_TLV_Length = 12;
skb_push(skb, sizeof(struct ethhdr));
/* Payload: MacAddressA */
hsr_sp = (typeof(hsr_sp)) skb_put(skb, sizeof(*hsr_sp));
ether_addr_copy(hsr_sp->MacAddressA, hsr_dev->dev_addr);
dev_queue_xmit(skb);
return;
out:
kfree_skb(skb);
}
开发者ID:7799,项目名称:linux,代码行数:56,代码来源:hsr_device.c
示例10: virt_send_ack
int virt_send_ack(struct virt_priv *virt, struct device_node *slave,
struct remote_link *link)
{
struct sk_buff *skb;
struct net_device *dev = slave->dev;
struct tunhdr *tunhdr;
struct pathinfo *path;
__be16 sport;
unsigned alloc_size = sizeof(struct tunhdr) + sizeof(struct udphdr) +
sizeof(struct iphdr) + LL_RESERVED_SPACE(dev);
path = lookup_pathinfo(&virt->network, slave, link);
if(!path)
return -EINVAL;
skb = alloc_skb(alloc_size, GFP_ATOMIC);
if(!skb) {
virt_path_put(path);
return -ENOMEM;
}
skb_reserve(skb, alloc_size);
tunhdr = virt_build_tunhdr(skb, NULL, NULL);
virt_finish_tunhdr(tunhdr, path, NULL, link->node);
/* TODO: We may want to split traffic among different ports, which
* may change how we send ACKs. For now, everything uses the same
* source port. */
sport = htons(virt_tunnel_source_port());
virt_build_udp_header(skb, sport, link->rif.data_port);
virt_build_ip_header(skb, slave->lif.ip4, link->rif.ip4);
skb->dev = dev;
skb->protocol = htons(ETH_P_IP);
dev_hard_header(skb, dev, ETH_P_IP, slave->next_hop_addr, dev->dev_addr, skb->len);
skb_reset_mac_header(skb);
/* Update link statistics -- these may not be accurate if the packet gets
* dropped after dev_queue_xmit. */
slave->stats.tx_packets++;
slave->stats.tx_bytes += skb->len;
/* Update device statistics. */
virt->stats.tx_packets++;
virt->stats.tx_bytes += skb->len;
/* Decrement refcnt. */
virt_path_put(path);
dev_queue_xmit(skb);
return 0;
}
开发者ID:UW-WiNGS,项目名称:virtnet,代码行数:56,代码来源:virtEgress.c
示例11: vlan_passthru_hard_header
static int vlan_passthru_hard_header(struct sk_buff *skb, struct net_device *dev,
unsigned short type,
const void *daddr, const void *saddr,
unsigned int len)
{
struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
struct net_device *real_dev = vlan->real_dev;
return dev_hard_header(skb, real_dev, type, daddr, saddr, len);
}
开发者ID:GSandeep24,项目名称:android_kernel_lenovo_msm8916,代码行数:10,代码来源:vlan_dev.c
示例12: netpoll_wrapper_send_arp_reply
static void netpoll_wrapper_send_arp_reply(struct netpoll_wrapper *pWrapper, struct queued_arp_reply *reply)
{
int hlen, tlen;
struct arphdr *arp;
struct sk_buff *send_skb;
unsigned char *arp_ptr;
int size = arp_hdr_len(pWrapper->pDeviceWithHandler);
hlen = LL_RESERVED_SPACE(pWrapper->pDeviceWithHandler);
tlen = pWrapper->pDeviceWithHandler->needed_tailroom;
send_skb = alloc_skb(size + hlen + tlen, GFP_ATOMIC);
if (!send_skb)
return;
skb_reserve(send_skb, hlen);
skb_reset_network_header(send_skb);
arp = (struct arphdr *) skb_put(send_skb, size);
send_skb->dev = pWrapper->pDeviceWithHandler;
send_skb->protocol = htons(ETH_P_ARP);
/* Fill the device header for the ARP frame */
if (dev_hard_header(send_skb, pWrapper->pDeviceWithHandler, ETH_P_ARP,
reply->remote_mac, pWrapper->pDeviceWithHandler->dev_addr,
send_skb->len) < 0)
{
kfree_skb(send_skb);
return;
}
/*
* Fill out the arp protocol part.
*
* we only support ethernet device type,
* which (according to RFC 1390) should
* always equal 1 (Ethernet).
*/
arp->ar_hrd = htons(pWrapper->pDeviceWithHandler->type);
arp->ar_pro = htons(ETH_P_IP);
arp->ar_hln = pWrapper->pDeviceWithHandler->addr_len;
arp->ar_pln = 4;
arp->ar_op = htons(ARPOP_REPLY);
arp_ptr = (unsigned char *)(arp + 1);
memcpy(arp_ptr, pWrapper->pDeviceWithHandler->dev_addr, pWrapper->pDeviceWithHandler->addr_len);
arp_ptr += pWrapper->pDeviceWithHandler->addr_len;
memcpy(arp_ptr, &reply->local_ip, 4);
arp_ptr += 4;
memcpy(arp_ptr, reply->remote_mac, pWrapper->pDeviceWithHandler->addr_len);
arp_ptr += pWrapper->pDeviceWithHandler->addr_len;
memcpy(arp_ptr, &reply->remote_ip, 4);
netpoll_send_skb(&pWrapper->netpoll_obj, send_skb);
}
开发者ID:lzto,项目名称:kgdboe,代码行数:54,代码来源:netpoll_wrapper.c
示例13: vlan_passthru_hard_header
static int vlan_passthru_hard_header(struct sk_buff *skb, struct net_device *dev,
unsigned short type,
const void *daddr, const void *saddr,
unsigned int len)
{
struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
if (saddr == NULL)
saddr = dev->dev_addr;
return dev_hard_header(skb, real_dev, type, daddr, saddr, len);
}
开发者ID:jing-git,项目名称:rt-n56u,代码行数:12,代码来源:vlan_dev.c
示例14: ztdeth_transmit
static int ztdeth_transmit(void *pvt, unsigned char *msg, int msglen)
{
struct ztdeth *z;
struct sk_buff *skb;
struct ztdeth_header *zh;
unsigned long flags;
struct net_device *dev;
unsigned char addr[ETH_ALEN];
unsigned short subaddr; /* Network byte order */
spin_lock_irqsave(&zlock, flags);
z = pvt;
if (z->dev) {
/* Copy fields to local variables to remove spinlock ASAP */
dev = z->dev;
memcpy(addr, z->addr, sizeof(z->addr));
subaddr = z->subaddr;
spin_unlock_irqrestore(&zlock, flags);
skb = dev_alloc_skb(msglen + dev->hard_header_len + sizeof(struct ztdeth_header) + 32);
if (skb) {
/* Reserve header space */
skb_reserve(skb, dev->hard_header_len + sizeof(struct ztdeth_header));
/* Copy message body */
memcpy(skb_put(skb, msglen), msg, msglen);
/* Throw on header */
zh = (struct ztdeth_header *)skb_push(skb, sizeof(struct ztdeth_header));
zh->subaddr = subaddr;
/* Setup protocol and such */
skb->protocol = __constant_htons(ETH_P_DAHDI_DETH);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
skb_set_network_header(skb, 0);
#else
skb->nh.raw = skb->data;
#endif
skb->dev = dev;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev_hard_header(skb, dev, ETH_P_DAHDI_DETH, addr, dev->dev_addr, skb->len);
#else
if (dev->hard_header)
dev->hard_header(skb, dev, ETH_P_DAHDI_DETH, addr, dev->dev_addr, skb->len);
#endif
skb_queue_tail(&skbs, skb);
}
}
else
spin_unlock_irqrestore(&zlock, flags);
return 0;
}
开发者ID:tws67,项目名称:asterisk-cygwin,代码行数:51,代码来源:dahdi_dynamic_eth.c
示例15: goose_trans_skb
int goose_trans_skb(struct net_device *dev, unsigned char *daddr,
struct sk_buff *__skb, int reliablity)
{
struct sk_buff *skb = __skb;
unsigned int skb_pull_len = NLMSG_LENGTH(0) + sizeof(struct nl_data_header);
if (unlikely((dev == NULL) || (!tran_active)))
goto goose_trans_skb_fail;
/* We use existing skb to form a new one:
*
* skb:
* old skb->data new skb->data
* | |
* -----------------------------------------------------------
* | NLMSG_LENGTH(0) | nl_data_header | goose header | APDU
* -----------------------------------------------------------
* | <== skb_pull_len ==> |
*
*/
skb_pull(skb, skb_pull_len);
skb_reset_network_header(skb);
/* But after pulling, if we have still no enough space for link-layer header,
we have to reconstruct a new skb */
if ((skb->head - skb->network_header) < LL_RESERVED_SPACE(dev)) {
skb = skb_copy_expand(__skb, LL_RESERVED_SPACE(dev), 16, GFP_ATOMIC);
kfree_skb(__skb);
}
/* Specify protocol type and frame information */
skb->dev = dev;
skb->protocol = ETH_P_GOOSE;
skb->pkt_type = PACKET_OUTGOING;
skb->csum = 0;
skb->ip_summed = 0;
/* Set the highest priority */
skb->priority = 0;
if (unlikely(dev_hard_header(skb, dev, ETH_P_GOOSE, daddr, dev->dev_addr, skb->len) < 0))
goto goose_trans_skb_fail;
/* If the message should be transmitted by GOOSE Enhanced Retransmission Mechanism,
call goose_enhan_retrans, otherwise transmit it directly.*/
return reliablity ? goose_enhan_retrans(skb):dev_queue_xmit(skb);
goose_trans_skb_fail:
kfree_skb(skb);
return -1;
}
开发者ID:adrianohrl,项目名称:simple_goose,代码行数:51,代码来源:goose_main.c
示例16: vlan_dev_hard_header
/*
* Create the VLAN header for an arbitrary protocol layer
*
* saddr=NULL means use device source address
* daddr=NULL means leave destination address (eg unresolved arp)
*
* This is called when the SKB is moving down the stack towards the
* physical devices.
*/
static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
unsigned short type,
const void *daddr, const void *saddr,
unsigned int len)
{
struct vlan_hdr *vhdr;
unsigned int vhdrlen = 0;
u16 vlan_tci = 0;
int rc;
if (WARN_ON(skb_headroom(skb) < dev->hard_header_len))
return -ENOSPC;
if (!(vlan_dev_info(dev)->flags & VLAN_FLAG_REORDER_HDR)) {
vhdr = (struct vlan_hdr *) skb_push(skb, VLAN_HLEN);
vlan_tci = vlan_dev_info(dev)->vlan_id;
vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
vhdr->h_vlan_TCI = htons(vlan_tci);
/*
* Set the protocol type. For a packet of type ETH_P_802_3 we
* put the length in here instead. It is up to the 802.2
* layer to carry protocol information.
*/
if (type != ETH_P_802_3)
vhdr->h_vlan_encapsulated_proto = htons(type);
else
vhdr->h_vlan_encapsulated_proto = htons(len);
skb->protocol = htons(ETH_P_8021Q);
type = ETH_P_8021Q;
vhdrlen = VLAN_HLEN;
}
/* Before delegating work to the lower layer, enter our MAC-address */
if (saddr == NULL)
saddr = dev->dev_addr;
/* Now make the underlying real hard header */
dev = vlan_dev_info(dev)->real_dev;
rc = dev_hard_header(skb, dev, type, daddr, saddr, len + vhdrlen);
if (rc > 0)
rc += vhdrlen;
return rc;
}
开发者ID:fr34k8,项目名称:DT_Hybrid_GPL_1.00.053,代码行数:55,代码来源:vlan_dev.c
示例17: send_msg
static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
struct tipc_media_addr *dest)
{
struct sk_buff *clone;
struct net_device *dev;
clone = skb_clone(buf, GFP_ATOMIC);
if (clone) {
clone->nh.raw = clone->data;
dev = ((struct eth_bearer *)(tb_ptr->usr_handle))->dev;
clone->dev = dev;
dev_hard_header(clone, dev, ETH_P_TIPC,
&dest->dev_addr.eth_addr,
dev->dev_addr, clone->len);
dev_queue_xmit(clone);
}
return TIPC_OK;
}
开发者ID:mrtos,项目名称:Logitech-Revue,代码行数:18,代码来源:eth_media.c
示例18: llc_mac_hdr_init
/**
* llc_mac_hdr_init - fills MAC header fields
* @skb: Address of the frame to initialize its MAC header
* @sa: The MAC source address
* @da: The MAC destination address
*
* Fills MAC header fields, depending on MAC type. Returns 0, If MAC type
* is a valid type and initialization completes correctly 1, otherwise.
*/
int llc_mac_hdr_init(struct sk_buff *skb,
unsigned char *sa, unsigned char *da)
{
int rc = -EINVAL;
switch (skb->dev->type) {
case ARPHRD_ETHER:
case ARPHRD_LOOPBACK:
rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
skb->len);
if (rc > 0)
rc = 0;
break;
default:
WARN(1, "device type not supported: %d\n", skb->dev->type);
}
return rc;
}
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:27,代码来源:llc_output.c
示例19: vlan_dev_hard_header
/*
* Create the VLAN header for an arbitrary protocol layer
*
* saddr=NULL means use device source address
* daddr=NULL means leave destination address (eg unresolved arp)
*
* This is called when the SKB is moving down the stack towards the
* physical devices.
*/
static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
unsigned short type,
const void *daddr, const void *saddr,
unsigned int len)
{
struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
struct vlan_hdr *vhdr;
unsigned int vhdrlen = 0;
u16 vlan_tci = 0;
int rc;
if (!(vlan->flags & VLAN_FLAG_REORDER_HDR)) {
vhdr = (struct vlan_hdr *) skb_push(skb, VLAN_HLEN);
vlan_tci = vlan->vlan_id;
vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb->priority);
vhdr->h_vlan_TCI = htons(vlan_tci);
/*
* Set the protocol type. For a packet of type ETH_P_802_3/2 we
* put the length in here instead.
*/
if (type != ETH_P_802_3 && type != ETH_P_802_2)
vhdr->h_vlan_encapsulated_proto = htons(type);
else
vhdr->h_vlan_encapsulated_proto = htons(len);
skb->protocol = vlan->vlan_proto;
type = ntohs(vlan->vlan_proto);
vhdrlen = VLAN_HLEN;
}
/* Before delegating work to the lower layer, enter our MAC-address */
if (saddr == NULL)
saddr = dev->dev_addr;
/* Now make the underlying real hard header */
dev = vlan->real_dev;
rc = dev_hard_header(skb, dev, type, daddr, saddr, len + vhdrlen);
if (rc > 0)
rc += vhdrlen;
return rc;
}
开发者ID:rldleblanc,项目名称:linux,代码行数:52,代码来源:vlan_dev.c
示例20: tipc_l2_send_msg
/**
* tipc_l2_send_msg - send a TIPC packet out over an L2 interface
* @skb: the packet to be sent
* @b: the bearer through which the packet is to be sent
* @dest: peer destination address
*/
int tipc_l2_send_msg(struct net *net, struct sk_buff *skb,
struct tipc_bearer *b, struct tipc_media_addr *dest)
{
struct net_device *dev;
int delta;
dev = (struct net_device *)rcu_dereference_rtnl(b->media_ptr);
if (!dev)
return 0;
delta = SKB_DATA_ALIGN(dev->hard_header_len - skb_headroom(skb));
if ((delta > 0) && pskb_expand_head(skb, delta, 0, GFP_ATOMIC)) {
kfree_skb(skb);
return 0;
}
skb_reset_network_header(skb);
skb->dev = dev;
skb->protocol = htons(ETH_P_TIPC);
dev_hard_header(skb, dev, ETH_P_TIPC, dest->value,
dev->dev_addr, skb->len);
dev_queue_xmit(skb);
return 0;
}
开发者ID:krzk,项目名称:linux,代码行数:29,代码来源:bearer.c
注:本文中的dev_hard_header函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论