rte_pcapng_t*rte_pcapng_fdopen(intfd,constchar*osname,constchar*hardware,constchar*appname,constchar*comment)
Write data to existing open file
Parametersfd file descriptor
osname Optional description of the operating system. Examples: 'Debian 11', 'Windows Server 22'
hardware Optional description of the hardware used to create this file. Examples: 'x86 Virtual
Machine'
appname Optional: application name recorded in the pcapng file. Example: 'dpdk-dumpcap 1.0 (DPDK
20.11)'
comment Optional comment to add to file header.
Returns
handle to library, or NULL in case of error (and rte_errno is set).
voidrte_pcapng_close(rte_pcapng_t*self)
Close capture file
Parametersself handle to library
intrte_pcapng_add_interface(rte_pcapng_t*self,uint16_tport,constchar*ifname,constchar*ifdescr,constchar*filter)
Add interface information to the capture file
Parametersself The handle to the packet capture file
port The Ethernet port to report stats on.
ifname (optional) Interface name to record in the file. If not specified, name will be constructed
from port
ifdescr (optional) Interface description to record in the file.
filter Capture filter to record in the file.
Interfaces must be added to the output file after opening and before any packet record. All ports used in
packet capture must be added.
structrte_mbuf*rte_pcapng_copy(uint16_tport_id,uint32_tqueue,conststructrte_mbuf*m,structrte_mempool*mp,uint32_tlength,enumrte_pcapng_directiondirection,constchar*comment)
Format an mbuf for writing to file.
Parametersport_id The Ethernet port on which packet was received or is going to be transmitted.
queue The queue on the Ethernet port where packet was received or is going to be transmitted.
mp The mempool from which the 'clone' mbufs are allocated.
m The mbuf to copy
length The upper limit on bytes to copy. Passing UINT32_MAX means all data (after offset).
direction The direction of the packer: receive, transmit or unknown.
comment Packet comment.
Returns
• The pointer to the new mbuf formatted for pcapng_write
• NULL if allocation fails.
uint32_trte_pcapng_mbuf_size(uint32_tlength)
Determine optimum mbuf data size.
Parameterslength The largest packet that will be copied.
Returns
The minimum size of mbuf data to handle packet with length bytes. Accounting for required header and
trailer fields
ssize_trte_pcapng_write_packets(rte_pcapng_t*self,structrte_mbuf*pkts[],uint16_tnb_pkts)
Write packets to the capture file.
Packets to be captured are copied by rte_pcapng_copy() and then this function is called to write them to
the file.
Warning
Do not pass original mbufs from transmit or receive or file will be invalid pcapng format.
Parametersself The handle to the packet capture file
pkts The address of an array of nb_pkts pointers to rte_mbufstructureswhichcontaintheoutputpacketsnb_pktsThenumberofpacketstowritetothefile.Returns
The number of bytes written to file, -1 on failure to write file. The mbuf's in pkts are always
freed.
ssize_trte_pcapng_write_stats(rte_pcapng_t*self,uint16_tport,uint64_tifrecv,uint64_tifdrop,constchar*comment)
Write an Interface statistics block. For statistics, use 0 if don't know or care to report it. Should be
called before closing capture to report results.
Parametersself The handle to the packet capture file
port The Ethernet port to report stats on.
ifrecv The number of packets received by capture. Optional: use UINT64_MAX if not known.
ifdrop The number of packets missed by the capture process. Optional: use UINT64_MAX if not known.
comment Optional comment to add to statistics.
Returns
number of bytes written to file, -1 on failure to write file