From: Piotrek Zadroga Date: Mon, 29 May 2023 10:06:35 +0000 (+0200) Subject: [#2834] Addressed review comments X-Git-Tag: Kea-2.3.8~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=437737a0e92a6cc315ffc809f38385b609926656;p=thirdparty%2Fkea.git [#2834] Addressed review comments --- diff --git a/src/bin/perfdhcp/command_options.cc b/src/bin/perfdhcp/command_options.cc index 11ee904673..b681740243 100644 --- a/src/bin/perfdhcp/command_options.cc +++ b/src/bin/perfdhcp/command_options.cc @@ -471,16 +471,16 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) { // custom option (expected format: code,hexstring) std::string opt_text = std::string(optarg); - size_t coma_loc = opt_text.find(','); - check(coma_loc == std::string::npos, - "-o option must provide option code, a coma and hexstring for" + size_t comma_loc = opt_text.find(','); + check(comma_loc == std::string::npos, + "-o option must provide option code, a comma and hexstring for" " the option content, e.g. -o60,646f63736973 for sending option" " 60 (class-id) with the value 'docsis'"); int code = 0; // Try to parse the option code try { - code = boost::lexical_cast(opt_text.substr(0,coma_loc)); + code = boost::lexical_cast(opt_text.substr(0, comma_loc)); check(code <= 0, "Option code can't be negative"); } catch (const boost::bad_lexical_cast&) { isc_throw(InvalidParameter, "Invalid option code specified for " @@ -488,7 +488,7 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) { } // Now try to interpret the hexstring - opt_text = opt_text.substr(coma_loc + 1); + opt_text = opt_text.substr(comma_loc + 1); std::vector bin; try { isc::util::encode::decodeHex(opt_text, bin); @@ -614,7 +614,7 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) { // custom option (expected format: encapsulation-level:code,hexstring) std::string opt_text = std::string(optarg); size_t colon_loc = opt_text.find(':'); - size_t coma_loc = opt_text.find(','); + size_t comma_loc = opt_text.find(','); // if encapsulation level is skipped by user, let's assume it is 1 uint8_t option_encapsulation_level = 1; @@ -636,8 +636,8 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) { } } - check(coma_loc == std::string::npos, - "--or option must provide encapsulation level, a colon, option code, a coma and " + check(comma_loc == std::string::npos, + "--or option must provide encapsulation level, a colon, option code, a comma and " "hexstring for the option content, e.g. --or 1:60,646f63736973 for sending option" " 60 (class-id) with the value 'docsis' at first level of encapsulation"); int code = 0; @@ -645,7 +645,7 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) { // Try to parse the option code try { code = boost::lexical_cast( - opt_text.substr(colon_loc + 1, coma_loc - colon_loc - 1)); + opt_text.substr(colon_loc + 1, comma_loc - colon_loc - 1)); check(code <= 0, "Option code can't be negative or zero"); } catch (const boost::bad_lexical_cast&) { isc_throw(InvalidParameter, @@ -654,7 +654,7 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) { } // Now try to interpret the hexstring - opt_text = opt_text.substr(coma_loc + 1); + opt_text = opt_text.substr(comma_loc + 1); std::vector bin; try { isc::util::encode::decodeHex(opt_text, bin); @@ -1394,7 +1394,7 @@ DHCPv6 only options: value is 1, which means that the generated traffic is an equivalent of the traffic passing through a single relay agent. ---or encapsulation-level:: Send custom option included +--or encapsulation-level:: Send given option included to simulated DHCPv6 relayed traffic at given level of encapsulation with the specified code and the specified buffer in hexstring format. Currently the only supported encapsulation-level value is 1. diff --git a/src/bin/perfdhcp/tests/command_options_unittest.cc b/src/bin/perfdhcp/tests/command_options_unittest.cc index db4254a22b..57989fc923 100644 --- a/src/bin/perfdhcp/tests/command_options_unittest.cc +++ b/src/bin/perfdhcp/tests/command_options_unittest.cc @@ -950,7 +950,7 @@ TEST_F(CommandOptionsTest, UseRelayV6OptionsWithMultiSubnets) { TEST_F(CommandOptionsTest, UseRelayV6OptionsNoComma) { CommandOptions opt; - // --or must be followed by encapsulation-level, colon, option code, a coma and hexstring + // --or must be followed by encapsulation-level, colon, option code, a comma and hexstring // in case encapsulation-level and colon are skipped, encapsulation-level is by default 1 EXPECT_THROW(process(opt, "perfdhcp -6 --or 3200000E10 -l ethx all"), isc::InvalidParameter); } @@ -958,7 +958,7 @@ TEST_F(CommandOptionsTest, UseRelayV6OptionsNoComma) { TEST_F(CommandOptionsTest, UseRelayV6OptionsNegativeOptionCode) { CommandOptions opt; - // --or must be followed by encapsulation-level, colon, positive option code, a coma and hexstring + // --or must be followed by encapsulation-level, colon, positive option code, a comma and hexstring // in case encapsulation-level and colon are skipped, encapsulation-level is by default 1 EXPECT_THROW(process(opt, "perfdhcp -6 --or -32,00000E10 -l ethx all"), isc::InvalidParameter); }