lwIP 2.2.0
Lightweight IP stack
Loading...
Searching...
No Matches
IP address handling

Modules

 IPv4 only
 
 IPv6 only
 

Data Structures

struct  ip_addr
 

Macros

#define ip_addr_netcmp(addr1, addr2, mask)   ip_addr_net_eq((addr1), (addr2), (mask))
 
#define ip_addr_net_eq(addr1, addr2, mask)
 
#define ip_addr_cmp(addr1, addr2)   ip_addr_eq((addr1), (addr2))
 
#define ip_addr_eq(addr1, addr2)
 
#define ip_addr_cmp_zoneless(addr1, addr2)   ip_addr_zoneless_eq((addr1), (addr2))
 
#define ip_addr_zoneless_eq(addr1, addr2)
 
#define ip_addr_isany(ipaddr)
 
#define ip_addr_isany_val(ipaddr)
 
#define ip_addr_isbroadcast(ipaddr, netif)
 
#define ip_addr_ismulticast(ipaddr)
 
#define ip_addr_isloopback(ipaddr)
 
#define ip_addr_islinklocal(ipaddr)
 
#define IP_ANY_TYPE   (&ip_addr_any_type)
 

Typedefs

typedef struct ip_addr ip_addr_t
 

Enumerations

enum  lwip_ip_addr_type { IPADDR_TYPE_V4 = 0U , IPADDR_TYPE_V6 = 6U , IPADDR_TYPE_ANY = 46U }
 

Functions

char * ipaddr_ntoa (const ip_addr_t *addr)
 
char * ipaddr_ntoa_r (const ip_addr_t *addr, char *buf, int buflen)
 
int ipaddr_aton (const char *cp, ip_addr_t *addr)
 

Detailed Description

Macro Definition Documentation

◆ ip_addr_cmp

#define ip_addr_cmp (   addr1,
  addr2 
)    ip_addr_eq((addr1), (addr2))

◆ ip_addr_cmp_zoneless

#define ip_addr_cmp_zoneless (   addr1,
  addr2 
)    ip_addr_zoneless_eq((addr1), (addr2))

◆ ip_addr_eq

#define ip_addr_eq (   addr1,
  addr2 
)
Value:
((IP_GET_TYPE(addr1) != IP_GET_TYPE(addr2)) ? 0 : (IP_IS_V6_VAL(*(addr1)) ? \
ip6_addr_eq(ip_2_ip6(addr1), ip_2_ip6(addr2)) : \
ip4_addr_eq(ip_2_ip4(addr1), ip_2_ip4(addr2))))
#define ip_2_ip4(ipaddr)
Definition ip_addr.h:120
#define ip_2_ip6(ipaddr)
Definition ip_addr.h:116
#define ip6_addr_eq(addr1, addr2)
Definition ip6_addr.h:192

Check if two ip addresses are equal.

◆ ip_addr_isany

#define ip_addr_isany (   ipaddr)
Value:
(((ipaddr) == NULL) ? 1 : ((IP_IS_V6(ipaddr)) ? \
ip6_addr_isany(ip_2_ip6(ipaddr)) : \
ip4_addr_isany(ip_2_ip4(ipaddr))))

Check if an ip address is the 'any' address.

◆ ip_addr_isany_val

#define ip_addr_isany_val (   ipaddr)
Value:
((IP_IS_V6_VAL(ipaddr)) ? \
ip6_addr_isany_val(*ip_2_ip6(&(ipaddr))) : \
ip4_addr_isany_val(*ip_2_ip4(&(ipaddr))))

Check if an ip address is the 'any' address, by value.

◆ ip_addr_isbroadcast

#define ip_addr_isbroadcast (   ipaddr,
  netif 
)
Value:
((IP_IS_V6(ipaddr)) ? \
0 : \
ip4_addr_isbroadcast(ip_2_ip4(ipaddr), netif))
Definition netif.h:269

Check if an ip address is a broadcast address.

◆ ip_addr_islinklocal

#define ip_addr_islinklocal (   ipaddr)
Value:
((IP_IS_V6(ipaddr)) ? \
ip6_addr_islinklocal(ip_2_ip6(ipaddr)) : \
ip4_addr_islinklocal(ip_2_ip4(ipaddr)))

Check inf an ip address is a link-local address.

◆ ip_addr_isloopback

#define ip_addr_isloopback (   ipaddr)
Value:
((IP_IS_V6(ipaddr)) ? \
ip6_addr_isloopback(ip_2_ip6(ipaddr)) : \
#define ip4_addr_isloopback(ipaddr)
Definition ip4_addr.h:119

Check inf an ip address is a loopback address.

◆ ip_addr_ismulticast

#define ip_addr_ismulticast (   ipaddr)
Value:
((IP_IS_V6(ipaddr)) ? \
ip6_addr_ismulticast(ip_2_ip6(ipaddr)) : \
ip4_addr_ismulticast(ip_2_ip4(ipaddr)))

Check inf an ip address is a multicast address.

◆ ip_addr_net_eq

#define ip_addr_net_eq (   addr1,
  addr2,
  mask 
)
Value:
((IP_IS_V6(addr1) && IP_IS_V6(addr2)) ? \
0 : \
ip4_addr_net_eq(ip_2_ip4(addr1), ip_2_ip4(addr2), mask))
#define ip4_addr_net_eq(addr1, addr2, mask)
Definition ip4_addr.h:146

Check if two ip addresses are share the same network, for a specific netmask.

◆ ip_addr_netcmp

#define ip_addr_netcmp (   addr1,
  addr2,
  mask 
)    ip_addr_net_eq((addr1), (addr2), (mask))

◆ ip_addr_zoneless_eq

#define ip_addr_zoneless_eq (   addr1,
  addr2 
)
Value:
((IP_GET_TYPE(addr1) != IP_GET_TYPE(addr2)) ? 0 : (IP_IS_V6_VAL(*(addr1)) ? \
ip4_addr_eq(ip_2_ip4(addr1), ip_2_ip4(addr2))))
#define ip6_addr_zoneless_eq(addr1, addr2)
Definition ip6_addr.h:178

Check if two ip addresses are equal, ignoring the zone.

◆ IP_ANY_TYPE

#define IP_ANY_TYPE   (&ip_addr_any_type)

Macro representing the 'any' address.

Typedef Documentation

◆ ip_addr_t

typedef struct ip_addr ip_addr_t

A union struct for both IP version's addresses. ATTENTION: watch out for its size when adding IPv6 address scope!

Enumeration Type Documentation

◆ lwip_ip_addr_type

IP address types for use in ip_addr_t.type member.

See also
tcp_new_ip_type(), udp_new_ip_type(), raw_new_ip_type().
Enumerator
IPADDR_TYPE_V4 

IPv4

IPADDR_TYPE_V6 

IPv6

IPADDR_TYPE_ANY 

IPv4+IPv6 ("dual-stack")

Function Documentation

◆ ipaddr_aton()

int ipaddr_aton ( const char *  cp,
ip_addr_t addr 
)

Convert IP address string (both versions) to numeric. The version is auto-detected from the string.

Parameters
cpIP address string to convert
addrconversion result is stored here
Returns
1 on success, 0 on error

◆ ipaddr_ntoa()

char * ipaddr_ntoa ( const ip_addr_t addr)

Convert numeric IP address (both versions) into ASCII representation. returns ptr to static buffer; not reentrant!

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

◆ ipaddr_ntoa_r()

char * ipaddr_ntoa_r ( const ip_addr_t addr,
char *  buf,
int  buflen 
)

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

Parameters
addrip 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