More generalized version rte_vlan_insert() */
| 402 | |
| 403 | /* More generalized version rte_vlan_insert() */ |
| 404 | static int |
| 405 | pcapng_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. |
no test coverage detected