| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#include "dhcp6-protocol.h" |
| 4 |
#include "string-table.h" |
| 5 |
|
| 6 |
static const char * const dhcp6_state_table[_DHCP6_STATE_MAX] = { |
| 7 |
[DHCP6_STATE_STOPPED] = "stopped", |
| 8 |
[DHCP6_STATE_INFORMATION_REQUEST] = "information-request", |
| 9 |
[DHCP6_STATE_SOLICITATION] = "solicitation", |
| 10 |
[DHCP6_STATE_REQUEST] = "request", |
| 11 |
[DHCP6_STATE_BOUND] = "bound", |
| 12 |
[DHCP6_STATE_RENEW] = "renew", |
| 13 |
[DHCP6_STATE_REBIND] = "rebind", |
| 14 |
[DHCP6_STATE_STOPPING] = "stopping", |
| 15 |
}; |
| 16 |
|
| 17 |
DEFINE_STRING_TABLE_LOOKUP_TO_STRING(dhcp6_state, DHCP6State); |
| 18 |
|
| 19 |
static const char * const dhcp6_message_type_table[_DHCP6_MESSAGE_TYPE_MAX] = { |
| 20 |
[DHCP6_MESSAGE_SOLICIT] = "Solicit", |
| 21 |
[DHCP6_MESSAGE_ADVERTISE] = "Advertise", |
| 22 |
[DHCP6_MESSAGE_REQUEST] = "Request", |
| 23 |
[DHCP6_MESSAGE_CONFIRM] = "Confirm", |
| 24 |
[DHCP6_MESSAGE_RENEW] = "Renew", |
| 25 |
[DHCP6_MESSAGE_REBIND] = "Rebind", |
| 26 |
[DHCP6_MESSAGE_REPLY] = "Reply", |
| 27 |
[DHCP6_MESSAGE_RELEASE] = "Release", |
| 28 |
[DHCP6_MESSAGE_DECLINE] = "Decline", |
| 29 |
[DHCP6_MESSAGE_RECONFIGURE] = "Reconfigure", |
| 30 |
[DHCP6_MESSAGE_INFORMATION_REQUEST] = "Information Request", |
| 31 |
[DHCP6_MESSAGE_RELAY_FORWARD] = "Relay Forward", |
| 32 |
[DHCP6_MESSAGE_RELAY_REPLY] = "Relay Reply", |
| 33 |
[DHCP6_MESSAGE_LEASE_QUERY] = "Lease Query", |
| 34 |
[DHCP6_MESSAGE_LEASE_QUERY_REPLY] = "Lease Query Reply", |
| 35 |
[DHCP6_MESSAGE_LEASE_QUERY_DONE] = "Lease Query Done", |
| 36 |
[DHCP6_MESSAGE_LEASE_QUERY_DATA] = "Lease Query Data", |
| 37 |
[DHCP6_MESSAGE_RECONFIGURE_REQUEST] = "Reconfigure Request", |
| 38 |
[DHCP6_MESSAGE_RECONFIGURE_REPLY] = "Reconfigure Reply", |
| 39 |
[DHCP6_MESSAGE_DHCPV4_QUERY] = "DHCPv4 Query", |
| 40 |
[DHCP6_MESSAGE_DHCPV4_RESPONSE] = "DHCPv4 Response", |
| 41 |
[DHCP6_MESSAGE_ACTIVE_LEASE_QUERY] = "Active Lease Query", |
| 42 |
[DHCP6_MESSAGE_START_TLS] = "Start TLS", |
| 43 |
[DHCP6_MESSAGE_BINDING_UPDATE] = "Binding Update", |
| 44 |
[DHCP6_MESSAGE_BINDING_REPLY] = "Binding Reply", |
| 45 |
[DHCP6_MESSAGE_POOL_REQUEST] = "Pool Request", |
| 46 |
[DHCP6_MESSAGE_POOL_RESPONSE] = "Pool Response", |
| 47 |
[DHCP6_MESSAGE_UPDATE_REQUEST] = "Update Request", |
| 48 |
[DHCP6_MESSAGE_UPDATE_REQUEST_ALL] = "Update Request All", |
| 49 |
[DHCP6_MESSAGE_UPDATE_DONE] = "Update Done", |
| 50 |
[DHCP6_MESSAGE_CONNECT] = "Connect", |
| 51 |
[DHCP6_MESSAGE_CONNECT_REPLY] = "Connect Reply", |
| 52 |
[DHCP6_MESSAGE_DISCONNECT] = "Disconnect", |
| 53 |
[DHCP6_MESSAGE_STATE] = "State", |
| 54 |
[DHCP6_MESSAGE_CONTACT] = "Contact", |
| 55 |
[DHCP6_MESSAGE_ADDR_REG_INFORM] = "Address Registration Inform", |
| 56 |
[DHCP6_MESSAGE_ADDR_REG_REPLY] = "Address Registration Reply", |
| 57 |
}; |
| 58 |
|
| 59 |
DEFINE_STRING_TABLE_LOOKUP(dhcp6_message_type, DHCP6MessageType); |
| 60 |
|
| 61 |
static const char * const dhcp6_message_status_table[_DHCP6_STATUS_MAX] = { |
| 62 |
[DHCP6_STATUS_SUCCESS] = "Success", |
| 63 |
[DHCP6_STATUS_UNSPEC_FAIL] = "Unspecified failure", |
| 64 |
[DHCP6_STATUS_NO_ADDRS_AVAIL] = "No addresses available", |
| 65 |
[DHCP6_STATUS_NO_BINDING] = "Binding unavailable", |
| 66 |
[DHCP6_STATUS_NOT_ON_LINK] = "Not on link", |
| 67 |
[DHCP6_STATUS_USE_MULTICAST] = "Use multicast", |
| 68 |
[DHCP6_STATUS_NO_PREFIX_AVAIL] = "No prefix available", |
| 69 |
[DHCP6_STATUS_UNKNOWN_QUERY_TYPE] = "Unknown query type", |
| 70 |
[DHCP6_STATUS_MALFORMED_QUERY] = "Malformed query", |
| 71 |
[DHCP6_STATUS_NOT_CONFIGURED] = "Not configured", |
| 72 |
[DHCP6_STATUS_NOT_ALLOWED] = "Not allowed", |
| 73 |
[DHCP6_STATUS_QUERY_TERMINATED] = "Query terminated", |
| 74 |
[DHCP6_STATUS_DATA_MISSING] = "Data missing", |
| 75 |
[DHCP6_STATUS_CATCHUP_COMPLETE] = "Catch up complete", |
| 76 |
[DHCP6_STATUS_NOT_SUPPORTED] = "Not supported", |
| 77 |
[DHCP6_STATUS_TLS_CONNECTION_REFUSED] = "TLS connection refused", |
| 78 |
[DHCP6_STATUS_ADDRESS_IN_USE] = "Address in use", |
| 79 |
[DHCP6_STATUS_CONFIGURATION_CONFLICT] = "Configuration conflict", |
| 80 |
[DHCP6_STATUS_MISSING_BINDING_INFORMATION] = "Missing binding information", |
| 81 |
[DHCP6_STATUS_OUTDATED_BINDING_INFORMATION] = "Outdated binding information", |
| 82 |
[DHCP6_STATUS_SERVER_SHUTTING_DOWN] = "Server shutting down", |
| 83 |
[DHCP6_STATUS_DNS_UPDATE_NOT_SUPPORTED] = "DNS update not supported", |
| 84 |
[DHCP6_STATUS_EXCESSIVE_TIME_SKEW] = "Excessive time skew", |
| 85 |
}; |
| 86 |
|
| 87 |
DEFINE_STRING_TABLE_LOOKUP(dhcp6_message_status, DHCP6Status); |
| 88 |
|
| 89 |
int dhcp6_message_status_to_errno(DHCP6Status s) { |
| 90 |
switch (s) { |
| 91 |
case DHCP6_STATUS_SUCCESS: |
| 92 |
return 0; |
| 93 |
case DHCP6_STATUS_NO_BINDING: |
| 94 |
return -EADDRNOTAVAIL; |
| 95 |
default: |
| 96 |
return -EINVAL; |
| 97 |
} |
| 98 |
} |