Loading...
Searching...
No Matches
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)
#define | IP6_ADDR(ip6addr, idx0, idx1, idx2, idx3)
#define | IP6_ADDR_BLOCK1(ip6addr)
#define | IP6_ADDR_BLOCK2(ip6addr)
#define | IP6_ADDR_BLOCK3(ip6addr)
#define | IP6_ADDR_BLOCK4(ip6addr)
#define | IP6_ADDR_BLOCK5(ip6addr)
#define | IP6_ADDR_BLOCK6(ip6addr)
#define | IP6_ADDR_BLOCK7(ip6addr)
#define | IP6_ADDR_BLOCK8(ip6addr)
#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)
#define | ip6_addr_set_loopback(ip6addr)
#define | ip6_addr_set_hton(dest, src)
#define | ip6_addr_netcmp_zoneless(addr1, addr2)
#define | ip6_addr_net_zoneless_eq(addr1, addr2)
#define | ip6_addr_netcmp(addr1, addr2)
#define | ip6_addr_net_eq(addr1, addr2)
#define | ip6_addr_cmp_zoneless(addr1, addr2)
#define | ip6_addr_zoneless_eq(addr1, addr2)
#define | ip6_addr_cmp(addr1, addr2)
#define | ip6_addr_eq(addr1, addr2)
#define | ip6_addr_cmp_packed(ip6addr, paddr, zone_idx)
#define | ip6_addr_packed_eq(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 | ) |

Value:
((u16_t)((lwip_htonl((ip6addr)->addr[0]) >> 16) & 0xffff))
lwip_htonl
u32_t lwip_htonl(u32_t n)
Definition def.c:90

Access address in 16-bit block

## IP6_ADDR_BLOCK2

#define IP6_ADDR_BLOCK2 | ( |  | ip6addr | ) |

Value:
((u16_t)((lwip_htonl((ip6addr)->addr[0])) & 0xffff))

Access address in 16-bit block

## IP6_ADDR_BLOCK3

#define IP6_ADDR_BLOCK3 | ( |  | ip6addr | ) |

Value:
((u16_t)((lwip_htonl((ip6addr)->addr[1]) >> 16) & 0xffff))

Access address in 16-bit block

## IP6_ADDR_BLOCK4

#define IP6_ADDR_BLOCK4 | ( |  | ip6addr | ) |

Value:
((u16_t)((lwip_htonl((ip6addr)->addr[1])) & 0xffff))

Access address in 16-bit block

## IP6_ADDR_BLOCK5

#define IP6_ADDR_BLOCK5 | ( |  | ip6addr | ) |

Value:
((u16_t)((lwip_htonl((ip6addr)->addr[2]) >> 16) & 0xffff))

Access address in 16-bit block

## IP6_ADDR_BLOCK6

#define IP6_ADDR_BLOCK6 | ( |  | ip6addr | ) |

Value:
((u16_t)((lwip_htonl((ip6addr)->addr[2])) & 0xffff))

Access address in 16-bit block

## IP6_ADDR_BLOCK7

#define IP6_ADDR_BLOCK7 | ( |  | ip6addr | ) |

Value:
((u16_t)((lwip_htonl((ip6addr)->addr[3]) >> 16) & 0xffff))

Access address in 16-bit block

## IP6_ADDR_BLOCK8

#define IP6_ADDR_BLOCK8 | ( |  | ip6addr | ) |

Value:
((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_eq(addr1, addr2)
ip6_addr_eq
#define ip6_addr_eq(addr1, addr2)
Definition ip6_addr.h:192

Deprecated
  Renamed to ip6_addr_eq

## ip6_addr_cmp_packed

#define ip6_addr_cmp_packed | ( |  | ip6addr,
|  |  | paddr,
|  |  | zone_idx )

Value:
ip6_addr_packed_eq(ip6addr, paddr, zone_idx)
ip6_addr_packed_eq
#define ip6_addr_packed_eq(ip6addr, paddr, zone_idx)
Definition ip6_addr.h:198

Deprecated
  Renamed to ip6_addr_packed_eq

## ip6_addr_cmp_zoneless

#define ip6_addr_cmp_zoneless | ( |  | addr1,
|  |  | addr2 )

Value:
ip6_addr_zoneless_eq(addr1, addr2)
ip6_addr_zoneless_eq
#define ip6_addr_zoneless_eq(addr1, addr2)
Definition ip6_addr.h:178

Deprecated
  Renamed to ip6_addr_zoneless_eq

## 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_eq

#define ip6_addr_eq | ( |  | addr1,
|  |  | addr2 )

Value:
(ip6_addr_zoneless_eq((addr1), (addr2)) && \
ip6_addr_zone_eq((addr1), (addr2)))

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

  addr1 | IPv6 address 1
  addr2 | IPv6 address 2

Returns
  1 if the addresses are considered equal, 0 if not

## ip6_addr_net_eq

#define ip6_addr_net_eq | ( |  | addr1,
|  |  | addr2 )

Value:
(ip6_addr_net_zoneless_eq((addr1), (addr2)) && \
ip6_addr_zone_eq((addr1), (addr2)))
ip6_addr_net_zoneless_eq
#define ip6_addr_net_zoneless_eq(addr1, addr2)
Definition ip6_addr.h:152

Determine if two IPv6 address are on the same network.

Parameters

  addr1 | IPv6 address 1
  addr2 | IPv6 address 2

Returns
  1 if the network identifiers of both address match, 0 if not

## ip6_addr_net_zoneless_eq

#define ip6_addr_net_zoneless_eq | ( |  | 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_netcmp

#define ip6_addr_netcmp | ( |  | addr1,
|  |  | addr2 )

Value:
ip6_addr_net_eq(addr1, addr2)
ip6_addr_net_eq
#define ip6_addr_net_eq(addr1, addr2)
Definition ip6_addr.h:167

Determine if two IPv6 address are on the same network.

Deprecated
  Renamed to ip6_addr_net_eq

## ip6_addr_netcmp_zoneless

#define ip6_addr_netcmp_zoneless | ( |  | addr1,
|  |  | addr2 )

Value:
ip6_addr_net_zoneless_eq(addr1, addr2)

Deprecated
  Renamed to ip6_addr_net_zoneless_eq

## ip6_addr_packed_eq

#define ip6_addr_packed_eq | ( |  | 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_PART

#define IP6_ADDR_PART | ( |  | ip6addr,
|  |  | index,
|  |  | a,
|  |  | b,
|  |  | c,
|  |  | d )

Value:
(ip6addr)->addr[index] = PP_HTONL(LWIP_MAKEU32(a,b,c,d))
LWIP_MAKEU32
#define LWIP_MAKEU32(a, b, c, d)
Definition def.h:72

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)
IP6_NO_ZONE
#define IP6_NO_ZONE
Definition ip6_zone.h:101
ip6_addr_zone
#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 | ) |

Value:
ip6_addr_set_zero(ip6addr)
ip6_addr_set_zero
#define ip6_addr_set_zero(ip6addr)
Definition ip6_addr.h:126

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)

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

## ip6_addr_zoneless_eq

#define ip6_addr_zoneless_eq | ( |  | 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!

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

  cp | IPv6 address in ascii representation (e.g. "FF01::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

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

  addr | ip6 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

  addr | ip6 address in network order to convert
  buf | target buffer where the string is stored
  buflen | length of buf

Returns
  either pointer to buf which now holds the ASCII representation of addr or NULL if buf was too small