From: Shawn Routhier Date: Wed, 6 Apr 2016 03:55:42 +0000 (-0700) Subject: [trac4265] updates per review comments X-Git-Tag: trac4106_update_base~51^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2a5d809ac51fce5d26570f5eb69da2f6244ae03;p=thirdparty%2Fkea.git [trac4265] updates per review comments --- diff --git a/src/lib/eval/eval_context.cc b/src/lib/eval/eval_context.cc index 9ef2faec89..188d5f1d9d 100644 --- a/src/lib/eval/eval_context.cc +++ b/src/lib/eval/eval_context.cc @@ -100,7 +100,6 @@ EvalContext::convertNestLevelNumber(const std::string& nest_level, try { n = boost::lexical_cast(nest_level); } catch (const boost::bad_lexical_cast &) { - // This can't happen... error(loc, "Nest level has invalid value in " + nest_level); } if (option_universe_ == Option::V6) { diff --git a/src/lib/eval/parser.yy b/src/lib/eval/parser.yy index d840f49a31..cc7ed8fd50 100644 --- a/src/lib/eval/parser.yy +++ b/src/lib/eval/parser.yy @@ -68,7 +68,7 @@ using namespace isc::eval; %type option_code %type option_repr_type -%type relay6_field +%type relay6_field %type nest_level %left OR @@ -210,7 +210,7 @@ string_expr : STRING switch (ctx.getUniverse()) { case Option::V6: { - TokenPtr relay6field(new TokenRelay6($3, $6)); + TokenPtr relay6field(new TokenRelay6Field($3, $6)); ctx.expression.push_back(relay6field); break; } @@ -272,8 +272,8 @@ length_expr : INTEGER } ; -relay6_field : PEERADDR { $$ = TokenRelay6::PEERADDR; } - | LINKADDR { $$ = TokenRelay6::LINKADDR; } +relay6_field : PEERADDR { $$ = TokenRelay6Field::PEERADDR; } + | LINKADDR { $$ = TokenRelay6Field::LINKADDR; } ; nest_level : INTEGER diff --git a/src/lib/eval/tests/context_unittest.cc b/src/lib/eval/tests/context_unittest.cc index 76939d0750..d086b3da46 100644 --- a/src/lib/eval/tests/context_unittest.cc +++ b/src/lib/eval/tests/context_unittest.cc @@ -210,12 +210,12 @@ public: /// @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 opt = - boost::dynamic_pointer_cast(token); + boost::shared_ptr opt = + boost::dynamic_pointer_cast(token); ASSERT_TRUE(opt); EXPECT_EQ(expected_level, opt->getNest()); @@ -223,7 +223,7 @@ public: } /// @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 @@ -232,7 +232,7 @@ public: /// @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); @@ -251,9 +251,9 @@ public: // 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 @@ -711,13 +711,13 @@ TEST_F(EvalContextTest, relay6OptionHex) { // 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); } // diff --git a/src/lib/eval/token.cc b/src/lib/eval/token.cc index 9647bd6ff9..b3e52ba924 100644 --- a/src/lib/eval/token.cc +++ b/src/lib/eval/token.cc @@ -311,7 +311,9 @@ OptionPtr TokenRelay6Option::getOption(const Pkt& pkt) { } 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()); } @@ -322,7 +324,7 @@ OptionPtr TokenRelay6Option::getOption(const Pkt& pkt) { } void -TokenRelay6::evaluate(const Pkt& pkt, ValueStack& values) { +TokenRelay6Field::evaluate(const Pkt& pkt, ValueStack& values) { vector binary; try { diff --git a/src/lib/eval/token.h b/src/lib/eval/token.h index 7512ac499b..e603192490 100644 --- a/src/lib/eval/token.h +++ b/src/lib/eval/token.h @@ -527,7 +527,7 @@ protected: /// 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. @@ -541,7 +541,7 @@ public: /// /// @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 @@ -556,7 +556,7 @@ public: /// @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. @@ -567,7 +567,7 @@ public: /// @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() {