inet.c File Reference


Functions

u32_t inet_addr (const char *cp)
int inet_aton (const char *cp, struct in_addr *addr)
char * inet_ntoa (struct in_addr addr)
u16_t htons (u16_t n)
u16_t ntohs (u16_t n)
u32_t htonl (u32_t n)
u32_t ntohl (u32_t n)

Detailed Description

Functions common to all TCP/IPv4 modules, such as the byte order functions.

Function Documentation

u32_t 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 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 inet_addr ( const char *  cp  ) 

Ascii internet address interpretation routine. The value returned is in network order.

Parameters:
cp IP address in ascii represenation (e.g. "127.0.0.1")
Returns:
ip address in network order

int inet_aton ( const char *  cp,
struct in_addr *  addr 
)

Check whether "cp" is a valid ascii representation of an Internet address and convert to a binary address. Returns 1 if the address is valid, 0 if not. This replaces inet_addr, the return value from which cannot distinguish between failure and a local broadcast address.

Parameters:
cp IP address in ascii represenation (e.g. "127.0.0.1")
addr pointer to which to save the ip address in network order
Returns:
1 if cp could be converted to addr, 0 on failure

char* inet_ntoa ( struct in_addr  addr  ) 

Convert numeric IP address into decimal dotted ASCII representation. returns ptr to static buffer; not reentrant!

Parameters:
addr ip address in network order to convert
Returns:
pointer to a global static (!) buffer that holds the ASCII represenation of addr

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


Generated on Sun Mar 23 19:22:46 2008 for lwIP 1.3.0 by  doxygen 1.5.4