![]() |
WE310F5
39.00.000
|
This section describes the M2MB APIs to perform network buffer allocation and deallocation operations. More...
#define | M2MB_NETBUF_MAX_QUEUE_NAME 6 |
#define | M2MB_NETBUF_MAX_QUEUES 3 |
#define | M2MB_NETBUF_UDP_HEADROOM (52) |
#define | M2MB_NETBUF_TCP_HEADROOM (64) |
#define | M2MB_NETBUF_UDP6_HEADROOM (72) |
#define | M2MB_NETBUF_TCP6_HEADROOM (88) |
#define | M2MB_NET_BUF_UPDATE_START(pkt, p) (p) = ((M2MB_NET_BUF_T *)(pkt))->nb_Prot |
#define | M2MB_NET_BUF_UPDATE_INT32(p, val) *(UINT32 *)(p) = (UINT32)(val); (p) += sizeof(UINT32) |
#define | M2MB_NET_BUF_UPDATE_INT16(p, val) *(uint16_t *)(p) = (uint16_t)(val); (p) += sizeof(uint16_t) |
#define | M2MB_NET_BUF_UPDATE_INT8(p, val) *(uint8_t *)(p) = (uint8_t)(val); (p) += sizeof(uint8_t) |
#define | M2MB_NET_BUF_UPDATE_DATA(p, data, len) memcpy((p), (data), (len)); (p) += (len) |
#define | M2MB_NET_BUF_UPDATE_END(pkt, len) |
#define | M2MB_NETBUF_APP 0x0 |
#define | M2MB_NETBUF_SYS 0x1 |
#define | M2MB_NETBUF_SYS_CONTIG (0x4 | M2MB_NETBUF_SYS) |
#define | M2MB_NETBUF_SSL 0x2 |
typedef struct M2MB_NET_BUF | M2MB_NET_BUF_T |
Structure to hold network buffer information. More... | |
typedef M2MB_NET_BUF_T * | PACKET |
typedef struct m2mb_Net_Buf_Queue_s | m2mb_Net_Buf_Queue_t |
Structure that contains information about a free queue. More... | |
typedef struct m2mb_Net_Buf_Queue_Status_s | m2mb_Net_Buf_Queue_Status_t |
Structure that contains information about all free queues. More... | |
void * | m2mb_Net_Buf_Alloc (UINT32 size, UINT32 id) |
Allocates a network buffer. More... | |
INT32 | m2mb_Net_Buf_Free (void *buf, UINT32 id) |
Frees a network buffer. More... | |
INT32 | m2mb_Net_Buf_Update (void *netbuf, UINT32 offset, void *srcbuf, UINT32 len, UINT32 id) |
Updates data in a network buffer. More... | |
M2MB_STATUS_T | m2mb_Net_Buf_Free_Queue_Status (m2mb_Net_Buf_Queue_Status_t *arg) |
This section describes the M2MB APIs to perform network buffer allocation and deallocation operations.
#define M2MB_NET_BUF_UPDATE_DATA | ( | p, | |
data, | |||
len | |||
) | memcpy((p), (data), (len)); (p) += (len) |
Copy application data into a non-chained buffer.
Definition at line 183 of file m2mb_netbuf.h.
#define M2MB_NET_BUF_UPDATE_END | ( | pkt, | |
len | |||
) |
Update the buffer size on a system buffer.
Definition at line 189 of file m2mb_netbuf.h.
#define M2MB_NET_BUF_UPDATE_INT16 | ( | p, | |
val | |||
) | *(uint16_t *)(p) = (uint16_t)(val); (p) += sizeof(uint16_t) |
Update 2 bytes of data in the buffer.
Definition at line 171 of file m2mb_netbuf.h.
Update 4 bytes of data in the buffer.
Definition at line 165 of file m2mb_netbuf.h.
#define M2MB_NET_BUF_UPDATE_INT8 | ( | p, | |
val | |||
) | *(uint8_t *)(p) = (uint8_t)(val); (p) += sizeof(uint8_t) |
Update 1 byte of data in the buffer.
Definition at line 177 of file m2mb_netbuf.h.
#define M2MB_NET_BUF_UPDATE_START | ( | pkt, | |
p | |||
) | (p) = ((M2MB_NET_BUF_T *)(pkt))->nb_Prot |
Update the data start pointer on a system buffer.
Definition at line 159 of file m2mb_netbuf.h.
#define M2MB_NETBUF_APP 0x0 |
Allocate a contiguous network buffer from the application heap. If the application does not enable the Zero-copy option for a socket, it should allocate memory using M2MB_NETBUF_APP for sending packets. The memory will be allocated from the heap.
Definition at line 201 of file m2mb_netbuf.h.
#define M2MB_NETBUF_MAX_QUEUE_NAME 6 |
Maximum size of the queue name.
Definition at line 80 of file m2mb_netbuf.h.
#define M2MB_NETBUF_MAX_QUEUES 3 |
Maximum number of free queues.
Definition at line 85 of file m2mb_netbuf.h.
#define M2MB_NETBUF_SSL 0x2 |
Allocate a network buffer for a secure connection. If the application enables the Zero-copy option for a socket and uses a secure connection over it, it must allocate memory using one of these two combinations of flags:
Definition at line 227 of file m2mb_netbuf.h.
#define M2MB_NETBUF_SYS 0x1 |
Allocate a network buffer from the system stack. If the application enables the Zero-copy option for a socket, it must allocate memory using M2MB_NETBUF_SYS for sending packets. The memory will be allocated from the packet buffer pool and might be made of a chain of smaller buffers.
Definition at line 210 of file m2mb_netbuf.h.
#define M2MB_NETBUF_SYS_CONTIG (0x4 | M2MB_NETBUF_SYS) |
Allocate a contiguous network buffer from the system stack. If the application enables the Zero-copy option for a socket, it must allocate memory using M2MB_NETBUF_SYS for sending packets. The memory will be allocated from the packet buffer pool.
Definition at line 218 of file m2mb_netbuf.h.
#define M2MB_NETBUF_TCP6_HEADROOM (88) |
TCP6 head room. 24+40+24(TCP with option) = 88
Definition at line 152 of file m2mb_netbuf.h.
#define M2MB_NETBUF_TCP_HEADROOM (64) |
TCP head room. MAC+IP+TCP = 24+20+20 = 64.
Definition at line 142 of file m2mb_netbuf.h.
#define M2MB_NETBUF_UDP6_HEADROOM (72) |
UDP6 head room. 24+40+8 = 72.
Definition at line 147 of file m2mb_netbuf.h.
#define M2MB_NETBUF_UDP_HEADROOM (52) |
UDP head room. MAC+IP+UDP = 24+20+8 = 52.
Definition at line 137 of file m2mb_netbuf.h.
typedef struct m2mb_Net_Buf_Queue_Status_s m2mb_Net_Buf_Queue_Status_t |
Structure that contains information about all free queues.
This structure contains the number of free packet buffers total numbers in each queue and the total number of free packet buffers in the system.
typedef struct m2mb_Net_Buf_Queue_s m2mb_Net_Buf_Queue_t |
Structure that contains information about a free queue.
This structure contains the number of free packet buffers and the total number of buffers in a given queue.
typedef struct M2MB_NET_BUF M2MB_NET_BUF_T |
Structure to hold network buffer information.
This structure is used when allocating a system buffer. The network buffer can be chained and accessed via pk_prev and pk_next.
typedef M2MB_NET_BUF_T* PACKET |
Definition at line 105 of file m2mb_netbuf.h.
Allocates a network buffer.
Call this function to allocate a network buffer. For M2MB_NETBUF_APP requests, the buffer is allocated from the application heap (4-byte aligned plain buffer), and the application owns it (the system will have its own copy).
For M2MB_NETBUF_SYS requests, the buffer is allocated from the system network buffer pool and is shared with the networking stack. The buffer is of the type M2MB_NET_BUF_T, and macros and helper functions must be used in order to read or write data. These buffers can be chained and non-contiguous. Additionally, after a successful send, the application cannot use the same buffer and must allocate a new one for additional sends. On receive, once the receive handler is called, the application must free the network buffer before returning.
[in] | size | Size, in bytes, of the buffer. |
[in] | id | See M2MB_NETBUF_APP, M2MB_NETBUF_SYS, and M2MB_NETBUF_SSL. |
Frees a network buffer.
Call this function to free a network buffer.
[in] | buf | Pointer to the buffer to be freed. |
[in] | id | ID; see M2MB_NETBUF_APP, M2MB_NETBUF_SYS, and M2MB_NETBUF_SSL. The same flag that was used to allocate it must be applied. |
M2MB_STATUS_T m2mb_Net_Buf_Free_Queue_Status | ( | m2mb_Net_Buf_Queue_Status_t * | arg | ) |
Gets the number of free packet buffers in all queues.
[in] | arg | Pointer to the m2mb_Net_Buf_Queue_Status_t data structure. |
Updates data in a network buffer.
Call this function to seamlessly update data in a network buffer, even in chained ones.
[in] | netbuf | Pointer to the buffer to be updated. |
[in] | offset | Data offset. |
[in] | srcbuf | Pointer to the data source. |
[in] | len | Data length. |
[in] | id | ID; ee M2MB_NETBUF_APP, M2MB_NETBUF_SYS and M2MB_NETBUF_SSL. |