1 // Copyright (C) 2014-2021 Internet Systems Consortium, Inc. ("ISC") 2 // 3 // This Source Code Form is subject to the terms of the Mozilla Public 4 // License, v. 2.0. If a copy of the MPL was not distributed with this 5 // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 7 #ifndef SUBNET_ID_H 8 #define SUBNET_ID_H 9 10 #include <exceptions/exceptions.h> 11 #include <stdint.h> 12 #include <typeinfo> 13 #include <limits> 14 15 namespace isc { 16 namespace dhcp { 17 18 /// @brief Defines unique IPv4 or IPv6 subnet identifier. 19 /// 20 /// Each subnet for which the DHCP service has been configured is identified 21 /// by the unique value called subnet id. Right now it is represented as 22 /// a simple unsigned integer. In the future it may be extended to more complex 23 /// type. 24 typedef uint32_t SubnetID; 25 26 /// @brief Special value is used for storing/recognizing global host reservations. 27 static const SubnetID SUBNET_ID_GLOBAL = 0; 28 /// @brief The largest valid value for auto-generated subnet IDs. 29 static const SubnetID SUBNET_ID_MAX = std::numeric_limits<uint32_t>::max()-1; 30 /// @brief Special value used to signify that a SubnetID is "not set" 31 static const SubnetID SUBNET_ID_UNUSED = std::numeric_limits<uint32_t>::max(); 32 33 /// @brief Exception thrown upon attempt to add subnet with an ID that belongs 34 /// to the subnet that already exists. 35 class DuplicateSubnetID : public Exception { 36 public: DuplicateSubnetID(const char * file,size_t line,const char * what)37 DuplicateSubnetID(const char* file, size_t line, const char* what) : 38 isc::Exception(file, line, what) { }; 39 }; 40 41 } 42 } 43 44 #endif // SUBNET_ID_H 45