本文整理汇总了C++中skb_copy函数的典型用法代码示例。如果您正苦于以下问题:C++ skb_copy函数的具体用法?C++ skb_copy怎么用?C++ skb_copy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了skb_copy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tipc_cltr_multicast
static void tipc_cltr_multicast(struct cluster *c_ptr, struct sk_buff *buf,
u32 lower, u32 upper)
{
struct sk_buff *buf_copy;
struct tipc_node *n_ptr;
u32 n_num;
u32 tstop;
assert(lower <= upper);
assert(((lower >= 1) && (lower <= tipc_max_nodes)) ||
((lower >= LOWEST_SLAVE) && (lower <= tipc_highest_allowed_slave)));
assert(((upper >= 1) && (upper <= tipc_max_nodes)) ||
((upper >= LOWEST_SLAVE) && (upper <= tipc_highest_allowed_slave)));
assert(in_own_cluster(c_ptr->addr));
tstop = is_slave(upper) ? c_ptr->highest_slave : c_ptr->highest_node;
if (tstop > upper)
tstop = upper;
for (n_num = lower; n_num <= tstop; n_num++) {
n_ptr = c_ptr->nodes[n_num];
if (n_ptr && tipc_node_has_active_links(n_ptr)) {
buf_copy = skb_copy(buf, GFP_ATOMIC);
if (buf_copy == NULL)
break;
msg_set_destnode(buf_msg(buf_copy), n_ptr->addr);
tipc_link_send(buf_copy, n_ptr->addr, n_ptr->addr);
}
}
buf_discard(buf);
}
示例2: mwifiex_handle_uap_rx_forward
/*
* This function contains logic for AP packet forwarding.
*
* If a packet is multicast/broadcast, it is sent to kernel/upper layer
* as well as queued back to AP TX queue so that it can be sent to other
* associated stations.
* If a packet is unicast and RA is present in associated station list,
* it is again requeued into AP TX queue.
* If a packet is unicast and RA is not in associated station list,
* packet is forwarded to kernel to handle routing logic.
*/
int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv,
struct sk_buff *skb)
{
struct mwifiex_adapter *adapter = priv->adapter;
struct uap_rxpd *uap_rx_pd;
struct rx_packet_hdr *rx_pkt_hdr;
u8 ra[ETH_ALEN];
struct sk_buff *skb_uap;
uap_rx_pd = (struct uap_rxpd *)(skb->data);
rx_pkt_hdr = (void *)uap_rx_pd + le16_to_cpu(uap_rx_pd->rx_pkt_offset);
/* don't do packet forwarding in disconnected state */
if (!priv->media_connected) {
dev_err(adapter->dev, "drop packet in disconnected state.\n");
dev_kfree_skb_any(skb);
return 0;
}
memcpy(ra, rx_pkt_hdr->eth803_hdr.h_dest, ETH_ALEN);
if (is_multicast_ether_addr(ra)) {
skb_uap = skb_copy(skb, GFP_ATOMIC);
mwifiex_uap_queue_bridged_pkt(priv, skb_uap);
} else {
if (mwifiex_get_sta_entry(priv, ra)) {
/* Requeue Intra-BSS packet */
mwifiex_uap_queue_bridged_pkt(priv, skb);
return 0;
}
}
/* Forward unicat/Inter-BSS packets to kernel. */
return mwifiex_process_rx_packet(adapter, skb);
}
示例3: set_ect_ip
/* set ECT codepoint from IP header.
* return 0 in case there was no ECT codepoint
* return 1 in case ECT codepoint has been overwritten
* return < 0 in case there was error */
static int inline
set_ect_ip(struct sk_buff **pskb, struct iphdr *iph,
const struct ipt_ECN_info *einfo)
{
if ((iph->tos & IPT_ECN_IP_MASK)
!= (einfo->ip_ect & IPT_ECN_IP_MASK)) {
u_int16_t diffs[2];
/* raw socket (tcpdump) may have clone of incoming
* skb: don't disturb it --RR */
if (skb_cloned(*pskb) && !(*pskb)->sk) {
struct sk_buff *nskb = skb_copy(*pskb, GFP_ATOMIC);
if (!nskb)
return NF_DROP;
kfree_skb(*pskb);
*pskb = nskb;
iph = (*pskb)->nh.iph;
}
diffs[0] = htons(iph->tos) ^ 0xFFFF;
iph->tos = iph->tos & ~IPT_ECN_IP_MASK;
iph->tos = iph->tos | (einfo->ip_ect & IPT_ECN_IP_MASK);
diffs[1] = htons(iph->tos);
iph->check = csum_fold(csum_partial((char *)diffs,
sizeof(diffs),
iph->check^0xFFFF));
(*pskb)->nfcache |= NFC_ALTERED;
return 1;
}
return 0;
}
示例4: ebt_target_snat
static int ebt_target_snat(struct sk_buff **pskb, unsigned int hooknr,
const struct net_device *in, const struct net_device *out,
const void *data, unsigned int datalen)
{
struct ebt_nat_info *info = (struct ebt_nat_info *) data;
if (skb_shared(*pskb) || skb_cloned(*pskb)) {
struct sk_buff *nskb;
nskb = skb_copy(*pskb, GFP_ATOMIC);
if (!nskb)
return NF_DROP;
if ((*pskb)->sk)
skb_set_owner_w(nskb, (*pskb)->sk);
kfree_skb(*pskb);
*pskb = nskb;
}
memcpy(eth_hdr(*pskb)->h_source, info->mac, ETH_ALEN);
if (!(info->target & NAT_ARP_BIT) &&
eth_hdr(*pskb)->h_proto == htons(ETH_P_ARP)) {
struct arphdr _ah, *ap;
ap = skb_header_pointer(*pskb, 0, sizeof(_ah), &_ah);
if (ap == NULL)
return EBT_DROP;
if (ap->ar_hln != ETH_ALEN)
goto out;
if (skb_store_bits(*pskb, sizeof(_ah), info->mac,ETH_ALEN))
return EBT_DROP;
}
out:
return info->target | ~EBT_VERDICT_BITS;
}
示例5: ip_vs_make_skb_writable
int ip_vs_make_skb_writable(struct sk_buff **pskb, int writable_len)
{
struct sk_buff *skb = *pskb;
/* skb is already used, better copy skb and its payload */
if (unlikely(skb_shared(skb) || skb->sk))
goto copy_skb;
/* skb data is already used, copy it */
if (unlikely(skb_cloned(skb)))
goto copy_data;
return pskb_may_pull(skb, writable_len);
copy_data:
if (unlikely(writable_len > skb->len))
return 0;
return !pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
copy_skb:
if (unlikely(writable_len > skb->len))
return 0;
skb = skb_copy(skb, GFP_ATOMIC);
if (!skb)
return 0;
BUG_ON(skb_is_nonlinear(skb));
/* Rest of kernel will get very unhappy if we pass it a
suddenly-orphaned skbuff */
if ((*pskb)->sk)
skb_set_owner_w(skb, (*pskb)->sk);
kfree_skb(*pskb);
*pskb = skb;
return 1;
}
示例6: pppoe_relay_broadcast
void pppoe_relay_broadcast(pppoe_if_t *src_if, struct sk_buff *m)
{
pppoe_if_t *iter;
int used = 0;
for (iter = if_head; iter; iter = iter->next)
{
struct sk_buff *mc;
struct ethhdr *eh;
if (iter==src_if || !iter->acOK || !(iter->dev->flags & IFF_UP))
continue;
if (!iter->next)
{
mc = m;
used = 1;
}
else
{
mc = skb_copy(m, GFP_ATOMIC);
if (!mc)
{
if (iter->dev->get_stats)
iter->dev->get_stats(iter->dev)->tx_errors++;
continue;
}
}
eh = MTOD(mc, struct ethhdr *);
memcpy(eh->h_source, DEV_MAC(iter->dev), ETH_ALEN);
relay_enqueue(iter->dev, mc);
}
if (!used)
kfree_skb(m);
}
示例7: GC_copy_buff
struct sk_buff __GC *
GC_copy_buff(struct GC_data *gc, struct sk_buff __GC * orig)
{
struct sk_buff *skb;
struct sk_buff __GC * ret;
if (gc->pool.len >= Q_GC_POOL_QUEUE_LEN) {
pr_devel("[PFQ] GC: pool exhausted!\n");
ret = NULL;
return ret;
}
skb = skb_copy(PFQ_SKB(orig), GFP_ATOMIC);
if (skb == NULL) {
pr_devel("[PFQ] GC: out of memory!\n");
ret = NULL;
return ret;
}
skb->mac_len = orig->mac_len;
/* GC_make_buff can't fail now */
ret = GC_make_buff(gc, skb);
PFQ_CB(ret)->group_mask = PFQ_CB(orig)->group_mask;
PFQ_CB(ret)->direct = PFQ_CB(orig)->direct;
PFQ_CB(ret)->monad = PFQ_CB(orig)->monad;
return ret;
}
示例8: ieee80211p_rx
static void ieee80211p_rx(struct sk_buff *skb) {
/* We copy the received buffer since we need to modify it */
drv_priv_data.rx_skb = skb_copy(skb,GFP_ATOMIC);
/* Schedule a tasklet to handle the receivded skb */
tasklet_schedule(&drv_priv_data.rx_tq);
}
示例9: target
static unsigned int
target(struct sk_buff **pskb,
const struct net_device *in, const struct net_device *out,
unsigned int hooknum, const struct xt_target *target,
const void *targinfo)
{
const struct arpt_mangle *mangle = targinfo;
struct arphdr *arp;
unsigned char *arpptr;
int pln, hln;
if (skb_shared(*pskb) || skb_cloned(*pskb)) {
struct sk_buff *nskb;
nskb = skb_copy(*pskb, GFP_ATOMIC);
if (!nskb)
return NF_DROP;
if ((*pskb)->sk)
skb_set_owner_w(nskb, (*pskb)->sk);
kfree_skb(*pskb);
*pskb = nskb;
}
arp = (*pskb)->nh.arph;
arpptr = (*pskb)->nh.raw + sizeof(*arp);
pln = arp->ar_pln;
hln = arp->ar_hln;
/* We assume that pln and hln were checked in the match */
if (mangle->flags & ARPT_MANGLE_SDEV) {
if (ARPT_DEV_ADDR_LEN_MAX < hln ||
(arpptr + hln > (**pskb).tail))
return NF_DROP;
memcpy(arpptr, mangle->src_devaddr, hln);
}
arpptr += hln;
if (mangle->flags & ARPT_MANGLE_SIP) {
if (ARPT_MANGLE_ADDR_LEN_MAX < pln ||
(arpptr + pln > (**pskb).tail))
return NF_DROP;
memcpy(arpptr, &mangle->u_s.src_ip, pln);
}
arpptr += pln;
if (mangle->flags & ARPT_MANGLE_TDEV) {
if (ARPT_DEV_ADDR_LEN_MAX < hln ||
(arpptr + hln > (**pskb).tail))
return NF_DROP;
memcpy(arpptr, mangle->tgt_devaddr, hln);
}
arpptr += hln;
if (mangle->flags & ARPT_MANGLE_TIP) {
if (ARPT_MANGLE_ADDR_LEN_MAX < pln ||
(arpptr + pln > (**pskb).tail))
return NF_DROP;
memcpy(arpptr, &mangle->u_t.tgt_ip, pln);
}
return mangle->target;
}
示例10: ax25_rx_iframe
/*
* This is where all valid I frames are sent to, to be dispatched to
* whichever protocol requires them.
*/
int ax25_rx_iframe(ax25_cb *ax25, struct sk_buff *skb)
{
int (*func)(struct sk_buff *, ax25_cb *);
volatile int queued = 0;
unsigned char pid;
if (skb == NULL) return 0;
ax25_start_idletimer(ax25);
pid = *skb->data;
#ifdef CONFIG_INET
if (pid == AX25_P_IP) {
/* working around a TCP bug to keep additional listeners
* happy. TCP re-uses the buffer and destroys the original
* content.
*/
struct sk_buff *skbn = skb_copy(skb, GFP_ATOMIC);
if (skbn != NULL) {
kfree_skb(skb);
skb = skbn;
}
skb_pull(skb, 1); /* Remove PID */
skb->h.raw = skb->data;
skb->nh.raw = skb->data;
skb->dev = ax25->ax25_dev->dev;
skb->pkt_type = PACKET_HOST;
skb->protocol = htons(ETH_P_IP);
ip_rcv(skb, skb->dev, NULL); /* Wrong ptype */
return 1;
}
#endif
if (pid == AX25_P_SEGMENT) {
skb_pull(skb, 1); /* Remove PID */
return ax25_rx_fragment(ax25, skb);
}
if ((func = ax25_protocol_function(pid)) != NULL) {
skb_pull(skb, 1); /* Remove PID */
return (*func)(skb, ax25);
}
if (ax25->sk != NULL && ax25->ax25_dev->values[AX25_VALUES_CONMODE] == 2) {
if ((!ax25->pidincl && ax25->sk->sk_protocol == pid) ||
ax25->pidincl) {
if (sock_queue_rcv_skb(ax25->sk, skb) == 0)
queued = 1;
else
ax25->condition |= AX25_COND_OWN_RX_BUSY;
}
}
return queued;
}
示例11: skb_copy
inline struct sk_buff *_rtw_skb_copy(const struct sk_buff *skb)
{
#ifdef PLATFORM_LINUX
return skb_copy(skb, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
#endif /* PLATFORM_LINUX */
#ifdef PLATFORM_FREEBSD
return NULL;
#endif /* PLATFORM_FREEBSD */
}
示例12: hycapi_send_message
void hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
{
__u16 appl_id;
int _len, _len2;
__u8 msghead[64];
appl_id = CAPIMSG_APPID(skb->data);
switch(_hycapi_appCheck(appl_id, ctrl->cnr))
{
case 0:
/* printk(KERN_INFO "Need to register\n"); */
hycapi_register_internal(ctrl,
appl_id,
&(hycapi_applications[appl_id-1].rp));
break;
case 1:
break;
default:
printk(KERN_ERR "HYCAPI: Controller mixup!\n");
return;
}
switch(CAPIMSG_CMD(skb->data)) {
case CAPI_DISCONNECT_B3_RESP:
ctrl->free_ncci(ctrl, appl_id,
CAPIMSG_NCCI(skb->data));
break;
case CAPI_DATA_B3_REQ:
_len = CAPIMSG_LEN(skb->data);
if (_len > 22) {
_len2 = _len - 22;
memcpy(msghead, skb->data, 22);
memcpy(skb->data + _len2, msghead, 22);
skb_pull(skb, _len2);
CAPIMSG_SETLEN(skb->data, 22);
}
break;
case CAPI_LISTEN_REQ:
if(hycapi_applications[appl_id-1].listen_req[ctrl->cnr-1])
{
kfree_skb(hycapi_applications[appl_id-1].listen_req[ctrl->cnr-1]);
hycapi_applications[appl_id-1].listen_req[ctrl->cnr-1] = NULL;
}
if (!(hycapi_applications[appl_id-1].listen_req[ctrl->cnr-1] = skb_copy(skb, GFP_ATOMIC)))
{
printk(KERN_ERR "HYSDN: memory squeeze in private_listen\n");
}
break;
default:
break;
}
hycapi_sendmsg_internal(ctrl, skb);
}
示例13: x25_lapb_receive_frame
int x25_lapb_receive_frame(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype, struct net_device *orig_dev)
{
struct sk_buff *nskb;
struct x25_neigh *nb;
if (!net_eq(dev_net(dev), &init_net))
goto drop;
nskb = skb_copy(skb, GFP_ATOMIC);
if (!nskb)
goto drop;
kfree_skb(skb);
skb = nskb;
/*
*/
nb = x25_get_neigh(dev);
if (!nb) {
printk(KERN_DEBUG "X.25: unknown neighbour - %s\n", dev->name);
goto drop;
}
if (!pskb_may_pull(skb, 1))
return 0;
switch (skb->data[0]) {
case X25_IFACE_DATA:
skb_pull(skb, 1);
if (x25_receive_data(skb, nb)) {
x25_neigh_put(nb);
goto out;
}
break;
case X25_IFACE_CONNECT:
x25_link_established(nb);
break;
case X25_IFACE_DISCONNECT:
x25_link_terminated(nb);
break;
}
x25_neigh_put(nb);
drop:
kfree_skb(skb);
out:
return 0;
}
示例14: rtw_mlcst2unicst
int rtw_mlcst2unicst(_adapter *padapter, struct sk_buff *skb)
{
struct sta_priv *pstapriv = &padapter->stapriv;
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
_irqL irqL;
_list *phead, *plist;
struct sk_buff *newskb;
struct sta_info *psta = NULL;
s32 res;
_enter_critical_bh(&pstapriv->asoc_list_lock, &irqL);
phead = &pstapriv->asoc_list;
plist = get_next(phead);
//free sta asoc_queue
while ((rtw_end_of_queue_search(phead, plist)) == _FALSE)
{
psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list);
plist = get_next(plist);
/* avoid come from STA1 and send back STA1 */
if (!memcmp(psta->hwaddr, &skb->data[6], 6))
continue;
newskb = skb_copy(skb, GFP_ATOMIC);
if (newskb) {
memcpy(newskb->data, psta->hwaddr, 6);
res = rtw_xmit(padapter, &newskb);
if (res < 0) {
DBG_871X("%s()-%d: rtw_xmit() return error!\n", __FUNCTION__, __LINE__);
pxmitpriv->tx_drop++;
dev_kfree_skb_any(newskb);
} else
pxmitpriv->tx_pkts++;
} else {
DBG_871X("%s-%d: skb_copy() failed!\n", __FUNCTION__, __LINE__);
pxmitpriv->tx_drop++;
_exit_critical_bh(&pstapriv->asoc_list_lock, &irqL);
//dev_kfree_skb_any(skb);
return _FALSE; // Caller shall tx this multicast frame via normal way.
}
}
_exit_critical_bh(&pstapriv->asoc_list_lock, &irqL);
dev_kfree_skb_any(skb);
return _TRUE;
}
示例15: bpf_dp_ctx_copy
static int bpf_dp_ctx_copy(struct bpf_dp_context *ctx,
struct bpf_dp_context *orig_ctx)
{
struct sk_buff *skb = skb_copy(orig_ctx->skb, GFP_ATOMIC);
if (!skb)
return -ENOMEM;
ctx->context = orig_ctx->context;
ctx->skb = skb;
ctx->dp = orig_ctx->dp;
ctx->stack = orig_ctx->stack;
return 0;
}