Microchip® Advanced Software Framework

ip6_addr.c File Reference

IPv6 addresses.

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

Macros

#define in_range(c, lo, up)   ((u8_t)c >= lo && (u8_t)c <= up)
 
#define isdigit(c)   in_range(c, '0', '9')
 
#define islower(c)   in_range(c, 'a', 'z')
 
#define isprint(c)   in_range(c, 0x20, 0x7f)
 
#define isspace(c)   (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v')
 
#define isxdigit(c)   (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F'))
 
#define xchar(i)   ((i) < 10 ? '0' + (i) : 'A' + (i) - 10)
 

Functions

int ip6addr_aton (const char *cp, ip6_addr_t *addr)
 Check whether "cp" is a valid ascii representation of an IPv6 address and convert to a binary address. More...
 
char * ip6addr_ntoa (const ip6_addr_t *addr)
 Convert numeric IPv6 address into ASCII representation. More...
 
char * ip6addr_ntoa_r (const ip6_addr_t *addr, char *buf, int buflen)
 Same as ipaddr_ntoa, but reentrant since a user-supplied buffer is used. More...
 

Variables

const ip6_addr_t ip6_addr_any = { { 0ul, 0ul, 0ul, 0ul } }
 IP6_ADDR_ANY can be used as a fixed IPv6 address for the wildcard. More...
 

#define in_range (   c,
  lo,
  up 
)    ((u8_t)c >= lo && (u8_t)c <= up)
#define isdigit (   c)    in_range(c, '0', '9')

Referenced by ip6addr_aton().

#define islower (   c)    in_range(c, 'a', 'z')

Referenced by ip6addr_aton().

#define isprint (   c)    in_range(c, 0x20, 0x7f)
#define isspace (   c)    (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v')
#define isxdigit (   c)    (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F'))

Referenced by ip6addr_aton().

#define xchar (   i)    ((i) < 10 ? '0' + (i) : 'A' + (i) - 10)

Referenced by ip6addr_ntoa_r().

int ip6addr_aton ( const char *  cp,
ip6_addr_t addr 
)

Check whether "cp" is a valid ascii representation of an IPv6 address and convert to a binary address.

Returns 1 if the address is valid, 0 if not.

Parameters
cpIPv6 address in ascii representation (e.g. "FF01::1")
addrpointer to which to save the ip address in network order
Returns
1 if cp could be converted to addr, 0 on failure

References htonl, isdigit, islower, and isxdigit.

char* ip6addr_ntoa ( const ip6_addr_t addr)

Convert numeric IPv6 address into ASCII representation.

returns ptr to static buffer; not reentrant!

returns ptr to static buffer; not reentrant!

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

References ip6addr_ntoa_r().

char* ip6addr_ntoa_r ( const ip6_addr_t addr,
char *  buf,
int  buflen 
)

Same as ipaddr_ntoa, but reentrant since a user-supplied buffer is used.

Parameters
addrip6 address in network order to convert
buftarget buffer where the string is stored
buflenlength of buf
Returns
either pointer to buf which now holds the ASCII representation of addr or NULL if buf was too small

References htonl, NULL, and xchar.

Referenced by ip6addr_ntoa().

const ip6_addr_t ip6_addr_any = { { 0ul, 0ul, 0ul, 0ul } }

IP6_ADDR_ANY can be used as a fixed IPv6 address for the wildcard.