lwIP  2.0.2
Lightweight IP stack
ip6_addr.h File Reference
#include "lwip/opt.h"
#include "def.h"

Data Structures

struct  ip6_addr
 

Macros

#define IP6_ADDR_PART(ip6addr, index, a, b, c, d)   (ip6addr)->addr[index] = PP_HTONL(LWIP_MAKEU32(a,b,c,d))
 
#define IP6_ADDR(ip6addr, idx0, idx1, idx2, idx3)
 
#define IP6_ADDR_BLOCK1(ip6addr)   ((u16_t)((lwip_htonl((ip6addr)->addr[0]) >> 16) & 0xffff))
 
#define IP6_ADDR_BLOCK2(ip6addr)   ((u16_t)((lwip_htonl((ip6addr)->addr[0])) & 0xffff))
 
#define IP6_ADDR_BLOCK3(ip6addr)   ((u16_t)((lwip_htonl((ip6addr)->addr[1]) >> 16) & 0xffff))
 
#define IP6_ADDR_BLOCK4(ip6addr)   ((u16_t)((lwip_htonl((ip6addr)->addr[1])) & 0xffff))
 
#define IP6_ADDR_BLOCK5(ip6addr)   ((u16_t)((lwip_htonl((ip6addr)->addr[2]) >> 16) & 0xffff))
 
#define IP6_ADDR_BLOCK6(ip6addr)   ((u16_t)((lwip_htonl((ip6addr)->addr[2])) & 0xffff))
 
#define IP6_ADDR_BLOCK7(ip6addr)   ((u16_t)((lwip_htonl((ip6addr)->addr[3]) >> 16) & 0xffff))
 
#define IP6_ADDR_BLOCK8(ip6addr)   ((u16_t)((lwip_htonl((ip6addr)->addr[3])) & 0xffff))
 
#define ip6_addr_copy(dest, src)
 
#define ip6_addr_set(dest, src)
 
#define ip6_addr_set_zero(ip6addr)
 
#define ip6_addr_set_any(ip6addr)   ip6_addr_set_zero(ip6addr)
 
#define ip6_addr_set_loopback(ip6addr)
 
#define ip6_addr_set_hton(dest, src)
 
#define ip6_addr_netcmp(addr1, addr2)
 

Typedefs

typedef struct ip6_addr ip6_addr_t
 

Functions

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

Detailed Description

IPv6 addresses.

Macro Definition Documentation

◆ IP6_ADDR

#define IP6_ADDR (   ip6addr,
  idx0,
  idx1,
  idx2,
  idx3 
)
Value:
do { \
(ip6addr)->addr[0] = idx0; \
(ip6addr)->addr[1] = idx1; \
(ip6addr)->addr[2] = idx2; \
(ip6addr)->addr[3] = idx3; } while(0)

Set a full IPv6 address by passing the 4 u32_t indices in network byte order (use PP_HTONL() for constants)

◆ IP6_ADDR_BLOCK1

#define IP6_ADDR_BLOCK1 (   ip6addr)    ((u16_t)((lwip_htonl((ip6addr)->addr[0]) >> 16) & 0xffff))

Access address in 16-bit block

◆ IP6_ADDR_BLOCK2

#define IP6_ADDR_BLOCK2 (   ip6addr)    ((u16_t)((lwip_htonl((ip6addr)->addr[0])) & 0xffff))

Access address in 16-bit block

◆ IP6_ADDR_BLOCK3

#define IP6_ADDR_BLOCK3 (   ip6addr)    ((u16_t)((lwip_htonl((ip6addr)->addr[1]) >> 16) & 0xffff))

Access address in 16-bit block

◆ IP6_ADDR_BLOCK4

#define IP6_ADDR_BLOCK4 (   ip6addr)    ((u16_t)((lwip_htonl((ip6addr)->addr[1])) & 0xffff))

Access address in 16-bit block

◆ IP6_ADDR_BLOCK5

#define IP6_ADDR_BLOCK5 (   ip6addr)    ((u16_t)((lwip_htonl((ip6addr)->addr[2]) >> 16) & 0xffff))

Access address in 16-bit block

◆ IP6_ADDR_BLOCK6

#define IP6_ADDR_BLOCK6 (   ip6addr)    ((u16_t)((lwip_htonl((ip6addr)->addr[2])) & 0xffff))

