lwIP  2.1.0
Lightweight IP stack
ip6_addr.h File Reference
#include "lwip/opt.h"
#include "def.h"
#include "lwip/ip6_zone.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_copy_from_packed(dest, src)
 
#define ip6_addr_copy_to_packed(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_zoneless(addr1, addr2)
 
#define ip6_addr_netcmp(addr1, addr2)
 
#define ip6_addr_cmp_zoneless(addr1, addr2)
 
#define ip6_addr_cmp(addr1, addr2)
 
#define ip6_addr_cmp_packed(ip6addr, paddr, zone_idx)
 

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; \
ip6_addr_clear_zone(ip6addr); } 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_cmp

#define ip6_addr_cmp (   addr1,
  addr2 
)
Value:
(ip6_addr_cmp_zoneless((addr1), (addr2)) && \
ip6_addr_cmp_zone((addr1), (addr2)))
#define ip6_addr_cmp_zoneless(addr1, addr2)
Definition: ip6_addr.h:168

Determine if two IPv6 addresses are the same. In particular, the address part of both must be the same, and the zone must be compatible.

Parameters
addr1IPv6 address 1
addr2IPv6 address 2
Returns
1 if the addresses are considered equal, 0 if not

◆ ip6_addr_cmp_packed

#define ip6_addr_cmp_packed (   ip6addr,
  paddr,
  zone_idx 
)
Value:
(((ip6addr)->addr[0] == (paddr)->addr[0]) && \
((ip6addr)->addr[1] == (paddr)->addr[1]) && \
((ip6addr)->addr[2] == (paddr)->addr[2]) && \
((ip6addr)->addr[3] == (paddr)->addr[3]) && \
ip6_addr_equals_zone((ip6addr), (zone_idx)))

Compare IPv6 address to packed address and zone

◆ ip6_addr_cmp_zoneless

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

Compare IPv6 addresses, ignoring zone information. To be used sparingly!

◆ 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]; \
ip6_addr_copy_zone((dest), (src)); }while(0)

Copy IPv6 address - faster than ip6_addr_set: no NULL check

◆ ip6_addr_copy_from_packed

#define ip6_addr_copy_from_packed (   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]; \
ip6_addr_clear_zone(&dest); }while(0)

Copy packed IPv6 address to unpacked IPv6 address; zone is not set

◆ ip6_addr_copy_to_packed

#define ip6_addr_copy_to_packed (   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 unpacked IPv6 address to packed IPv6 address; zone is lost

◆ ip6_addr_netcmp

#define ip6_addr_netcmp (   addr1,
  addr2 
)
Value:
(ip6_addr_netcmp_zoneless((addr1), (addr2)) && \
ip6_addr_cmp_zone((addr1), (addr2)))
#define ip6_addr_netcmp_zoneless(addr1, addr2)
Definition: ip6_addr.h:150

Determine if two IPv6 address are on the same network.

Parameters
addr1IPv6 address 1
addr2IPv6 address 2
Returns
1 if the network identifiers of both address match, 0 if not

◆ ip6_addr_netcmp_zoneless

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

Compare IPv6 networks, ignoring zone information. To be used sparingly!

◆ 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]; \
ip6_addr_set_zone((dest), (src) == NULL ? IP6_NO_ZONE : ip6_addr_zone(src)); }while(0)
#define IP6_NO_ZONE
Definition: ip6_zone.h:101
#define ip6_addr_zone(ip6addr)
Definition: ip6_zone.h:109

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]); \
ip6_addr_set_zone((dest), (src) == NULL ? IP6_NO_ZONE : ip6_addr_zone(src));}while(0)
u32_t lwip_htonl(u32_t n)
Definition: def.c:90
#define IP6_NO_ZONE
Definition: ip6_zone.h:101
#define ip6_addr_zone(ip6addr)
Definition: ip6_zone.h:109

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); \
ip6_addr_clear_zone(ip6addr);}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; \
ip6_addr_clear_zone(ip6addr);}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