IPv4 address types and helper function.
More...
IPv4 address types and helper function.
|
| file | addr.h |
| | IPv4 address type and helper functions definitions.
|
| |
◆ IPV4_ADDR_INIT
| #define IPV4_ADDR_INIT |
( |
|
a, |
|
|
|
b, |
|
|
|
c, |
|
|
|
d |
|
) |
| { .u8 = {a, b, c, d} } |
Static initializer for an IPv4 address.
- Parameters
-
| [in] | a | 1st octet |
| [in] | b | 2nd octet |
| [in] | c | 3rd octet |
| [in] | d | 4th octet |
- Returns
- initialized IPv4 address
Definition at line 48 of file addr.h.
◆ ipv4_addr_equal()
Checks if two IPv4 addresses are equal.
- Parameters
-
| [in] | a | An IPv4 address. |
| [in] | b | Another IPv4 address. |
- Returns
- true, if
a and b are equal
-
false, otherwise.
Definition at line 72 of file addr.h.
◆ ipv4_addr_from_buf()
Converts an IPv4 address from a buffer of characters to a byte-represented IPv4 address.
- Note
addr_len should be between 0 and IPV4_ADDR_MAX_STR_LEN
- Parameters
-
| [out] | result | The resulting byte representation |
| [in] | addr | An IPv4 address string representation |
| [in] | addr_len | The amount of characters to parse |
- Returns
result, on success
-
NULL, if
addr was malformed
-
NULL, if
result or addr was NULL
◆ ipv4_addr_from_str()
Converts an IPv4 address string representation to a byte-represented IPv4 address.
- Parameters
-
| [out] | result | The resulting byte representation |
| [in] | addr | An IPv4 address string representation |
- Returns
result, on success
-
NULL, if
addr was malformed
-
NULL, if
result or addr was NULL
◆ ipv4_addr_is_multicast()
| static bool ipv4_addr_is_multicast |
( |
const ipv4_addr_t * |
addr | ) |
|
|
inlinestatic |
Check if addr is a multicast address.
- See also
- RFC 1112, section 4
- Parameters
-
- Returns
- true, if
addr is multicast address,
-
false, otherwise.
Definition at line 89 of file addr.h.
◆ ipv4_addr_print()
Print IPv4 address to stdout.
- Parameters
-
◆ ipv4_addr_to_str()
| char* ipv4_addr_to_str |
( |
char * |
result, |
|
|
const ipv4_addr_t * |
addr, |
|
|
uint8_t |
result_len |
|
) |
| |
Converts an IPv4 address to its string representation.
- Parameters
-
| [out] | result | The resulting string representation of at least IPV4_ADDR_MAX_STR_LEN. |
| [in] | addr | An IPv4 address |
| [in] | result_len | Length of result |
- Returns
result, on success
-
NULL, if
result_len was lesser than IPV4_ADDR_MAX_STR_LEN
-
NULL, if
result or addr was NULL