Skip to content

Commit bcc0d01

Browse files
committed
sys/net/ipv4: add IPV4_ADDR_INIT() macro
This patch adds a macro to statically initialize an IPv4 address.
1 parent 4df5306 commit bcc0d01

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sys/include/net/ipv4/addr.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ extern "C" {
3535
*/
3636
#define IPV4_ADDR_MAX_STR_LEN (sizeof("255.255.255.255"))
3737

38+
/**
39+
* @brief Static initializer for an IPv4 address.
40+
41+
* @param[in] a 1st octet
42+
* @param[in] b 2nd octet
43+
* @param[in] c 3rd octet
44+
* @param[in] d 4th octet
45+
*
46+
* @return initialized IPv4 address
47+
*/
48+
#define IPV4_ADDR_INIT(a, b, c, d) { .u8 = {a, b, c, d} }
49+
3850
/**
3951
* @brief Data type to represent an IPv4 address.
4052
*/

0 commit comments

Comments
 (0)