From: Andrei Pavel Date: Fri, 24 Oct 2025 07:27:16 +0000 (+0300) Subject: [#4100] Change enums to uint16_t X-Git-Tag: Kea-3.1.3~31 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4a3e848cbd0a746e09045a2933190f0a0e05e2ee;p=thirdparty%2Fkea.git [#4100] Change enums to uint16_t Addresses the range checks in *toText() functions. --- diff --git a/src/bin/d2/d2_queue_mgr.h b/src/bin/d2/d2_queue_mgr.h index 4d34b726b1..00b87db2c9 100644 --- a/src/bin/d2/d2_queue_mgr.h +++ b/src/bin/d2/d2_queue_mgr.h @@ -136,7 +136,7 @@ public: static const size_t MAX_QUEUE_DEFAULT = 1024; /// @brief Defines the list of possible states for D2QueueMgr. - enum State : int { + enum State : uint16_t { NOT_INITTED = 0, INITTED = 1, RUNNING = 2, diff --git a/src/hooks/dhcp/radius/radius_accounting.h b/src/hooks/dhcp/radius/radius_accounting.h index 52a0568429..9a826c4213 100644 --- a/src/hooks/dhcp/radius/radius_accounting.h +++ b/src/hooks/dhcp/radius/radius_accounting.h @@ -22,7 +22,7 @@ namespace isc { namespace radius { /// @brief Type of accounting events. -enum Event : int { +enum Event : uint16_t { EVENT_CREATE = 0, //< A new lease was created (leaseX_select hooks). EVENT_RENEW = 1, //< A lease was renewed (leaseX_renew hooks). EVENT_REBIND = 2, //< A lease was rebound (lease6_rebind hook). diff --git a/src/lib/asiodns/io_fetch.h b/src/lib/asiodns/io_fetch.h index a2c8c92dd2..e9c85b58c5 100644 --- a/src/lib/asiodns/io_fetch.h +++ b/src/lib/asiodns/io_fetch.h @@ -56,7 +56,7 @@ public: /// @note that this applies to the status of I/Os in the fetch - a fetch that /// resulted in a packet being received from the server is a SUCCESS, even if /// the contents of the packet indicate that some error occurred. - enum Result : int { + enum Result : uint16_t { SUCCESS = 0, // Success, fetch completed TIME_OUT = 1, // Failure, fetch timed out STOPPED = 2, // Control code, fetch has been stopped diff --git a/src/lib/cc/data.h b/src/lib/cc/data.h index b93e2ec29e..f684581cb2 100644 --- a/src/lib/cc/data.h +++ b/src/lib/cc/data.h @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2024 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2010-2025 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -136,7 +136,7 @@ public: /// /// any is a special type used in list specifications, specifying that the /// elements can be of any type. - enum types : int { + enum types : uint16_t { integer = 0, real = 1, boolean = 2, diff --git a/src/lib/cryptolink/cryptolink.h b/src/lib/cryptolink/cryptolink.h index 4749dc136b..cd7ac99f98 100644 --- a/src/lib/cryptolink/cryptolink.h +++ b/src/lib/cryptolink/cryptolink.h @@ -20,7 +20,7 @@ namespace isc { namespace cryptolink { /// @brief Hash algorithm identifiers. -enum HashAlgorithm : int { +enum HashAlgorithm : uint16_t { UNKNOWN_HASH = 0, // This value can be used in conversion // functions, to be returned when the // input is unknown (but a value MUST be diff --git a/src/lib/d2srv/dns_client.h b/src/lib/d2srv/dns_client.h index 5c1f2c2f2a..c7cbd3c43b 100644 --- a/src/lib/d2srv/dns_client.h +++ b/src/lib/d2srv/dns_client.h @@ -55,7 +55,7 @@ public: }; /// @brief A status code of the DNSClient. - enum Status : int { + enum Status : uint16_t { SUCCESS = 0, ///< Response received and is ok. TIMEOUT = 1, ///< No response, timeout. IO_STOPPED = 2, ///< IO was stopped. diff --git a/src/lib/dhcp/option4_client_fqdn.h b/src/lib/dhcp/option4_client_fqdn.h index 07dacd6d21..47392b42f9 100644 --- a/src/lib/dhcp/option4_client_fqdn.h +++ b/src/lib/dhcp/option4_client_fqdn.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2024 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2025 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -145,7 +145,7 @@ public: /// @brief Type of the domain-name: partial or full. - enum DomainNameType : int { + enum DomainNameType : uint16_t { PARTIAL, FULL }; diff --git a/src/lib/dhcp/option6_client_fqdn.h b/src/lib/dhcp/option6_client_fqdn.h index f51e18584d..9d625354b4 100644 --- a/src/lib/dhcp/option6_client_fqdn.h +++ b/src/lib/dhcp/option6_client_fqdn.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2024 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2025 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -102,7 +102,7 @@ public: static const uint16_t FLAG_FIELD_LEN = 1; /// @brief Type of the domain-name: partial or full. - enum DomainNameType : int { + enum DomainNameType : uint16_t { PARTIAL, FULL }; diff --git a/src/lib/dhcp/option_data_types.h b/src/lib/dhcp/option_data_types.h index 6621d2fec0..9a0596d456 100644 --- a/src/lib/dhcp/option_data_types.h +++ b/src/lib/dhcp/option_data_types.h @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2024 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2025 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -42,7 +42,7 @@ public: /// must always be and OPT_RECORD_TYPE must be at second to last. /// This is because some functions perform sanity checks on data type /// values using '>' operators, assuming that all values beyond the -enum OptionDataType : int { +enum OptionDataType : uint16_t { OPT_EMPTY_TYPE = 0, OPT_BINARY_TYPE = 1, OPT_BOOLEAN_TYPE = 2, diff --git a/src/lib/dhcp_ddns/ncr_io.h b/src/lib/dhcp_ddns/ncr_io.h index db0d572cfc..3965db391f 100644 --- a/src/lib/dhcp_ddns/ncr_io.h +++ b/src/lib/dhcp_ddns/ncr_io.h @@ -475,7 +475,7 @@ public: static const size_t MAX_QUEUE_DEFAULT = 1024; /// @brief Defines the outcome of an asynchronous NCR send. - enum Result : int { + enum Result : uint16_t { SUCCESS = 0, TIME_OUT = 1, STOPPED = 2, diff --git a/src/lib/dhcpsrv/cfg_globals.h b/src/lib/dhcpsrv/cfg_globals.h index 1129f24d4c..88d587037f 100644 --- a/src/lib/dhcpsrv/cfg_globals.h +++ b/src/lib/dhcpsrv/cfg_globals.h @@ -36,7 +36,7 @@ public: /// @c SimpleParser6::GLOBAL6_PARAMETERS, first part with common /// parameters followed by DHCPv4 and DHCPv6 specific parameters. /// Keep the order, enum element names is uppercase with - replaced by _. - enum Index : int { + enum Index : uint16_t { // Common parameters. VALID_LIFETIME, MIN_VALID_LIFETIME, diff --git a/src/lib/dhcpsrv/host.h b/src/lib/dhcpsrv/host.h index 1ef85c25e3..63a84b04fa 100644 --- a/src/lib/dhcpsrv/host.h +++ b/src/lib/dhcpsrv/host.h @@ -334,7 +334,7 @@ public: /// - DUID (DHCPv4 and DHCPv6) (identifier name: "duid"), /// - circuit identifier (DHCPv4) (identifier name: "circuit-id"), /// - client identifier (DHCPv4) (identifier name: "client-id") - enum IdentifierType : int { + enum IdentifierType : uint16_t { IDENT_HWADDR = 0, IDENT_DUID = 1, IDENT_CIRCUIT_ID = 2, diff --git a/src/lib/dhcpsrv/lease.h b/src/lib/dhcpsrv/lease.h index 9618fd5ee8..1096d5d112 100644 --- a/src/lib/dhcpsrv/lease.h +++ b/src/lib/dhcpsrv/lease.h @@ -43,7 +43,7 @@ struct Lease : public isc::data::UserContext, public isc::data::CfgToElement { static std::string lifetimeToText(uint32_t lifetime); /// @brief Type of lease or pool - enum Type : int { + enum Type : uint16_t { TYPE_NA = 0, ///< the lease contains non-temporary IPv6 address TYPE_TA = 1, ///< the lease contains temporary IPv6 address TYPE_PD = 2, ///< the lease contains IPv6 prefix (for prefix delegation) diff --git a/src/lib/dns/message.h b/src/lib/dns/message.h index 1dea110ddb..6240a380d2 100644 --- a/src/lib/dns/message.h +++ b/src/lib/dns/message.h @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2024 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2009-2025 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -199,7 +199,7 @@ public: /// introducing a separately defined class considering the balance /// between the complexity and advantage, but hopefully the cast notation /// is sufficiently ugly to prevent proliferation of the usage. - enum HeaderFlag : int { + enum HeaderFlag : uint16_t { HEADERFLAG_QR = 0x8000, // Query (if cleared) or response (if set) HEADERFLAG_AA = 0x0400, // Authoritative answer HEADERFLAG_TC = 0x0200, // Truncation @@ -239,7 +239,7 @@ public: /// /// Future Extension: We'll probably also define constants for /// the section names used in dynamic updates in future versions. - enum Section : int { + enum Section : uint16_t { SECTION_QUESTION = 0, // Question section SECTION_ANSWER = 1, // Answer section SECTION_AUTHORITY = 2, // Authority section diff --git a/src/lib/eval/token.h b/src/lib/eval/token.h index 8c1570b3a1..c87dcc28b2 100644 --- a/src/lib/eval/token.h +++ b/src/lib/eval/token.h @@ -570,7 +570,7 @@ class TokenPkt : public Token { public: /// @brief enum value that determines the field. - enum MetadataType : int { + enum MetadataType : uint16_t { IFACE, ///< interface name (string) SRC, ///< source (IP address) DST, ///< destination (IP address) @@ -620,7 +620,7 @@ class TokenPkt4 : public Token { public: /// @brief enum value that determines the field. - enum FieldType : int { + enum FieldType : uint16_t { CHADDR, ///< chaddr field (up to 16 bytes link-layer address) GIADDR, ///< giaddr (IPv4 address) CIADDR, ///< ciaddr (IPv4 address) @@ -674,7 +674,7 @@ private: class TokenPkt6 : public Token { public: /// @brief enum value that determines the field. - enum FieldType : int { + enum FieldType : uint16_t { MSGTYPE, ///< msg type TRANSID ///< transaction id (integer but manipulated as a string) }; @@ -727,7 +727,7 @@ class TokenRelay6Field : public Token { public: /// @brief enum value that determines the field. - enum FieldType : int { + enum FieldType : uint16_t { PEERADDR, ///< Peer address field (IPv6 address) LINKADDR ///< Link address field (IPv6 address) }; @@ -1137,7 +1137,7 @@ class TokenVendor : public TokenOption { public: /// @brief Specifies a field of the vendor option - enum FieldType : int { + enum FieldType : uint16_t { SUBOPTION, ///< If this token fetches a suboption, not a field. ENTERPRISE_ID, ///< enterprise-id field (vendor-info, vendor-class) EXISTS, ///< vendor[123].exists