_DHCP6_STATE_INVALID = -EINVAL,
} DHCP6State;
-enum {
- DHCP6_SOLICIT = 1,
- DHCP6_ADVERTISE = 2,
- DHCP6_REQUEST = 3,
- DHCP6_CONFIRM = 4,
- DHCP6_RENEW = 5,
- DHCP6_REBIND = 6,
- DHCP6_REPLY = 7,
- DHCP6_RELEASE = 8,
- DHCP6_DECLINE = 9,
- DHCP6_RECONFIGURE = 10,
- DHCP6_INFORMATION_REQUEST = 11,
- DHCP6_RELAY_FORW = 12,
- DHCP6_RELAY_REPL = 13,
- _DHCP6_MESSAGE_MAX = 14,
-};
+/* https://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xhtml#dhcpv6-parameters-1 */
+typedef enum DHCP6MessageType {
+ DHCP6_MESSAGE_SOLICIT = 1, /* RFC 8415 */
+ DHCP6_MESSAGE_ADVERTISE = 2, /* RFC 8415 */
+ DHCP6_MESSAGE_REQUEST = 3, /* RFC 8415 */
+ DHCP6_MESSAGE_CONFIRM = 4, /* RFC 8415 */
+ DHCP6_MESSAGE_RENEW = 5, /* RFC 8415 */
+ DHCP6_MESSAGE_REBIND = 6, /* RFC 8415 */
+ DHCP6_MESSAGE_REPLY = 7, /* RFC 8415 */
+ DHCP6_MESSAGE_RELEASE = 8, /* RFC 8415 */
+ DHCP6_MESSAGE_DECLINE = 9, /* RFC 8415 */
+ DHCP6_MESSAGE_RECONFIGURE = 10, /* RFC 8415 */
+ DHCP6_MESSAGE_INFORMATION_REQUEST = 11, /* RFC 8415 */
+ DHCP6_MESSAGE_RELAY_FORWARD = 12, /* RFC 8415 */
+ DHCP6_MESSAGE_RELAY_REPLY = 13, /* RFC 8415 */
+ DHCP6_MESSAGE_LEASE_QUERY = 14, /* RFC 5007 */
+ DHCP6_MESSAGE_LEASE_QUERY_REPLY = 15, /* RFC 5007 */
+ DHCP6_MESSAGE_LEASE_QUERY_DONE = 16, /* RFC 5460 */
+ DHCP6_MESSAGE_LEASE_QUERY_DATA = 17, /* RFC 5460 */
+ DHCP6_MESSAGE_RECONFIGURE_REQUEST = 18, /* RFC 6977 */
+ DHCP6_MESSAGE_RECONFIGURE_REPLY = 19, /* RFC 6977 */
+ DHCP6_MESSAGE_DHCPV4_QUERY = 20, /* RFC 7341 */
+ DHCP6_MESSAGE_DHCPV4_RESPONSE = 21, /* RFC 7341 */
+ DHCP6_MESSAGE_ACTIVE_LEASE_QUERY = 22, /* RFC 7653 */
+ DHCP6_MESSAGE_START_TLS = 23, /* RFC 7653 */
+ DHCP6_MESSAGE_BINDING_UPDATE = 24, /* RFC 8156 */
+ DHCP6_MESSAGE_BINDING_REPLY = 25, /* RFC 8156 */
+ DHCP6_MESSAGE_POOL_REQUEST = 26, /* RFC 8156 */
+ DHCP6_MESSAGE_POOL_RESPONSE = 27, /* RFC 8156 */
+ DHCP6_MESSAGE_UPDATE_REQUEST = 28, /* RFC 8156 */
+ DHCP6_MESSAGE_UPDATE_REQUEST_ALL = 29, /* RFC 8156 */
+ DHCP6_MESSAGE_UPDATE_DONE = 30, /* RFC 8156 */
+ DHCP6_MESSAGE_CONNECT = 31, /* RFC 8156 */
+ DHCP6_MESSAGE_CONNECT_REPLY = 32, /* RFC 8156 */
+ DHCP6_MESSAGE_DISCONNECT = 33, /* RFC 8156 */
+ DHCP6_MESSAGE_STATE = 34, /* RFC 8156 */
+ DHCP6_MESSAGE_CONTACT = 35, /* RFC 8156 */
+ _DHCP6_MESSAGE_TYPE_MAX,
+ _DHCP6_MESSAGE_TYPE_INVALID = -EINVAL,
+} DHCP6MessageType;
typedef enum DHCP6NTPSubOption {
DHCP6_NTP_SUBOPTION_SRV_ADDR = 1,
SD_DHCP6_OPTION_SNTP_SERVERS,
};
-const char * dhcp6_message_type_table[_DHCP6_MESSAGE_MAX] = {
- [DHCP6_SOLICIT] = "SOLICIT",
- [DHCP6_ADVERTISE] = "ADVERTISE",
- [DHCP6_REQUEST] = "REQUEST",
- [DHCP6_CONFIRM] = "CONFIRM",
- [DHCP6_RENEW] = "RENEW",
- [DHCP6_REBIND] = "REBIND",
- [DHCP6_REPLY] = "REPLY",
- [DHCP6_RELEASE] = "RELEASE",
- [DHCP6_DECLINE] = "DECLINE",
- [DHCP6_RECONFIGURE] = "RECONFIGURE",
- [DHCP6_INFORMATION_REQUEST] = "INFORMATION-REQUEST",
- [DHCP6_RELAY_FORW] = "RELAY-FORW",
- [DHCP6_RELAY_REPL] = "RELAY-REPL",
+const char * dhcp6_message_type_table[_DHCP6_MESSAGE_TYPE_MAX] = {
+ [DHCP6_MESSAGE_SOLICIT] = "Solicit",
+ [DHCP6_MESSAGE_ADVERTISE] = "Advertise",
+ [DHCP6_MESSAGE_REQUEST] = "Request",
+ [DHCP6_MESSAGE_CONFIRM] = "Confirm",
+ [DHCP6_MESSAGE_RENEW] = "Renew",
+ [DHCP6_MESSAGE_REBIND] = "Rebind",
+ [DHCP6_MESSAGE_REPLY] = "Reply",
+ [DHCP6_MESSAGE_RELEASE] = "Release",
+ [DHCP6_MESSAGE_DECLINE] = "Decline",
+ [DHCP6_MESSAGE_RECONFIGURE] = "Reconfigure",
+ [DHCP6_MESSAGE_INFORMATION_REQUEST] = "Information Request",
+ [DHCP6_MESSAGE_RELAY_FORWARD] = "Relay Forward",
+ [DHCP6_MESSAGE_RELAY_REPLY] = "Relay Reply",
+ [DHCP6_MESSAGE_LEASE_QUERY] = "Lease Query",
+ [DHCP6_MESSAGE_LEASE_QUERY_REPLY] = "Lease Query Reply",
+ [DHCP6_MESSAGE_LEASE_QUERY_DONE] = "Lease Query Done",
+ [DHCP6_MESSAGE_LEASE_QUERY_DATA] = "Lease Query Data",
+ [DHCP6_MESSAGE_RECONFIGURE_REQUEST] = "Reconfigure Request",
+ [DHCP6_MESSAGE_RECONFIGURE_REPLY] = "Reconfigure Reply",
+ [DHCP6_MESSAGE_DHCPV4_QUERY] = "DHCPv4 Query",
+ [DHCP6_MESSAGE_DHCPV4_RESPONSE] = "DHCPv4 Response",
+ [DHCP6_MESSAGE_ACTIVE_LEASE_QUERY] = "Active Lease Query",
+ [DHCP6_MESSAGE_START_TLS] = "Start TLS",
+ [DHCP6_MESSAGE_BINDING_UPDATE] = "Binding Update",
+ [DHCP6_MESSAGE_BINDING_REPLY] = "Binding Reply",
+ [DHCP6_MESSAGE_POOL_REQUEST] = "Pool Request",
+ [DHCP6_MESSAGE_POOL_RESPONSE] = "Pool Response",
+ [DHCP6_MESSAGE_UPDATE_REQUEST] = "Update Request",
+ [DHCP6_MESSAGE_UPDATE_REQUEST_ALL] = "Update Request All",
+ [DHCP6_MESSAGE_UPDATE_DONE] = "Update Done",
+ [DHCP6_MESSAGE_CONNECT] = "Connect",
+ [DHCP6_MESSAGE_CONNECT_REPLY] = "Connect Reply",
+ [DHCP6_MESSAGE_DISCONNECT] = "Disconnect",
+ [DHCP6_MESSAGE_STATE] = "State",
+ [DHCP6_MESSAGE_CONTACT] = "Contact",
};
DEFINE_STRING_TABLE_LOOKUP(dhcp6_message_type, int);
switch(client->state) {
case DHCP6_STATE_INFORMATION_REQUEST:
- message->type = DHCP6_INFORMATION_REQUEST;
+ message->type = DHCP6_MESSAGE_INFORMATION_REQUEST;
if (client->mudurl) {
r = dhcp6_option_append(&opt, &optlen,
break;
case DHCP6_STATE_SOLICITATION:
- message->type = DHCP6_SOLICIT;
+ message->type = DHCP6_MESSAGE_SOLICIT;
r = dhcp6_option_append(&opt, &optlen,
SD_DHCP6_OPTION_RAPID_COMMIT, 0, NULL);
case DHCP6_STATE_RENEW:
if (client->state == DHCP6_STATE_REQUEST)
- message->type = DHCP6_REQUEST;
+ message->type = DHCP6_MESSAGE_REQUEST;
else
- message->type = DHCP6_RENEW;
+ message->type = DHCP6_MESSAGE_RENEW;
r = dhcp6_option_append(&opt, &optlen, SD_DHCP6_OPTION_SERVERID,
client->lease->serverid_len,
break;
case DHCP6_STATE_REBIND:
- message->type = DHCP6_REBIND;
+ message->type = DHCP6_MESSAGE_REBIND;
if (FLAGS_SET(client->request_ia, DHCP6_REQUEST_IA_NA)) {
r = dhcp6_option_append_ia(&opt, &optlen, &client->lease->ia);
assert(client);
assert(reply);
- if (reply->type != DHCP6_REPLY)
+ if (reply->type != DHCP6_MESSAGE_REPLY)
return 0;
r = dhcp6_lease_new(&lease);
uint8_t pref_advertise = 0, pref_lease = 0;
int r;
- if (advertise->type != DHCP6_ADVERTISE)
+ if (advertise->type != DHCP6_MESSAGE_ADVERTISE)
return 0;
r = dhcp6_lease_new(&lease);
return 0;
}
- switch(message->type) {
- case DHCP6_SOLICIT:
- case DHCP6_REQUEST:
- case DHCP6_CONFIRM:
- case DHCP6_RENEW:
- case DHCP6_REBIND:
- case DHCP6_RELEASE:
- case DHCP6_DECLINE:
- case DHCP6_INFORMATION_REQUEST:
- case DHCP6_RELAY_FORW:
- case DHCP6_RELAY_REPL:
- return 0;
-
- case DHCP6_ADVERTISE:
- case DHCP6_REPLY:
- case DHCP6_RECONFIGURE:
- break;
-
- default:
- log_dhcp6_client(client, "Unknown message type %d", message->type);
+ if (!IN_SET(message->type, DHCP6_MESSAGE_ADVERTISE, DHCP6_MESSAGE_REPLY, DHCP6_MESSAGE_RECONFIGURE)) {
+ const char *type_str = dhcp6_message_type_to_string(message->type);
+ if (type_str)
+ log_dhcp6_client(client, "Received unexpected %s message, ignoring.", type_str);
+ else
+ log_dhcp6_client(client, "Received unsupported message type %u, ignoring.", message->type);
return 0;
}
assert_se(dhcp6_lease_new(&lease) >= 0);
- assert_se(advertise->type == DHCP6_ADVERTISE);
+ assert_se(advertise->type == DHCP6_MESSAGE_ADVERTISE);
assert_se((be32toh(advertise->transaction_id) & 0x00ffffff) ==
0x0fb4e5);
log_debug("/* %s */", __func__);
reply.transaction_id = request->transaction_id;
- reply.type = DHCP6_REPLY;
+ reply.type = DHCP6_MESSAGE_REPLY;
memcpy(msg_reply, &reply.transaction_id, 4);
log_debug("/* %s */", __func__);
- assert_se(request->type == DHCP6_REQUEST);
+ assert_se(request->type == DHCP6_MESSAGE_REQUEST);
assert_se(dhcp6_lease_new(&lease) >= 0);
len -= sizeof(DHCP6Message);
log_debug("/* %s */", __func__);
advertise.transaction_id = solicit->transaction_id;
- advertise.type = DHCP6_ADVERTISE;
+ advertise.type = DHCP6_MESSAGE_ADVERTISE;
memcpy(msg_advertise, &advertise.transaction_id, 4);
log_debug("/* %s */", __func__);
- assert_se(solicit->type == DHCP6_SOLICIT);
+ assert_se(solicit->type == DHCP6_MESSAGE_SOLICIT);
len -= sizeof(DHCP6Message);
log_debug("/* %s */", __func__);
- assert_se(information_request->type == DHCP6_INFORMATION_REQUEST);
+ assert_se(information_request->type == DHCP6_MESSAGE_INFORMATION_REQUEST);
assert_se(dhcp6_lease_new(&lease) >= 0);
len -= sizeof(DHCP6Message);