From af08545ccda35c1736b5cbdf8d595dd400bf1c58 Mon Sep 17 00:00:00 2001 From: Razvan Becheriu Date: Fri, 23 Apr 2021 20:32:11 +0300 Subject: [PATCH] [#1680] added ChangeLog entry and addressed comments --- ChangeLog | 6 +++++ doc/sphinx/arm/hooks.rst | 4 +++- src/lib/eval/tests/context_unittest.cc | 6 ++--- src/lib/eval/token.cc | 31 ++++++++++++++++---------- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 977defd04d..ba1dd47879 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +1895. [func] razvan + Added additional evaluation tokens to extract and print data: + addrtotext, int8totext, int16totext, int32totext, uint8totext, + uint16totext, uint32totext. + (Gitlab #1680) + 1894. [func] fdupont Implemented 'auth' logger, dedicated to logging access control information, such as basic HTTP authentication. diff --git a/doc/sphinx/arm/hooks.rst b/doc/sphinx/arm/hooks.rst index eb4be73687..5f4f03b591 100644 --- a/doc/sphinx/arm/hooks.rst +++ b/doc/sphinx/arm/hooks.rst @@ -321,7 +321,9 @@ loaded by the correct process per the table below. | | |sufficient it may be used directly. If your jurisdiction | | | |requires that you save a different set of information, you | | | |may use it as a template or example and create your own | - | | |custom logging hooks. | + | | |custom logging hooks. In Kea 1.9.7 additional parameters | + | | |have been added to give users more flexibility regarding | + | | |what information should be logged. | +-----------------+---------------+------------------------------------------------------------+ | Flexible | Support |Kea software provides a way to handle host reservations that| | Identifier | customers |include addresses, prefixes, options, client classes and | diff --git a/src/lib/eval/tests/context_unittest.cc b/src/lib/eval/tests/context_unittest.cc index 13eb9b8a77..617204dea8 100644 --- a/src/lib/eval/tests/context_unittest.cc +++ b/src/lib/eval/tests/context_unittest.cc @@ -493,12 +493,12 @@ public: } /// @brief checks if the given token is a inttotext operator - template + template void checkTokenIntToText(const TokenPtr& token, const std::string& expected) { ASSERT_TRUE(token); - boost::shared_ptr inttotext = - boost::dynamic_pointer_cast(token); + boost::shared_ptr inttotext = + boost::dynamic_pointer_cast(token); EXPECT_TRUE(inttotext); Pkt4Ptr pkt4(new Pkt4(DHCPDISCOVER, 12345)); diff --git a/src/lib/eval/token.cc b/src/lib/eval/token.cc index 4bc96daf94..18e9782f87 100644 --- a/src/lib/eval/token.cc +++ b/src/lib/eval/token.cc @@ -116,6 +116,7 @@ TokenIpAddressToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { if (!size) { return; } + values.pop(); if ((size != V4ADDRESS_LEN) && (size != V6ADDRESS_LEN)) { @@ -143,12 +144,13 @@ TokenInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { isc_throw(EvalBadStack, "Incorrect empty stack."); } - size_t size; string op = values.top(); + size_t size = op.size(); - if (!(size = op.size())) { + if (!size) { return; } + values.pop(); if (size != sizeof(int8_t)) { @@ -171,12 +173,13 @@ TokenInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { isc_throw(EvalBadStack, "Incorrect empty stack."); } - size_t size; string op = values.top(); + size_t size = op.size(); - if (!(size = op.size())) { + if (!size) { return; } + values.pop(); if (size != sizeof(int16_t)) { @@ -201,12 +204,13 @@ TokenInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { isc_throw(EvalBadStack, "Incorrect empty stack."); } - size_t size; string op = values.top(); + size_t size = op.size(); - if (!(size = op.size())) { + if (!size) { return; } + values.pop(); if (size != sizeof(int32_t)) { @@ -231,12 +235,13 @@ TokenUInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { isc_throw(EvalBadStack, "Incorrect empty stack."); } - size_t size; string op = values.top(); + size_t size = op.size(); - if (!(size = op.size())) { + if (!size) { return; } + values.pop(); if (size != sizeof(uint8_t)) { @@ -259,12 +264,13 @@ TokenUInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { isc_throw(EvalBadStack, "Incorrect empty stack."); } - size_t size; string op = values.top(); + size_t size = op.size(); - if (!(size = op.size())) { + if (!size) { return; } + values.pop(); if (size != sizeof(uint16_t)) { @@ -289,12 +295,13 @@ TokenUInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { isc_throw(EvalBadStack, "Incorrect empty stack."); } - size_t size; string op = values.top(); + size_t size = op.size(); - if (!(size = op.size())) { + if (!size) { return; } + values.pop(); if (size != sizeof(uint32_t)) {