Commit ef8592eb authored by Thomas Markwalder's avatar Thomas Markwalder Committed by Tomek Mrugalski

[#129,!55] Add missing global keyword parsing to kea-dhcp6

src/bin/dhcp6/dhcp6_lexer.ll
src/bin/dhcp6/dhcp6_parser.yy
    adde keyword value of "global"

src/bin/dhcp6/tests/config_parser_unittest.cc
    TEST_F(Dhcp6ParserTest, hostReservationPerSubnet) - added check
    for "global" mode value

src/bin/dhcp6/tests/get_config_unittest.cc
     Updated generated config tests
parent b9fe00fc
// Generated 201804111444
// A Bison parser, made by GNU Bison 3.0.4.
// Locations for Bison parsers in C++
......
// Generated 201804111444
// A Bison parser, made by GNU Bison 3.0.4.
// Positions for Bison parsers in C++
......
// Generated 201804111444
// A Bison parser, made by GNU Bison 3.0.4.
// Stack handling for Bison parsers in C++
......
This diff is collapsed.
......@@ -1083,6 +1083,15 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"global\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::RESERVATION_MODE:
return isc::dhcp::Dhcp6Parser::make_GLOBAL(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("global", driver.loc_);
}
}
\"all\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::RESERVATION_MODE:
......
This diff is collapsed.
This diff is collapsed.
......@@ -118,6 +118,7 @@ using namespace std;
RESERVATION_MODE "reservation-mode"
DISABLED "disabled"
OUT_OF_POOL "out-of-pool"
GLOBAL "global"
ALL "all"
SHARED_NETWORKS "shared-networks"
......@@ -1093,6 +1094,7 @@ reservation_mode: RESERVATION_MODE {
hr_mode: DISABLED { $$ = ElementPtr(new StringElement("disabled", ctx.loc2pos(@1))); }
| OUT_OF_POOL { $$ = ElementPtr(new StringElement("out-of-pool", ctx.loc2pos(@1))); }
| GLOBAL { $$ = ElementPtr(new StringElement("global", ctx.loc2pos(@1))); }
| ALL { $$ = ElementPtr(new StringElement("all", ctx.loc2pos(@1))); }
;
......
......@@ -5214,7 +5214,12 @@ TEST_F(Dhcp6ParserTest, hostReservationPerSubnet) {
" },"
" {"
" \"pools\": [ { \"pool\": \"2001:db8:4::/64\" } ],"
" \"subnet\": \"2001:db8:4::/48\" "
" \"subnet\": \"2001:db8:4::/48\", "
" \"reservation-mode\": \"global\""
" },"
" {"
" \"pools\": [ { \"pool\": \"2001:db8:5::/64\" } ],"
" \"subnet\": \"2001:db8:5::/48\" "
" } ],"
"\"valid-lifetime\": 4000 }";
......@@ -5233,7 +5238,7 @@ TEST_F(Dhcp6ParserTest, hostReservationPerSubnet) {
ConstCfgSubnets6Ptr subnets = CfgMgr::instance().getCurrentCfg()->getCfgSubnets6();
ASSERT_TRUE(subnets);
const Subnet6Collection* subnet_col = subnets->getAll();
ASSERT_EQ(4, subnet_col->size()); // We expect 4 subnets
ASSERT_EQ(5, subnet_col->size()); // We expect 4 subnets
// Let's check if the parsed subnets have correct HR modes.
......@@ -5256,6 +5261,11 @@ TEST_F(Dhcp6ParserTest, hostReservationPerSubnet) {
// Subnet 4
subnet = subnets->selectSubnet(IOAddress("2001:db8:4::1"));
ASSERT_TRUE(subnet);
EXPECT_EQ(Network::HR_GLOBAL, subnet->getHostReservationMode());
// Subnet 5
subnet = subnets->selectSubnet(IOAddress("2001:db8:5::1"));
ASSERT_TRUE(subnet);
EXPECT_EQ(Network::HR_ALL, subnet->getHostReservationMode());
}
......
......@@ -1344,7 +1344,16 @@ const char* EXTRACTED_CONFIGS[] = {
" \"pool\": \"2001:db8:4::/64\"\n"
" }\n"
" ],\n"
" \"reservation-mode\": \"global\",\n"
" \"subnet\": \"2001:db8:4::/48\"\n"
" },\n"
" {\n"
" \"pools\": [\n"
" {\n"
" \"pool\": \"2001:db8:5::/64\"\n"
" }\n"
" ],\n"
" \"subnet\": \"2001:db8:5::/48\"\n"
" }\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
......@@ -5892,10 +5901,32 @@ const char* UNPARSED_CONFIGS[] = {
" \"ip-addresses\": [ ]\n"
" },\n"
" \"renew-timer\": 1000,\n"
" \"reservation-mode\": \"all\",\n"
" \"reservation-mode\": \"global\",\n"
" \"reservations\": [ ],\n"
" \"subnet\": \"2001:db8:4::/48\",\n"
" \"valid-lifetime\": 4000\n"
" },\n"
" {\n"
" \"id\": 5,\n"
" \"option-data\": [ ],\n"
" \"pd-pools\": [ ],\n"
" \"pools\": [\n"
" {\n"
" \"option-data\": [ ],\n"
" \"pool\": \"2001:db8:5::/64\"\n"
" }\n"
" ],\n"
" \"preferred-lifetime\": 3000,\n"
" \"rapid-commit\": false,\n"
" \"rebind-timer\": 2000,\n"
" \"relay\": {\n"
" \"ip-addresses\": [ ]\n"
" },\n"
" \"renew-timer\": 1000,\n"
" \"reservation-mode\": \"all\",\n"
" \"reservations\": [ ],\n"
" \"subnet\": \"2001:db8:5::/48\",\n"
" \"valid-lifetime\": 4000\n"
" }\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
......
// Generated 201809161042
// A Bison parser, made by GNU Bison 3.0.5.
// A Bison parser, made by GNU Bison 3.0.4.
// Locations for Bison parsers in C++
// Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
// Copyright (C) 2002-2015 Free Software Foundation, Inc.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
......@@ -41,9 +40,9 @@
# include "position.hh"
#line 14 "parser.yy" // location.cc:292
#line 14 "parser.yy" // location.cc:296
namespace isc { namespace eval {
#line 46 "location.hh" // location.cc:292
#line 46 "location.hh" // location.cc:296
/// Abstract a location.
class location
{
......@@ -53,27 +52,30 @@ namespace isc { namespace eval {
location (const position& b, const position& e)
: begin (b)
, end (e)
{}
{
}
/// Construct a 0-width location in \a p.
explicit location (const position& p = position ())
: begin (p)
, end (p)
{}
{
}
/// Construct a 0-width location in \a f, \a l, \a c.
explicit location (std::string* f,
unsigned l = 1u,
unsigned c = 1u)
unsigned int l = 1u,
unsigned int c = 1u)
: begin (f, l, c)
, end (f, l, c)
{}
{
}
/// Initialization.
void initialize (std::string* f = YY_NULLPTR,
unsigned l = 1u,
unsigned c = 1u)
unsigned int l = 1u,
unsigned int c = 1u)
{
begin.initialize (f, l, c);
end = begin;
......@@ -171,7 +173,7 @@ namespace isc { namespace eval {
inline std::basic_ostream<YYChar>&
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
{
unsigned end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
unsigned int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
ostr << loc.begin;
if (loc.end.filename
&& (!loc.begin.filename
......@@ -184,7 +186,7 @@ namespace isc { namespace eval {
return ostr;
}
#line 14 "parser.yy" // location.cc:292
#line 14 "parser.yy" // location.cc:296
} } // isc::eval
#line 189 "location.hh" // location.cc:292
#line 192 "location.hh" // location.cc:296
#endif // !YY_EVAL_LOCATION_HH_INCLUDED
This diff is collapsed.
// A Bison parser, made by GNU Bison 3.0.5.
// A Bison parser, made by GNU Bison 3.0.4.
// Skeleton interface for Bison LALR(1) parsers in C++
// Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
// Copyright (C) 2002-2015 Free Software Foundation, Inc.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
......@@ -40,7 +40,7 @@
#ifndef YY_EVAL_PARSER_H_INCLUDED
# define YY_EVAL_PARSER_H_INCLUDED
// // "%code requires" blocks.
#line 17 "parser.yy" // lalr1.cc:379
#line 17 "parser.yy" // lalr1.cc:377
#include <string>
#include <eval/token.h>
......@@ -51,7 +51,7 @@
using namespace isc::dhcp;
using namespace isc::eval;
#line 55 "parser.h" // lalr1.cc:379
#line 55 "parser.h" // lalr1.cc:377
# include <cassert>
# include <cstdlib> // std::abort
......@@ -134,9 +134,9 @@ using namespace isc::eval;
# endif /* ! defined YYDEBUG */
#endif /* ! defined EVALDEBUG */
#line 14 "parser.yy" // lalr1.cc:379
#line 14 "parser.yy" // lalr1.cc:377
namespace isc { namespace eval {
#line 140 "parser.h" // lalr1.cc:379
#line 140 "parser.h" // lalr1.cc:377
......@@ -914,8 +914,6 @@ namespace isc { namespace eval {
typedef basic_symbol<by_state> super_type;
/// Construct an empty symbol.
stack_symbol_type ();
/// Copy construct.
stack_symbol_type (const stack_symbol_type& that);
/// Steal the contents from \a sym to build this.
stack_symbol_type (state_type s, symbol_type& sym);
/// Assignment, needed by push_back.
......@@ -944,7 +942,7 @@ namespace isc { namespace eval {
void yypush_ (const char* m, state_type s, symbol_type& sym);
/// Pop \a n symbols the three stacks.
void yypop_ (unsigned n = 1);
void yypop_ (unsigned int n = 1);
/// Constants.
enum
......@@ -1004,12 +1002,12 @@ namespace isc { namespace eval {
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 52, 53, 54
};
const unsigned user_token_number_max_ = 309;
const unsigned int user_token_number_max_ = 309;
const token_number_type undef_token_ = 2;
if (static_cast<int> (t) <= yyeof_)
if (static_cast<int>(t) <= yyeof_)
return yyeof_;
else if (static_cast<unsigned> (t) <= user_token_number_max_)
else if (static_cast<unsigned int> (t) <= user_token_number_max_)
return translate_table[t];
else
return undef_token_;
......@@ -1023,17 +1021,19 @@ namespace isc { namespace eval {
// basic_symbol.
template <typename Base>
inline
EvalParser::basic_symbol<Base>::basic_symbol ()
: value ()
{}
template <typename Base>
inline
EvalParser::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
: Base (other)
, value ()
, location (other.location)
{
switch (other.type_get ())
switch (other.type_get ())
{
case 62: // option_repr_type
value.copy< TokenOption::RepresentationType > (other.value);
......@@ -1082,14 +1082,16 @@ namespace isc { namespace eval {
}
template <typename Base>
inline
EvalParser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const semantic_type& v, const location_type& l)
: Base (t)
, value ()
, location (l)
{
(void) v;
switch (this->type_get ())
switch (this->type_get ())
{
case 62: // option_repr_type
value.copy< TokenOption::RepresentationType > (v);
......@@ -1212,12 +1214,14 @@ namespace isc { namespace eval {
template <typename Base>
inline
EvalParser::basic_symbol<Base>::~basic_symbol ()
{
clear ();
}
template <typename Base>
inline
void
EvalParser::basic_symbol<Base>::clear ()
{
......@@ -1232,7 +1236,7 @@ namespace isc { namespace eval {
}
// Type destructor.
switch (yytype)
switch (yytype)
{
case 62: // option_repr_type
value.template destroy< TokenOption::RepresentationType > ();
......@@ -1283,6 +1287,7 @@ namespace isc { namespace eval {
}
template <typename Base>
inline
bool
EvalParser::basic_symbol<Base>::empty () const
{
......@@ -1290,11 +1295,12 @@ namespace isc { namespace eval {
}
template <typename Base>
inline
void
EvalParser::basic_symbol<Base>::move (basic_symbol& s)
{
super_type::move (s);
switch (this->type_get ())
super_type::move(s);
switch (this->type_get ())
{
case 62: // option_repr_type
value.move< TokenOption::RepresentationType > (s.value);
......@@ -1721,9 +1727,9 @@ namespace isc { namespace eval {
}
#line 14 "parser.yy" // lalr1.cc:379
#line 14 "parser.yy" // lalr1.cc:377
} } // isc::eval
#line 1727 "parser.h" // lalr1.cc:379
#line 1733 "parser.h" // lalr1.cc:377
......
// Generated 201809161042
// A Bison parser, made by GNU Bison 3.0.5.
// A Bison parser, made by GNU Bison 3.0.4.
// Positions for Bison parsers in C++
// Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
// Copyright (C) 2002-2015 Free Software Foundation, Inc.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
......@@ -51,27 +50,28 @@
# endif
# endif
#line 14 "parser.yy" // location.cc:292
#line 14 "parser.yy" // location.cc:296
namespace isc { namespace eval {
#line 56 "position.hh" // location.cc:292
#line 56 "position.hh" // location.cc:296
/// Abstract a position.
class position
{
public:
/// Construct a position.
explicit position (std::string* f = YY_NULLPTR,
unsigned l = 1u,
unsigned c = 1u)
unsigned int l = 1u,
unsigned int c = 1u)
: filename (f)
, line (l)
, column (c)
{}
{
}
/// Initialization.
void initialize (std::string* fn = YY_NULLPTR,
unsigned l = 1u,
unsigned c = 1u)
unsigned int l = 1u,
unsigned int c = 1u)
{
filename = fn;
line = l;
......@@ -100,15 +100,15 @@ namespace isc { namespace eval {
/// File name to which this position refers.
std::string* filename;
/// Current line number.
unsigned line;
unsigned int line;
/// Current column number.
unsigned column;
unsigned int column;
private:
/// Compute max(min, lhs+rhs) (provided min <= lhs).
static unsigned add_ (unsigned lhs, int rhs, unsigned min)
static unsigned int add_ (unsigned int lhs, int rhs, unsigned int min)
{
return (0 < rhs || -static_cast<unsigned>(rhs) < lhs
return (0 < rhs || -static_cast<unsigned int>(rhs) < lhs
? rhs + lhs
: min);
}
......@@ -174,7 +174,7 @@ namespace isc { namespace eval {
return ostr << pos.line << '.' << pos.column;
}
#line 14 "parser.yy" // location.cc:292
#line 14 "parser.yy" // location.cc:296
} } // isc::eval
#line 179 "position.hh" // location.cc:292
#line 180 "position.hh" // location.cc:296
#endif // !YY_EVAL_POSITION_HH_INCLUDED
// Generated 201809161042
// A Bison parser, made by GNU Bison 3.0.5.
// A Bison parser, made by GNU Bison 3.0.4.
// Stack handling for Bison parsers in C++
// Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
// Copyright (C) 2002-2015 Free Software Foundation, Inc.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
......@@ -41,10 +40,9 @@
# include <vector>
#line 14 "parser.yy" // stack.hh:131
#line 14 "parser.yy" // stack.hh:132
namespace isc { namespace eval {
#line 46 "stack.hh" // stack.hh:131
/// A stack with random access from its top.
#line 46 "stack.hh" // stack.hh:132
template <class T, class S = std::vector<T> >
class stack
{
......@@ -59,24 +57,20 @@ namespace isc { namespace eval {
seq_.reserve (200);
}
stack (unsigned n)
stack (unsigned int n)
: seq_ (n)
{}
/// Random access.
///
/// Index 0 returns the topmost element.
inline
T&
operator[] (unsigned i)
operator[] (unsigned int i)
{
return seq_[seq_.size () - 1 - i];
}
/// Random access.
///
/// Index 0 returns the topmost element.
inline
const T&
operator[] (unsigned i) const
operator[] (unsigned int i) const
{
return seq_[seq_.size () - 1 - i];
}
......@@ -84,6 +78,7 @@ namespace isc { namespace eval {
/// Steal the contents of \a t.
///
/// Close to move-semantics.
inline
void
push (T& t)
{
......@@ -91,8 +86,9 @@ namespace isc { namespace eval {
operator[](0).move (t);
}
inline
void
pop (unsigned n = 1)
pop (unsigned int n = 1)
{
for (; n; --n)
seq_.pop_back ();
......@@ -104,18 +100,21 @@ namespace isc { namespace eval {
seq_.clear ();
}
inline
typename S::size_type
size () const
{
return seq_.size ();
}
inline
const_iterator
begin () const
{
return seq_.rbegin ();
}
inline
const_iterator
end () const
{
......@@ -134,24 +133,25 @@ namespace isc { namespace eval {
class slice
{
public:
slice (const S& stack, unsigned range)
slice (const S& stack, unsigned int range)
: stack_ (stack)
, range_ (range)
{}
inline
const T&
operator [] (unsigned i) const
operator [] (unsigned int i) const
{
return stack_[range_ - i];
}
private:
const S& stack_;
unsigned range_;
unsigned int range_;
};
#line 14 "parser.yy" // stack.hh:131
#line 14 "parser.yy" // stack.hh:132
} } // isc::eval
#line 155 "stack.hh" // stack.hh:131
#line 156 "stack.hh" // stack.hh:132
#endif // !YY_EVAL_STACK_HH_INCLUDED
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment