| 142 | } |
| 143 | |
| 144 | static int |
| 145 | fill_pcapng_file(rte_pcapng_t *pcapng, unsigned int num_packets) |
| 146 | { |
| 147 | struct dummy_mbuf mbfs; |
| 148 | struct rte_mbuf *orig; |
| 149 | unsigned int burst_size; |
| 150 | unsigned int count; |
| 151 | ssize_t len; |
| 152 | |
| 153 | /* make a dummy packet */ |
| 154 | mbuf1_prepare(&mbfs, pkt_len); |
| 155 | orig = &mbfs.mb[0]; |
| 156 | |
| 157 | for (count = 0; count < num_packets; count += burst_size) { |
| 158 | struct rte_mbuf *clones[MAX_BURST]; |
| 159 | unsigned int i; |
| 160 | |
| 161 | /* put 1 .. MAX_BURST packets in one write call */ |
| 162 | burst_size = rte_rand_max(MAX_BURST) + 1; |
| 163 | for (i = 0; i < burst_size; i++) { |
| 164 | struct rte_mbuf *mc; |
| 165 | |
| 166 | mc = rte_pcapng_copy(port_id, 0, orig, mp, rte_pktmbuf_pkt_len(orig), |
| 167 | RTE_PCAPNG_DIRECTION_IN, NULL); |
| 168 | if (mc == NULL) { |
| 169 | fprintf(stderr, "Cannot copy packet\n"); |
| 170 | return -1; |
| 171 | } |
| 172 | clones[i] = mc; |
| 173 | } |
| 174 | |
| 175 | /* write it to capture file */ |
| 176 | len = rte_pcapng_write_packets(pcapng, clones, burst_size); |
| 177 | rte_pktmbuf_free_bulk(clones, burst_size); |
| 178 | |
| 179 | if (len <= 0) { |
| 180 | fprintf(stderr, "Write of packets failed: %s\n", |
| 181 | rte_strerror(rte_errno)); |
| 182 | return -1; |
| 183 | } |
| 184 | |
| 185 | /* Leave a small gap between packets to test for time wrap */ |
| 186 | usleep(rte_rand_max(MAX_GAP_US)); |
| 187 | } |
| 188 | |
| 189 | return count; |
| 190 | } |
| 191 | |
| 192 | static char * |
| 193 | fmt_time(char *buf, size_t size, uint64_t ts_ns) |
no test coverage detected