File syn_netbuf.c¶
FileList > src > syntropic > util > syn_netbuf.c
Go to the source code of this file
Zero-Copy Packet Buffer Pool implementation.
#include "syn_netbuf.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| SYN_NetBuf * | syn_netbuf_alloc (SYN_NetBufPool * pool, size_t headroom) Allocate a packet buffer from the pool. |
| void | syn_netbuf_free (SYN_NetBufPool * pool, SYN_NetBuf * buf) Decrement reference counter and free buffer if count reaches 0. |
| size_t | syn_netbuf_len (const SYN_NetBuf * buf) Get payload length in bytes. |
| SYN_Status | syn_netbuf_pool_init (SYN_NetBufPool * pool, SYN_NetBuf * bufs, uint8_t * raw_mem, size_t buf_count, size_t buf_size) Initialize a packet buffer pool. |
| uint8_t * | syn_netbuf_pull (SYN_NetBuf * buf, size_t len) Strip header bytes from start of payload. |
| uint8_t * | syn_netbuf_push (SYN_NetBuf * buf, size_t len) Prepend header space before payload data. |
| uint8_t * | syn_netbuf_put (SYN_NetBuf * buf, size_t len) Append payload bytes to end of buffer. |
| void | syn_netbuf_ref (SYN_NetBuf * buf) Increment the reference counter of a packet buffer. |
Public Functions Documentation¶
function syn_netbuf_alloc¶
Allocate a packet buffer from the pool.
Parameters:
poolPointer to pool descriptor.headroomInitial headroom bytes reserved for network headers.
Returns:
Allocated SYN_NetBuf pointer, or NULL if pool is exhausted.
function syn_netbuf_free¶
Decrement reference counter and free buffer if count reaches 0.
Parameters:
poolPointer to pool descriptor.bufPointer to packet buffer.
function syn_netbuf_len¶
Get payload length in bytes.
Parameters:
bufPointer to packet buffer.
Returns:
Payload length in bytes.
function syn_netbuf_pool_init¶
Initialize a packet buffer pool.
SYN_Status syn_netbuf_pool_init (
SYN_NetBufPool * pool,
SYN_NetBuf * bufs,
uint8_t * raw_mem,
size_t buf_count,
size_t buf_size
)
Parameters:
poolPointer to pool descriptor.bufsArray of buffer descriptors.raw_memRaw memory block storage.buf_countNumber of buffers in pool.buf_sizeSize of each buffer block in bytes.
Returns:
SYN_OK on success.
function syn_netbuf_pull¶
Strip header bytes from start of payload.
Parameters:
bufPointer to packet buffer.lenBytes to strip.
Returns:
Pointer to new payload start, or NULL if payload shorter than len.
function syn_netbuf_push¶
Prepend header space before payload data.
Parameters:
bufPointer to packet buffer.lenBytes to prepend.
Returns:
Pointer to new payload start, or NULL if headroom insufficient.
function syn_netbuf_put¶
Append payload bytes to end of buffer.
Parameters:
bufPointer to packet buffer.lenBytes to append.
Returns:
Pointer to start of appended bytes, or NULL if tailroom insufficient.
function syn_netbuf_ref¶
Increment the reference counter of a packet buffer.
Parameters:
bufPointer to packet buffer.
The documentation for this class was generated from the following file src/syntropic/util/syn_netbuf.c