]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2834] Addressed review comments
authorPiotrek Zadroga <piotrek@isc.org>
Fri, 26 May 2023 09:03:59 +0000 (11:03 +0200)
committerPiotrek Zadroga <piotrek@isc.org>
Fri, 26 May 2023 13:22:24 +0000 (15:22 +0200)
doc/sphinx/man/perfdhcp.8.rst
src/bin/perfdhcp/command_options.cc
src/bin/perfdhcp/tests/command_options_unittest.cc

index 82f41482d9619c3b293c18f259542db5df1df4a6..d3127cde1342d0e148883dfb98b4b78971511f69 100644 (file)
@@ -360,7 +360,7 @@ The following options only apply for DHCPv6 (i.e. when ``-6`` is given).
 ``--o1r code,hexstring``
    This option is very similar to ``-o``, only that it forces ``perfdhcp``
    to insert the specified extra option (or options if used several times)
-   into relayed DHCPv6 message at 1st level of encapsulation. The code
+   into relayed DHCPv6 message at first level of encapsulation. The code
    specifies the option code and the hexstring is a hexadecimal string that
    defines the content of the option. Care should be taken as ``perfdhcp``
    does not offer any kind of logic behind those options; they are simply
index 5167421c820e7e3855cf5b49c7d99c44b3d48397..a01f967be308b460d027caf738f7ddfdac8349fc 100644 (file)
@@ -608,9 +608,8 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) {
             // and must be used together with -A option.
             check((ipversion_ != 6),
                   "-6 must be explicitly specified before --o1r is used.");
-            if (v6_relay_encapsulation_level_ != 1) {
-                isc_throw(isc::InvalidParameter, "-A must be explicitly specified before --o1r is used.");
-            }
+            check(v6_relay_encapsulation_level_ <= 0,
+                  "-A must be explicitly specified before --o1r is used.");
 
             // custom option (expected format: code,hexstring)
             std::string opt_text = std::string(optarg);
index 7f5eb271eabfab06021df2aef835a2d69b1e221f..e2ac820c2597065c514695854f862e9dfb9bc374 100644 (file)
@@ -899,6 +899,16 @@ TEST_F(CommandOptionsTest, ElapsedTime) {
     EXPECT_EQ(10, opt.getWaitForElapsedTime());
 }
 
+TEST_F(CommandOptionsTest, UseRelayV6OptionsWithoutV6) {
+    CommandOptions opt;
+    EXPECT_NO_THROW(process(opt, "perfdhcp -6 -A1 --o1r 32,00000E10 -l ethx all"));
+    EXPECT_TRUE(opt.isUseRelayedV6());
+    EXPECT_EQ(1, opt.getRelayOpts().size());
+
+    // --o1r must be used together with -6
+    EXPECT_THROW(process(opt, "perfdhcp -A1 --o1r 32,00000E10 -l ethx all"), isc::InvalidParameter);
+}
+
 TEST_F(CommandOptionsTest, UseRelayV6OptionsWithoutRelayEncapsulation) {
     CommandOptions opt;
     EXPECT_NO_THROW(process(opt, "perfdhcp -6 -A1 --o1r 32,00000E10 -l ethx all"));