---
name: "rte_pcapng_mbuf_size"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_pcapng.h"
---

# rte\_pcapng\_mbuf\_size(3)

Part of [rte\_pcapng.h(3)](/rte_pcapng.h/3.md).

## NAME

rte\_pcapng.h

## SYNOPSIS

`#include <stdint.h>`\
 `#include <sys/types.h>`\
 `#include <rte_mempool.h>`\

### Enumerations

enum **rte\_pcapng\_direction** \

### Functions

rte\_pcapng\_t \* **rte\_pcapng\_fdopen** (int fd, const char \*osname, const char \*hardware, const char \*appname, const char \*comment)\
 void **rte\_pcapng\_close** (rte\_pcapng\_t \*self)\
 int **rte\_pcapng\_add\_interface** (rte\_pcapng\_t \*self, uint16\_t port, const char \*ifname, const char \*ifdescr, const char \*filter)\
 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, enum **rte\_pcapng\_direction** direction, const char \*comment)\
 uint32\_t **rte\_pcapng\_mbuf\_size** (uint32\_t length)\
 ssize\_t **rte\_pcapng\_write\_packets** (rte\_pcapng\_t \*self, struct **rte\_mbuf** \*pkts\[\], uint16\_t nb\_pkts)\
 ssize\_t **rte\_pcapng\_write\_stats** (rte\_pcapng\_t \*self, uint16\_t port, uint64\_t ifrecv, uint64\_t ifdrop, const char \*comment)\

## Detailed Description

RTE pcapng

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

### enum rte\_pcapng\_direction

Direction flag These should match Enhanced Packet Block flag bits

Definition at line **95** of file **rte\_pcapng.h**.

## Function Documentation

### 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

**Parameters**

*fd* 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).

### void rte\_pcapng\_close (rte\_pcapng\_t \* self)

Close capture file

**Parameters**

*self* handle to library

### int rte\_pcapng\_add\_interface (rte\_pcapng\_t \* self, uint16\_t port, const char \* ifname, const char \* ifdescr, const char \* filter)

Add interface information to the capture file

**Parameters**

*self* 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.

### 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, enum rte\_pcapng\_direction direction, const char \* comment)

Format an mbuf for writing to file.

**Parameters**

*port\_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\_t rte\_pcapng\_mbuf\_size (uint32\_t length)

Determine optimum mbuf data size.

**Parameters**

*length* 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\_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.

**Warning**

Do not pass original mbufs from transmit or receive or file will be invalid pcapng format.

**Parameters**

*self* The handle to the packet capture file \
 *pkts* The address of an array of *nb\_pkts* pointers to **rte\_mbuf structures which contain the output packets** \
 *nb\_pkts* **The number of packets to write to the file.**

**Returns**

**The number of bytes written to file, -1 on failure to write file. The mbuf's in** *pkts* **are always freed.**

### ssize\_t rte\_pcapng\_write\_stats (rte\_pcapng\_t \* self, uint16\_t port, uint64\_t ifrecv, uint64\_t ifdrop, const char \* 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.**

**Parameters**

*self* **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**

## Author

**Generated automatically by Doxygen for DPDK from the source code.**
