Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys/net/ipv4: add IPV4_ADDR_INIT() macro #20354

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
sys/net/ipv4: add IPV4_ADDR_INIT() macro
This patch adds a macro to statically initialize an IPv4 address.
  • Loading branch information
Enoch247 committed Feb 7, 2024
commit bcc0d01c088a4cf0433700c6e8b91d708c6c33bb
12 changes: 12 additions & 0 deletions sys/include/net/ipv4/addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ extern "C" {
*/
#define IPV4_ADDR_MAX_STR_LEN (sizeof("255.255.255.255"))

/**
* @brief Static initializer for an IPv4 address.

* @param[in] a 1st octet
* @param[in] b 2nd octet
* @param[in] c 3rd octet
* @param[in] d 4th octet
*
* @return initialized IPv4 address
*/
#define IPV4_ADDR_INIT(a, b, c, d) { .u8 = {a, b, c, d} }

/**
* @brief Data type to represent an IPv4 address.
*/
Expand Down
Loading