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

Function v4_allocate_packet_of

dpdk/app/test/test_ipfrag.c:165–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165static void
166v4_allocate_packet_of(struct rte_mbuf *b, int fill, size_t s,
167 int df, uint8_t mf, uint16_t off, uint8_t ttl, uint8_t proto,
168 uint16_t pktid, bool have_opt, bool is_first_frag, bool opt_copied)
169{
170 /* Create a packet, 2k bytes long */
171 b->data_off = 0;
172 char *data = rte_pktmbuf_mtod(b, char *);
173 rte_be16_t fragment_offset = 0; /* fragmentation offset */
174 uint16_t iph_len;
175 struct test_opt_data opt;
176
177 opt.len = 0;
178
179 if (have_opt)
180 test_get_ipv4_opt(is_first_frag, opt_copied, &opt);
181
182 iph_len = sizeof(struct rte_ipv4_hdr) + opt.len;
183 memset(data, fill, iph_len + s);
184
185 struct rte_ipv4_hdr *hdr = (struct rte_ipv4_hdr *)data;
186
187 hdr->version_ihl = 0x40; /* ipv4 */
188 hdr->version_ihl += (iph_len / 4);
189 hdr->type_of_service = 0;
190 b->pkt_len = s + iph_len;
191 b->data_len = b->pkt_len;
192 hdr->total_length = rte_cpu_to_be_16(b->pkt_len);
193 hdr->packet_id = rte_cpu_to_be_16(pktid);
194
195 if (df)
196 fragment_offset |= 0x4000;
197
198 if (mf)
199 fragment_offset |= 0x2000;
200
201 if (off)
202 fragment_offset |= off;
203
204 hdr->fragment_offset = rte_cpu_to_be_16(fragment_offset);
205
206 if (!ttl)
207 ttl = 64; /* default to 64 */
208
209 if (!proto)
210 proto = 1; /* icmp */
211
212 hdr->time_to_live = ttl;
213 hdr->next_proto_id = proto;
214 hdr->hdr_checksum = 0;
215 hdr->src_addr = rte_cpu_to_be_32(0x8080808);
216 hdr->dst_addr = rte_cpu_to_be_32(0x8080404);
217
218 memcpy(hdr + 1, opt.data, opt.len);
219}
220
221static void
222v6_allocate_packet_of(struct rte_mbuf *b, int fill, size_t s, uint8_t ttl,

Callers 1

test_ip_fragFunction · 0.85

Calls 3

test_get_ipv4_optFunction · 0.85
memsetFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected