MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pcapng_vlan_insert

Function pcapng_vlan_insert

dpdk/lib/pcapng/rte_pcapng.c:404–429  ·  view source on GitHub ↗

More generalized version rte_vlan_insert() */

Source from the content-addressed store, hash-verified

402
403/* More generalized version rte_vlan_insert() */
404static int
405pcapng_vlan_insert(struct rte_mbuf *m, uint16_t ether_type, uint16_t tci)
406{
407 struct rte_ether_hdr *nh, *oh;
408 struct rte_vlan_hdr *vh;
409
410 if (!RTE_MBUF_DIRECT(m) || rte_mbuf_refcnt_read(m) > 1)
411 return -EINVAL;
412
413 if (rte_pktmbuf_data_len(m) < sizeof(*oh))
414 return -EINVAL;
415
416 oh = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
417 nh = (struct rte_ether_hdr *)
418 rte_pktmbuf_prepend(m, sizeof(struct rte_vlan_hdr));
419 if (nh == NULL)
420 return -ENOSPC;
421
422 memmove(nh, oh, 2 * RTE_ETHER_ADDR_LEN);
423 nh->ether_type = rte_cpu_to_be_16(ether_type);
424
425 vh = (struct rte_vlan_hdr *) (nh + 1);
426 vh->vlan_tci = rte_cpu_to_be_16(tci);
427
428 return 0;
429}
430
431/*
432 * The mbufs created use the Pcapng standard enhanced packet block.

Callers 1

rte_pcapng_copyFunction · 0.85

Calls 3

rte_mbuf_refcnt_readFunction · 0.85
rte_pktmbuf_prependFunction · 0.85
memmoveFunction · 0.50

Tested by

no test coverage detected