]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[67-expressions-hexa-strings] Addressed comments
authorFrancis Dupont <fdupont@isc.org>
Tue, 18 Sep 2018 16:21:44 +0000 (18:21 +0200)
committerFrancis Dupont <fdupont@isc.org>
Tue, 18 Sep 2018 16:21:44 +0000 (18:21 +0200)
doc/guide/classify.xml
src/lib/eval/tests/evaluate_unittest.cc
src/lib/eval/token.cc
src/lib/eval/token.h

index 0be70b329bfc23bf9268a715cf42c3a5b41a59e9..626ac7c1bce6ac31f1b2b94ca2a3205b1a9d26b7 100644 (file)
 <row><entry>Concat</entry><entry>concat('foo','bar')</entry><entry>Return the
 concatenation of the strings</entry></row>
 <row><entry>Ifelse</entry><entry>ifelse('foo' == 'bar','us','them')</entry><entry>Return the branch value according to the condition</entry></row>
-<row><entry>Hexstring</entry><entry>hexstring('foo', '-')</entry><entry>Return the binary value as an hexadecimal string</entry></row>
+<row><entry>Hexstring</entry><entry>hexstring('foo', '-')</entry><entry>Converts the value to a hexadecimal string, e.g. 0a:1b:2c:3e</entry></row>
           </tbody>
           </tgroup>
         </table>
@@ -777,8 +777,8 @@ concatenation of the strings</entry></row>
           <title>Hexstring</title>
           The hexstring function "hexstring(binary, separator)" returns
           the binary value as its hexadecimal string representation:
-          pairs of hexadecimal digits separated by '-' or ':' or not
-          separated (separator '').
+          pairs of hexadecimal digits separated by the separator, e.g
+          ':', '-', '' (empty separator).
             <screen>
           hexstring(pkt4.mac, ':')
             </screen>
index 144141166d386f33352fb1e7695e8263c6072ee2..839981c29dde27f11b2d88f2e2bcd64c8baaa573 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -509,7 +509,7 @@ TEST_F(ExpressionsTest, evaluateString) {
     testExpressionString(Option::V4, "hexstring(0x1234,':')", "12:34");
     testExpressionString(Option::V4, "hexstring(0x56789a,'-')", "56-78-9a");
     testExpressionString(Option::V4, "hexstring(0xbcde,'')", "bcde");
-    testExpressionString(Option::V4, "hexstring(0xf01234,'foo')", "f01234");
+    testExpressionString(Option::V4, "hexstring(0xf01234,'..')", "f0..12..34");
 }
 
 };
index 402782686d6d6b459c982d0e53c1506fcc7903e4..1147fdfa3badf1bfcb8f9b11815026e6c0f2a475 100644 (file)
@@ -643,11 +643,6 @@ TokenToHexString::evaluate(Pkt& /*pkt*/, ValueStack& values) {
     string binary = values.top();
     values.pop();
 
-    // Unknown separator is interpreted as none.
-    if ((separator != ":") && (separator != "-") && !separator.empty()) {
-        separator.clear();
-    }
-
     bool first = true;
     stringstream tmp;
     tmp << hex;
index bba3ab99173e16da2e498ff616726120113ffee0..0d9472e54db9cd77d06fd7208e179092d4a63b5d 100644 (file)
@@ -745,13 +745,13 @@ public:
     /// two values on the stack as parameters and push the resulting
     /// hexadecimal string onto the stack.
     /// From the top it expects the values on the stack as:
-    /// - separator ('-', ':' or something else interpreted as '')
+    /// - separator
     /// - binary
     ///
     /// binary is the binary value (note it can be any value, i.e.
     /// it is not checked to really be not printable).
-    /// separator is litteral '-' or ':' or something else interpreted as ''
-    /// i.e. no separator.
+    /// separator is litteral for instance '-' or ':'. The empty separator
+    /// means no separator.
     ///
     /// The following example use a binary MAC address 06:ce:8f:55:b3:33:
     /// - <mac>, '-' => "06-ce-8f-55-b3-33"