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

Function mbuf1_prepare

dpdk/app/test/test_pcapng.c:67–113  ·  view source on GitHub ↗

Make an IP packet consisting of chain of one packets */

Source from the content-addressed store, hash-verified

65
66/* Make an IP packet consisting of chain of one packets */
67static void
68mbuf1_prepare(struct dummy_mbuf *dm, uint32_t plen)
69{
70 struct {
71 struct rte_ether_hdr eth;
72 struct rte_ipv4_hdr ip;
73 struct rte_udp_hdr udp;
74 } pkt = {
75 .eth = {
76 .dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
77 .ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4),
78 },
79 .ip = {
80 .version_ihl = RTE_IPV4_VHL_DEF,
81 .time_to_live = 1,
82 .next_proto_id = IPPROTO_UDP,
83 .src_addr = rte_cpu_to_be_32(RTE_IPV4_LOOPBACK),
84 .dst_addr = rte_cpu_to_be_32(RTE_IPV4_BROADCAST),
85 },
86 .udp = {
87 .dst_port = rte_cpu_to_be_16(9), /* Discard port */
88 },
89 };
90
91 memset(dm, 0, sizeof(*dm));
92 dummy_mbuf_prep(&dm->mb[0], dm->buf[0], sizeof(dm->buf[0]), plen);
93
94 rte_eth_random_addr(pkt.eth.src_addr.addr_bytes);
95 plen -= sizeof(struct rte_ether_hdr);
96
97 pkt.ip.total_length = rte_cpu_to_be_16(plen);
98 pkt.ip.hdr_checksum = rte_ipv4_cksum(&pkt.ip);
99
100 plen -= sizeof(struct rte_ipv4_hdr);
101 pkt.udp.src_port = rte_rand();
102 pkt.udp.dgram_len = rte_cpu_to_be_16(plen);
103
104 memcpy(rte_pktmbuf_mtod(dm->mb, void *), &pkt, sizeof(pkt));
105
106 /* Idea here is to create mbuf chain big enough that after mbuf deep copy they won't be
107 * compressed into single mbuf to properly test store of chained mbufs
108 */
109 dummy_mbuf_prep(&dm->mb[1], dm->buf[1], sizeof(dm->buf[1]), pkt_len);
110 dummy_mbuf_prep(&dm->mb[2], dm->buf[2], sizeof(dm->buf[2]), pkt_len);
111 rte_pktmbuf_chain(&dm->mb[0], &dm->mb[1]);
112 rte_pktmbuf_chain(&dm->mb[0], &dm->mb[2]);
113}
114
115static int
116test_setup(void)

Callers 1

fill_pcapng_fileFunction · 0.85

Calls 7

memsetFunction · 0.85
rte_eth_random_addrFunction · 0.85
rte_ipv4_cksumFunction · 0.85
rte_randFunction · 0.85
rte_pktmbuf_chainFunction · 0.85
dummy_mbuf_prepFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected