summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-05-04 22:21:44 +0200
committerThomas Haller <thaller@redhat.com>2022-05-16 16:34:32 +0200
commit8d121b17b57ab995726a0b081fde31b5bfbaf70f (patch)
treea150de4564b164406d595f1e4efa67688e6e2886
parent1093e6677606aaeafc422821bd25b2e4ff239247 (diff)
downloadNetworkManager-8d121b17b57ab995726a0b081fde31b5bfbaf70f.tar.gz
dhcp: move code in "nm-dhcp-client.c"
So that it makes more sense, related parts are closer together.
-rw-r--r--src/core/dhcp/nm-dhcp-client.c96
1 files changed, 49 insertions, 47 deletions
diff --git a/src/core/dhcp/nm-dhcp-client.c b/src/core/dhcp/nm-dhcp-client.c
index c747659618..fbf388cc23 100644
--- a/src/core/dhcp/nm-dhcp-client.c
+++ b/src/core/dhcp/nm-dhcp-client.c
@@ -75,6 +75,42 @@ G_STATIC_ASSERT(!(((pid_t) -1) > 0));
/*****************************************************************************/
+NM_UTILS_LOOKUP_STR_DEFINE(nm_dhcp_state_to_string,
+ NMDhcpState,
+ NM_UTILS_LOOKUP_DEFAULT(NULL),
+ NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_BOUND, "bound"),
+ NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_DONE, "done"),
+ NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_EXPIRE, "expire"),
+ NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_EXTENDED, "extended"),
+ NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_FAIL, "fail"),
+ NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_NOOP, "noop"),
+ NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_TERMINATED, "terminated"),
+ NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_TIMEOUT, "timeout"),
+ NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_UNKNOWN, "unknown"), );
+
+static NMDhcpState
+reason_to_state(const char *reason)
+{
+ if (NM_IN_STRSET_ASCII_CASE(reason, "bound", "bound6", "static"))
+ return NM_DHCP_STATE_BOUND;
+ if (NM_IN_STRSET_ASCII_CASE(reason, "renew", "renew6", "reboot", "rebind", "rebind6"))
+ return NM_DHCP_STATE_EXTENDED;
+ if (NM_IN_STRSET_ASCII_CASE(reason, "timeout"))
+ return NM_DHCP_STATE_TIMEOUT;
+ if (NM_IN_STRSET_ASCII_CASE(reason, "nak", "expire", "expire6"))
+ return NM_DHCP_STATE_EXPIRE;
+ if (NM_IN_STRSET_ASCII_CASE(reason, "end", "stop", "stopped"))
+ return NM_DHCP_STATE_DONE;
+ if (NM_IN_STRSET_ASCII_CASE(reason, "fail", "abend"))
+ return NM_DHCP_STATE_FAIL;
+ if (NM_IN_STRSET_ASCII_CASE(reason, "preinit"))
+ return NM_DHCP_STATE_NOOP;
+
+ return NM_DHCP_STATE_UNKNOWN;
+}
+
+/*****************************************************************************/
+
static void
_emit_notify(NMDhcpClient *self, const NMDhcpClientNotifyData *notify_data)
{
@@ -104,13 +140,7 @@ connect_l3cfg_notify(NMDhcpClient *self)
}
}
-pid_t
-nm_dhcp_client_get_pid(NMDhcpClient *self)
-{
- g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), -1);
-
- return NM_DHCP_CLIENT_GET_PRIVATE(self)->pid;
-}
+/*****************************************************************************/
void
nm_dhcp_client_set_effective_client_id(NMDhcpClient *self, GBytes *client_id)
@@ -136,44 +166,24 @@ nm_dhcp_client_set_effective_client_id(NMDhcpClient *self, GBytes *client_id)
: "default");
}
-/*****************************************************************************/
-
-NM_UTILS_LOOKUP_STR_DEFINE(nm_dhcp_state_to_string,
- NMDhcpState,
- NM_UTILS_LOOKUP_DEFAULT(NULL),
- NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_BOUND, "bound"),
- NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_DONE, "done"),
- NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_EXPIRE, "expire"),
- NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_EXTENDED, "extended"),
- NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_FAIL, "fail"),
- NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_NOOP, "noop"),
- NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_TERMINATED, "terminated"),
- NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_TIMEOUT, "timeout"),
- NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_UNKNOWN, "unknown"), );
-
-static NMDhcpState
-reason_to_state(const char *reason)
+const NMDhcpClientConfig *
+nm_dhcp_client_get_config(NMDhcpClient *self)
{
- if (NM_IN_STRSET_ASCII_CASE(reason, "bound", "bound6", "static"))
- return NM_DHCP_STATE_BOUND;
- if (NM_IN_STRSET_ASCII_CASE(reason, "renew", "renew6", "reboot", "rebind", "rebind6"))
- return NM_DHCP_STATE_EXTENDED;
- if (NM_IN_STRSET_ASCII_CASE(reason, "timeout"))
- return NM_DHCP_STATE_TIMEOUT;
- if (NM_IN_STRSET_ASCII_CASE(reason, "nak", "expire", "expire6"))
- return NM_DHCP_STATE_EXPIRE;
- if (NM_IN_STRSET_ASCII_CASE(reason, "end", "stop", "stopped"))
- return NM_DHCP_STATE_DONE;
- if (NM_IN_STRSET_ASCII_CASE(reason, "fail", "abend"))
- return NM_DHCP_STATE_FAIL;
- if (NM_IN_STRSET_ASCII_CASE(reason, "preinit"))
- return NM_DHCP_STATE_NOOP;
+ NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self);
- return NM_DHCP_STATE_UNKNOWN;
+ return &priv->config;
}
/*****************************************************************************/
+pid_t
+nm_dhcp_client_get_pid(NMDhcpClient *self)
+{
+ g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), -1);
+
+ return NM_DHCP_CLIENT_GET_PRIVATE(self)->pid;
+}
+
static void
watch_cleanup(NMDhcpClient *self)
{
@@ -234,14 +244,6 @@ _no_lease_timeout(gpointer user_data)
return G_SOURCE_CONTINUE;
}
-const NMDhcpClientConfig *
-nm_dhcp_client_get_config(NMDhcpClient *self)
-{
- NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self);
-
- return &priv->config;
-}
-
static void
_no_lease_timeout_schedule(NMDhcpClient *self)
{