dhcp-protocol: introduce {bootp,dhcp}_message_type_to_string()
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "dhcp-protocol.h"
|
||||
#include "string-table.h"
|
||||
|
||||
static const char * const bootp_message_type_table[_BOOTP_MESSAGE_TYPE_MAX] = {
|
||||
[BOOTREQUEST] = "BOOTREQUEST",
|
||||
[BOOTREPLY] = "BOOTREPLY",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP_TO_STRING(bootp_message_type, BOOTPMessageType);
|
||||
|
||||
static const char * const dhcp_message_type_table[_DHCP_MESSAGE_TYPE_MAX] = {
|
||||
[DHCP_DISCOVER] = "DISCOVER",
|
||||
[DHCP_OFFER] = "OFFER",
|
||||
[DHCP_REQUEST] = "REQUEST",
|
||||
[DHCP_DECLINE] = "DECLINE",
|
||||
[DHCP_ACK] = "ACK",
|
||||
[DHCP_NAK] = "NAK",
|
||||
[DHCP_RELEASE] = "RELEASE",
|
||||
[DHCP_INFORM] = "INFORM",
|
||||
[DHCP_FORCERENEW] = "FORCERENEW",
|
||||
[DHCP_LEASEQUERY] = "LEASEQUERY",
|
||||
[DHCP_LEASEUNASSIGNED] = "LEASEUNASSIGNED",
|
||||
[DHCP_LEASEUNKNOWN] = "LEASEUNKNOWN",
|
||||
[DHCP_LEASEACTIVE] = "LEASEACTIVE",
|
||||
[DHCP_BULKLEASEQUERY] = "BULKLEASEQUERY",
|
||||
[DHCP_LEASEQUERYDONE] = "LEASEQUERYDONE",
|
||||
[DHCP_ACTIVELEASEQUERY] = "ACTIVELEASEQUERY",
|
||||
[DHCP_LEASEQUERYSTATUS] = "LEASEQUERYSTATUS",
|
||||
[DHCP_TLS] = "TLS",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP_TO_STRING(dhcp_message_type, DHCPMessageType);
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/udp.h>
|
||||
|
||||
#include "sd-dhcp-protocol.h"
|
||||
#include "sd-dhcp-protocol.h" /* IWYU pragma: export */
|
||||
|
||||
#include "sd-forward.h"
|
||||
#include "sparse-endian.h"
|
||||
@@ -74,12 +74,16 @@ enum {
|
||||
DHCP_PORT_CLIENT = 68,
|
||||
};
|
||||
|
||||
enum {
|
||||
typedef enum {
|
||||
BOOTREQUEST = 1,
|
||||
BOOTREPLY = 2,
|
||||
};
|
||||
_BOOTP_MESSAGE_TYPE_MAX,
|
||||
_BOOTP_MESSAGE_TYPE_INVALID = -EINVAL,
|
||||
} BOOTPMessageType;
|
||||
|
||||
enum {
|
||||
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(bootp_message_type, BOOTPMessageType);
|
||||
|
||||
typedef enum {
|
||||
DHCP_DISCOVER = 1, /* [RFC2132] */
|
||||
DHCP_OFFER = 2, /* [RFC2132] */
|
||||
DHCP_REQUEST = 3, /* [RFC2132] */
|
||||
@@ -98,7 +102,11 @@ enum {
|
||||
DHCP_ACTIVELEASEQUERY = 16, /* [RFC7724] */
|
||||
DHCP_LEASEQUERYSTATUS = 17, /* [RFC7724] */
|
||||
DHCP_TLS = 18, /* [RFC7724] */
|
||||
};
|
||||
_DHCP_MESSAGE_TYPE_MAX,
|
||||
_DHCP_MESSAGE_TYPE_INVALID = -EINVAL,
|
||||
} DHCPMessageType;
|
||||
|
||||
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(dhcp_message_type, DHCPMessageType);
|
||||
|
||||
typedef enum {
|
||||
DHCP_OVERLOAD_NONE = 0,
|
||||
|
||||
@@ -5,6 +5,7 @@ libsystemd_network_sources = files(
|
||||
'dhcp-network.c',
|
||||
'dhcp-option.c',
|
||||
'dhcp-packet.c',
|
||||
'dhcp-protocol.c',
|
||||
'dhcp6-network.c',
|
||||
'dhcp6-option.c',
|
||||
'dhcp6-protocol.c',
|
||||
|
||||
Reference in New Issue
Block a user