Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Razvan Becheriu committed Jun 14, 2018
1 parent 552f467 commit 3d23cef
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/bin/dhcp4/dhcp4_srv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Dhcpv4Exchange::Dhcpv4Exchange(const AllocEnginePtr& alloc_engine,
.arg(query_->getLabel())
.arg(classes.toText());
}
};
}

void
Dhcpv4Exchange::initResponse() {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dhcp/dhcp4.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ enum DHCPOptionType {
DHO_V4_CAPTIVE_PORTAL = 160,
// 161-209 are removed/unassigned
// DHO_PATH_PREFIX = 210,
// DHO_REBOOT_TIME = 211,
// DHO_REBOOT_TIME = 211,
DHO_6RD = 212,
DHO_V4_ACCESS_DOMAIN = 213,
// 214-219 are removed/unassigned
Expand Down
74 changes: 37 additions & 37 deletions src/lib/dhcp/option_definition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -662,59 +662,59 @@ OptionDefinition::writeToBuffer(Option::Universe u,
OptionDataTypeUtil::writePrefix(PrefixLen(len), address, buf);

return;
}
}
case OPT_PSID_TYPE:
{
std::string txt = value;
{
std::string txt = value;

// first let's remove any whitespaces
boost::erase_all(txt, " "); // space
boost::erase_all(txt, "\t"); // tabulation
// first let's remove any whitespaces
boost::erase_all(txt, " "); // space
boost::erase_all(txt, "\t"); // tabulation

// Is this prefix/len notation?
size_t pos = txt.find("/");
// Is this prefix/len notation?
size_t pos = txt.find("/");

if (pos == string::npos) {
isc_throw(BadDataTypeCast, "provided PSID value "
<< value << " is not valid");
}
if (pos == string::npos) {
isc_throw(BadDataTypeCast, "provided PSID value "
<< value << " is not valid");
}

const std::string txt_psid = txt.substr(0, pos);
const std::string txt_psid_len = txt.substr(pos + 1);
const std::string txt_psid = txt.substr(0, pos);
const std::string txt_psid_len = txt.substr(pos + 1);

uint16_t psid = 0;
uint8_t psid_len = 0;
uint16_t psid = 0;
uint8_t psid_len = 0;

try {
psid = lexicalCastWithRangeCheck<uint16_t>(txt_psid);
} catch (...) {
isc_throw(BadDataTypeCast, "provided PSID "
<< txt_psid << " is not valid");
}
try {
psid = lexicalCastWithRangeCheck<uint16_t>(txt_psid);
} catch (...) {
isc_throw(BadDataTypeCast, "provided PSID "
<< txt_psid << " is not valid");
}

try {
psid_len = lexicalCastWithRangeCheck<uint8_t>(txt_psid_len);
} catch (...) {
isc_throw(BadDataTypeCast, "provided PSID length "
<< txt_psid_len << " is not valid");
}
try {
psid_len = lexicalCastWithRangeCheck<uint8_t>(txt_psid_len);
} catch (...) {
isc_throw(BadDataTypeCast, "provided PSID length "
<< txt_psid_len << " is not valid");
}

OptionDataTypeUtil::writePsid(PSIDLen(psid_len), PSID(psid), buf);
return;
}
OptionDataTypeUtil::writePsid(PSIDLen(psid_len), PSID(psid), buf);
return;
}
case OPT_STRING_TYPE:
OptionDataTypeUtil::writeString(value, buf);
return;
case OPT_FQDN_TYPE:
OptionDataTypeUtil::writeFqdn(value, buf);
return;
case OPT_TUPLE_TYPE:
{
OpaqueDataTuple::LengthFieldType lft = u == Option::V4 ?
OpaqueDataTuple::LENGTH_1_BYTE : OpaqueDataTuple::LENGTH_2_BYTES;
OptionDataTypeUtil::writeTuple(value, lft, buf);
return;
}
{
OpaqueDataTuple::LengthFieldType lft = u == Option::V4 ?
OpaqueDataTuple::LENGTH_1_BYTE : OpaqueDataTuple::LENGTH_2_BYTES;
OptionDataTypeUtil::writeTuple(value, lft, buf);
return;
}
default:
// We hit this point because invalid option data type has been specified
// This may be the case because 'empty' or 'record' data type has been
Expand Down
9 changes: 6 additions & 3 deletions src/lib/dhcp/std_option_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ const OptionDefParams STANDARD_V4_OPTION_DEFINITIONS[] = {

/// Number of option definitions defined.
const int STANDARD_V4_OPTION_DEFINITIONS_SIZE =
sizeof(STANDARD_V4_OPTION_DEFINITIONS) / sizeof(STANDARD_V4_OPTION_DEFINITIONS[0]);
sizeof(STANDARD_V4_OPTION_DEFINITIONS) /
sizeof(STANDARD_V4_OPTION_DEFINITIONS[0]);

/// Last resort definitions (only option 43 for now, these definitions
/// are applied in deferred unpacking when none is found).
Expand All @@ -277,7 +278,9 @@ const OptionDefParams LAST_RESORT_V4_OPTION_DEFINITIONS[] = {
OPT_EMPTY_TYPE, false, NO_RECORD_DEF, "vendor-encapsulated-options-space" }
};

const int LAST_RESORT_V4_OPTION_DEFINITIONS_SIZE = 1;
const int LAST_RESORT_V4_OPTION_DEFINITIONS_SIZE =
sizeof(LAST_RESORT_V4_OPTION_DEFINITIONS) /
sizeof(LAST_RESORT_V4_OPTION_DEFINITIONS[0]);

/// Start Definition of DHCPv6 options

Expand Down Expand Up @@ -421,7 +424,7 @@ const OptionDefParams STANDARD_V6_OPTION_DEFINITIONS[] = {
{ "v6-access-domain", D6O_V6_ACCESS_DOMAIN, OPT_FQDN_TYPE, false,
NO_RECORD_DEF, "" },
{ "sip-ua-cs-list", D6O_SIP_UA_CS_LIST, OPT_FQDN_TYPE, true,
NO_RECORD_DEF, "" },
NO_RECORD_DEF, "" },
{ "bootfile-url", D6O_BOOTFILE_URL, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
{ "bootfile-param", D6O_BOOTFILE_PARAM, OPT_TUPLE_TYPE, true, NO_RECORD_DEF, "" },
{ "client-arch-type", D6O_CLIENT_ARCH_TYPE, OPT_UINT16_TYPE, true, NO_RECORD_DEF, "" },
Expand Down
8 changes: 0 additions & 8 deletions src/lib/dhcpsrv/cql_exchange.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@
namespace isc {
namespace dhcp {

/// @brief Macro to return directly from caller function
#define KEA_CASS_CHECK(cass_error) \
{ \
if (cass_error != CASS_OK) { \
return cass_error; \
} \
}

/// @brief a helper structure with a function call operator that returns
/// key value in a format expected by std::hash.
struct ExchangeDataTypeHash {
Expand Down

0 comments on commit 3d23cef

Please sign in to comment.