<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>
<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>
-// 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
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");
}
};
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;
/// 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"