本文整理汇总了C++中dev_hard_header函数的典型用法代码示例。如果您正苦于以下问题:C++ dev_hard_header函数的具体用法?C++ dev_hard_header怎么用?C++ dev_hard_header使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dev_hard_header函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}