DPDK  22.07.0
Enumerations | Functions
rte_pcapng.h File Reference
#include <stdint.h>
#include <sys/types.h>
#include <rte_compat.h>
#include <rte_mempool.h>

Go to the source code of this file.


enum  rte_pcapng_direction


__rte_experimental rte_pcapng_t * rte_pcapng_fdopen (int fd, const char *osname, const char *hardware, const char *appname, const char *comment)
__rte_experimental void rte_pcapng_close (rte_pcapng_t *self)
__rte_experimental struct rte_mbufrte_pcapng_copy (uint16_t port_id, uint32_t queue, const struct rte_mbuf *m, struct rte_mempool *mp, uint32_t length, uint64_t timestamp, enum rte_pcapng_direction direction)
__rte_experimental uint32_t rte_pcapng_mbuf_size (uint32_t length)
__rte_experimental ssize_t rte_pcapng_write_packets (rte_pcapng_t *self, struct rte_mbuf *pkts[], uint16_t nb_pkts)
__rte_experimental ssize_t rte_pcapng_write_stats (rte_pcapng_t *self, uint16_t port, const char *comment, uint64_t start_time, uint64_t end_time, uint64_t ifrecv, uint64_t ifdrop)

Detailed Description

RTE pcapng

EXPERIMENTAL: All functions in this file may be changed or removed without prior notice.

Pcapng is an evolution from the pcap format, created to address some of its deficiencies. Namely, the lack of extensibility and inability to store additional information.

For details about the file format see RFC: https://www.ietf.org/id/draft-tuexen-opsawg-pcapng-03.html and https://github.com/pcapng/pcapng/

Definition in file rte_pcapng.h.

Enumeration Type Documentation

◆ rte_pcapng_direction

Direction flag These should match Enhanced Packet Block flag bits

Definition at line 77 of file rte_pcapng.h.

Function Documentation

◆ rte_pcapng_fdopen()

__rte_experimental rte_pcapng_t* rte_pcapng_fdopen ( int  fd,
const char *  osname,
const char *  hardware,
const char *  appname,
const char *  comment 

Write data to existing open file

fdfile descriptor
osnameOptional description of the operating system. Examples: "Debian 11", "Windows Server 22"
hardwareOptional description of the hardware used to create this file. Examples: "x86 Virtual Machine"
appnameOptional: application name recorded in the pcapng file. Example: "dpdk-dumpcap 1.0 (DPDK 20.11)"
commentOptional comment to add to file header.
handle to library, or NULL in case of error (and rte_errno is set).

◆ rte_pcapng_close()

__rte_experimental void rte_pcapng_close ( rte_pcapng_t *  self)

Close capture file

selfhandle to library

◆ rte_pcapng_copy()

__rte_experimental struct rte_mbuf* rte_pcapng_copy ( uint16_t  port_id,
uint32_t  queue,
const struct rte_mbuf m,
struct rte_mempool mp,
uint32_t  length,
uint64_t  timestamp,
enum rte_pcapng_direction  direction 

Format an mbuf for writing to file.

port_idThe Ethernet port on which packet was received or is going to be transmitted.
queueThe queue on the Ethernet port where packet was received or is going to be transmitted.
mpThe mempool from which the "clone" mbufs are allocated.
mThe mbuf to copy
lengthThe upper limit on bytes to copy. Passing UINT32_MAX means all data (after offset).
timestampThe timestamp in TSC cycles.
directionThe direction of the packer: receive, transmit or unknown.
  • The pointer to the new mbuf formatted for pcapng_write
  • NULL if allocation fails.

◆ rte_pcapng_mbuf_size()

__rte_experimental uint32_t rte_pcapng_mbuf_size ( uint32_t  length)

Determine optimum mbuf data size.

lengthThe largest packet that will be copied.
The minimum size of mbuf data to handle packet with length bytes. Accounting for required header and trailer fields

◆ rte_pcapng_write_packets()

__rte_experimental ssize_t rte_pcapng_write_packets ( rte_pcapng_t *  self,
struct rte_mbuf pkts[],
uint16_t  nb_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.

Do not pass original mbufs from transmit or receive or file will be invalid pcapng format.
selfThe handle to the packet capture file
pktsThe address of an array of nb_pkts pointers to rte_mbuf structures which contain the output packets
nb_pktsThe number of packets to write to the file.
The number of bytes written to file, -1 on failure to write file. The mbuf's in pkts are always freed.

◆ rte_pcapng_write_stats()

__rte_experimental ssize_t rte_pcapng_write_stats ( rte_pcapng_t *  self,
uint16_t  port,
const char *  comment,
uint64_t  start_time,
uint64_t  end_time,
uint64_t  ifrecv,
uint64_t  ifdrop 

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.

selfThe handle to the packet capture file
portThe Ethernet port to report stats on.
commentOptional comment to add to statistics.
start_timeThe time when packet capture was started in nanoseconds. Optional: can be zero if not known.
end_timeThe time when packet capture was stopped in nanoseconds. Optional: can be zero if not finished;
ifrecvThe number of packets received by capture. Optional: use UINT64_MAX if not known.
ifdropThe number of packets missed by the capture process. Optional: use UINT64_MAX if not known.
number of bytes written to file, -1 on failure to write file