%type <uint16_t> option_code
%type <TokenOption::RepresentationType> option_repr_type
-%type <TokenRelay6::FieldType> relay6_field
+%type <TokenRelay6Field::FieldType> relay6_field
%type <uint8_t> nest_level
%left OR
switch (ctx.getUniverse()) {
case Option::V6:
{
- TokenPtr relay6field(new TokenRelay6($3, $6));
+ TokenPtr relay6field(new TokenRelay6Field($3, $6));
ctx.expression.push_back(relay6field);
break;
}
}
;
-relay6_field : PEERADDR { $$ = TokenRelay6::PEERADDR; }
- | LINKADDR { $$ = TokenRelay6::LINKADDR; }
+relay6_field : PEERADDR { $$ = TokenRelay6Field::PEERADDR; }
+ | LINKADDR { $$ = TokenRelay6Field::LINKADDR; }
;
nest_level : INTEGER
/// @param expected_level expected nesting level
/// @param expected_code expected option code
/// @param expected_repr expected representation (text, hex, exists)
- void checkTokenRelay6(const TokenPtr& token,
- uint8_t expected_level,
- TokenRelay6::FieldType expected_type) {
+ void checkTokenRelay6Field(const TokenPtr& token,
+ uint8_t expected_level,
+ TokenRelay6Field::FieldType expected_type) {
ASSERT_TRUE(token);
- boost::shared_ptr<TokenRelay6> opt =
- boost::dynamic_pointer_cast<TokenRelay6>(token);
+ boost::shared_ptr<TokenRelay6Field> opt =
+ boost::dynamic_pointer_cast<TokenRelay6Field>(token);
ASSERT_TRUE(opt);
EXPECT_EQ(expected_level, opt->getNest());
}
/// @brief This tests attempts to parse the expression then checks
- /// if the number of tokens is correct and the TokenRelay6 is as
+ /// if the number of tokens is correct and the TokenRelay6Field is as
/// expected.
///
/// @param expr expression to be parsed
/// @param exp_tokens expected number of tokens
void testRelay6Field(std::string expr,
uint8_t exp_level,
- TokenRelay6::FieldType exp_type,
+ TokenRelay6Field::FieldType exp_type,
int exp_tokens) {
EvalContext eval(Option::V6);
// There should be the expected number of tokens.
ASSERT_EQ(exp_tokens, eval.expression.size());
- // checkt that the first token is TokenRelay6 and that
+ // checkt that the first token is TokenRelay6Field and that
// is has the correct attributes
- checkTokenRelay6(eval.expression.at(0), exp_level, exp_type);
+ checkTokenRelay6Field(eval.expression.at(0), exp_level, exp_type);
}
/// @brief checks if the given expression raises the expected message
// Tests if the linkaddr field in a Relay6 encapsulation can be accessed.
TEST_F(EvalContextTest, relay6FieldLinkAddr) {
testRelay6Field("relay6[0].linkaddr == ::",
- 0, TokenRelay6::LINKADDR, 3);
+ 0, TokenRelay6Field::LINKADDR, 3);
}
// Tests if the peeraddr field in a Relay6 encapsulation can be accessed.
TEST_F(EvalContextTest, relay6FieldPeerAddr) {
testRelay6Field("relay6[1].peeraddr == ::",
- 1, TokenRelay6::PEERADDR, 3);
+ 1, TokenRelay6Field::PEERADDR, 3);
}
//
}
catch (const isc::OutOfRange&) {
// The only exception we expect is OutOfRange if the nest
- // level is invalid. We return a NULL in that case.
+ // level is out of range of the encapsulations, for example
+ // if nest_level_ is 4 and there are only 2 encapsulations.
+ // We return a NULL in that case.
return (OptionPtr());
}
}
void
-TokenRelay6::evaluate(const Pkt& pkt, ValueStack& values) {
+TokenRelay6Field::evaluate(const Pkt& pkt, ValueStack& values) {
vector<uint8_t> binary;
try {
/// set the field it may be 0s.
///
/// The nesting level can go from 0 (closest to the server) to 31.
-class TokenRelay6 : public Token {
+class TokenRelay6Field : public Token {
public:
/// @brief enum value that determines the field.
///
/// @param nest_level the nesting level for which relay to examine.
/// @param type which field to extract.
- TokenRelay6(const uint8_t nest_level, const FieldType type)
+ TokenRelay6Field(const uint8_t nest_level, const FieldType type)
: nest_level_(nest_level), type_(type) {}
/// @brief Extracts the specified field from the requested relay
/// @brief Returns nest-level
///
/// This method is used in testing to determine if the parser has
- /// instantiated TokenRelay6 with correct parameters.
+ /// instantiated TokenRelay6Field with correct parameters.
///
/// @return nest-level of the relay block this token expects to use
/// for extraction.
/// @brief Returns field type
///
/// This method is used only in testing to determine if the parser has
- /// instantiated TokenRelay6 with correct parameters.
+ /// instantiated TokenRelay6Field with correct parameters.
///
/// @return type of the field.
FieldType getType() {