WE310F5  39.00.000
M2MB NET UTILS

This section describes the M2MB APIs to perform network utilities. More...

#define min(a, b)   (((a) <= (b)) ? (a) : (b))
 macro to find minimum value in between two values More...
 
#define m2mb_socket_bsd_htonl(l)
 Conversion between host and network byte order. More...
 
#define m2mb_socket_bsd_ntohl(l)   m2mb_socket_bsd_htonl(l)
 Conversion between host and network byte order. More...
 
#define m2mb_socket_bsd_htons(s)   ((((s) >> 8) & 0xff) | (((s) << 8) & 0xff00))
 Conversion between host and network byte order. More...
 
#define m2mb_socket_bsd_ntohs(s)   m2mb_socket_bsd_htons(s)
 Conversion between host and network byte order. More...
 
typedef struct M2MB_Q_ELT M2MB_Q_ELT_T
 
typedef M2MB_Q_ELT_Tqp
 
typedef struct M2MB_QUEUE M2MB_QUEUE_T
 queue header More...
 
UINT32 m2mb_get_time (TIME_STRUCT_T *time)
 Getting time. More...
 
void m2mb_msec_delay (UINT32 ms)
 provides milliseconds delay. More...
 
void m2mb_usec_delay (UINT32 us)
 provides micro seconds delay. More...
 
void enqueue (M2MB_QUEUE_T *q, void *item)
 add item to the q's tail More...
 
void * dequeue (M2MB_QUEUE_T *q)
 remove item from the q's head More...
 

Detailed Description

This section describes the M2MB APIs to perform network utilities.

Macro Definition Documentation

◆ m2mb_socket_bsd_htonl

#define m2mb_socket_bsd_htonl (   l)
Value:
(((((l) >> 24) & 0x000000ff)) | \
((((l) >> 8) & 0x0000ff00)) | \
(((l) & 0x0000ff00) << 8) | \
(((l) & 0x000000ff) << 24))

Conversion between host and network byte order.

Converts the unsigned integer x from host byte order to network byte order.

Parameters
[in]lUnsigned integer to be converted
Returns
Result of the conversion
Note
<Notes>

Example

<C code example>

Definition at line 99 of file m2mb_netutils.h.

◆ m2mb_socket_bsd_htons

#define m2mb_socket_bsd_htons (   s)    ((((s) >> 8) & 0xff) | (((s) << 8) & 0xff00))

Conversion between host and network byte order.

Converts the unsigned short integer x from host byte order to network byte order

Parameters
[in]sUnsigned short integer to be converted
Returns
Result of the conversion
Note
<Notes>

Example

<C code example>

Definition at line 151 of file m2mb_netutils.h.

◆ m2mb_socket_bsd_ntohl

#define m2mb_socket_bsd_ntohl (   l)    m2mb_socket_bsd_htonl(l)

Conversion between host and network byte order.

Converts the unsigned integer x from network byte order to host byte order.

Parameters
[in]lUnsigned integer to be converted
Returns
Result of the conversion
Note
<Notes>

Example

<C code example>

Definition at line 126 of file m2mb_netutils.h.

◆ m2mb_socket_bsd_ntohs

#define m2mb_socket_bsd_ntohs (   s)    m2mb_socket_bsd_htons(s)

Conversion between host and network byte order.

Converts the unsigned short integer x from network byte order to host byte order

Parameters
[in]sUnsigned short integer to be converted
Returns
Result of the conversion
Note
<Notes>

Example

<C code example>

Definition at line 175 of file m2mb_netutils.h.

◆ min

#define min (   a,
 
)    (((a) <= (b)) ? (a) : (b))

macro to find minimum value in between two values

Definition at line 45 of file m2mb_netutils.h.

Typedef Documentation

◆ M2MB_Q_ELT_T

typedef struct M2MB_Q_ELT M2MB_Q_ELT_T

◆ M2MB_QUEUE_T

typedef struct M2MB_QUEUE M2MB_QUEUE_T

queue header

◆ qp

typedef M2MB_Q_ELT_T* qp

q pointer

Definition at line 53 of file m2mb_netutils.h.

Function Documentation

◆ dequeue()

void* dequeue ( M2MB_QUEUE_T q)

remove item from the q's head

remove item from the q's head

Parameters
[in]qqueue pointer to add item to it.
Returns
on success returns removed item, else returns NULL.
Note

Example

M2MB_QUEUE_T freeq = {0};
while ((pPkt = M2M_SOCKET_BUF_ALLOC(M2M_MAX_DATA_ARRAY_FRAG_SIZE, M2MB_NETBUF_SYS )) == NULL)
{
}
pTx = MALLOC( sizeof(M2MB_ZC_TX_INFO_T ));
if( pTx )
{
pTx->pkt = pPkt;
enqueue(&freeq, pTx);
}
enqueue(&freeq, pTx);

◆ enqueue()

void enqueue ( M2MB_QUEUE_T q,
void *  item 
)

add item to the q's tail

add item to the q's tail

Parameters
[in]qqueue pointer to add item to it.
[in]itemitem to add to queue
Returns
no retun value.
Note

Example

M2MB_QUEUE_T freeq = {0};
while ((pPkt = M2M_SOCKET_BUF_ALLOC(M2M_MAX_DATA_ARRAY_FRAG_SIZE, M2MB_NETBUF_SYS )) == NULL)
{
}
pTx = MALLOC( sizeof(M2MB_ZC_TX_INFO_T ));
if( pTx )
{
pTx->pkt = pPkt;
enqueue(&freeq, pTx);
}
enqueue(&freeq, pTx);

◆ m2mb_get_time()

UINT32 m2mb_get_time ( TIME_STRUCT_T time)

Getting time.

Getting time.

Parameters
[out]timePointer to a TIME_STRUCT_T to contain the time.
Returns
returns time in milliseconds.
Note

Example

◆ m2mb_msec_delay()

void m2mb_msec_delay ( UINT32  ms)

provides milliseconds delay.

Suspends the current thread for the specified time interval

Parameters
[in]msdelay value in milliseconds.
Returns
no retun value.
Note

Example

◆ m2mb_usec_delay()

void m2mb_usec_delay ( UINT32  us)

provides micro seconds delay.

Suspends the current thread for the specified time interval

Parameters
[in]usdelay value in micro seconds.
Returns
no retun value.
Note

Example