Convert network addresses from ASCII to binary and vice versa. More...
Functions | |
const char * | netIP_ntoa (int16_t addr_type, const uint8_t *ip_addr, char *string_buf, uint32_t buf_len) |
Convert IP address from binary to text form. [thread-safe]. | |
bool | netIP_aton (const char *addr_string, int16_t addr_type, uint8_t *ip_addr) |
Convert IP address from text to binary form. [thread-safe]. | |
const char * | netMAC_ntoa (const uint8_t *mac_addr, char *string_buf, uint32_t buf_len) |
Convert MAC address from binary to text form. [thread-safe]. | |
bool | netMAC_aton (const char *mac_string, uint8_t *mac_addr) |
Convert MAC address from text to binary form. [thread-safe]. | |
Convert network addresses from ASCII to binary and vice versa.
The address conversion functions are used for conversion of IP or MAC addresses from binary to ASCII strings and vice versa.
bool netIP_aton | ( | const char * | addr_string, |
int16_t | addr_type, | ||
uint8_t * | ip_addr | ||
) |
Convert IP address from text to binary form. [thread-safe].
[in] | addr_string | network address string:
|
[in] | addr_type | network address type:
|
[out] | ip_addr | IPv6 or IPv6 address in binary form. |
The function netIP_aton converts an ASCII to a network address.
The argument addr_string specifies the ASCII representation of the IP address.
The argument addr_type specifies if the address to be converted is IPv4 or IPv6.
The argument ip_addr points to the buffer that stores the converted IP address.
Code Example
const char * netIP_ntoa | ( | int16_t | addr_type, |
const uint8_t * | ip_addr, | ||
char * | string_buf, | ||
uint32_t | buf_len | ||
) |
Convert IP address from binary to text form. [thread-safe].
[in] | addr_type | network address type:
|
[in] | ip_addr | IPv4 or IPv6 address in binary form. |
[out] | string_buf | buffer to store converted IP address to. |
[in] | buf_len | length of a string buffer, at least:
|
The function netIP_ntoa converts a network address to ASCII.
The argument addr_type specifies if the address to be converted is IPv4 or IPv6.
The argument ip_addr points to the buffer containing the IP address to be converted.
Code Example
bool netMAC_aton | ( | const char * | mac_string, |
uint8_t * | mac_addr | ||
) |
Convert MAC address from text to binary form. [thread-safe].
[in] | mac_string | address string in hyphen MAC-address notation. |
[out] | mac_addr | MAC address in binary form. |
The function netMAC_aton converts an ASCII string to a MAC address.
The argument mac_string specifies the ASCII representation of the MAC address.
The argument mac_addr is a pointer to the buffer that stores the converted MAC address.
Code Example
const char * netMAC_ntoa | ( | const uint8_t * | mac_addr, |
char * | string_buf, | ||
uint32_t | buf_len | ||
) |
Convert MAC address from binary to text form. [thread-safe].
[in] | mac_addr | MAC address in binary form. |
[out] | string_buf | buffer to store converted MAC address to. |
[in] | buf_len | length of a string buffer, at least 18 characters. |
The function netMAC_ntoa converts a MAC address to ASCII.
The argument mac_addr specifies the MAC address to be converted.
Code Example