Commit 7be6514d authored by Francis Dupont's avatar Francis Dupont
Browse files

[master] Finished merge of trac5035 (migrate lease expiration config)

parents 4c3d035d 3f07550f
This diff is collapsed.
......@@ -788,6 +788,60 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"reclaim-timer-wait-time\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::EXPIRED_LEASES_PROCESSING:
return isc::dhcp::Dhcp4Parser::make_RECLAIM_TIMER_WAIT_TIME(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("reclaim-timer-wait-time", driver.loc_);
}
}
\"flush-reclaimed-timer-wait-time\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::EXPIRED_LEASES_PROCESSING:
return isc::dhcp::Dhcp4Parser::make_FLUSH_RECLAIMED_TIMER_WAIT_TIME(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("flush-reclaimed-timer-wait-time", driver.loc_);
}
}
\"hold-reclaimed-time\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::EXPIRED_LEASES_PROCESSING:
return isc::dhcp::Dhcp4Parser::make_HOLD_RECLAIMED_TIME(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("hold-reclaimed-time", driver.loc_);
}
}
\"max-reclaim-leases\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::EXPIRED_LEASES_PROCESSING:
return isc::dhcp::Dhcp4Parser::make_MAX_RECLAIM_LEASES(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("max-reclaim-leases", driver.loc_);
}
}
\"max-reclaim-time\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::EXPIRED_LEASES_PROCESSING:
return isc::dhcp::Dhcp4Parser::make_MAX_RECLAIM_TIME(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("max-reclaim-time", driver.loc_);
}
}
\"unwarned-reclaim-cycles\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::EXPIRED_LEASES_PROCESSING:
return isc::dhcp::Dhcp4Parser::make_UNWARNED_RECLAIM_CYCLES(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("unwarned-reclaim-cycles", driver.loc_);
}
}
\"dhcp4o6-port\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP4:
......
This diff is collapsed.
......@@ -40,7 +40,7 @@
#ifndef YY_PARSER4_DHCP4_PARSER_H_INCLUDED
# define YY_PARSER4_DHCP4_PARSER_H_INCLUDED
// // "%code requires" blocks.
#line 17 "dhcp4_parser.yy" // lalr1.cc:377
#line 17 "dhcp4_parser.yy" // lalr1.cc:392
#include <string>
#include <cc/data.h>
......@@ -52,7 +52,7 @@ using namespace isc::dhcp;
using namespace isc::data;
using namespace std;
#line 56 "dhcp4_parser.h" // lalr1.cc:377
#line 56 "dhcp4_parser.h" // lalr1.cc:392
# include <cassert>
# include <cstdlib> // std::abort
......@@ -135,9 +135,9 @@ using namespace std;
# endif /* ! defined YYDEBUG */
#endif /* ! defined PARSER4_DEBUG */
#line 14 "dhcp4_parser.yy" // lalr1.cc:377
#line 14 "dhcp4_parser.yy" // lalr1.cc:392
namespace isc { namespace dhcp {
#line 141 "dhcp4_parser.h" // lalr1.cc:377
#line 141 "dhcp4_parser.h" // lalr1.cc:392
......@@ -411,38 +411,44 @@ namespace isc { namespace dhcp {
TOKEN_LIBRARY = 324,
TOKEN_PARAMETERS = 325,
TOKEN_EXPIRED_LEASES_PROCESSING = 326,
TOKEN_SERVER_ID = 327,
TOKEN_IDENTIFIER = 328,
TOKEN_HTYPE = 329,
TOKEN_TIME = 330,
TOKEN_ENTERPRISE_ID = 331,
TOKEN_DHCP4O6_PORT = 332,
TOKEN_CONTROL_SOCKET = 333,
TOKEN_SOCKET_TYPE = 334,
TOKEN_SOCKET_NAME = 335,
TOKEN_DHCP_DDNS = 336,
TOKEN_LOGGING = 337,
TOKEN_LOGGERS = 338,
TOKEN_OUTPUT_OPTIONS = 339,
TOKEN_OUTPUT = 340,
TOKEN_DEBUGLEVEL = 341,
TOKEN_SEVERITY = 342,
TOKEN_DHCP6 = 343,
TOKEN_DHCPDDNS = 344,
TOKEN_TOPLEVEL_JSON = 345,
TOKEN_TOPLEVEL_DHCP4 = 346,
TOKEN_SUB_DHCP4 = 347,
TOKEN_SUB_INTERFACES4 = 348,
TOKEN_SUB_SUBNET4 = 349,
TOKEN_SUB_POOL4 = 350,
TOKEN_SUB_RESERVATION = 351,
TOKEN_SUB_OPTION_DEF = 352,
TOKEN_SUB_OPTION_DATA = 353,
TOKEN_SUB_HOOKS_LIBRARY = 354,
TOKEN_STRING = 355,
TOKEN_INTEGER = 356,
TOKEN_FLOAT = 357,
TOKEN_BOOLEAN = 358
TOKEN_RECLAIM_TIMER_WAIT_TIME = 327,
TOKEN_FLUSH_RECLAIMED_TIMER_WAIT_TIME = 328,
TOKEN_HOLD_RECLAIMED_TIME = 329,
TOKEN_MAX_RECLAIM_LEASES = 330,
TOKEN_MAX_RECLAIM_TIME = 331,
TOKEN_UNWARNED_RECLAIM_CYCLES = 332,
TOKEN_SERVER_ID = 333,
TOKEN_IDENTIFIER = 334,
TOKEN_HTYPE = 335,
TOKEN_TIME = 336,
TOKEN_ENTERPRISE_ID = 337,
TOKEN_DHCP4O6_PORT = 338,
TOKEN_CONTROL_SOCKET = 339,
TOKEN_SOCKET_TYPE = 340,
TOKEN_SOCKET_NAME = 341,
TOKEN_DHCP_DDNS = 342,
TOKEN_LOGGING = 343,
TOKEN_LOGGERS = 344,
TOKEN_OUTPUT_OPTIONS = 345,
TOKEN_OUTPUT = 346,
TOKEN_DEBUGLEVEL = 347,
TOKEN_SEVERITY = 348,
TOKEN_DHCP6 = 349,
TOKEN_DHCPDDNS = 350,
TOKEN_TOPLEVEL_JSON = 351,
TOKEN_TOPLEVEL_DHCP4 = 352,
TOKEN_SUB_DHCP4 = 353,
TOKEN_SUB_INTERFACES4 = 354,
TOKEN_SUB_SUBNET4 = 355,
TOKEN_SUB_POOL4 = 356,
TOKEN_SUB_RESERVATION = 357,
TOKEN_SUB_OPTION_DEF = 358,
TOKEN_SUB_OPTION_DATA = 359,
TOKEN_SUB_HOOKS_LIBRARY = 360,
TOKEN_STRING = 361,
TOKEN_INTEGER = 362,
TOKEN_FLOAT = 363,
TOKEN_BOOLEAN = 364
};
};
......@@ -837,6 +843,30 @@ namespace isc { namespace dhcp {
symbol_type
make_EXPIRED_LEASES_PROCESSING (const location_type& l);
static inline
symbol_type
make_RECLAIM_TIMER_WAIT_TIME (const location_type& l);
static inline
symbol_type
make_FLUSH_RECLAIMED_TIMER_WAIT_TIME (const location_type& l);
static inline
symbol_type
make_HOLD_RECLAIMED_TIME (const location_type& l);
static inline
symbol_type
make_MAX_RECLAIM_LEASES (const location_type& l);
static inline
symbol_type
make_MAX_RECLAIM_TIME (const location_type& l);
static inline
symbol_type
make_UNWARNED_RECLAIM_CYCLES (const location_type& l);
static inline
symbol_type
make_SERVER_ID (const location_type& l);
......@@ -1170,12 +1200,12 @@ namespace isc { namespace dhcp {
enum
{
yyeof_ = 0,
yylast_ = 626, ///< Last index in yytable_.
yynnts_ = 268, ///< Number of nonterminal symbols.
yylast_ = 647, ///< Last index in yytable_.
yynnts_ = 274, ///< Number of nonterminal symbols.
yyfinal_ = 22, ///< Termination state number.
yyterror_ = 1,
yyerrcode_ = 256,
yyntokens_ = 104 ///< Number of tokens.
yyntokens_ = 110 ///< Number of tokens.
};
......@@ -1227,9 +1257,10 @@ namespace isc { namespace dhcp {
65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
95, 96, 97, 98, 99, 100, 101, 102, 103
95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109
};
const unsigned int user_token_number_max_ = 358;
const unsigned int user_token_number_max_ = 364;
const token_number_type undef_token_ = 2;
if (static_cast<int>(t) <= yyeof_)
......@@ -1262,24 +1293,24 @@ namespace isc { namespace dhcp {
{
switch (other.type_get ())
{
case 116: // value
case 155: // socket_type
case 122: // value
case 161: // socket_type
value.copy< ElementPtr > (other.value);
break;
case 103: // "boolean"
case 109: // "boolean"
value.copy< bool > (other.value);
break;
case 102: // "floating point"
case 108: // "floating point"
value.copy< double > (other.value);
break;
case 101: // "integer"
case 107: // "integer"
value.copy< int64_t > (other.value);
break;
case 100: // "constant string"
case 106: // "constant string"
value.copy< std::string > (other.value);
break;
......@@ -1300,24 +1331,24 @@ namespace isc { namespace dhcp {
(void) v;
switch (this->type_get ())
{
case 116: // value
case 155: // socket_type
case 122: // value
case 161: // socket_type
value.copy< ElementPtr > (v);
break;
case 103: // "boolean"
case 109: // "boolean"
value.copy< bool > (v);
break;
case 102: // "floating point"
case 108: // "floating point"
value.copy< double > (v);
break;
case 101: // "integer"
case 107: // "integer"
value.copy< int64_t > (v);
break;
case 100: // "constant string"
case 106: // "constant string"
value.copy< std::string > (v);
break;
......@@ -1397,24 +1428,24 @@ namespace isc { namespace dhcp {
// Type destructor.
switch (yytype)
{
case 116: // value
case 155: // socket_type
case 122: // value
case 161: // socket_type
value.template destroy< ElementPtr > ();
break;
case 103: // "boolean"
case 109: // "boolean"
value.template destroy< bool > ();
break;
case 102: // "floating point"
case 108: // "floating point"
value.template destroy< double > ();
break;
case 101: // "integer"
case 107: // "integer"
value.template destroy< int64_t > ();
break;
case 100: // "constant string"
case 106: // "constant string"
value.template destroy< std::string > ();
break;
......@@ -1441,24 +1472,24 @@ namespace isc { namespace dhcp {
super_type::move(s);
switch (this->type_get ())
{
case 116: // value
case 155: // socket_type
case 122: // value
case 161: // socket_type
value.move< ElementPtr > (s.value);
break;
case 103: // "boolean"
case 109: // "boolean"
value.move< bool > (s.value);
break;
case 102: // "floating point"
case 108: // "floating point"
value.move< double > (s.value);
break;
case 101: // "integer"
case 107: // "integer"
value.move< int64_t > (s.value);
break;
case 100: // "constant string"
case 106: // "constant string"
value.move< std::string > (s.value);
break;
......@@ -1527,7 +1558,7 @@ namespace isc { namespace dhcp {
325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
355, 356, 357, 358
355, 356, 357, 358, 359, 360, 361, 362, 363, 364
};
return static_cast<token_type> (yytoken_number_[type]);
}
......@@ -1952,6 +1983,42 @@ namespace isc { namespace dhcp {
return symbol_type (token::TOKEN_EXPIRED_LEASES_PROCESSING, l);
}
Dhcp4Parser::symbol_type
Dhcp4Parser::make_RECLAIM_TIMER_WAIT_TIME (const location_type& l)
{
return symbol_type (token::TOKEN_RECLAIM_TIMER_WAIT_TIME, l);
}
Dhcp4Parser::symbol_type
Dhcp4Parser::make_FLUSH_RECLAIMED_TIMER_WAIT_TIME (const location_type& l)
{
return symbol_type (token::TOKEN_FLUSH_RECLAIMED_TIMER_WAIT_TIME, l);
}
Dhcp4Parser::symbol_type
Dhcp4Parser::make_HOLD_RECLAIMED_TIME (const location_type& l)
{
return symbol_type (token::TOKEN_HOLD_RECLAIMED_TIME, l);
}
Dhcp4Parser::symbol_type
Dhcp4Parser::make_MAX_RECLAIM_LEASES (const location_type& l)
{
return symbol_type (token::TOKEN_MAX_RECLAIM_LEASES, l);
}
Dhcp4Parser::symbol_type
Dhcp4Parser::make_MAX_RECLAIM_TIME (const location_type& l)
{
return symbol_type (token::TOKEN_MAX_RECLAIM_TIME, l);
}
Dhcp4Parser::symbol_type
Dhcp4Parser::make_UNWARNED_RECLAIM_CYCLES (const location_type& l)
{
return symbol_type (token::TOKEN_UNWARNED_RECLAIM_CYCLES, l);
}
Dhcp4Parser::symbol_type
Dhcp4Parser::make_SERVER_ID (const location_type& l)
{
......@@ -2145,9 +2212,9 @@ namespace isc { namespace dhcp {
}
#line 14 "dhcp4_parser.yy" // lalr1.cc:377
#line 14 "dhcp4_parser.yy" // lalr1.cc:392
} } // isc::dhcp
#line 2151 "dhcp4_parser.h" // lalr1.cc:377
#line 2218 "dhcp4_parser.h" // lalr1.cc:392
......
......@@ -122,6 +122,12 @@ using namespace std;
PARAMETERS "parameters"
EXPIRED_LEASES_PROCESSING "expired-leases-processing"
RECLAIM_TIMER_WAIT_TIME "reclaim-timer-wait-time"
FLUSH_RECLAIMED_TIMER_WAIT_TIME "flush-reclaimed-timer-wait-time"
HOLD_RECLAIMED_TIME "hold-reclaimed-time"
MAX_RECLAIM_LEASES "max-reclaim-leases"
MAX_RECLAIM_TIME "max-reclaim-time"
UNWARNED_RECLAIM_CYCLES "unwarned-reclaim-cycles"
SERVER_ID "server-id"
IDENTIFIER "identifier"
......@@ -650,7 +656,7 @@ expired_leases_processing: EXPIRED_LEASES_PROCESSING {
ElementPtr m(new MapElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("expired-leases-processing", m);
ctx.stack_.push_back(m);
ctx.enter(ctx.NO_KEYWORD);
ctx.enter(ctx.EXPIRED_LEASES_PROCESSING);
} COLON LCURLY_BRACKET expired_leases_params RCURLY_BRACKET {
ctx.stack_.pop_back();
ctx.leave();
......@@ -660,12 +666,42 @@ expired_leases_params: expired_leases_param
| expired_leases_params COMMA expired_leases_param
;
// This is a bit of a simplification. But it can also serve as an example.
// Instead of explicitly listing all allowed expired leases parameters, we
// simply say that all of them as integers.
expired_leases_param: STRING COLON INTEGER {
expired_leases_param: reclaim_timer_wait_time
| flush_reclaimed_timer_wait_time
| hold_reclaimed_time
| max_reclaim_leases
| max_reclaim_time
| unwarned_reclaim_cycles
;
reclaim_timer_wait_time: RECLAIM_TIMER_WAIT_TIME COLON INTEGER {
ElementPtr value(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("reclaim-timer-wait-time", value);
};
flush_reclaimed_timer_wait_time: FLUSH_RECLAIMED_TIMER_WAIT_TIME COLON INTEGER {
ElementPtr value(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("flush-reclaimed-timer-wait-time", value);
};
hold_reclaimed_time: HOLD_RECLAIMED_TIME COLON INTEGER {
ElementPtr value(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("hold-reclaimed-time", value);
};
max_reclaim_leases: MAX_RECLAIM_LEASES COLON INTEGER {
ElementPtr value(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("max-reclaim-leases", value);
};
max_reclaim_time: MAX_RECLAIM_TIME COLON INTEGER {
ElementPtr value(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("max-reclaim-time", value);
};
unwarned_reclaim_cycles: UNWARNED_RECLAIM_CYCLES COLON INTEGER {
ElementPtr value(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set($1, value);
ctx.stack_.back()->set("unwarned-reclaim-cycles", value);
};
// --- subnet4 ------------------------------------------
......
......@@ -438,8 +438,7 @@ DhcpConfigParser* createGlobalDhcp4ConfigParser(const std::string& config_id,
} else if (config_id.compare("match-client-id") == 0) {
parser = new BooleanParser(config_id, globalContext()->boolean_values_);
// control-socket has been converted to SimpleParser already.
} else if (config_id.compare("expired-leases-processing") == 0) {
parser = new ExpirationConfigParser();
// expired-leases-processing has been converted to SimpleParser already.
} else if (config_id.compare("client-classes") == 0) {
parser = new ClientClassDefListParser(config_id, globalContext());
// host-reservation-identifiers have been converted to SimpleParser already.
......@@ -656,6 +655,12 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
continue;
}
if (config_pair.first == "expired-leases-processing") {
ExpirationConfigParser parser;
parser.parse(config_pair.second);
continue;
}
// Legacy DhcpConfigParser stuff below
ParserPtr parser(createGlobalDhcp4ConfigParser(config_pair.first,
config_pair.second));
......
// Generated 201701062338
// A Bison parser, made by GNU Bison 3.0.4.
// Locations for Bison parsers in C++
......@@ -41,9 +40,9 @@
# include "position.hh"
#line 14 "dhcp4_parser.yy" // location.cc:296
#line 14 "dhcp4_parser.yy" // location.cc:337
namespace isc { namespace dhcp {
#line 46 "location.hh" // location.cc:296
#line 46 "location.hh" // location.cc:337
/// Abstract a location.
class location
{
......@@ -187,7 +186,7 @@ namespace isc { namespace dhcp {
return ostr;
}
#line 14 "dhcp4_parser.yy" // location.cc:296
#line 14 "dhcp4_parser.yy" // location.cc:337
} } // isc::dhcp
#line 192 "location.hh" // location.cc:296
#line 192 "location.hh" // location.cc:337
#endif // !YY_PARSER4_LOCATION_HH_INCLUDED
......@@ -145,6 +145,8 @@ Parser4Context::contextName()
return ("option-data");
case CLIENT_CLASSES:
return ("client-classes");
case EXPIRED_LEASES_PROCESSING:
return ("expired-leases-processing");
case SERVER_ID:
return ("server-id");
case CONTROL_SOCKET:
......
......@@ -222,6 +222,9 @@ public:
/// Used while parsing Dhcp4/client-classes structures.
CLIENT_CLASSES,
/// Used while parsing Dhcp4/expired-leases-processing.
EXPIRED_LEASES_PROCESSING,
/// Used while parsing Dhcp4/server-id structures.
SERVER_ID,
......
// Generated 201701062338
// A Bison parser, made by GNU Bison 3.0.4.
// Positions for Bison parsers in C++
......@@ -51,9 +50,9 @@
# endif
# endif
#line 14 "dhcp4_parser.yy" // location.cc:296
#line 14 "dhcp4_parser.yy" // location.cc:337
namespace isc { namespace dhcp {
#line 56 "position.hh" // location.cc:296
#line 56 "position.hh" // location.cc:337
/// Abstract a position.
class position
{
......@@ -175,7 +174,7 @@ namespace isc { namespace dhcp {
return ostr << pos.line << '.' << pos.column;
}
#line 14 "dhcp4_parser.yy" // location.cc:296
#line 14 "dhcp4_parser.yy" // location.cc:337
} } // isc::dhcp
#line 180 "position.hh" // location.cc:296
#line 180 "position.hh" // location.cc:337
#endif // !YY_PARSER4_POSITION_HH_INCLUDED
// Generated 201701062338
// A Bison parser, made by GNU Bison 3.0.4.
// Stack handling for Bison parsers in C++
......@@ -41,9 +40,9 @@
# include <vector>
#line 14 "dhcp4_parser.yy" // stack.hh:132
#line 14 "dhcp4_parser.yy" // stack.hh:151
namespace isc { namespace dhcp {
#line 46 "stack.hh" // stack.hh:132
#line 46 "stack.hh" // stack.hh:151
template <class T, class S = std::vector<T> >
class stack
{
......@@ -151,8 +150,8 @@ namespace isc { namespace dhcp {
unsigned int range_;
};
#line 14 "dhcp4_parser.yy" // stack.hh:132
#line 14 "dhcp4_parser.yy" // stack.hh:151
} } // isc::dhcp
#line 156 "stack.hh" // stack.hh:132
#line 156 "stack.hh" // stack.hh:151
#endif // !YY_PARSER4_STACK_HH_INCLUDED
This diff is collapsed.
......@@ -871,6 +871,60 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"reclaim-timer-wait-time\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::EXPIRED_LEASES_PROCESSING:
return isc::dhcp::Dhcp6Parser::make_RECLAIM_TIMER_WAIT_TIME(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("reclaim-timer-wait-time", driver.loc_);
}