dhcp: move definition of enum DHCPState to dhcp-protocol.[ch]

It will be also used in DHCP server, later.
This commit is contained in:
Yu Watanabe
2026-05-22 08:34:22 +09:00
parent 3115496c8c
commit 05c295d269
5 changed files with 32 additions and 32 deletions
+1 -16
View File
@@ -4,6 +4,7 @@
#include "sd-dhcp-client.h"
#include "dhcp-client-id-internal.h"
#include "dhcp-protocol.h"
#include "ether-addr-util.h"
#include "iovec-wrapper.h"
#include "network-common.h"
@@ -11,22 +12,6 @@
#include "socket-util.h"
#include "tlv-util.h"
typedef enum DHCPState {
DHCP_STATE_STOPPED,
DHCP_STATE_INIT,
DHCP_STATE_SELECTING,
DHCP_STATE_INIT_REBOOT,
DHCP_STATE_REBOOTING,
DHCP_STATE_REQUESTING,
DHCP_STATE_BOUND,
DHCP_STATE_RENEWING,
DHCP_STATE_REBINDING,
_DHCP_STATE_MAX,
_DHCP_STATE_INVALID = -EINVAL,
} DHCPState;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(dhcp_state, DHCPState);
struct sd_dhcp_client {
unsigned n_ref;
+14
View File
@@ -188,3 +188,17 @@ static const char * const dhcp_option_code_table[] = {
};
DEFINE_STRING_TABLE_LOOKUP_TO_STRING(dhcp_option_code, int);
static const char* const dhcp_state_table[_DHCP_STATE_MAX] = {
[DHCP_STATE_STOPPED] = "stopped",
[DHCP_STATE_INIT] = "initialization",
[DHCP_STATE_SELECTING] = "selecting",
[DHCP_STATE_INIT_REBOOT] = "init-reboot",
[DHCP_STATE_REBOOTING] = "rebooting",
[DHCP_STATE_REQUESTING] = "requesting",
[DHCP_STATE_BOUND] = "bound",
[DHCP_STATE_RENEWING] = "renewing",
[DHCP_STATE_REBINDING] = "rebinding",
};
DEFINE_STRING_TABLE_LOOKUP_TO_STRING(dhcp_state, DHCPState);
+16
View File
@@ -138,3 +138,19 @@ enum {
};
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(dhcp_option_code, int);
typedef enum DHCPState {
DHCP_STATE_STOPPED,
DHCP_STATE_INIT,
DHCP_STATE_SELECTING,
DHCP_STATE_INIT_REBOOT,
DHCP_STATE_REBOOTING,
DHCP_STATE_REQUESTING,
DHCP_STATE_BOUND,
DHCP_STATE_RENEWING,
DHCP_STATE_REBINDING,
_DHCP_STATE_MAX,
_DHCP_STATE_INVALID = -EINVAL,
} DHCPState;
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(dhcp_state, DHCPState);
+1 -1
View File
@@ -6,7 +6,7 @@
#include "sd-event.h"
#include "sd-json.h"
#include "dhcp-client-internal.h"
#include "dhcp-client-internal.h" /* IWYU pragma: keep */
#include "dhcp-lease-internal.h"
#include "dhcp-message.h"
#include "fd-util.h"
-15
View File
@@ -24,7 +24,6 @@
#include "random-util.h"
#include "set.h"
#include "socket-util.h"
#include "string-table.h"
#include "string-util.h"
#include "time-util.h"
#include "web-util.h"
@@ -1443,17 +1442,3 @@ int sd_dhcp_client_new(sd_dhcp_client **ret) {
return 0;
}
static const char* const dhcp_state_table[_DHCP_STATE_MAX] = {
[DHCP_STATE_STOPPED] = "stopped",
[DHCP_STATE_INIT] = "initialization",
[DHCP_STATE_SELECTING] = "selecting",
[DHCP_STATE_INIT_REBOOT] = "init-reboot",
[DHCP_STATE_REBOOTING] = "rebooting",
[DHCP_STATE_REQUESTING] = "requesting",
[DHCP_STATE_BOUND] = "bound",
[DHCP_STATE_RENEWING] = "renewing",
[DHCP_STATE_REBINDING] = "rebinding",
};
DEFINE_STRING_TABLE_LOOKUP_TO_STRING(dhcp_state, DHCPState);