Access address in 16-bit block

◆ IP6_ADDR_BLOCK7

#define IP6_ADDR_BLOCK7 (   ip6addr)    ((u16_t)((lwip_htonl((ip6addr)->addr[3]) >> 16) & 0xffff))

Access address in 16-bit block

◆ IP6_ADDR_BLOCK8

#define IP6_ADDR_BLOCK8 (   ip6addr)    ((u16_t)((lwip_htonl((ip6addr)->addr[3])) & 0xffff))

Access address in 16-bit block

◆ ip6_addr_copy

#define ip6_addr_copy (   dest,
  src 
)
Value:
do{(dest).addr[0] = (src).addr[0]; \
(dest).addr[1] = (src).addr[1]; \
(dest).addr[2] = (src).addr[2]; \
(dest).addr[3] = (src).addr[3];}while(0)

Copy IPv6 address - faster than ip6_addr_set: no NULL check

◆ ip6_addr_netcmp

#define ip6_addr_netcmp (   addr1,
  addr2 
)
Value:
(((addr1)->addr[0] == (addr2)->addr[0]) && \
((addr1)->addr[1] == (addr2)->addr[1]))

Determine if two IPv6 address are on the same network.

  • addr1 IPv6 address 1
  • addr2 IPv6 address 2
    Returns
    !0 if the network identifiers of both address match

◆ IP6_ADDR_PART

#define IP6_ADDR_PART (   ip6addr,
  index,
  a,
  b,
  c,
 
)    (ip6addr)->addr[index] = PP_HTONL(LWIP_MAKEU32(a,b,c,d))

Set an IPv6 partial address given by byte-parts

◆ ip6_addr_set

#define ip6_addr_set (   dest,
  src 
)
Value:
do{(dest)->addr[0] = (src) == NULL ? 0 : (src)->addr[0]; \
(dest)->addr[1] = (src) == NULL ? 0 : (src)->addr[1]; \
(dest)->addr[2] = (src) == NULL ? 0 : (src)->addr[2]; \
(dest)->addr[3] = (src) == NULL ? 0 : (src)->addr[3];}while(0)

Safely copy one IPv6 address to another (src may be NULL)

◆ ip6_addr_set_any

#define ip6_addr_set_any (   ip6addr)    ip6_addr_set_zero(ip6addr)

Set address to ipv6 'any' (no need for lwip_htonl())

◆ ip6_addr_set_hton

#define ip6_addr_set_hton (   dest,
  src 
)
Value:
do{(dest)->addr[0] = (src) == NULL ? 0 : lwip_htonl((src)->addr[0]); \
(dest)->addr[1] = (src) == NULL ? 0 : lwip_htonl((src)->addr[1]); \
(dest)->addr[2] = (src) == NULL ? 0 : lwip_htonl((src)->addr[2]); \
(dest)->addr[3] = (src) == NULL ? 0 : lwip_htonl((src)->addr[3]);}while(0)
u32_t lwip_htonl(u32_t n)
Definition: def.c:90

Safely copy one IPv6 address to another and change byte order from host- to network-order.

◆ ip6_addr_set_loopback

#define ip6_addr_set_loopback (   ip6addr)
Value:
do{(ip6addr)->addr[0] = 0; \
(ip6addr)->addr[1] = 0; \
(ip6addr)->addr[2] = 0; \
(ip6addr)->addr[3] = PP_HTONL(0x00000001UL);}while(0)

Set address to ipv6 loopback address

◆ ip6_addr_set_zero

#define ip6_addr_set_zero (   ip6addr)
Value:
do{(ip6addr)->addr[0] = 0; \
(ip6addr)->addr[1] = 0; \
(ip6addr)->addr[2] = 0; \
(ip6addr)->addr[3] = 0;}while(0)

Set complete address to zero

Typedef Documentation

◆ ip6_addr_t

typedef struct ip6_addr ip6_addr_t

IPv6 address

Function Documentation

◆ ip6addr_aton()

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

◆ ip6addr_ntoa()

char* ip6addr_ntoa ( const ip6_addr_t addr)

returns ptr to static buffer; not reentrant!

Convert numeric IPv6 address into ASCII representation. 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

◆ 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