From fc83acbd99f9d2558176b1546ba560696fd13974 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 10 Feb 2021 15:14:10 +0100 Subject: [PATCH] dhcp: add nm_dhcp_option_add_option_in_addr() helper --- src/core/dhcp/nm-dhcp-options.c | 11 +++++++++++ src/core/dhcp/nm-dhcp-options.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/core/dhcp/nm-dhcp-options.c b/src/core/dhcp/nm-dhcp-options.c index c3ef8478e8..e03fa23192 100644 --- a/src/core/dhcp/nm-dhcp-options.c +++ b/src/core/dhcp/nm-dhcp-options.c @@ -267,6 +267,17 @@ nm_dhcp_option_add_option_u64(GHashTable * options, g_strdup_printf("%" G_GUINT64_FORMAT, value)); } +void +nm_dhcp_option_add_option_in_addr(GHashTable * options, + const NMDhcpOption *requests, + guint option, + in_addr_t value) +{ + char sbuf[NM_UTILS_INET_ADDRSTRLEN]; + + nm_dhcp_option_add_option(options, requests, option, _nm_utils_inet4_ntop(value, sbuf)); +} + void nm_dhcp_option_add_requests_to_options(GHashTable *options, const NMDhcpOption *requests) { diff --git a/src/core/dhcp/nm-dhcp-options.h b/src/core/dhcp/nm-dhcp-options.h index 9e6e4d1cf1..2ebf339ed7 100644 --- a/src/core/dhcp/nm-dhcp-options.h +++ b/src/core/dhcp/nm-dhcp-options.h @@ -200,6 +200,10 @@ void nm_dhcp_option_add_option_utf8safe_escape(GHashTable * option guint option, const guint8 * data, gsize n_data); +void nm_dhcp_option_add_option_in_addr(GHashTable * options, + const NMDhcpOption *requests, + guint option, + in_addr_t value); void nm_dhcp_option_add_option_u64(GHashTable * options, const NMDhcpOption *requests, guint option,