2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[#1680] addressed comments

This commit is contained in:
Razvan Becheriu
2021-04-23 15:14:40 +03:00
parent 4612d7d2f9
commit 949e347607
7 changed files with 58 additions and 85 deletions

View File

@@ -476,27 +476,27 @@ Notes:
| | | IPv6 address in human | | | | IPv6 address in human |
| | | readable format | | | | readable format |
+-----------------------+---------------------------+------------------------+ +-----------------------+---------------------------+------------------------+
| Int8ToText | int8totext (-1) | Represents the 8 bits | | Int8ToText | int8totext (-1) | Represents the 8 bit |
| | | signed integer in text | | | | signed integer in text |
| | | format | | | | format |
+-----------------------+---------------------------+------------------------+ +-----------------------+---------------------------+------------------------+
| Int16ToText | int16totext (-1) | Represents the 16 bits | | Int16ToText | int16totext (-1) | Represents the 16 bit |
| | | signed integer in text | | | | signed integer in text |
| | | format | | | | format |
+-----------------------+---------------------------+------------------------+ +-----------------------+---------------------------+------------------------+
| Int32ToText | int32totext (-1) | Represents the 32 bits | | Int32ToText | int32totext (-1) | Represents the 32 bit |
| | | signed integer in text | | | | signed integer in text |
| | | format | | | | format |
+-----------------------+---------------------------+------------------------+ +-----------------------+---------------------------+------------------------+
| UInt8ToText | uint8totext (255) | Represents the 8 bits | | UInt8ToText | uint8totext (255) | Represents the 8 bit |
| | | unsigned integer in | | | | unsigned integer in |
| | | text format | | | | text format |
+-----------------------+---------------------------+------------------------+ +-----------------------+---------------------------+------------------------+
| UInt16ToText | uint16totext (65535) | Represents the 16 bits | | UInt16ToText | uint16totext (65535) | Represents the 16 bit |
| | | unsigned integer in | | | | unsigned integer in |
| | | text format | | | | text format |
+-----------------------+---------------------------+------------------------+ +-----------------------+---------------------------+------------------------+
| UInt32ToText | uint32totext (4294967295) | Represents the 32 bits | | UInt32ToText | uint32totext (4294967295) | Represents the 32 bit |
| | | unsigned integer in | | | | unsigned integer in |
| | | text format | | | | text format |
+-----------------------+---------------------------+------------------------+ +-----------------------+---------------------------+------------------------+

View File

@@ -164,17 +164,17 @@ instantiated with the appropriate value and put onto the expression vector.
- isc::dhcp::TokenIfElse -- represents the ifelse(cond, iftrue, ifelse) operator. - isc::dhcp::TokenIfElse -- represents the ifelse(cond, iftrue, ifelse) operator.
- isc::dhcp::TokenToHexString -- represents the hexstring operator which - isc::dhcp::TokenToHexString -- represents the hexstring operator which
converts a binary value to its hexadecimal string representation. converts a binary value to its hexadecimal string representation.
- isc::dhcp::TokenInt8ToText -- represents the signed 8 bits integer in string - isc::dhcp::TokenInt8ToText -- represents the signed 8 bit integer in string
representation. representation.
- isc::dhcp::TokenInt16ToText -- represents the signed 16 bits integer in string - isc::dhcp::TokenInt16ToText -- represents the signed 16 bit integer in string
representation. representation.
- isc::dhcp::TokenInt32ToText -- represents the signed 32 bits integer in string - isc::dhcp::TokenInt32ToText -- represents the signed 32 bit integer in string
representation. representation.
- isc::dhcp::TokenUInt8ToText -- represents the unsigned 8 bits integer in string - isc::dhcp::TokenUInt8ToText -- represents the unsigned 8 bit integer in string
representation. representation.
- isc::dhcp::TokenUInt16ToText -- represents the unsigned 16 bits integer in string - isc::dhcp::TokenUInt16ToText -- represents the unsigned 16 bit integer in string
representation. representation.
- isc::dhcp::TokenUInt32ToText -- represents the unsigned 32 bits integer in string - isc::dhcp::TokenUInt32ToText -- represents the unsigned 32 bit integer in string
representation. representation.
- isc::dhcp::TokenNot -- the logical not operator. - isc::dhcp::TokenNot -- the logical not operator.
- isc::dhcp::TokenAnd -- the logical and (strict) operator. - isc::dhcp::TokenAnd -- the logical and (strict) operator.

View File

@@ -127,9 +127,9 @@ EvalContext::convertNestLevelNumber(const std::string& nest_level,
uint8_t uint8_t
EvalContext::convertUint8(const std::string& number, EvalContext::convertUint8(const std::string& number,
const isc::eval::location& loc) { const isc::eval::location& loc) {
int32_t n = 0; int64_t n = 0;
try { try {
n = boost::lexical_cast<int32_t>(number); n = boost::lexical_cast<int64_t>(number);
} catch (const boost::bad_lexical_cast &) { } catch (const boost::bad_lexical_cast &) {
error(loc, "Invalid integer value in " + number); error(loc, "Invalid integer value in " + number);
} }
@@ -144,9 +144,9 @@ EvalContext::convertUint8(const std::string& number,
int8_t int8_t
EvalContext::convertInt8(const std::string& number, EvalContext::convertInt8(const std::string& number,
const isc::eval::location& loc) { const isc::eval::location& loc) {
int32_t n = 0; int64_t n = 0;
try { try {
n = boost::lexical_cast<int32_t>(number); n = boost::lexical_cast<int64_t>(number);
} catch (const boost::bad_lexical_cast &) { } catch (const boost::bad_lexical_cast &) {
error(loc, "Invalid integer value in " + number); error(loc, "Invalid integer value in " + number);
} }

View File

@@ -64,37 +64,37 @@ address.
% EVAL_DEBUG_INT8TOTEXT Pushing Int8 %1 % EVAL_DEBUG_INT8TOTEXT Pushing Int8 %1
This debug message indicates that the given address string representation is This debug message indicates that the given address string representation is
being pushed onto the value stack. This represents an 8 bits integer. being pushed onto the value stack. This represents an 8 bit integer.
# For use with TokenInt16ToText # For use with TokenInt16ToText
% EVAL_DEBUG_INT16TOTEXT Pushing Int16 %1 % EVAL_DEBUG_INT16TOTEXT Pushing Int16 %1
This debug message indicates that the given address string representation is This debug message indicates that the given address string representation is
being pushed onto the value stack. This represents a 16 bits integer. being pushed onto the value stack. This represents a 16 bit integer.
# For use with TokenInt32ToText # For use with TokenInt32ToText
% EVAL_DEBUG_INT32TOTEXT Pushing Int32 %1 % EVAL_DEBUG_INT32TOTEXT Pushing Int32 %1
This debug message indicates that the given address string representation is This debug message indicates that the given address string representation is
being pushed onto the value stack. This represents a 32 bits integer. being pushed onto the value stack. This represents a 32 bit integer.
# For use with TokenUInt8ToText # For use with TokenUInt8ToText
% EVAL_DEBUG_UINT8TOTEXT Pushing UInt8 %1 % EVAL_DEBUG_UINT8TOTEXT Pushing UInt8 %1
This debug message indicates that the given address string representation is This debug message indicates that the given address string representation is
being pushed onto the value stack. This represents an 8 bits unsigned integer. being pushed onto the value stack. This represents an 8 bit unsigned integer.
# For use with TokenUInt16ToText # For use with TokenUInt16ToText
% EVAL_DEBUG_UINT16TOTEXT Pushing UInt16 %1 % EVAL_DEBUG_UINT16TOTEXT Pushing UInt16 %1
This debug message indicates that the given address string representation is This debug message indicates that the given address string representation is
being pushed onto the value stack. This represents a 16 bits unsigned integer. being pushed onto the value stack. This represents a 16 bit unsigned integer.
# For use with TokenUInt32ToText # For use with TokenUInt32ToText
% EVAL_DEBUG_UINT32TOTEXT Pushing UInt32 %1 % EVAL_DEBUG_UINT32TOTEXT Pushing UInt32 %1
This debug message indicates that the given address string representation is This debug message indicates that the given address string representation is
being pushed onto the value stack. This represents a 32 bits unsigned integer. being pushed onto the value stack. This represents a 32 bit unsigned integer.
# For use with TokenMember # For use with TokenMember

View File

@@ -493,7 +493,7 @@ public:
} }
/// @brief checks if the given token is a inttotext operator /// @brief checks if the given token is a inttotext operator
template <typename Integer, typename TokenInteger> template <typename IntegerType, typename TokenInteger>
void checkTokenIntToText(const TokenPtr& token, void checkTokenIntToText(const TokenPtr& token,
const std::string& expected) { const std::string& expected) {
ASSERT_TRUE(token); ASSERT_TRUE(token);
@@ -504,13 +504,13 @@ public:
Pkt4Ptr pkt4(new Pkt4(DHCPDISCOVER, 12345)); Pkt4Ptr pkt4(new Pkt4(DHCPDISCOVER, 12345));
ValueStack values; ValueStack values;
Integer n; IntegerType n;
try { try {
if (is_signed<Integer>()) { if (is_signed<IntegerType>()) {
n = static_cast<Integer>(boost::lexical_cast<int32_t>(expected)); n = static_cast<IntegerType>(boost::lexical_cast<int32_t>(expected));
} else { } else {
n = static_cast<Integer>(boost::lexical_cast<uint32_t>(expected)); n = static_cast<IntegerType>(boost::lexical_cast<uint32_t>(expected));
} }
} catch (const boost::bad_lexical_cast& e) { } catch (const boost::bad_lexical_cast& e) {
FAIL() << "invalid value " << expected << " while expecting " FAIL() << "invalid value " << expected << " while expecting "
@@ -518,7 +518,7 @@ public:
<< e.what(); << e.what();
} }
values.push(std::string(const_cast<const char*>(reinterpret_cast<char*>(&n)), sizeof(Integer))); values.push(std::string(const_cast<const char*>(reinterpret_cast<char*>(&n)), sizeof(IntegerType)));
EXPECT_NO_THROW(token->evaluate(*pkt4, values)); EXPECT_NO_THROW(token->evaluate(*pkt4, values));
@@ -1512,7 +1512,7 @@ TEST_F(EvalContextTest, toHexString) {
checkTokenToHexString(tmp3); checkTokenToHexString(tmp3);
} }
// Test the parsing of a addrtotext expression // Test the parsing of an addrtotext expression
TEST_F(EvalContextTest, addressToText) { TEST_F(EvalContextTest, addressToText) {
{ {
EvalContext eval(Option::V4); EvalContext eval(Option::V4);
@@ -1943,27 +1943,27 @@ TEST_F(EvalContextTest, typeErrors) {
checkError("addrtotext('192.100.1.1')", checkError("addrtotext('192.100.1.1')",
"<string>:1.26: syntax error, unexpected end of file, expecting =="); "<string>:1.26: syntax error, unexpected end of file, expecting ==");
// Int8totext requires string storing the binary representation of the 8 bits integer. // Int8totext requires string storing the binary representation of the 8 bit integer.
checkError("int8totext('0123')", checkError("int8totext('0123')",
"<string>:1.19: syntax error, unexpected end of file, expecting =="); "<string>:1.19: syntax error, unexpected end of file, expecting ==");
// Int16totext requires string storing the binary representation of the 16 bits integer. // Int16totext requires string storing the binary representation of the 16 bit integer.
checkError("int16totext('01')", checkError("int16totext('01')",
"<string>:1.18: syntax error, unexpected end of file, expecting =="); "<string>:1.18: syntax error, unexpected end of file, expecting ==");
// Int32totext requires string storing the binary representation of the 32 bits integer. // Int32totext requires string storing the binary representation of the 32 bit integer.
checkError("int32totext('01')", checkError("int32totext('01')",
"<string>:1.18: syntax error, unexpected end of file, expecting =="); "<string>:1.18: syntax error, unexpected end of file, expecting ==");
// Uint8totext requires string storing the binary representation of the 8 bits unsigned integer. // Uint8totext requires string storing the binary representation of the 8 bit unsigned integer.
checkError("uint8totext('0123')", checkError("uint8totext('0123')",
"<string>:1.20: syntax error, unexpected end of file, expecting =="); "<string>:1.20: syntax error, unexpected end of file, expecting ==");
// Uint16totext requires string storing the binary representation of the 16 bits unsigned integer. // Uint16totext requires string storing the binary representation of the 16 bit unsigned integer.
checkError("uint16totext('01')", checkError("uint16totext('01')",
"<string>:1.19: syntax error, unexpected end of file, expecting =="); "<string>:1.19: syntax error, unexpected end of file, expecting ==");
// Uint32totext requires string storing the binary representation of the 32 bits unsigned integer. // Uint32totext requires string storing the binary representation of the 32 bit unsigned integer.
checkError("uint32totext('01')", checkError("uint32totext('01')",
"<string>:1.19: syntax error, unexpected end of file, expecting =="); "<string>:1.19: syntax error, unexpected end of file, expecting ==");
} }

View File

@@ -32,7 +32,6 @@ using isc::util::encode::toHex;
void void
TokenString::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenString::evaluate(Pkt& /*pkt*/, ValueStack& values) {
// Literals only push, nothing to pop // Literals only push, nothing to pop
values.push(value_); values.push(value_);
@@ -71,7 +70,6 @@ TokenHexString::TokenHexString(const string& str) : value_("") {
void void
TokenHexString::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenHexString::evaluate(Pkt& /*pkt*/, ValueStack& values) {
// Literals only push, nothing to pop // Literals only push, nothing to pop
values.push(value_); values.push(value_);
@@ -97,7 +95,6 @@ TokenIpAddress::TokenIpAddress(const string& addr) : value_("") {
void void
TokenIpAddress::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenIpAddress::evaluate(Pkt& /*pkt*/, ValueStack& values) {
// Literals only push, nothing to pop // Literals only push, nothing to pop
values.push(value_); values.push(value_);
@@ -108,26 +105,25 @@ TokenIpAddress::evaluate(Pkt& /*pkt*/, ValueStack& values) {
void void
TokenIpAddressToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenIpAddressToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() == 0) { if (values.size() == 0) {
isc_throw(EvalBadStack, "Incorrect empty stack."); isc_throw(EvalBadStack, "Incorrect empty stack.");
} }
size_t size;
string op = values.top(); string op = values.top();
size_t size = op.size();
if (!(size = op.size())) { if (!size) {
return; return;
} }
values.pop(); values.pop();
if ((size != sizeof(uint32_t)) && (size != INET_ADDRSTRLEN)) { if ((size != V4ADDRESS_LEN) && (size != V6ADDRESS_LEN)) {
isc_throw(EvalTypeError, "Can not convert to valid address."); isc_throw(EvalTypeError, "Can not convert to valid address.");
} }
std::vector<uint8_t> binary(op.begin(), op.end()); std::vector<uint8_t> binary(op.begin(), op.end());
if (size == sizeof(uint32_t)) { if (size == V4ADDRESS_LEN) {
op = asiolink::IOAddress::fromBytes(AF_INET, binary.data()).toText(); op = asiolink::IOAddress::fromBytes(AF_INET, binary.data()).toText();
} else { } else {
op = asiolink::IOAddress::fromBytes(AF_INET6, binary.data()).toText(); op = asiolink::IOAddress::fromBytes(AF_INET6, binary.data()).toText();
@@ -142,7 +138,6 @@ TokenIpAddressToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
void void
TokenInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() == 0) { if (values.size() == 0) {
isc_throw(EvalBadStack, "Incorrect empty stack."); isc_throw(EvalBadStack, "Incorrect empty stack.");
} }
@@ -171,7 +166,6 @@ TokenInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
void void
TokenInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() == 0) { if (values.size() == 0) {
isc_throw(EvalBadStack, "Incorrect empty stack."); isc_throw(EvalBadStack, "Incorrect empty stack.");
} }
@@ -202,7 +196,6 @@ TokenInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
void void
TokenInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() == 0) { if (values.size() == 0) {
isc_throw(EvalBadStack, "Incorrect empty stack."); isc_throw(EvalBadStack, "Incorrect empty stack.");
} }
@@ -233,7 +226,6 @@ TokenInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
void void
TokenUInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenUInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() == 0) { if (values.size() == 0) {
isc_throw(EvalBadStack, "Incorrect empty stack."); isc_throw(EvalBadStack, "Incorrect empty stack.");
} }
@@ -262,7 +254,6 @@ TokenUInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
void void
TokenUInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenUInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() == 0) { if (values.size() == 0) {
isc_throw(EvalBadStack, "Incorrect empty stack."); isc_throw(EvalBadStack, "Incorrect empty stack.");
} }
@@ -293,7 +284,6 @@ TokenUInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
void void
TokenUInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenUInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() == 0) { if (values.size() == 0) {
isc_throw(EvalBadStack, "Incorrect empty stack."); isc_throw(EvalBadStack, "Incorrect empty stack.");
} }
@@ -329,7 +319,6 @@ TokenOption::getOption(Pkt& pkt) {
void void
TokenOption::evaluate(Pkt& pkt, ValueStack& values) { TokenOption::evaluate(Pkt& pkt, ValueStack& values) {
OptionPtr opt = getOption(pkt); OptionPtr opt = getOption(pkt);
std::string opt_str; std::string opt_str;
if (opt) { if (opt) {
@@ -429,7 +418,6 @@ OptionPtr TokenRelay6Option::getOption(Pkt& pkt) {
void void
TokenPkt::evaluate(Pkt& pkt, ValueStack& values) { TokenPkt::evaluate(Pkt& pkt, ValueStack& values) {
string value; string value;
vector<uint8_t> binary; vector<uint8_t> binary;
string type_str; string type_str;
@@ -481,7 +469,6 @@ TokenPkt::evaluate(Pkt& pkt, ValueStack& values) {
void void
TokenPkt4::evaluate(Pkt& pkt, ValueStack& values) { TokenPkt4::evaluate(Pkt& pkt, ValueStack& values) {
vector<uint8_t> binary; vector<uint8_t> binary;
string value; string value;
string type_str; string type_str;
@@ -561,7 +548,6 @@ TokenPkt4::evaluate(Pkt& pkt, ValueStack& values) {
void void
TokenPkt6::evaluate(Pkt& pkt, ValueStack& values) { TokenPkt6::evaluate(Pkt& pkt, ValueStack& values) {
string value; string value;
string type_str; string type_str;
try { try {
@@ -602,7 +588,6 @@ TokenPkt6::evaluate(Pkt& pkt, ValueStack& values) {
void void
TokenRelay6Field::evaluate(Pkt& pkt, ValueStack& values) { TokenRelay6Field::evaluate(Pkt& pkt, ValueStack& values) {
vector<uint8_t> binary; vector<uint8_t> binary;
string type_str; string type_str;
try { try {
@@ -665,7 +650,6 @@ TokenRelay6Field::evaluate(Pkt& pkt, ValueStack& values) {
void void
TokenEqual::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenEqual::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() < 2) { if (values.size() < 2) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least " isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
"2 values for == operator, got " << values.size()); "2 values for == operator, got " << values.size());
@@ -690,7 +674,6 @@ TokenEqual::evaluate(Pkt& /*pkt*/, ValueStack& values) {
void void
TokenSubstring::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenSubstring::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() < 3) { if (values.size() < 3) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least " isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
"3 values for substring operator, got " << values.size()); "3 values for substring operator, got " << values.size());
@@ -786,7 +769,6 @@ TokenSubstring::evaluate(Pkt& /*pkt*/, ValueStack& values) {
void void
TokenConcat::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenConcat::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() < 2) { if (values.size() < 2) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least " isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
"2 values for concat, got " << values.size()); "2 values for concat, got " << values.size());
@@ -809,7 +791,6 @@ TokenConcat::evaluate(Pkt& /*pkt*/, ValueStack& values) {
void void
TokenIfElse::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenIfElse::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() < 3) { if (values.size() < 3) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least " isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
"3 values for ifelse, got " << values.size()); "3 values for ifelse, got " << values.size());
@@ -845,7 +826,6 @@ TokenIfElse::evaluate(Pkt& /*pkt*/, ValueStack& values) {
void void
TokenToHexString::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenToHexString::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() < 2) { if (values.size() < 2) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least " isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
"2 values for hexstring, got " << values.size()); "2 values for hexstring, got " << values.size());
@@ -879,7 +859,6 @@ TokenToHexString::evaluate(Pkt& /*pkt*/, ValueStack& values) {
void void
TokenNot::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenNot::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() == 0) { if (values.size() == 0) {
isc_throw(EvalBadStack, "Incorrect empty stack."); isc_throw(EvalBadStack, "Incorrect empty stack.");
} }
@@ -902,7 +881,6 @@ TokenNot::evaluate(Pkt& /*pkt*/, ValueStack& values) {
void void
TokenAnd::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenAnd::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() < 2) { if (values.size() < 2) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least " isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
"2 values for and operator, got " << values.size()); "2 values for and operator, got " << values.size());
@@ -930,7 +908,6 @@ TokenAnd::evaluate(Pkt& /*pkt*/, ValueStack& values) {
void void
TokenOr::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenOr::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() < 2) { if (values.size() < 2) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least " isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
"2 values for or operator, got " << values.size()); "2 values for or operator, got " << values.size());
@@ -958,7 +935,6 @@ TokenOr::evaluate(Pkt& /*pkt*/, ValueStack& values) {
void void
TokenMember::evaluate(Pkt& pkt, ValueStack& values) { TokenMember::evaluate(Pkt& pkt, ValueStack& values) {
if (pkt.inClass(client_class_)) { if (pkt.inClass(client_class_)) {
values.push("true"); values.push("true");
} else { } else {
@@ -994,7 +970,6 @@ TokenVendor::FieldType TokenVendor::getField() const {
} }
void TokenVendor::evaluate(Pkt& pkt, ValueStack& values) { void TokenVendor::evaluate(Pkt& pkt, ValueStack& values) {
// Get the option first. // Get the option first.
uint16_t code = 0; uint16_t code = 0;
switch (universe_) { switch (universe_) {
@@ -1100,7 +1075,6 @@ uint16_t TokenVendorClass::getDataIndex() const {
} }
void TokenVendorClass::evaluate(Pkt& pkt, ValueStack& values) { void TokenVendorClass::evaluate(Pkt& pkt, ValueStack& values) {
// Get the option first. // Get the option first.
uint16_t code = 0; uint16_t code = 0;
switch (universe_) { switch (universe_) {
@@ -1206,7 +1180,6 @@ TokenSubOption::getSubOption(const OptionPtr& parent) {
void void
TokenSubOption::evaluate(Pkt& pkt, ValueStack& values) { TokenSubOption::evaluate(Pkt& pkt, ValueStack& values) {
OptionPtr parent = getOption(pkt); OptionPtr parent = getOption(pkt);
std::string txt; std::string txt;
isc::log::MessageID msgid = EVAL_DEBUG_SUB_OPTION; isc::log::MessageID msgid = EVAL_DEBUG_SUB_OPTION;

View File

@@ -224,9 +224,9 @@ public:
void evaluate(Pkt& pkt, ValueStack& values); void evaluate(Pkt& pkt, ValueStack& values);
}; };
/// @brief Token representing an 8 bits integer as a string /// @brief Token representing an 8 bit integer as a string
/// ///
/// This token holds the value of an 8 bits integer as a string, for instance /// This token holds the value of an 8 bit integer as a string, for instance
/// 0xff is '-1' /// 0xff is '-1'
class TokenInt8ToText : public Token { class TokenInt8ToText : public Token {
public: public:
@@ -237,14 +237,14 @@ public:
/// decoding) /// decoding)
/// ///
/// @param pkt (ignored) /// @param pkt (ignored)
/// @param values (represented 8 bits integer as a string will be pushed /// @param values (represented 8 bit integer as a string will be pushed
/// here) /// here)
void evaluate(Pkt& pkt, ValueStack& values); void evaluate(Pkt& pkt, ValueStack& values);
}; };
/// @brief Token representing a 16 bits integer as a string /// @brief Token representing a 16 bit integer as a string
/// ///
/// This token holds the value of a 16 bits integer as a string, for instance /// This token holds the value of a 16 bit integer as a string, for instance
/// 0xffff is '-1' /// 0xffff is '-1'
class TokenInt16ToText : public Token { class TokenInt16ToText : public Token {
public: public:
@@ -255,14 +255,14 @@ public:
/// decoding) /// decoding)
/// ///
/// @param pkt (ignored) /// @param pkt (ignored)
/// @param values (represented 16 bits integer as a string will be pushed /// @param values (represented 16 bit integer as a string will be pushed
/// here) /// here)
void evaluate(Pkt& pkt, ValueStack& values); void evaluate(Pkt& pkt, ValueStack& values);
}; };
/// @brief Token representing a 32 bits integer as a string /// @brief Token representing a 32 bit integer as a string
/// ///
/// This token holds the value of a 32 bits integer as a string, for instance /// This token holds the value of a 32 bit integer as a string, for instance
/// 0xffffffff is '-1' /// 0xffffffff is '-1'
class TokenInt32ToText : public Token { class TokenInt32ToText : public Token {
public: public:
@@ -273,14 +273,14 @@ public:
/// decoding) /// decoding)
/// ///
/// @param pkt (ignored) /// @param pkt (ignored)
/// @param values (represented 32 bits integer as a string will be pushed /// @param values (represented 32 bit integer as a string will be pushed
/// here) /// here)
void evaluate(Pkt& pkt, ValueStack& values); void evaluate(Pkt& pkt, ValueStack& values);
}; };
/// @brief Token representing an 8 bits unsigned integer as a string /// @brief Token representing an 8 bit unsigned integer as a string
/// ///
/// This token holds the value of an 8 bits unsigned integer as a string, for /// This token holds the value of an 8 bit unsigned integer as a string, for
/// instance 0xff is '255' /// instance 0xff is '255'
class TokenUInt8ToText : public Token { class TokenUInt8ToText : public Token {
public: public:
@@ -291,14 +291,14 @@ public:
/// decoding) /// decoding)
/// ///
/// @param pkt (ignored) /// @param pkt (ignored)
/// @param values (represented 8 bits unsigned integer as a string will be /// @param values (represented 8 bit unsigned integer as a string will be
/// pushed here) /// pushed here)
void evaluate(Pkt& pkt, ValueStack& values); void evaluate(Pkt& pkt, ValueStack& values);
}; };
/// @brief Token representing a 16 bits unsigned integer as a string /// @brief Token representing a 16 bit unsigned integer as a string
/// ///
/// This token holds the value of a 16 bits unsigned integer as a string, for /// This token holds the value of a 16 bit unsigned integer as a string, for
/// instance 0xffff is '65535' /// instance 0xffff is '65535'
class TokenUInt16ToText : public Token { class TokenUInt16ToText : public Token {
public: public:
@@ -309,14 +309,14 @@ public:
/// decoding) /// decoding)
/// ///
/// @param pkt (ignored) /// @param pkt (ignored)
/// @param values (represented 16 bits unsigned integer as a string will be /// @param values (represented 16 bit unsigned integer as a string will be
/// pushed here) /// pushed here)
void evaluate(Pkt& pkt, ValueStack& values); void evaluate(Pkt& pkt, ValueStack& values);
}; };
/// @brief Token representing a 32 bits unsigned integer as a string /// @brief Token representing a 32 bit unsigned integer as a string
/// ///
/// This token holds the value of a 32 bits unsigned integer as a string, for /// This token holds the value of a 32 bit unsigned integer as a string, for
/// instance 0xffffffff is '4294967295' /// instance 0xffffffff is '4294967295'
class TokenUInt32ToText : public Token { class TokenUInt32ToText : public Token {
public: public:
@@ -327,7 +327,7 @@ public:
/// decoding) /// decoding)
/// ///
/// @param pkt (ignored) /// @param pkt (ignored)
/// @param values (represented 32 bits unsigned integer as a string will be /// @param values (represented 32 bit unsigned integer as a string will be
/// pushed here) /// pushed here)
void evaluate(Pkt& pkt, ValueStack& values); void evaluate(Pkt& pkt, ValueStack& values);
}; };