dhcp: move DHCPState to dhcp-client-internal.h

All other definitions in dhcp-protocol.h are common for client and
server. Let's move DHCP client specific definitions.
This commit is contained in:
Yu Watanabe
2023-10-21 01:54:07 +09:00
parent f3d84e20c9
commit 8320db407c
6 changed files with 35 additions and 38 deletions
@@ -1,8 +1,28 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <errno.h>
#include "sd-dhcp-client.h"
#include "macro.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;
const char *dhcp_state_to_string(DHCPState s) _const_;
extern const struct hash_ops dhcp_option_hash_ops;
int dhcp_client_set_state_callback(
-18
View File
@@ -1,18 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "dhcp-protocol.h"
#include "string-table.h"
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);
-18
View File
@@ -59,22 +59,6 @@ enum {
DHCP_PORT_CLIENT = 68,
};
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,
};
typedef enum DHCPState DHCPState;
enum {
BOOTREQUEST = 1,
BOOTREPLY = 2,
@@ -114,5 +98,3 @@ enum {
DHCP_FQDN_FLAG_E = (1 << 2),
DHCP_FQDN_FLAG_N = (1 << 3),
};
const char *dhcp_state_to_string(DHCPState s) _const_;
-1
View File
@@ -6,7 +6,6 @@ sources = files(
'dhcp-network.c',
'dhcp-option.c',
'dhcp-packet.c',
'dhcp-protocol.c',
'dhcp6-network.c',
'dhcp6-option.c',
'dhcp6-protocol.c',
+15
View File
@@ -30,6 +30,7 @@
#include "random-util.h"
#include "set.h"
#include "sort-util.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "time-util.h"
@@ -2425,3 +2426,17 @@ int sd_dhcp_client_new(sd_dhcp_client **ret, int anonymize) {
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);
-1
View File
@@ -6,7 +6,6 @@
#include "bus-common-errors.h"
#include "bus-util.h"
#include "dhcp-client-internal.h"
#include "dhcp-protocol.h"
#include "networkd-dhcp4-bus.h"
#include "networkd-link-bus.h"
#include "networkd-manager.h"