| | | IPv6 address in human |
| | | readable format |
+-----------------------+---------------------------+------------------------+
- | Int8ToText | int8totext (-1) | Represents the 8 bits |
+ | Int8ToText | int8totext (-1) | Represents the 8 bit |
| | | signed integer in text |
| | | format |
+-----------------------+---------------------------+------------------------+
- | Int16ToText | int16totext (-1) | Represents the 16 bits |
+ | Int16ToText | int16totext (-1) | Represents the 16 bit |
| | | signed integer in text |
| | | format |
+-----------------------+---------------------------+------------------------+
- | Int32ToText | int32totext (-1) | Represents the 32 bits |
+ | Int32ToText | int32totext (-1) | Represents the 32 bit |
| | | signed integer in text |
| | | format |
+-----------------------+---------------------------+------------------------+
- | UInt8ToText | uint8totext (255) | Represents the 8 bits |
+ | UInt8ToText | uint8totext (255) | Represents the 8 bit |
| | | unsigned integer in |
| | | text format |
+-----------------------+---------------------------+------------------------+
- | UInt16ToText | uint16totext (65535) | Represents the 16 bits |
+ | UInt16ToText | uint16totext (65535) | Represents the 16 bit |
| | | unsigned integer in |
| | | text format |
+-----------------------+---------------------------+------------------------+
- | UInt32ToText | uint32totext (4294967295) | Represents the 32 bits |
+ | UInt32ToText | uint32totext (4294967295) | Represents the 32 bit |
| | | unsigned integer in |
| | | text format |
+-----------------------+---------------------------+------------------------+
concatenate two other tokens.
- isc::dhcp::TokenIfElse -- represents the ifelse(cond, iftrue, ifelse) operator.
- isc::dhcp::TokenToHexString -- represents the hexstring operator which
- converts a binary value to its hexadecimal string representation.
- - isc::dhcp::TokenInt8ToText -- represents the signed 8 bits integer in string
+ converts a binary value to its hexadecimal string representation.
+ - isc::dhcp::TokenInt8ToText -- represents the signed 8 bit integer in string
representation.
- - isc::dhcp::TokenInt16ToText -- represents the signed 16 bits integer in string
+ - isc::dhcp::TokenInt16ToText -- represents the signed 16 bit integer in string
representation.
- - isc::dhcp::TokenInt32ToText -- represents the signed 32 bits integer in string
+ - isc::dhcp::TokenInt32ToText -- represents the signed 32 bit integer in string
representation.
- - isc::dhcp::TokenUInt8ToText -- represents the unsigned 8 bits integer in string
+ - isc::dhcp::TokenUInt8ToText -- represents the unsigned 8 bit integer in string
representation.
- - isc::dhcp::TokenUInt16ToText -- represents the unsigned 16 bits integer in string
+ - isc::dhcp::TokenUInt16ToText -- represents the unsigned 16 bit integer in string
representation.
- - isc::dhcp::TokenUInt32ToText -- represents the unsigned 32 bits integer in string
+ - isc::dhcp::TokenUInt32ToText -- represents the unsigned 32 bit integer in string
representation.
- isc::dhcp::TokenNot -- the logical not operator.
- isc::dhcp::TokenAnd -- the logical and (strict) operator.
uint8_t
EvalContext::convertUint8(const std::string& number,
const isc::eval::location& loc) {
- int32_t n = 0;
+ int64_t n = 0;
try {
- n = boost::lexical_cast<int32_t>(number);
+ n = boost::lexical_cast<int64_t>(number);
} catch (const boost::bad_lexical_cast &) {
error(loc, "Invalid integer value in " + number);
}
int8_t
EvalContext::convertInt8(const std::string& number,
const isc::eval::location& loc) {
- int32_t n = 0;
+ int64_t n = 0;
try {
- n = boost::lexical_cast<int32_t>(number);
+ n = boost::lexical_cast<int64_t>(number);
} catch (const boost::bad_lexical_cast &) {
error(loc, "Invalid integer value in " + number);
}
% EVAL_DEBUG_INT8TOTEXT Pushing Int8 %1
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
% EVAL_DEBUG_INT16TOTEXT Pushing Int16 %1
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
% EVAL_DEBUG_INT32TOTEXT Pushing Int32 %1
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
% EVAL_DEBUG_UINT8TOTEXT Pushing UInt8 %1
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
% EVAL_DEBUG_UINT16TOTEXT Pushing UInt16 %1
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
% EVAL_DEBUG_UINT32TOTEXT Pushing UInt32 %1
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
}
/// @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,
const std::string& expected) {
ASSERT_TRUE(token);
Pkt4Ptr pkt4(new Pkt4(DHCPDISCOVER, 12345));
ValueStack values;
- Integer n;
+ IntegerType n;
try {
- if (is_signed<Integer>()) {
- n = static_cast<Integer>(boost::lexical_cast<int32_t>(expected));
+ if (is_signed<IntegerType>()) {
+ n = static_cast<IntegerType>(boost::lexical_cast<int32_t>(expected));
} 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) {
FAIL() << "invalid value " << expected << " while expecting "
<< 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));
checkTokenToHexString(tmp3);
}
-// Test the parsing of a addrtotext expression
+// Test the parsing of an addrtotext expression
TEST_F(EvalContextTest, addressToText) {
{
EvalContext eval(Option::V4);
checkError("addrtotext('192.100.1.1')",
"<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')",
"<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')",
"<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')",
"<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')",
"<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')",
"<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')",
"<string>:1.19: syntax error, unexpected end of file, expecting ==");
}
void
TokenString::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
// Literals only push, nothing to pop
values.push(value_);
void
TokenHexString::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
// Literals only push, nothing to pop
values.push(value_);
void
TokenIpAddress::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
// Literals only push, nothing to pop
values.push(value_);
void
TokenIpAddressToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
if (values.size() == 0) {
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)) && (size != INET_ADDRSTRLEN)) {
+ if ((size != V4ADDRESS_LEN) && (size != V6ADDRESS_LEN)) {
isc_throw(EvalTypeError, "Can not convert to valid address.");
}
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();
} else {
op = asiolink::IOAddress::fromBytes(AF_INET6, binary.data()).toText();
void
TokenInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
if (values.size() == 0) {
isc_throw(EvalBadStack, "Incorrect empty stack.");
}
void
TokenInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
if (values.size() == 0) {
isc_throw(EvalBadStack, "Incorrect empty stack.");
}
void
TokenInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
if (values.size() == 0) {
isc_throw(EvalBadStack, "Incorrect empty stack.");
}
void
TokenUInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
if (values.size() == 0) {
isc_throw(EvalBadStack, "Incorrect empty stack.");
}
void
TokenUInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
if (values.size() == 0) {
isc_throw(EvalBadStack, "Incorrect empty stack.");
}
void
TokenUInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
if (values.size() == 0) {
isc_throw(EvalBadStack, "Incorrect empty stack.");
}
void
TokenOption::evaluate(Pkt& pkt, ValueStack& values) {
-
OptionPtr opt = getOption(pkt);
std::string opt_str;
if (opt) {
void
TokenPkt::evaluate(Pkt& pkt, ValueStack& values) {
-
string value;
vector<uint8_t> binary;
string type_str;
void
TokenPkt4::evaluate(Pkt& pkt, ValueStack& values) {
-
vector<uint8_t> binary;
string value;
string type_str;
void
TokenPkt6::evaluate(Pkt& pkt, ValueStack& values) {
-
string value;
string type_str;
try {
void
TokenRelay6Field::evaluate(Pkt& pkt, ValueStack& values) {
-
vector<uint8_t> binary;
string type_str;
try {
void
TokenEqual::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
if (values.size() < 2) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
"2 values for == operator, got " << values.size());
void
TokenSubstring::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
if (values.size() < 3) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
"3 values for substring operator, got " << values.size());
void
TokenConcat::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
if (values.size() < 2) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
"2 values for concat, got " << values.size());
void
TokenIfElse::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
if (values.size() < 3) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
"3 values for ifelse, got " << values.size());
void
TokenToHexString::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
if (values.size() < 2) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
"2 values for hexstring, got " << values.size());
void
TokenNot::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
if (values.size() == 0) {
isc_throw(EvalBadStack, "Incorrect empty stack.");
}
void
TokenAnd::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
if (values.size() < 2) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
"2 values for and operator, got " << values.size());
void
TokenOr::evaluate(Pkt& /*pkt*/, ValueStack& values) {
-
if (values.size() < 2) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
"2 values for or operator, got " << values.size());
void
TokenMember::evaluate(Pkt& pkt, ValueStack& values) {
-
if (pkt.inClass(client_class_)) {
values.push("true");
} else {
}
void TokenVendor::evaluate(Pkt& pkt, ValueStack& values) {
-
// Get the option first.
uint16_t code = 0;
switch (universe_) {
}
void TokenVendorClass::evaluate(Pkt& pkt, ValueStack& values) {
-
// Get the option first.
uint16_t code = 0;
switch (universe_) {
void
TokenSubOption::evaluate(Pkt& pkt, ValueStack& values) {
-
OptionPtr parent = getOption(pkt);
std::string txt;
isc::log::MessageID msgid = EVAL_DEBUG_SUB_OPTION;
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'
class TokenInt8ToText : public Token {
public:
/// decoding)
///
/// @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)
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'
class TokenInt16ToText : public Token {
public:
/// decoding)
///
/// @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)
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'
class TokenInt32ToText : public Token {
public:
/// decoding)
///
/// @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)
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'
class TokenUInt8ToText : public Token {
public:
/// decoding)
///
/// @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)
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'
class TokenUInt16ToText : public Token {
public:
/// decoding)
///
/// @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)
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'
class TokenUInt32ToText : public Token {
public:
/// decoding)
///
/// @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)
void evaluate(Pkt& pkt, ValueStack& values);
};