diff options
Diffstat (limited to 'src/libsystemd-network/dhcp-identifier.h')
-rw-r--r-- | src/libsystemd-network/dhcp-identifier.h | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/libsystemd-network/dhcp-identifier.h b/src/libsystemd-network/dhcp-identifier.h index cb953cb416..e6486b78f8 100644 --- a/src/libsystemd-network/dhcp-identifier.h +++ b/src/libsystemd-network/dhcp-identifier.h @@ -25,15 +25,15 @@ #include "sparse-endian.h" #include "unaligned.h" -typedef enum DHCPDUIDType { - DHCP_DUID_TYPE_RAW = 0, - DHCP_DUID_TYPE_LLT = 1, - DHCP_DUID_TYPE_EN = 2, - DHCP_DUID_TYPE_LL = 3, - DHCP_DUID_TYPE_UUID = 4, - _DHCP_DUID_TYPE_MAX, - _DHCP_DUID_TYPE_INVALID = -1, -} DHCPDUIDType; +typedef enum DUIDType { + DUID_TYPE_RAW = 0, + DUID_TYPE_LLT = 1, + DUID_TYPE_EN = 2, + DUID_TYPE_LL = 3, + DUID_TYPE_UUID = 4, + _DUID_TYPE_MAX, + _DUID_TYPE_INVALID = -1, +} DUIDType; /* RFC 3315 section 9.1: * A DUID can be no more than 128 octets long (not including the type code). @@ -72,29 +72,31 @@ struct duid { int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len); int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, void *_id); -static inline int dhcp_validate_duid_len(be16_t duid_type, size_t duid_len) { +static inline int dhcp_validate_duid_len(uint16_t duid_type, size_t duid_len) { struct duid d; - assert_return(duid_len > 0 && duid_len <= MAX_DUID_LEN, -EINVAL); + assert(duid_len > 0); - switch (be16toh(duid_type)) { - case DHCP_DUID_TYPE_LLT: + switch (duid_type) { + case DUID_TYPE_LLT: if (duid_len <= sizeof(d.llt)) return -EINVAL; break; - case DHCP_DUID_TYPE_EN: + case DUID_TYPE_EN: if (duid_len != sizeof(d.en)) return -EINVAL; break; - case DHCP_DUID_TYPE_LL: + case DUID_TYPE_LL: if (duid_len <= sizeof(d.ll)) return -EINVAL; break; - case DHCP_DUID_TYPE_UUID: + case DUID_TYPE_UUID: if (duid_len != sizeof(d.uuid)) return -EINVAL; break; default: + if (duid_len > sizeof(d.raw)) + return -EINVAL; /* accept unknown type in order to be forward compatible */ break; } |