]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1858] addressed comments
authorRazvan Becheriu <razvan@isc.org>
Tue, 15 Jun 2021 13:10:41 +0000 (16:10 +0300)
committerRazvan Becheriu <razvan@isc.org>
Tue, 15 Jun 2021 15:06:51 +0000 (18:06 +0300)
src/lib/dhcp/option_data_types.cc

index 6a1c05b8bee74df61a0438f6da4a12b903262afe..fe41b67079ff7cbdf09ea6ff5129bc63bdc7067e 100644 (file)
 using namespace isc::asiolink;
 
 namespace {
-/// @brief Mast used to compute PSID value
+/// @brief Bit mask used to compute PSID value.
 ///
-/// The mask represents the useful bits of the PSID. The value 0 is not used
-/// because the RFC explicitly specifies that PSID value should be ignored if
-/// psid_len is 0. The last entry corresponding to psid_len 16 (which translates
-/// to 'all bits are useful') is added so that an extra check can be omitted.
-std::vector<uint16_t> mask = { 0x0,
+/// The mask represents the useful bits of the PSID. The value 0 is a special
+/// case because the RFC explicitly specifies that PSID value should be ignored
+/// if psid_len is 0.
+std::vector<uint16_t> psid_bitmask = { 0xffff,
     0x8000, 0xc000, 0xe000, 0xf000,
     0xf800, 0xfc00, 0xfe00, 0xff00,
     0xff80, 0xffc0, 0xffe0, 0xfff0,
@@ -540,7 +539,7 @@ OptionDataTypeUtil::readPsid(const std::vector<uint8_t>& buf) {
     // psid_len from the left must be set to 0.
     // The value 0 is a special case because the RFC explicitly says that the
     // PSID value should be ignored if psid_len is 0.
-    if ((psid_len > 0) && ((psid & ~mask[psid_len]) != 0)) {
+    if ((psid & ~psid_bitmask[psid_len]) != 0) {
         isc_throw(BadDataTypeCast, "invalid PSID value " << psid
                   << " for a specified PSID length "
                   << static_cast<unsigned>(psid_len));