Defines | Functions

alexb/lib/lwip/contrib/src/include/lwip/def.h File Reference

#include "lwip/arch.h"
#include "lwip/opt.h"

Defines

#define LWIP_MAX(x, y)   (((x) > (y)) ? (x) : (y))
#define LWIP_MIN(x, y)   (((x) < (y)) ? (x) : (y))
#define NULL   ((void *)0)
#define LWIP_U32_DIFF(a, b)   (((a) >= (b)) ? ((a) - (b)) : (((a) + ((b) ^ 0xFFFFFFFF) + 1)))
 Get the absolute difference between 2 u32_t values (correcting overflows) 'a' is expected to be 'higher' (without overflow) than 'b'.
#define LWIP_MAKE_U16(a, b)   ((b << 8) | a)
#define LWIP_PLATFORM_BYTESWAP   0
#define htons(x)   lwip_htons(x)
#define ntohs(x)   lwip_ntohs(x)
#define htonl(x)   lwip_htonl(x)
#define ntohl(x)   lwip_ntohl(x)
#define PP_HTONS(x)   ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
#define PP_NTOHS(x)   PP_HTONS(x)
#define PP_HTONL(x)
#define PP_NTOHL(x)   PP_HTONL(x)

Functions

u16_t lwip_htons (u16_t x)
 These are reference implementations of the byte swapping functions.
u16_t lwip_ntohs (u16_t x)
 Convert an u16_t from network- to host byte order.
u32_t lwip_htonl (u32_t x)
 Convert an u32_t from host- to network byte order.
u32_t lwip_ntohl (u32_t x)
 Convert an u32_t from network- to host byte order.

Define Documentation

#define htonl (   x  )     lwip_htonl(x)
#define htons (   x  )     lwip_htons(x)
#define LWIP_MAKE_U16 (   a,
  b 
)    ((b << 8) | a)
#define LWIP_MAX (   x,
  y 
)    (((x) > (y)) ? (x) : (y))
#define LWIP_MIN (   x,
  y 
)    (((x) < (y)) ? (x) : (y))
#define LWIP_PLATFORM_BYTESWAP   0
#define LWIP_U32_DIFF (   a,
  b 
)    (((a) >= (b)) ? ((a) - (b)) : (((a) + ((b) ^ 0xFFFFFFFF) + 1)))

Get the absolute difference between 2 u32_t values (correcting overflows) 'a' is expected to be 'higher' (without overflow) than 'b'.

#define ntohl (   x  )     lwip_ntohl(x)
#define ntohs (   x  )     lwip_ntohs(x)
#define NULL   ((void *)0)
#define PP_HTONL (   x  ) 
Value:
((((x) & 0xff) << 24) | \
                     (((x) & 0xff00) << 8) | \
                     (((x) & 0xff0000UL) >> 8) | \
                     (((x) & 0xff000000UL) >> 24))
#define PP_HTONS (   x  )     ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
#define PP_NTOHL (   x  )     PP_HTONL(x)
#define PP_NTOHS (   x  )     PP_HTONS(x)

Function Documentation

u32_t lwip_htonl ( u32_t  n  ) 

Convert an u32_t from host- to network byte order.

Parameters:
n u32_t in host byte order
Returns:
n in network byte order
u16_t lwip_htons ( u16_t  n  ) 

These are reference implementations of the byte swapping functions.

Again with the aim of being simple, correct and fully portable. Byte swapping is the second thing you would want to optimize. You will need to port it to your architecture and in your cc.h:

define LWIP_PLATFORM_BYTESWAP 1 define LWIP_PLATFORM_HTONS(x) <your_htons> define LWIP_PLATFORM_HTONL(x) <your_htonl>

Note ntohs() and ntohl() are merely references to the htonx counterparts. Convert an u16_t from host- to network byte order.

Parameters:
n u16_t in host byte order
Returns:
n in network byte order
u32_t lwip_ntohl ( u32_t  n  ) 

Convert an u32_t from network- to host byte order.

Parameters:
n u32_t in network byte order
Returns:
n in host byte order
u16_t lwip_ntohs ( u16_t  n  ) 

Convert an u16_t from network- to host byte order.

Parameters:
n u16_t in network byte order
Returns:
n in host byte order
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines