/* 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);

static const char * const dhcp_option_code_table[] = {
        [SD_DHCP_OPTION_PAD]                                            = "pad",
        [SD_DHCP_OPTION_SUBNET_MASK]                                    = "subnet mask",
        [SD_DHCP_OPTION_TIME_OFFSET]                                    = "time offset",
        [SD_DHCP_OPTION_ROUTER]                                         = "router",
        [SD_DHCP_OPTION_TIME_SERVER]                                    = "time server",
        [SD_DHCP_OPTION_NAME_SERVER]                                    = "name server",
        [SD_DHCP_OPTION_DOMAIN_NAME_SERVER]                             = "domain name server",
        [SD_DHCP_OPTION_LOG_SERVER]                                     = "log server",
        [SD_DHCP_OPTION_QUOTES_SERVER]                                  = "quotes server",
        [SD_DHCP_OPTION_LPR_SERVER]                                     = "LPR server",
        [SD_DHCP_OPTION_IMPRESS_SERVER]                                 = "impress server",
        [SD_DHCP_OPTION_RLP_SERVER]                                     = "RLP server",
        [SD_DHCP_OPTION_HOST_NAME]                                      = "hostname",
        [SD_DHCP_OPTION_BOOT_FILE_SIZE]                                 = "boot file size",
        [SD_DHCP_OPTION_MERIT_DUMP_FILE]                                = "merit dump file",
        [SD_DHCP_OPTION_DOMAIN_NAME]                                    = "domain name",
        [SD_DHCP_OPTION_SWAP_SERVER]                                    = "swap server",
        [SD_DHCP_OPTION_ROOT_PATH]                                      = "root path",
        [SD_DHCP_OPTION_EXTENSION_FILE]                                 = "extension file",
        [SD_DHCP_OPTION_FORWARD]                                        = "IP forwarding",
        [SD_DHCP_OPTION_SOURCE_ROUTE]                                   = "source routing",
        [SD_DHCP_OPTION_POLICY_FILTER]                                  = "policy filter",
        [SD_DHCP_OPTION_MAX_DATAGRAM_ASSEMBLY]                          = "max datagram assembly",
        [SD_DHCP_OPTION_DEFAULT_IP_TTL]                                 = "default IP TTL",
        [SD_DHCP_OPTION_MTU_TIMEOUT]                                    = "MTU timeout",
        [SD_DHCP_OPTION_MTU_PLATEAU]                                    = "MTU plateau",
        [SD_DHCP_OPTION_MTU_INTERFACE]                                  = "MTU size",
        [SD_DHCP_OPTION_MTU_SUBNET]                                     = "MTU subnet",
        [SD_DHCP_OPTION_BROADCAST]                                      = "broadcast address",
        [SD_DHCP_OPTION_MASK_DISCOVERY]                                 = "mask discovery",
        [SD_DHCP_OPTION_MASK_SUPPLIER]                                  = "mask supplier",
        [SD_DHCP_OPTION_ROUTER_DISCOVERY]                               = "router discovery",
        [SD_DHCP_OPTION_ROUTER_REQUEST]                                 = "router request",
        [SD_DHCP_OPTION_STATIC_ROUTE]                                   = "static route",
        [SD_DHCP_OPTION_TRAILERS]                                       = "trailers",
        [SD_DHCP_OPTION_ARP_TIMEOUT]                                    = "ARP timeout",
        [SD_DHCP_OPTION_ETHERNET]                                       = "Ethernet encapsulation",
        [SD_DHCP_OPTION_DEFAULT_TCP_TTL]                                = "default TCP TTL",
        [SD_DHCP_OPTION_KEEPALIVE_TIME]                                 = "keepalive time",
        [SD_DHCP_OPTION_KEEPALIVE_DATA]                                 = "keepalive data",
        [SD_DHCP_OPTION_NIS_DOMAIN]                                     = "NIS domain",
        [SD_DHCP_OPTION_NIS_SERVER]                                     = "NIS server",
        [SD_DHCP_OPTION_NTP_SERVER]                                     = "NTP server",
        [SD_DHCP_OPTION_VENDOR_SPECIFIC_INFORMATION]                    = "vendor-specific information",
        [SD_DHCP_OPTION_NETBIOS_NAME_SERVER]                            = "NETBIOS name server",
        [SD_DHCP_OPTION_NETBIOS_DIST_SERVER]                            = "NETBIOS distribution server",
        [SD_DHCP_OPTION_NETBIOS_NODE_TYPE]                              = "NETBIOS node type",
        [SD_DHCP_OPTION_NETBIOS_SCOPE]                                  = "NETBIOS scope",
        [SD_DHCP_OPTION_X_WINDOW_FONT]                                  = "X Window font",
        [SD_DHCP_OPTION_X_WINDOW_MANAGER]                               = "X Window manager",
        [SD_DHCP_OPTION_REQUESTED_IP_ADDRESS]                           = "requested IP address",
        [SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME]                          = "lease time",
        [SD_DHCP_OPTION_OVERLOAD]                                       = "overload",
        [SD_DHCP_OPTION_MESSAGE_TYPE]                                   = "message type",
        [SD_DHCP_OPTION_SERVER_IDENTIFIER]                              = "server identifier",
        [SD_DHCP_OPTION_PARAMETER_REQUEST_LIST]                         = "parameter request list",
        [SD_DHCP_OPTION_ERROR_MESSAGE]                                  = "error message",
        [SD_DHCP_OPTION_MAXIMUM_MESSAGE_SIZE]                           = "max message size",
        [SD_DHCP_OPTION_RENEWAL_TIME]                                   = "renewal time",
        [SD_DHCP_OPTION_REBINDING_TIME]                                 = "rebinding time",
        [SD_DHCP_OPTION_VENDOR_CLASS_IDENTIFIER]                        = "vendor class identifier",
        [SD_DHCP_OPTION_CLIENT_IDENTIFIER]                              = "client identifier",
        [SD_DHCP_OPTION_NETWARE_IP_DOMAIN]                              = "NetWare IP domain",
        [SD_DHCP_OPTION_NETWARE_IP_OPTION]                              = "NetWare IP option",
        [SD_DHCP_OPTION_NIS_DOMAIN_NAME]                                = "NIS+ v3 domain",
        [SD_DHCP_OPTION_NIS_SERVER_ADDR]                                = "NIS+ v3 server",
        [SD_DHCP_OPTION_BOOT_SERVER_NAME]                               = "TFTP server name",
        [SD_DHCP_OPTION_BOOT_FILENAME]                                  = "boot file name",
        [SD_DHCP_OPTION_HOME_AGENT_ADDRESS]                             = "home agent address",
        [SD_DHCP_OPTION_SMTP_SERVER]                                    = "SMTP server",
        [SD_DHCP_OPTION_POP3_SERVER]                                    = "POP3 server",
        [SD_DHCP_OPTION_NNTP_SERVER]                                    = "NNTP server",
        [SD_DHCP_OPTION_WWW_SERVER]                                     = "WWW server",
        [SD_DHCP_OPTION_FINGER_SERVER]                                  = "finger server",
        [SD_DHCP_OPTION_IRC_SERVER]                                     = "IRC server",
        [SD_DHCP_OPTION_STREETTALK_SERVER]                              = "StreetTalk server",
        [SD_DHCP_OPTION_STDA_SERVER]                                    = "STDA server",
        [SD_DHCP_OPTION_USER_CLASS]                                     = "user class",
        [SD_DHCP_OPTION_DIRECTORY_AGENT]                                = "directory agent",
        [SD_DHCP_OPTION_SERVICE_SCOPE]                                  = "service scope",
        [SD_DHCP_OPTION_RAPID_COMMIT]                                   = "rapid commit",
        [SD_DHCP_OPTION_FQDN]                                           = "FQDN",
        [SD_DHCP_OPTION_RELAY_AGENT_INFORMATION]                        = "relay agent information",
        [SD_DHCP_OPTION_ISNS]                                           = "iSNS",
        [SD_DHCP_OPTION_NDS_SERVER]                                     = "NDS server",
        [SD_DHCP_OPTION_NDS_TREE_NAME]                                  = "NDS tree name",
        [SD_DHCP_OPTION_NDS_CONTEXT]                                    = "NDS context",
        [SD_DHCP_OPTION_BCMCS_CONTROLLER_DOMAIN_NAME]                   = "BCMCS controller domain name",
        [SD_DHCP_OPTION_BCMCS_CONTROLLER_ADDRESS]                       = "BCMCS controller address",
        [SD_DHCP_OPTION_AUTHENTICATION]                                 = "authentication",
        [SD_DHCP_OPTION_CLIENT_LAST_TRANSACTION_TIME]                   = "client last transaction time",
        [SD_DHCP_OPTION_ASSOCIATED_IP]                                  = "associated IP",
        [SD_DHCP_OPTION_CLIENT_SYSTEM]                                  = "client system",
        [SD_DHCP_OPTION_CLIENT_NDI]                                     = "client NDI",
        [SD_DHCP_OPTION_LDAP]                                           = "LDAP",
        [SD_DHCP_OPTION_UUID]                                           = "UUID",
        [SD_DHCP_OPTION_USER_AUTHENTICATION]                            = "user authentication",
        [SD_DHCP_OPTION_GEOCONF_CIVIC]                                  = "geoconf civic",
        [SD_DHCP_OPTION_POSIX_TIMEZONE]                                 = "posix timezone",
        [SD_DHCP_OPTION_TZDB_TIMEZONE]                                  = "tzdb timezone",
        [SD_DHCP_OPTION_IPV6_ONLY_PREFERRED]                            = "IPv6-only preferred",
        [SD_DHCP_OPTION_DHCP4O6_SOURCE_ADDRESS]                         = "DHCPv4 over DHCPv6 source address",
        [SD_DHCP_OPTION_NETINFO_ADDRESS]                                = "Netinfo address",
        [SD_DHCP_OPTION_NETINFO_TAG]                                    = "Netinfo tag",
        [SD_DHCP_OPTION_DHCP_CAPTIVE_PORTAL]                            = "captive portal",
        [SD_DHCP_OPTION_AUTO_CONFIG]                                    = "auto config",
        [SD_DHCP_OPTION_NAME_SERVICE_SEARCH]                            = "name service search",
        [SD_DHCP_OPTION_SUBNET_SELECTION]                               = "subnet selection",
        [SD_DHCP_OPTION_DOMAIN_SEARCH]                                  = "domain search",
        [SD_DHCP_OPTION_SIP_SERVER]                                     = "SIP server",
        [SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE]                         = "classless static route",
        [SD_DHCP_OPTION_CABLELABS_CLIENT_CONFIGURATION]                 = "CableLabs client configuration",
        [SD_DHCP_OPTION_GEOCONF]                                        = "geoconf",
        [SD_DHCP_OPTION_VENDOR_IDENTIFYING_VENDOR_CLASS]                = "vendor-identifying vendor class",
        [SD_DHCP_OPTION_VENDOR_IDENTIFYING_VENDOR_SPECIFIC_INFORMATION] = "vendor-identifying vendor-specific information",
        [SD_DHCP_OPTION_PANA_AGENT]                                     = "PANA agent",
        [SD_DHCP_OPTION_LOST_SERVER_FQDN]                               = "LoST server",
        [SD_DHCP_OPTION_CAPWAP_AC_ADDRESS]                              = "CAPWAP access controller address",
        [SD_DHCP_OPTION_MOS_ADDRESS]                                    = "MoS address",
        [SD_DHCP_OPTION_MOS_FQDN]                                       = "MoS FQDN",
        [SD_DHCP_OPTION_SIP_SERVICE_DOMAIN]                             = "SIP service domain",
        [SD_DHCP_OPTION_ANDSF_ADDRESS]                                  = "ANDSF address",
        [SD_DHCP_OPTION_SZTP_REDIRECT]                                  = "SZTP server",
        [SD_DHCP_OPTION_GEOLOC]                                         = "geospatial location",
        [SD_DHCP_OPTION_FORCERENEW_NONCE_CAPABLE]                       = "forcerenew nonce capable",
        [SD_DHCP_OPTION_RDNSS_SELECTION]                                = "RDNSS selection",
        [SD_DHCP_OPTION_DOTS_RI]                                        = "DOTS agent name",
        [SD_DHCP_OPTION_DOTS_ADDRESS]                                   = "DOTS agent address",
        [SD_DHCP_OPTION_TFTP_SERVER_ADDRESS]                            = "TFTP server address",
        [SD_DHCP_OPTION_STATUS_CODE]                                    = "status code",
        [SD_DHCP_OPTION_BASE_TIME]                                      = "base time",
        [SD_DHCP_OPTION_START_TIME_OF_STATE]                            = "start time of state",
        [SD_DHCP_OPTION_QUERY_START_TIME]                               = "query start time",
        [SD_DHCP_OPTION_QUERY_END_TIME]                                 = "query end time",
        [SD_DHCP_OPTION_DHCP_STATE]                                     = "DHCP state",
        [SD_DHCP_OPTION_DATA_SOURCE]                                    = "data source",
        [SD_DHCP_OPTION_PCP_SERVER]                                     = "PCP server",
        [SD_DHCP_OPTION_PORT_PARAMS]                                    = "port parameter",
        [SD_DHCP_OPTION_MUD_URL]                                        = "MUD URL",
        [SD_DHCP_OPTION_V4_DNR]                                         = "encrypted DNS server",
        [SD_DHCP_OPTION_PXELINUX_MAGIC]                                 = "PXELinux magic",
        [SD_DHCP_OPTION_CONFIGURATION_FILE]                             = "configuration file",
        [SD_DHCP_OPTION_PATH_PREFIX]                                    = "path prefix",
        [SD_DHCP_OPTION_REBOOT_TIME]                                    = "reboot time",
        [SD_DHCP_OPTION_6RD]                                            = "6rd",
        [SD_DHCP_OPTION_ACCESS_DOMAIN]                                  = "access network domain",
        [SD_DHCP_OPTION_SUBNET_ALLOCATION]                              = "subnet allocation",
        [SD_DHCP_OPTION_VIRTUAL_SUBNET_SELECTION]                       = "virtual subnet selection",
        [SD_DHCP_OPTION_PRIVATE_CLASSLESS_STATIC_ROUTE]                 = "(private) classless static route",
        [SD_DHCP_OPTION_PRIVATE_PROXY_AUTODISCOVERY]                    = "(private) proxy autodiscovery",
        [SD_DHCP_OPTION_END]                                            = "end",
};

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);
