Microchip® Advanced Software Framework

src/core/def.c File Reference

Common functions used throughout the stack.

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

Functions

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

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
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
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.