本文整理汇总了C++中dev_queue_xmit函数的典型用法代码示例。如果您正苦于以下问题:C++ dev_queue_xmit函数的具体用法?C++ dev_queue_xmit怎么用?C++ dev_queue_xmit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dev_queue_xmit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serval_ip_local_out
static inline int serval_ip_local_out(struct sk_buff *skb)
{
int err;
#if defined(OS_LINUX_KERNEL)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
err = ip_local_out(skb);
#else
struct iphdr *iph = ip_hdr(skb);
iph->tot_len = htons(skb->len);
ip_send_check(iph);
err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, skb->dst->dev,
dst_output);
#endif
#else /* OS_USER */
/* Calculate checksum */
ip_send_check(ip_hdr(skb));
err = dev_queue_xmit(skb);
#endif
if (err < 0) {
LOG_ERR("packet_xmit failed err=%d\n", err);
}
return err;
}
示例2: error
/* Transmit routine used by generic_netmap_txsync(). Returns 0 on success
and -1 on error (which may be packet drops or other errors). */
int generic_xmit_frame(struct ifnet *ifp, struct mbuf *m,
void *addr, u_int len, u_int ring_nr)
{
netdev_tx_t ret;
/* Empty the sk_buff. */
if (unlikely(skb_headroom(m)))
skb_push(m, skb_headroom(m));
skb_trim(m, 0);
/* TODO Support the slot flags (NS_MOREFRAG, NS_INDIRECT). */
skb_copy_to_linear_data(m, addr, len); // skb_store_bits(m, 0, addr, len);
skb_put(m, len);
NM_ATOMIC_INC(&m->users);
m->dev = ifp;
/* Tell generic_ndo_start_xmit() to pass this mbuf to the driver. */
m->priority = NM_MAGIC_PRIORITY_TX;
skb_set_queue_mapping(m, ring_nr);
ret = dev_queue_xmit(m);
if (likely(ret == NET_XMIT_SUCCESS)) {
return 0;
}
if (unlikely(ret != NET_XMIT_DROP)) {
/* If something goes wrong in the TX path, there is nothing
intelligent we can do (for now) apart from error reporting. */
RD(5, "dev_queue_xmit failed: HARD ERROR %d", ret);
}
return -1;
}
示例3: x25_send_frame
void x25_send_frame(struct sk_buff *skb, struct x25_neigh *nb)
{
unsigned char *dptr;
skb_reset_network_header(skb);
switch (nb->dev->type) {
case ARPHRD_X25:
dptr = skb_push(skb, 1);
*dptr = 0x00;
break;
#if defined(CONFIG_LLC) || defined(CONFIG_LLC_MODULE)
case ARPHRD_ETHER:
kfree_skb(skb);
return;
#endif
default:
kfree_skb(skb);
return;
}
skb->protocol = htons(ETH_P_X25);
skb->dev = nb->dev;
dev_queue_xmit(skb);
}
示例4: cisco_keepalive_send
static void cisco_keepalive_send(struct net_device *dev, u32 type,
u32 par1, u32 par2)
{
struct sk_buff *skb;
cisco_packet *data;
skb = dev_alloc_skb(sizeof(hdlc_header) + sizeof(cisco_packet));
if (!skb) {
printk(KERN_WARNING
"%s: Memory squeeze on cisco_keepalive_send()\n",
dev->name);
return;
}
skb_reserve(skb, 4);
cisco_hard_header(skb, dev, CISCO_KEEPALIVE, NULL, NULL, 0);
data = (cisco_packet*)skb->tail;
data->type = htonl(type);
data->par1 = htonl(par1);
data->par2 = htonl(par2);
data->rel = 0xFFFF;
/* we will need do_div here if 1000 % HZ != 0 */
data->time = htonl((jiffies - INITIAL_JIFFIES) * (1000 / HZ));
skb_put(skb, sizeof(cisco_packet));
skb->priority = TC_PRIO_CONTROL;
skb->dev = dev;
skb->nh.raw = skb->data;
dev_queue_xmit(skb);
}
示例5: alb_send_learning_packets
static void
alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
{
struct sk_buff *skb = NULL;
struct learning_pkt pkt;
char *data = NULL;
int i;
unsigned int size = sizeof(struct learning_pkt);
memset(&pkt, 0, size);
memcpy(pkt.mac_dst, mac_addr, ETH_ALEN);
memcpy(pkt.mac_src, mac_addr, ETH_ALEN);
pkt.type = __constant_htons(ETH_P_LOOP);
for (i=0; i < MAX_LP_RETRY; i++) {
skb = NULL;
skb = dev_alloc_skb(size);
if (!skb) {
return;
}
data = skb_put(skb, size);
memcpy(data, &pkt, size);
skb->mac.raw = data;
skb->nh.raw = data + ETH_HLEN;
skb->protocol = pkt.type;
skb->priority = TC_PRIO_CONTROL;
skb->dev = slave->dev;
dev_queue_xmit(skb);
}
}
示例6: dsa_slave_xmit
static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct sk_buff *nskb;
dev->stats.tx_packets++;
dev->stats.tx_bytes += skb->len;
/* Transmit function may have to reallocate the original SKB */
nskb = p->xmit(skb, dev);
if (!nskb)
return NETDEV_TX_OK;
/* SKB for netpoll still need to be mangled with the protocol-specific
* tag to be successfully transmitted
*/
if (unlikely(netpoll_tx_running(dev)))
return dsa_netpoll_send_skb(p, nskb);
/* Queue the SKB for transmission on the parent interface, but
* do not modify its EtherType
*/
nskb->dev = p->parent->dst->master_netdev;
dev_queue_xmit(nskb);
return NETDEV_TX_OK;
}
示例7: wlan_offchan_send_data_frame
/* TODO: only support linux for now */
void wlan_offchan_send_data_frame(struct ieee80211_node *ni, struct net_device *netdev)
{
#if defined(LINUX) || defined(__linux__)
struct ieee80211vap *vap = ni->ni_vap;
struct ieee80211com *ic = ni->ni_ic;
wbuf_t wbuf;
struct ieee80211_qosframe *qwh;
const u_int8_t dst[6] = {0x00, 0x02, 0x03, 0x04, 0x05, 0x06};
struct sk_buff *skb;
wbuf = wbuf_alloc(ic->ic_osdev, WBUF_TX_DATA, 1000);
if (wbuf == NULL)
{
return ;
}
ieee80211_prepare_qosnulldata(ni, wbuf, WME_AC_VO);
qwh = (struct ieee80211_qosframe *)wbuf_header(wbuf);
ieee80211_send_setup(vap, ni, (struct ieee80211_frame *)qwh,
IEEE80211_FC0_TYPE_DATA,
vap->iv_myaddr, /* SA */
dst, /* DA */
ni->ni_bssid);
wbuf_set_pktlen(wbuf, 1000);
/* force with NONPAUSE_TID */
wbuf_set_tid(wbuf, OFFCHAN_EXT_TID_NONPAUSE);
skb = (struct sk_buff *)wbuf;
skb->dev = netdev;
dev_queue_xmit(skb);
#endif
}
示例8: vhost_dev_xmit
netdev_tx_t
vhost_dev_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct vhost_priv *vp;
struct vr_interface *vifp;
struct net_device *pdev;
vp = netdev_priv(dev);
vifp = vp->vp_vifp;
if (!vifp) {
if (!(pdev = vp->vp_phys_dev)) {
(void)__sync_fetch_and_add(&dev->stats.tx_dropped, 1);
kfree_skb(skb);
return NETDEV_TX_OK;
}
skb->dev = pdev;
dev_queue_xmit(skb);
} else {
linux_to_vr(vifp, skb);
}
(void)__sync_fetch_and_add(&dev->stats.tx_packets, 1);
(void)__sync_fetch_and_add(&dev->stats.tx_bytes, skb->len);
return NETDEV_TX_OK;
}
示例9: x25_terminate_link
void x25_terminate_link(struct x25_neigh *nb)
{
struct sk_buff *skb;
unsigned char *ptr;
#if defined(CONFIG_LLC) || defined(CONFIG_LLC_MODULE)
if (nb->dev->type == ARPHRD_ETHER)
return;
#endif
if (nb->dev->type != ARPHRD_X25)
return;
skb = alloc_skb(1, GFP_ATOMIC);
if (!skb) {
printk(KERN_ERR "x25_dev: out of memory\n");
return;
}
ptr = skb_put(skb, 1);
*ptr = X25_IFACE_DISCONNECT;
skb->protocol = htons(ETH_P_X25);
skb->dev = nb->dev;
dev_queue_xmit(skb);
}
示例10: vlan_dev_hwaccel_hard_start_xmit
static netdev_tx_t vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb,
struct net_device *dev)
{
int i = skb_get_queue_mapping(skb);
struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
u16 vlan_tci;
unsigned int len;
int ret;
vlan_tci = vlan_dev_info(dev)->vlan_id;
vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
skb = __vlan_hwaccel_put_tag(skb, vlan_tci);
skb->dev = vlan_dev_info(dev)->real_dev;
len = skb->len;
ret = dev_queue_xmit(skb);
if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) {
txq->tx_packets++;
txq->tx_bytes += len;
} else
txq->tx_dropped++;
return ret;
}
示例11: cisco_keepalive_send
static void cisco_keepalive_send(struct net_device *dev, u32 type,
__be32 par1, __be32 par2)
{
struct sk_buff *skb;
struct cisco_packet *data;
skb = dev_alloc_skb(sizeof(struct hdlc_header) +
sizeof(struct cisco_packet));
if (!skb) {
netdev_warn(dev, "Memory squeeze on cisco_keepalive_send()\n");
return;
}
skb_reserve(skb, 4);
cisco_hard_header(skb, dev, CISCO_KEEPALIVE, NULL, NULL, 0);
data = (struct cisco_packet*)(skb->data + 4);
data->type = htonl(type);
data->par1 = par1;
data->par2 = par2;
data->rel = cpu_to_be16(0xFFFF);
data->time = htonl((jiffies - INITIAL_JIFFIES) * (1000 / HZ));
skb_put(skb, sizeof(struct cisco_packet));
skb->priority = TC_PRIO_CONTROL;
skb->dev = dev;
skb_reset_network_header(skb);
dev_queue_xmit(skb);
}
示例12: __dev_queue_push_xmit
static int __dev_queue_push_xmit(struct sk_buff *skb)
{
skb_push(skb, ETH_HLEN);
dev_queue_xmit(skb);
return 0;
}
示例13: cisco_keepalive_send
static void cisco_keepalive_send(hdlc_device *hdlc, u32 type,
u32 par1, u32 par2)
{
struct sk_buff *skb;
cisco_packet *data;
skb = dev_alloc_skb(sizeof(hdlc_header)+sizeof(cisco_packet));
if (!skb) {
printk(KERN_WARNING "%s: Memory squeeze on cisco_keepalive_send()\n",
hdlc_to_name(hdlc));
return;
}
skb_reserve(skb, 4);
cisco_hard_header(skb, hdlc_to_dev(hdlc), CISCO_KEEPALIVE,
NULL, NULL, 0);
data = (cisco_packet*)skb->tail;
data->type = htonl(type);
data->par1 = htonl(par1);
data->par2 = htonl(par2);
data->rel = 0xFFFF;
data->time = htonl(jiffies * 1000 / HZ);
skb_put(skb, sizeof(cisco_packet));
skb->priority = TC_PRIO_CONTROL;
skb->dev = hdlc_to_dev(hdlc);
dev_queue_xmit(skb);
}
示例14: 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;
}
示例15: x25_establish_link
void x25_establish_link(struct x25_neigh *nb)
{
struct sk_buff *skb;
unsigned char *ptr;
switch (nb->dev->type) {
case ARPHRD_X25:
if ((skb = alloc_skb(1, GFP_ATOMIC)) == NULL) {
printk(KERN_ERR "x25_dev: out of memory\n");
return;
}
ptr = skb_put(skb, 1);
*ptr = X25_IFACE_CONNECT;
break;
#if defined(CONFIG_LLC) || defined(CONFIG_LLC_MODULE)
case ARPHRD_ETHER:
return;
#endif
default:
return;
}
skb->protocol = htons(ETH_P_X25);
skb->dev = nb->dev;
dev_queue_xmit(skb);
}