lwIP
2.1.0
Lightweight IP stack
|
Data Structures | |
struct | ip4_addr |
Macros | |
#define | IPADDR_NONE ((u32_t)0xffffffffUL) |
#define | IPADDR_LOOPBACK ((u32_t)0x7f000001UL) |
#define | IPADDR_ANY ((u32_t)0x00000000UL) |
#define | IPADDR_BROADCAST ((u32_t)0xffffffffUL) |
#define | IP4_ADDR(ipaddr, a, b, c, d) (ipaddr)->addr = PP_HTONL(LWIP_MAKEU32(a,b,c,d)) |
#define | ip4_addr_copy(dest, src) ((dest).addr = (src).addr) |
#define | ip4_addr_set(dest, src) |
#define | ip4_addr_set_zero(ipaddr) ((ipaddr)->addr = 0) |
#define | ip4_addr_set_any(ipaddr) ((ipaddr)->addr = IPADDR_ANY) |
#define | ip4_addr_set_loopback(ipaddr) ((ipaddr)->addr = PP_HTONL(IPADDR_LOOPBACK)) |
#define | ip4_addr_isloopback(ipaddr) (((ipaddr)->addr & PP_HTONL(IP_CLASSA_NET)) == PP_HTONL(((u32_t)IP_LOOPBACKNET) << 24)) |
#define | ip4_addr_set_hton(dest, src) |
#define | ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32)) |
#define | ip4_addr_get_u32(src_ipaddr) ((src_ipaddr)->addr) |
#define | ip4_addr_get_network(target, host, netmask) do { ((target)->addr = ((host)->addr) & ((netmask)->addr)); } while(0) |
#define | ip4_addr_netcmp(addr1, addr2, mask) |
#define | ip_ntoa(ipaddr) ipaddr_ntoa(ipaddr) |
Typedefs | |
typedef struct ip4_addr | ip4_addr_t |
Functions | |
u8_t | ip4_addr_isbroadcast_u32 (u32_t addr, const struct netif *netif) |
u8_t | ip4_addr_netmask_valid (u32_t netmask) |
u32_t | ipaddr_addr (const char *cp) |
int | ip4addr_aton (const char *cp, ip4_addr_t *addr) |
char * | ip4addr_ntoa (const ip4_addr_t *addr) |
char * | ip4addr_ntoa_r (const ip4_addr_t *addr, char *buf, int buflen) |
IPv4 address API
#define IP4_ADDR | ( | ipaddr, | |
a, | |||
b, | |||
c, | |||
d | |||
) | (ipaddr)->addr = PP_HTONL(LWIP_MAKEU32(a,b,c,d)) |
Set an IP address given by the four byte-parts
#define ip4_addr_copy | ( | dest, | |
src | |||
) | ((dest).addr = (src).addr) |
Copy IP address - faster than ip4_addr_set: no NULL check
#define ip4_addr_get_network | ( | target, | |
host, | |||
netmask | |||
) | do { ((target)->addr = ((host)->addr) & ((netmask)->addr)); } while(0) |
Get the network address by combining host address with netmask
#define ip4_addr_get_u32 | ( | src_ipaddr | ) | ((src_ipaddr)->addr) |
IPv4 only: get the IP address as an u32_t
#define ip4_addr_isloopback | ( | ipaddr | ) | (((ipaddr)->addr & PP_HTONL(IP_CLASSA_NET)) == PP_HTONL(((u32_t)IP_LOOPBACKNET) << 24)) |
Check if an address is in the loopback region
#define ip4_addr_netcmp | ( | addr1, | |
addr2, | |||
mask | |||
) |
Determine if two address are on the same network.
#define ip4_addr_set | ( | dest, | |
src | |||
) |
Safely copy one IP address to another (src may be NULL)
#define ip4_addr_set_any | ( | ipaddr | ) | ((ipaddr)->addr = IPADDR_ANY) |
Set address to IPADDR_ANY (no need for lwip_htonl())
#define ip4_addr_set_hton | ( | dest, | |
src | |||
) |
Safely copy one IP address to another and change byte order from host- to network-order.
#define ip4_addr_set_loopback | ( | ipaddr | ) | ((ipaddr)->addr = PP_HTONL(IPADDR_LOOPBACK)) |
Set address to loopback address
#define ip4_addr_set_u32 | ( | dest_ipaddr, | |
src_u32 | |||
) | ((dest_ipaddr)->addr = (src_u32)) |
IPv4 only: set the IP address given as an u32_t
#define ip4_addr_set_zero | ( | ipaddr | ) | ((ipaddr)->addr = 0) |
Set complete address to zero
#define ip_ntoa | ( | ipaddr | ) | ipaddr_ntoa(ipaddr) |
For backwards compatibility
#define IPADDR_ANY ((u32_t)0x00000000UL) |
0.0.0.0
#define IPADDR_BROADCAST ((u32_t)0xffffffffUL) |
255.255.255.255
#define IPADDR_LOOPBACK ((u32_t)0x7f000001UL) |
127.0.0.1
#define IPADDR_NONE ((u32_t)0xffffffffUL) |
255.255.255.255
typedef struct ip4_addr ip4_addr_t |
ip4_addr_t uses a struct for convenience only, so that the same defines can operate both on ip4_addr_t as well as on ip4_addr_p_t.
u8_t ip4_addr_isbroadcast_u32 | ( | u32_t | addr, |
const struct netif * | netif | ||
) |
Determine if an address is a broadcast address on a network interface
addr | address to be checked |
netif | the network interface against which the address is checked |
u8_t ip4_addr_netmask_valid | ( | u32_t | netmask | ) |
Checks if a netmask is valid (starting with ones, then only zeros)
netmask | the IPv4 netmask to check (in network byte order!) |
int ip4addr_aton | ( | const char * | cp, |
ip4_addr_t * | addr | ||
) |
Check whether "cp" is a valid ascii representation of an Internet address and convert to a binary address. Returns 1 if the address is valid, 0 if not. This replaces inet_addr, the return value from which cannot distinguish between failure and a local broadcast address.
cp | IP address in ascii representation (e.g. "127.0.0.1") |
addr | pointer to which to save the ip address in network order |
char* ip4addr_ntoa | ( | const ip4_addr_t * | addr | ) |
returns ptr to static buffer; not reentrant!
Convert numeric IP address into decimal dotted ASCII representation. returns ptr to static buffer; not reentrant!
addr | ip address in network order to convert |
char* ip4addr_ntoa_r | ( | const ip4_addr_t * | addr, |
char * | buf, | ||
int | buflen | ||
) |
Same as ip4addr_ntoa, but reentrant since a user-supplied buffer is used.
addr | ip address in network order to convert |
buf | target buffer where the string is stored |
buflen | length of buf |
u32_t ipaddr_addr | ( | const char * | cp | ) |
Ascii internet address interpretation routine. The value returned is in network order.
cp | IP address in ascii representation (e.g. "127.0.0.1") |