From f426d3313534be2a714a958d475d456edc4c6323 Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Sat, 7 Jan 2017 06:29:27 +0100 Subject: [PATCH] [5035] Did flex/bison side --- src/bin/dhcp4/dhcp4_lexer.ll | 56 ++++++++++++++++++++++++++++++++- src/bin/dhcp4/dhcp4_parser.yy | 50 ++++++++++++++++++++++++----- src/bin/dhcp4/parser_context.cc | 2 ++ src/bin/dhcp4/parser_context.h | 5 ++- src/bin/dhcp6/dhcp6_lexer.ll | 56 ++++++++++++++++++++++++++++++++- src/bin/dhcp6/dhcp6_parser.yy | 50 ++++++++++++++++++++++++----- src/bin/dhcp6/parser_context.cc | 2 ++ src/bin/dhcp6/parser_context.h | 5 ++- 8 files changed, 208 insertions(+), 18 deletions(-) diff --git a/src/bin/dhcp4/dhcp4_lexer.ll b/src/bin/dhcp4/dhcp4_lexer.ll index 0063c5ddb5..4ea88bfbdc 100644 --- a/src/bin/dhcp4/dhcp4_lexer.ll +++ b/src/bin/dhcp4/dhcp4_lexer.ll @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC") +/* Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC") This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this @@ -770,6 +770,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: diff --git a/src/bin/dhcp4/dhcp4_parser.yy b/src/bin/dhcp4/dhcp4_parser.yy index 579adb158f..f0a0128b02 100644 --- a/src/bin/dhcp4/dhcp4_parser.yy +++ b/src/bin/dhcp4/dhcp4_parser.yy @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC") +/* Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC") This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this @@ -120,6 +120,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" @@ -644,7 +650,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(); @@ -654,12 +660,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 ------------------------------------------ diff --git a/src/bin/dhcp4/parser_context.cc b/src/bin/dhcp4/parser_context.cc index ef168e4fbc..58fdf6e554 100644 --- a/src/bin/dhcp4/parser_context.cc +++ b/src/bin/dhcp4/parser_context.cc @@ -143,6 +143,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: diff --git a/src/bin/dhcp4/parser_context.h b/src/bin/dhcp4/parser_context.h index 5f37dda521..8480ce80d4 100644 --- a/src/bin/dhcp4/parser_context.h +++ b/src/bin/dhcp4/parser_context.h @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2016 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -219,6 +219,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, diff --git a/src/bin/dhcp6/dhcp6_lexer.ll b/src/bin/dhcp6/dhcp6_lexer.ll index 47235057da..667182e599 100644 --- a/src/bin/dhcp6/dhcp6_lexer.ll +++ b/src/bin/dhcp6/dhcp6_lexer.ll @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC") +/* Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC") This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this @@ -844,6 +844,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_); + } +} + +\"flush-reclaimed-timer-wait-time\" { + switch(driver.ctx_) { + case isc::dhcp::Parser6Context::EXPIRED_LEASES_PROCESSING: + return isc::dhcp::Dhcp6Parser::make_FLUSH_RECLAIMED_TIMER_WAIT_TIME(driver.loc_); + default: + return isc::dhcp::Dhcp6Parser::make_STRING("flush-reclaimed-timer-wait-time", driver.loc_); + } +} + +\"hold-reclaimed-time\" { + switch(driver.ctx_) { + case isc::dhcp::Parser6Context::EXPIRED_LEASES_PROCESSING: + return isc::dhcp::Dhcp6Parser::make_HOLD_RECLAIMED_TIME(driver.loc_); + default: + return isc::dhcp::Dhcp6Parser::make_STRING("hold-reclaimed-time", driver.loc_); + } +} + +\"max-reclaim-leases\" { + switch(driver.ctx_) { + case isc::dhcp::Parser6Context::EXPIRED_LEASES_PROCESSING: + return isc::dhcp::Dhcp6Parser::make_MAX_RECLAIM_LEASES(driver.loc_); + default: + return isc::dhcp::Dhcp6Parser::make_STRING("max-reclaim-leases", driver.loc_); + } +} + +\"max-reclaim-time\" { + switch(driver.ctx_) { + case isc::dhcp::Parser6Context::EXPIRED_LEASES_PROCESSING: + return isc::dhcp::Dhcp6Parser::make_MAX_RECLAIM_TIME(driver.loc_); + default: + return isc::dhcp::Dhcp6Parser::make_STRING("max-reclaim-time", driver.loc_); + } +} + +\"unwarned-reclaim-cycles\" { + switch(driver.ctx_) { + case isc::dhcp::Parser6Context::EXPIRED_LEASES_PROCESSING: + return isc::dhcp::Dhcp6Parser::make_UNWARNED_RECLAIM_CYCLES(driver.loc_); + default: + return isc::dhcp::Dhcp6Parser::make_STRING("unwarned-reclaim-cycles", driver.loc_); + } +} + \"dhcp4o6-port\" { switch(driver.ctx_) { case isc::dhcp::Parser6Context::DHCP6: diff --git a/src/bin/dhcp6/dhcp6_parser.yy b/src/bin/dhcp6/dhcp6_parser.yy index d3a460ace7..ab975a7b68 100644 --- a/src/bin/dhcp6/dhcp6_parser.yy +++ b/src/bin/dhcp6/dhcp6_parser.yy @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC") +/* Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC") This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this @@ -119,6 +119,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" @@ -644,7 +650,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(); @@ -654,12 +660,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); }; // --- subnet6 ------------------------------------------ diff --git a/src/bin/dhcp6/parser_context.cc b/src/bin/dhcp6/parser_context.cc index b0d4e54f77..68b9c34faf 100644 --- a/src/bin/dhcp6/parser_context.cc +++ b/src/bin/dhcp6/parser_context.cc @@ -145,6 +145,8 @@ Parser6Context::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: diff --git a/src/bin/dhcp6/parser_context.h b/src/bin/dhcp6/parser_context.h index 077bb6e639..1a394d3c44 100644 --- a/src/bin/dhcp6/parser_context.h +++ b/src/bin/dhcp6/parser_context.h @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2016 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -225,6 +225,9 @@ public: /// Used while parsing Dhcp6/client-classes structures. CLIENT_CLASSES, + /// Used while parsing Dhcp6/expired-leases-processing. + EXPIRED_LEASES_PROCESSING, + /// Used while parsing Dhcp6/server-id structures. SERVER_ID, -- 2.47.3