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

Function pcap_write_packets

dpdk/app/dumpcap/main.c:872–901  ·  view source on GitHub ↗

Write multiple packets in older pcap format */

Source from the content-addressed store, hash-verified

870
871/* Write multiple packets in older pcap format */
872static ssize_t
873pcap_write_packets(pcap_dumper_t *dumper,
874 struct rte_mbuf *pkts[], uint16_t n)
875{
876 uint8_t temp_data[RTE_ETHER_MAX_JUMBO_FRAME_LEN];
877 struct pcap_pkthdr header;
878 uint16_t i;
879 size_t total = 0;
880
881 gettimeofday(&header.ts, NULL);
882
883 for (i = 0; i < n; i++) {
884 struct rte_mbuf *m = pkts[i];
885 size_t len, caplen;
886
887 len = caplen = rte_pktmbuf_pkt_len(m);
888 if (unlikely(!rte_pktmbuf_is_contiguous(m) && len > sizeof(temp_data)))
889 caplen = sizeof(temp_data);
890
891 header.len = len;
892 header.caplen = caplen;
893
894 pcap_dump((u_char *)dumper, &header,
895 rte_pktmbuf_read(m, 0, caplen, temp_data));
896
897 total += sizeof(header) + caplen;
898 }
899
900 return total;
901}
902
903/* Process all packets in ring and dump to capture file */
904static int process_ring(dumpcap_out_t out, struct rte_ring *r)

Callers 1

process_ringFunction · 0.85

Calls 2

rte_pktmbuf_readFunction · 0.85

Tested by

no test coverage detected