Microchip® Advanced Software Framework

def.h File Reference
#include "lwip/arch.h"
#include "lwip/opt.h"

Macros

#define htonl(x)   lwip_htonl(x)
 
#define htons(x)   lwip_htons(x)
 
#define LWIP_MAKE_U16(a, b)   ((a << 8) | b)
 
#define LWIP_MAX(x, y)   (((x) > (y)) ? (x) : (y))
 
#define LWIP_MIN(x, y)   (((x) < (y)) ? (x) : (y))
 
#define LWIP_PLATFORM_BYTESWAP   0
 
#define ntohl(x)   lwip_ntohl(x)
 
#define ntohs(x)   lwip_ntohs(x)
 
#define NULL   ((void *)0)
 
#define PP_HTONL(x)
 
#define PP_HTONS(x)   ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
 
#define PP_NTOHL(x)   PP_HTONL(x)
 
#define PP_NTOHS(x)   PP_HTONS(x)
 

Functions

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

#define LWIP_MAKE_U16 (   a,
 
)    ((a << 8) | b)
#define LWIP_MAX (   x,
 
)    (((x) > (y)) ? (x) : (y))

Referenced by lwip_listen(), and tcp_write().

#define LWIP_PLATFORM_BYTESWAP   0
#define NULL   ((void *)0)
#define PP_HTONL (   x)
Value:
((((x) & 0xff) << 24) | \
(((x) & 0xff00) << 8) | \
(((x) & 0xff0000UL) >> 8) | \
(((x) & 0xff000000UL) >> 24))

Referenced by dhcp_bind(), dhcp_create_msg(), netif_create_ip6_linklocal_address(), and netif_init().

#define PP_HTONS (   x)    ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
#define PP_NTOHL (   x)    PP_HTONL(x)
#define PP_NTOHS (   x)    PP_HTONS(x)

Referenced by ip_reass().

u32_t lwip_htonl ( u32_t  n)

Convert an u32_t from host- to network byte order.

Parameters
nu32_t in host byte order
Returns
n in network byte order

Referenced by ip4_addr_netmask_valid(), and lwip_ntohl().

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
nu16_t in host byte order
Returns
n in network byte order

Referenced by lwip_ntohs().

u32_t lwip_ntohl ( u32_t  n)

Convert an u32_t from network- to host byte order.

Parameters
nu32_t in network byte order
Returns
n in host byte order

References lwip_htonl().

u16_t lwip_ntohs ( u16_t  n)

Convert an u16_t from network- to host byte order.

Parameters
nu16_t in network byte order
Returns
n in host byte order

References lwip_htons().