12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814 |
- /* 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
- file, You can obtain one at http://mozilla.org/MPL/2.0/. */
- %skeleton "lalr1.cc" /* -*- C++ -*- */
- %require "3.0.0"
- %defines
- %define parser_class_name {Dhcp4Parser}
- %define api.prefix {parser4_}
- %define api.token.constructor
- %define api.value.type variant
- %define api.namespace {isc::dhcp}
- %define parse.assert
- %code requires
- {
- #include <string>
- #include <cc/data.h>
- #include <dhcp/option.h>
- #include <boost/lexical_cast.hpp>
- #include <dhcp4/parser_context_decl.h>
- using namespace isc::dhcp;
- using namespace isc::data;
- using namespace std;
- }
- // The parsing context.
- %param { isc::dhcp::Parser4Context& ctx }
- %locations
- %define parse.trace
- %define parse.error verbose
- %code
- {
- #include <dhcp4/parser_context.h>
- }
- %define api.token.prefix {TOKEN_}
- // Tokens in an order which makes sense and related to the intented use.
- // Actual regexps for tokens are defined in dhcp4_lexer.ll.
- %token
- END 0 "end of file"
- COMMA ","
- COLON ":"
- LSQUARE_BRACKET "["
- RSQUARE_BRACKET "]"
- LCURLY_BRACKET "{"
- RCURLY_BRACKET "}"
- NULL_TYPE "null"
- DHCP4 "Dhcp4"
- INTERFACES_CONFIG "interfaces-config"
- INTERFACES "interfaces"
- DHCP_SOCKET_TYPE "dhcp-socket-type"
- RAW "raw"
- UDP "udp"
- RE_DETECT "re-detect"
- ECHO_CLIENT_ID "echo-client-id"
- MATCH_CLIENT_ID "match-client-id"
- NEXT_SERVER "next-server"
- SERVER_HOSTNAME "server-hostname"
- BOOT_FILE_NAME "boot-file-name"
- LEASE_DATABASE "lease-database"
- HOSTS_DATABASE "hosts-database"
- TYPE "type"
- MEMFILE "memfile"
- MYSQL "mysql"
- POSTGRESQL "postgresql"
- CQL "cql"
- USER "user"
- PASSWORD "password"
- HOST "host"
- PORT "port"
- PERSIST "persist"
- LFC_INTERVAL "lfc-interval"
- READONLY "readonly"
- CONNECT_TIMEOUT "connect-timeout"
- CONTACT_POINTS "contact-points"
- KEYSPACE "keyspace"
- VALID_LIFETIME "valid-lifetime"
- RENEW_TIMER "renew-timer"
- REBIND_TIMER "rebind-timer"
- DECLINE_PROBATION_PERIOD "decline-probation-period"
- SUBNET4 "subnet4"
- SUBNET_4O6_INTERFACE "4o6-interface"
- SUBNET_4O6_INTERFACE_ID "4o6-interface-id"
- SUBNET_4O6_SUBNET "4o6-subnet"
- OPTION_DEF "option-def"
- OPTION_DATA "option-data"
- NAME "name"
- DATA "data"
- CODE "code"
- SPACE "space"
- CSV_FORMAT "csv-format"
- ALWAYS_SEND "always-send"
- RECORD_TYPES "record-types"
- ENCAPSULATE "encapsulate"
- ARRAY "array"
- POOLS "pools"
- POOL "pool"
- USER_CONTEXT "user-context"
- SUBNET "subnet"
- INTERFACE "interface"
- INTERFACE_ID "interface-id"
- ID "id"
- RAPID_COMMIT "rapid-commit"
- RESERVATION_MODE "reservation-mode"
- DISABLED "disabled"
- OUT_OF_POOL "out-of-pool"
- ALL "all"
- HOST_RESERVATION_IDENTIFIERS "host-reservation-identifiers"
- CLIENT_CLASSES "client-classes"
- TEST "test"
- CLIENT_CLASS "client-class"
- RESERVATIONS "reservations"
- DUID "duid"
- HW_ADDRESS "hw-address"
- CIRCUIT_ID "circuit-id"
- CLIENT_ID "client-id"
- HOSTNAME "hostname"
- FLEX_ID "flex-id"
- RELAY "relay"
- IP_ADDRESS "ip-address"
- HOOKS_LIBRARIES "hooks-libraries"
- LIBRARY "library"
- 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"
- DHCP4O6_PORT "dhcp4o6-port"
- CONTROL_SOCKET "control-socket"
- SOCKET_TYPE "socket-type"
- SOCKET_NAME "socket-name"
- DHCP_DDNS "dhcp-ddns"
- ENABLE_UPDATES "enable-updates"
- QUALIFYING_SUFFIX "qualifying-suffix"
- SERVER_IP "server-ip"
- SERVER_PORT "server-port"
- SENDER_IP "sender-ip"
- SENDER_PORT "sender-port"
- MAX_QUEUE_SIZE "max-queue-size"
- NCR_PROTOCOL "ncr-protocol"
- NCR_FORMAT "ncr-format"
- ALWAYS_INCLUDE_FQDN "always-include-fqdn"
- OVERRIDE_NO_UPDATE "override-no-update"
- OVERRIDE_CLIENT_UPDATE "override-client-update"
- REPLACE_CLIENT_NAME "replace-client-name"
- GENERATED_PREFIX "generated-prefix"
- TCP "tcp"
- JSON "JSON"
- WHEN_PRESENT "when-present"
- NEVER "never"
- ALWAYS "always"
- WHEN_NOT_PRESENT "when-not-present"
- LOGGING "Logging"
- LOGGERS "loggers"
- OUTPUT_OPTIONS "output_options"
- OUTPUT "output"
- DEBUGLEVEL "debuglevel"
- SEVERITY "severity"
- FLUSH "flush"
- MAXSIZE "maxsize"
- MAXVER "maxver"
- DHCP6 "Dhcp6"
- DHCPDDNS "DhcpDdns"
- CONTROL_AGENT "Control-agent"
- // Not real tokens, just a way to signal what the parser is expected to
- // parse.
- TOPLEVEL_JSON
- TOPLEVEL_DHCP4
- SUB_DHCP4
- SUB_INTERFACES4
- SUB_SUBNET4
- SUB_POOL4
- SUB_RESERVATION
- SUB_OPTION_DEF
- SUB_OPTION_DATA
- SUB_HOOKS_LIBRARY
- SUB_DHCP_DDNS
- ;
- %token <std::string> STRING "constant string"
- %token <int64_t> INTEGER "integer"
- %token <double> FLOAT "floating point"
- %token <bool> BOOLEAN "boolean"
- %type <ElementPtr> value
- %type <ElementPtr> map_value
- %type <ElementPtr> socket_type
- %type <ElementPtr> db_type
- %type <ElementPtr> hr_mode
- %type <ElementPtr> ncr_protocol_value
- %type <ElementPtr> replace_client_name_value
- %printer { yyoutput << $$; } <*>;
- %%
- // The whole grammar starts with a map, because the config file
- // consists of Dhcp, Logger and DhcpDdns entries in one big { }.
- // We made the same for subparsers at the exception of the JSON value.
- %start start;
- start: TOPLEVEL_JSON { ctx.ctx_ = ctx.NO_KEYWORD; } sub_json
- | TOPLEVEL_DHCP4 { ctx.ctx_ = ctx.CONFIG; } syntax_map
- | SUB_DHCP4 { ctx.ctx_ = ctx.DHCP4; } sub_dhcp4
- | SUB_INTERFACES4 { ctx.ctx_ = ctx.INTERFACES_CONFIG; } sub_interfaces4
- | SUB_SUBNET4 { ctx.ctx_ = ctx.SUBNET4; } sub_subnet4
- | SUB_POOL4 { ctx.ctx_ = ctx.POOLS; } sub_pool4
- | SUB_RESERVATION { ctx.ctx_ = ctx.RESERVATIONS; } sub_reservation
- | SUB_OPTION_DEF { ctx.ctx_ = ctx.OPTION_DEF; } sub_option_def
- | SUB_OPTION_DATA { ctx.ctx_ = ctx.OPTION_DATA; } sub_option_data
- | SUB_HOOKS_LIBRARY { ctx.ctx_ = ctx.HOOKS_LIBRARIES; } sub_hooks_library
- | SUB_DHCP_DDNS { ctx.ctx_ = ctx.DHCP_DDNS; } sub_dhcp_ddns
- ;
- // ---- generic JSON parser ---------------------------------
- // Note that ctx_ is NO_KEYWORD here
- // Values rule
- value: INTEGER { $$ = ElementPtr(new IntElement($1, ctx.loc2pos(@1))); }
- | FLOAT { $$ = ElementPtr(new DoubleElement($1, ctx.loc2pos(@1))); }
- | BOOLEAN { $$ = ElementPtr(new BoolElement($1, ctx.loc2pos(@1))); }
- | STRING { $$ = ElementPtr(new StringElement($1, ctx.loc2pos(@1))); }
- | NULL_TYPE { $$ = ElementPtr(new NullElement(ctx.loc2pos(@1))); }
- | map2 { $$ = ctx.stack_.back(); ctx.stack_.pop_back(); }
- | list_generic { $$ = ctx.stack_.back(); ctx.stack_.pop_back(); }
- ;
- sub_json: value {
- // Push back the JSON value on the stack
- ctx.stack_.push_back($1);
- };
- map2: LCURLY_BRACKET {
- // This code is executed when we're about to start parsing
- // the content of the map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } map_content RCURLY_BRACKET {
- // map parsing completed. If we ever want to do any wrap up
- // (maybe some sanity checking), this would be the best place
- // for it.
- };
- map_value: map2 { $$ = ctx.stack_.back(); ctx.stack_.pop_back(); };
- // Assignments rule
- map_content: %empty // empty map
- | not_empty_map
- ;
- not_empty_map: STRING COLON value {
- // map containing a single entry
- ctx.stack_.back()->set($1, $3);
- }
- | not_empty_map COMMA STRING COLON value {
- // map consisting of a shorter map followed by
- // comma and string:value
- ctx.stack_.back()->set($3, $5);
- }
- ;
- list_generic: LSQUARE_BRACKET {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(l);
- } list_content RSQUARE_BRACKET {
- // list parsing complete. Put any sanity checking here
- };
- list_content: %empty // Empty list
- | not_empty_list
- ;
- not_empty_list: value {
- // List consisting of a single element.
- ctx.stack_.back()->add($1);
- }
- | not_empty_list COMMA value {
- // List ending with , and a value.
- ctx.stack_.back()->add($3);
- }
- ;
- // This one is used in syntax parser and is restricted to strings.
- list_strings: LSQUARE_BRACKET {
- // List parsing about to start
- } list_strings_content RSQUARE_BRACKET {
- // list parsing complete. Put any sanity checking here
- //ctx.stack_.pop_back();
- };
- list_strings_content: %empty // Empty list
- | not_empty_list_strings
- ;
- not_empty_list_strings: STRING {
- ElementPtr s(new StringElement($1, ctx.loc2pos(@1)));
- ctx.stack_.back()->add(s);
- }
- | not_empty_list_strings COMMA STRING {
- ElementPtr s(new StringElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->add(s);
- }
- ;
- // ---- generic JSON parser ends here ----------------------------------
- // ---- syntax checking parser starts here -----------------------------
- // Unknown keyword in a map
- unknown_map_entry: STRING COLON {
- const std::string& where = ctx.contextName();
- const std::string& keyword = $1;
- error(@1,
- "got unexpected keyword \"" + keyword + "\" in " + where + " map.");
- };
- // This defines the top-level { } that holds Control-agent, Dhcp6, Dhcp4,
- // DhcpDdns or Logging objects.
- syntax_map: LCURLY_BRACKET {
- // This code is executed when we're about to start parsing
- // the content of the map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } global_objects RCURLY_BRACKET {
- // map parsing completed. If we ever want to do any wrap up
- // (maybe some sanity checking), this would be the best place
- // for it.
- };
- // This represents top-level entries: Control-agent, Dhcp6, Dhcp4,
- // DhcpDdns, Logging
- global_objects: global_object
- | global_objects COMMA global_object
- ;
- // This represents a single top level entry, e.g. Dhcp4 or DhcpDdns.
- global_object: dhcp4_object
- | logging_object
- | dhcp6_json_object
- | dhcpddns_json_object
- | control_agent_json_object
- | unknown_map_entry
- ;
- dhcp4_object: DHCP4 {
- // This code is executed when we're about to start parsing
- // the content of the map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("Dhcp4", m);
- ctx.stack_.push_back(m);
- ctx.enter(ctx.DHCP4);
- } COLON LCURLY_BRACKET global_params RCURLY_BRACKET {
- // map parsing completed. If we ever want to do any wrap up
- // (maybe some sanity checking), this would be the best place
- // for it.
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // subparser: similar to the corresponding rule but without parent
- // so the stack is empty at the rule entry.
- sub_dhcp4: LCURLY_BRACKET {
- // Parse the Dhcp4 map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } global_params RCURLY_BRACKET {
- // parsing completed
- };
- global_params: global_param
- | global_params COMMA global_param
- ;
- // These are the parameters that are allowed in the top-level for
- // Dhcp4.
- global_param: valid_lifetime
- | renew_timer
- | rebind_timer
- | decline_probation_period
- | subnet4_list
- | interfaces_config
- | lease_database
- | hosts_database
- | host_reservation_identifiers
- | client_classes
- | option_def_list
- | option_data_list
- | hooks_libraries
- | expired_leases_processing
- | dhcp4o6_port
- | control_socket
- | dhcp_ddns
- | echo_client_id
- | match_client_id
- | next_server
- | unknown_map_entry
- ;
- valid_lifetime: VALID_LIFETIME COLON INTEGER {
- ElementPtr prf(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("valid-lifetime", prf);
- };
- renew_timer: RENEW_TIMER COLON INTEGER {
- ElementPtr prf(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("renew-timer", prf);
- };
- rebind_timer: REBIND_TIMER COLON INTEGER {
- ElementPtr prf(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("rebind-timer", prf);
- };
- decline_probation_period: DECLINE_PROBATION_PERIOD COLON INTEGER {
- ElementPtr dpp(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("decline-probation-period", dpp);
- };
- echo_client_id: ECHO_CLIENT_ID COLON BOOLEAN {
- ElementPtr echo(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("echo-client-id", echo);
- };
- match_client_id: MATCH_CLIENT_ID COLON BOOLEAN {
- ElementPtr match(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("match-client-id", match);
- };
- interfaces_config: INTERFACES_CONFIG {
- ElementPtr i(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("interfaces-config", i);
- ctx.stack_.push_back(i);
- ctx.enter(ctx.INTERFACES_CONFIG);
- } COLON LCURLY_BRACKET interfaces_config_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- interfaces_config_params: interfaces_config_param
- | interfaces_config_params COMMA interfaces_config_param
- ;
- interfaces_config_param: interfaces_list
- | dhcp_socket_type
- | re_detect
- ;
- sub_interfaces4: LCURLY_BRACKET {
- // Parse the interfaces-config map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } interfaces_config_params RCURLY_BRACKET {
- // parsing completed
- };
- interfaces_list: INTERFACES {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("interfaces", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.NO_KEYWORD);
- } COLON list_strings {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- dhcp_socket_type: DHCP_SOCKET_TYPE {
- ctx.enter(ctx.DHCP_SOCKET_TYPE);
- } COLON socket_type {
- ctx.stack_.back()->set("dhcp-socket-type", $4);
- ctx.leave();
- };
- socket_type: RAW { $$ = ElementPtr(new StringElement("raw", ctx.loc2pos(@1))); }
- | UDP { $$ = ElementPtr(new StringElement("udp", ctx.loc2pos(@1))); }
- ;
- re_detect: RE_DETECT COLON BOOLEAN {
- ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("re-detect", b);
- };
- lease_database: LEASE_DATABASE {
- ElementPtr i(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("lease-database", i);
- ctx.stack_.push_back(i);
- ctx.enter(ctx.LEASE_DATABASE);
- } COLON LCURLY_BRACKET database_map_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- hosts_database: HOSTS_DATABASE {
- ElementPtr i(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("hosts-database", i);
- ctx.stack_.push_back(i);
- ctx.enter(ctx.HOSTS_DATABASE);
- } COLON LCURLY_BRACKET database_map_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- database_map_params: database_map_param
- | database_map_params COMMA database_map_param
- ;
- database_map_param: database_type
- | user
- | password
- | host
- | port
- | name
- | persist
- | lfc_interval
- | readonly
- | connect_timeout
- | contact_points
- | keyspace
- | unknown_map_entry
- ;
- database_type: TYPE {
- ctx.enter(ctx.DATABASE_TYPE);
- } COLON db_type {
- ctx.stack_.back()->set("type", $4);
- ctx.leave();
- };
- db_type: MEMFILE { $$ = ElementPtr(new StringElement("memfile", ctx.loc2pos(@1))); }
- | MYSQL { $$ = ElementPtr(new StringElement("mysql", ctx.loc2pos(@1))); }
- | POSTGRESQL { $$ = ElementPtr(new StringElement("postgresql", ctx.loc2pos(@1))); }
- | CQL { $$ = ElementPtr(new StringElement("cql", ctx.loc2pos(@1))); }
- ;
- user: USER {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr user(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("user", user);
- ctx.leave();
- };
- password: PASSWORD {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr pwd(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("password", pwd);
- ctx.leave();
- };
- host: HOST {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr h(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("host", h);
- ctx.leave();
- };
- port: PORT COLON INTEGER {
- ElementPtr p(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("port", p);
- };
- name: NAME {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("name", name);
- ctx.leave();
- };
- persist: PERSIST COLON BOOLEAN {
- ElementPtr n(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("persist", n);
- };
- lfc_interval: LFC_INTERVAL COLON INTEGER {
- ElementPtr n(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("lfc-interval", n);
- };
- readonly: READONLY COLON BOOLEAN {
- ElementPtr n(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("readonly", n);
- };
- connect_timeout: CONNECT_TIMEOUT COLON INTEGER {
- ElementPtr n(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("connect-timeout", n);
- };
- contact_points: CONTACT_POINTS {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr cp(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("contact-points", cp);
- ctx.leave();
- };
- keyspace: KEYSPACE {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr ks(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("keyspace", ks);
- ctx.leave();
- };
- host_reservation_identifiers: HOST_RESERVATION_IDENTIFIERS {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("host-reservation-identifiers", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.HOST_RESERVATION_IDENTIFIERS);
- } COLON LSQUARE_BRACKET host_reservation_identifiers_list RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- host_reservation_identifiers_list: host_reservation_identifier
- | host_reservation_identifiers_list COMMA host_reservation_identifier
- ;
- host_reservation_identifier: duid_id
- | hw_address_id
- | circuit_id
- | client_id
- | flex_id
- ;
- duid_id : DUID {
- ElementPtr duid(new StringElement("duid", ctx.loc2pos(@1)));
- ctx.stack_.back()->add(duid);
- };
- hw_address_id : HW_ADDRESS {
- ElementPtr hwaddr(new StringElement("hw-address", ctx.loc2pos(@1)));
- ctx.stack_.back()->add(hwaddr);
- };
- circuit_id : CIRCUIT_ID {
- ElementPtr circuit(new StringElement("circuit-id", ctx.loc2pos(@1)));
- ctx.stack_.back()->add(circuit);
- };
- client_id : CLIENT_ID {
- ElementPtr client(new StringElement("client-id", ctx.loc2pos(@1)));
- ctx.stack_.back()->add(client);
- };
- flex_id: FLEX_ID {
- ElementPtr flex_id(new StringElement("flex-id", ctx.loc2pos(@1)));
- ctx.stack_.back()->add(flex_id);
- }
- hooks_libraries: HOOKS_LIBRARIES {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("hooks-libraries", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.HOOKS_LIBRARIES);
- } COLON LSQUARE_BRACKET hooks_libraries_list RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- hooks_libraries_list: %empty
- | not_empty_hooks_libraries_list
- ;
- not_empty_hooks_libraries_list: hooks_library
- | not_empty_hooks_libraries_list COMMA hooks_library
- ;
- hooks_library: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } hooks_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- sub_hooks_library: LCURLY_BRACKET {
- // Parse the hooks-libraries list entry map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } hooks_params RCURLY_BRACKET {
- // parsing completed
- };
- hooks_params: hooks_param
- | hooks_params COMMA hooks_param
- | unknown_map_entry
- ;
- hooks_param: library
- | parameters
- ;
- library: LIBRARY {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr lib(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("library", lib);
- ctx.leave();
- };
- parameters: PARAMETERS {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON value {
- ctx.stack_.back()->set("parameters", $4);
- ctx.leave();
- };
- // --- expired-leases-processing ------------------------
- 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.EXPIRED_LEASES_PROCESSING);
- } COLON LCURLY_BRACKET expired_leases_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- expired_leases_params: expired_leases_param
- | expired_leases_params COMMA expired_leases_param
- ;
- 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("unwarned-reclaim-cycles", value);
- };
- // --- subnet4 ------------------------------------------
- // This defines subnet4 as a list of maps.
- // "subnet4": [ ... ]
- subnet4_list: SUBNET4 {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("subnet4", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.SUBNET4);
- } COLON LSQUARE_BRACKET subnet4_list_content RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // This defines the ... in "subnet4": [ ... ]
- // It can either be empty (no subnets defined), have one subnet
- // or have multiple subnets separate by comma.
- subnet4_list_content: %empty
- | not_empty_subnet4_list
- ;
- not_empty_subnet4_list: subnet4
- | not_empty_subnet4_list COMMA subnet4
- ;
- // --- Subnet definitions -------------------------------
- // This defines a single subnet, i.e. a single map with
- // subnet4 array.
- subnet4: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } subnet4_params RCURLY_BRACKET {
- // Once we reached this place, the subnet parsing is now complete.
- // If we want to, we can implement default values here.
- // In particular we can do things like this:
- // if (!ctx.stack_.back()->get("interface")) {
- // ctx.stack_.back()->set("interface", StringElement("loopback"));
- // }
- //
- // We can also stack up one level (Dhcp4) and copy over whatever
- // global parameters we want to:
- // if (!ctx.stack_.back()->get("renew-timer")) {
- // ElementPtr renew = ctx_stack_[...].get("renew-timer");
- // if (renew) {
- // ctx.stack_.back()->set("renew-timer", renew);
- // }
- // }
- ctx.stack_.pop_back();
- };
- sub_subnet4: LCURLY_BRACKET {
- // Parse the subnet4 list entry map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } subnet4_params RCURLY_BRACKET {
- // parsing completed
- };
- // This defines that subnet can have one or more parameters.
- subnet4_params: subnet4_param
- | subnet4_params COMMA subnet4_param
- ;
- // This defines a list of allowed parameters for each subnet.
- subnet4_param: valid_lifetime
- | renew_timer
- | rebind_timer
- | option_data_list
- | pools_list
- | subnet
- | interface
- | interface_id
- | id
- | rapid_commit
- | client_class
- | reservations
- | reservation_mode
- | relay
- | match_client_id
- | next_server
- | subnet_4o6_interface
- | subnet_4o6_interface_id
- | subnet_4o6_subnet
- | unknown_map_entry
- ;
- subnet: SUBNET {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr subnet(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("subnet", subnet);
- ctx.leave();
- };
- subnet_4o6_interface: SUBNET_4O6_INTERFACE {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr iface(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("4o6-interface", iface);
- ctx.leave();
- };
- subnet_4o6_interface_id: SUBNET_4O6_INTERFACE_ID {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr iface(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("4o6-interface-id", iface);
- ctx.leave();
- };
- subnet_4o6_subnet: SUBNET_4O6_SUBNET {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr iface(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("4o6-subnet", iface);
- ctx.leave();
- };
- interface: INTERFACE {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr iface(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("interface", iface);
- ctx.leave();
- };
- interface_id: INTERFACE_ID {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr iface(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("interface-id", iface);
- ctx.leave();
- };
- client_class: CLIENT_CLASS {
- ctx.enter(ctx.CLIENT_CLASS);
- } COLON STRING {
- ElementPtr cls(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("client-class", cls);
- ctx.leave();
- };
- reservation_mode: RESERVATION_MODE {
- ctx.enter(ctx.RESERVATION_MODE);
- } COLON hr_mode {
- ctx.stack_.back()->set("reservation-mode", $4);
- ctx.leave();
- };
- hr_mode: DISABLED { $$ = ElementPtr(new StringElement("disabled", ctx.loc2pos(@1))); }
- | OUT_OF_POOL { $$ = ElementPtr(new StringElement("out-of-pool", ctx.loc2pos(@1))); }
- | ALL { $$ = ElementPtr(new StringElement("all", ctx.loc2pos(@1))); }
- ;
- id: ID COLON INTEGER {
- ElementPtr id(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("id", id);
- };
- rapid_commit: RAPID_COMMIT COLON BOOLEAN {
- ElementPtr rc(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("rapid-commit", rc);
- };
- // ---- option-def --------------------------
- // This defines the "option-def": [ ... ] entry that may appear
- // at a global option.
- option_def_list: OPTION_DEF {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("option-def", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.OPTION_DEF);
- } COLON LSQUARE_BRACKET option_def_list_content RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // This defines the content of option-def. It may be empty,
- // have one entry or multiple entries separated by comma.
- option_def_list_content: %empty
- | not_empty_option_def_list
- ;
- not_empty_option_def_list: option_def_entry
- | not_empty_option_def_list COMMA option_def_entry
- ;
- // This defines the content of a single entry { ... } within
- // option-def list.
- option_def_entry: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } option_def_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- // This defines the top level scope when the parser is told to parse a single
- // option definition. It's almost exactly the same as option_def_entry, except
- // that it does leave its value on stack.
- sub_option_def: LCURLY_BRACKET {
- // Parse the option-def list entry map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } option_def_params RCURLY_BRACKET {
- // parsing completed
- };
- // This defines parameters specified inside the map that itself
- // is an entry in option-def list.
- option_def_params: %empty
- | not_empty_option_def_params
- ;
- not_empty_option_def_params: option_def_param
- | not_empty_option_def_params COMMA option_def_param
- ;
- option_def_param: option_def_name
- | option_def_code
- | option_def_type
- | option_def_record_types
- | option_def_space
- | option_def_encapsulate
- | option_def_array
- | unknown_map_entry
- ;
- option_def_name: name;
- code: CODE COLON INTEGER {
- ElementPtr code(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("code", code);
- };
- option_def_code: code;
- option_def_type: TYPE {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr prf(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("type", prf);
- ctx.leave();
- };
- option_def_record_types: RECORD_TYPES {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr rtypes(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("record-types", rtypes);
- ctx.leave();
- };
- space: SPACE {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr space(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("space", space);
- ctx.leave();
- };
- option_def_space: space;
- option_def_encapsulate: ENCAPSULATE {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr encap(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("encapsulate", encap);
- ctx.leave();
- };
- option_def_array: ARRAY COLON BOOLEAN {
- ElementPtr array(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("array", array);
- };
- // ---- option-data --------------------------
- // This defines the "option-data": [ ... ] entry that may appear
- // in several places, but most notably in subnet4 entries.
- option_data_list: OPTION_DATA {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("option-data", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.OPTION_DATA);
- } COLON LSQUARE_BRACKET option_data_list_content RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // This defines the content of option-data. It may be empty,
- // have one entry or multiple entries separated by comma.
- option_data_list_content: %empty
- | not_empty_option_data_list
- ;
- // This defines the content of option-data list. It can either
- // be a single value or multiple entries separated by comma.
- not_empty_option_data_list: option_data_entry
- | not_empty_option_data_list COMMA option_data_entry
- ;
- // This defines th content of a single entry { ... } within
- // option-data list.
- option_data_entry: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } option_data_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- // This defines the top level scope when the parser is told to parse a single
- // option data. It's almost exactly the same as option_data_entry, except
- // that it does leave its value on stack.
- sub_option_data: LCURLY_BRACKET {
- // Parse the option-data list entry map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } option_data_params RCURLY_BRACKET {
- // parsing completed
- };
- // This defines parameters specified inside the map that itself
- // is an entry in option-data list. It can either be empty
- // or have a non-empty list of parameters.
- option_data_params: %empty
- | not_empty_option_data_params
- ;
- // Those parameters can either be a single parameter or
- // a list of parameters separated by comma.
- not_empty_option_data_params: option_data_param
- | not_empty_option_data_params COMMA option_data_param
- ;
- // Each single option-data parameter can be one of the following
- // expressions.
- option_data_param: option_data_name
- | option_data_data
- | option_data_code
- | option_data_space
- | option_data_csv_format
- | option_data_always_send
- | unknown_map_entry
- ;
- option_data_name: name;
- option_data_data: DATA {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr data(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("data", data);
- ctx.leave();
- };
- option_data_code: code;
- option_data_space: space;
- option_data_csv_format: CSV_FORMAT COLON BOOLEAN {
- ElementPtr space(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("csv-format", space);
- };
- option_data_always_send: ALWAYS_SEND COLON BOOLEAN {
- ElementPtr persist(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("always-send", persist);
- };
- // ---- pools ------------------------------------
- // This defines the "pools": [ ... ] entry that may appear in subnet4.
- pools_list: POOLS {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("pools", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.POOLS);
- } COLON LSQUARE_BRACKET pools_list_content RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // Pools may be empty, contain a single pool entry or multiple entries
- // separate by commas.
- pools_list_content: %empty
- | not_empty_pools_list
- ;
- not_empty_pools_list: pool_list_entry
- | not_empty_pools_list COMMA pool_list_entry
- ;
- pool_list_entry: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } pool_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- sub_pool4: LCURLY_BRACKET {
- // Parse the pool list entry map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } pool_params RCURLY_BRACKET {
- // parsing completed
- };
- pool_params: pool_param
- | pool_params COMMA pool_param
- ;
- pool_param: pool_entry
- | option_data_list
- | user_context
- | unknown_map_entry
- ;
- pool_entry: POOL {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr pool(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("pool", pool);
- ctx.leave();
- };
- user_context: USER_CONTEXT {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON map_value {
- ctx.stack_.back()->set("user-context", $4);
- ctx.leave();
- };
- // --- end of pools definition -------------------------------
- // --- reservations ------------------------------------------
- reservations: RESERVATIONS {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("reservations", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.RESERVATIONS);
- } COLON LSQUARE_BRACKET reservations_list RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- reservations_list: %empty
- | not_empty_reservations_list
- ;
- not_empty_reservations_list: reservation
- | not_empty_reservations_list COMMA reservation
- ;
- reservation: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } reservation_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- sub_reservation: LCURLY_BRACKET {
- // Parse the reservations list entry map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } reservation_params RCURLY_BRACKET {
- // parsing completed
- };
- reservation_params: %empty
- | not_empty_reservation_params
- ;
- not_empty_reservation_params: reservation_param
- | not_empty_reservation_params COMMA reservation_param
- ;
- // @todo probably need to add mac-address as well here
- reservation_param: duid
- | reservation_client_classes
- | client_id_value
- | circuit_id_value
- | flex_id_value
- | ip_address
- | hw_address
- | hostname
- | option_data_list
- | next_server
- | server_hostname
- | boot_file_name
- | unknown_map_entry
- ;
- next_server: NEXT_SERVER {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr next_server(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("next-server", next_server);
- ctx.leave();
- };
- server_hostname: SERVER_HOSTNAME {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr srv(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("server-hostname", srv);
- ctx.leave();
- };
- boot_file_name: BOOT_FILE_NAME {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr bootfile(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("boot-file-name", bootfile);
- ctx.leave();
- };
- ip_address: IP_ADDRESS {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr addr(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("ip-address", addr);
- ctx.leave();
- };
- duid: DUID {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr d(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("duid", d);
- ctx.leave();
- };
- hw_address: HW_ADDRESS {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr hw(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("hw-address", hw);
- ctx.leave();
- };
- client_id_value: CLIENT_ID {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr hw(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("client-id", hw);
- ctx.leave();
- };
- circuit_id_value: CIRCUIT_ID {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr hw(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("circuit-id", hw);
- ctx.leave();
- };
- flex_id_value: FLEX_ID {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr hw(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("flex-id", hw);
- ctx.leave();
- };
- hostname: HOSTNAME {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr host(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("hostname", host);
- ctx.leave();
- };
- reservation_client_classes: CLIENT_CLASSES {
- ElementPtr c(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("client-classes", c);
- ctx.stack_.push_back(c);
- ctx.enter(ctx.NO_KEYWORD);
- } COLON list_strings {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // --- end of reservations definitions -----------------------
- // --- relay -------------------------------------------------
- relay: RELAY {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("relay", m);
- ctx.stack_.push_back(m);
- ctx.enter(ctx.RELAY);
- } COLON LCURLY_BRACKET relay_map RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- relay_map: IP_ADDRESS {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr ip(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("ip-address", ip);
- ctx.leave();
- };
- // --- end of relay definitions ------------------------------
- // --- client classes ----------------------------------------
- client_classes: CLIENT_CLASSES {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("client-classes", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.CLIENT_CLASSES);
- } COLON LSQUARE_BRACKET client_classes_list RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- client_classes_list: client_class
- | client_classes_list COMMA client_class
- ;
- client_class: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } client_class_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- client_class_params: %empty
- | not_empty_client_class_params
- ;
- not_empty_client_class_params: client_class_param
- | not_empty_client_class_params COMMA client_class_param
- ;
- client_class_param: client_class_name
- | client_class_test
- | option_data_list
- | next_server
- | server_hostname
- | boot_file_name
- | unknown_map_entry
- ;
- client_class_name: name;
- client_class_test: TEST {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr test(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("test", test);
- ctx.leave();
- };
- // --- end of client classes ---------------------------------
- // was server-id but in is DHCPv6-only
- dhcp4o6_port: DHCP4O6_PORT COLON INTEGER {
- ElementPtr time(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("dhcp4o6-port", time);
- };
- // --- control socket ----------------------------------------
- control_socket: CONTROL_SOCKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("control-socket", m);
- ctx.stack_.push_back(m);
- ctx.enter(ctx.CONTROL_SOCKET);
- } COLON LCURLY_BRACKET control_socket_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- control_socket_params: control_socket_param
- | control_socket_params COMMA control_socket_param
- ;
- control_socket_param: control_socket_type
- | control_socket_name
- ;
- control_socket_type: SOCKET_TYPE {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr stype(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("socket-type", stype);
- ctx.leave();
- };
- control_socket_name: SOCKET_NAME {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("socket-name", name);
- ctx.leave();
- };
- // --- dhcp ddns ---------------------------------------------
- dhcp_ddns: DHCP_DDNS {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("dhcp-ddns", m);
- ctx.stack_.push_back(m);
- ctx.enter(ctx.DHCP_DDNS);
- } COLON LCURLY_BRACKET dhcp_ddns_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- sub_dhcp_ddns: LCURLY_BRACKET {
- // Parse the dhcp-ddns map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } dhcp_ddns_params RCURLY_BRACKET {
- // parsing completed
- };
- dhcp_ddns_params: dhcp_ddns_param
- | dhcp_ddns_params COMMA dhcp_ddns_param
- ;
- dhcp_ddns_param: enable_updates
- | qualifying_suffix
- | server_ip
- | server_port
- | sender_ip
- | sender_port
- | max_queue_size
- | ncr_protocol
- | ncr_format
- | always_include_fqdn
- | override_no_update
- | override_client_update
- | replace_client_name
- | generated_prefix
- | unknown_map_entry
- ;
- enable_updates: ENABLE_UPDATES COLON BOOLEAN {
- ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("enable-updates", b);
- };
- qualifying_suffix: QUALIFYING_SUFFIX {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr s(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("qualifying-suffix", s);
- ctx.leave();
- };
- server_ip: SERVER_IP {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr s(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("server-ip", s);
- ctx.leave();
- };
- server_port: SERVER_PORT COLON INTEGER {
- ElementPtr i(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("server-port", i);
- };
- sender_ip: SENDER_IP {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr s(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("sender-ip", s);
- ctx.leave();
- };
- sender_port: SENDER_PORT COLON INTEGER {
- ElementPtr i(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("sender-port", i);
- };
- max_queue_size: MAX_QUEUE_SIZE COLON INTEGER {
- ElementPtr i(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("max-queue-size", i);
- };
- ncr_protocol: NCR_PROTOCOL {
- ctx.enter(ctx.NCR_PROTOCOL);
- } COLON ncr_protocol_value {
- ctx.stack_.back()->set("ncr-protocol", $4);
- ctx.leave();
- };
- ncr_protocol_value:
- UDP { $$ = ElementPtr(new StringElement("UDP", ctx.loc2pos(@1))); }
- | TCP { $$ = ElementPtr(new StringElement("TCP", ctx.loc2pos(@1))); }
- ;
- ncr_format: NCR_FORMAT {
- ctx.enter(ctx.NCR_FORMAT);
- } COLON JSON {
- ElementPtr json(new StringElement("JSON", ctx.loc2pos(@4)));
- ctx.stack_.back()->set("ncr-format", json);
- ctx.leave();
- };
- always_include_fqdn: ALWAYS_INCLUDE_FQDN COLON BOOLEAN {
- ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("always-include-fqdn", b);
- };
- override_no_update: OVERRIDE_NO_UPDATE COLON BOOLEAN {
- ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("override-no-update", b);
- };
- override_client_update: OVERRIDE_CLIENT_UPDATE COLON BOOLEAN {
- ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("override-client-update", b);
- };
- replace_client_name: REPLACE_CLIENT_NAME {
- ctx.enter(ctx.REPLACE_CLIENT_NAME);
- } COLON replace_client_name_value {
- ctx.stack_.back()->set("replace-client-name", $4);
- ctx.leave();
- };
- replace_client_name_value:
- WHEN_PRESENT {
- $$ = ElementPtr(new StringElement("when-present", ctx.loc2pos(@1)));
- }
- | NEVER {
- $$ = ElementPtr(new StringElement("never", ctx.loc2pos(@1)));
- }
- | ALWAYS {
- $$ = ElementPtr(new StringElement("always", ctx.loc2pos(@1)));
- }
- | WHEN_NOT_PRESENT {
- $$ = ElementPtr(new StringElement("when-not-present", ctx.loc2pos(@1)));
- }
- | BOOLEAN {
- error(@1, "boolean values for the replace-client-name are "
- "no longer supported");
- }
- ;
- generated_prefix: GENERATED_PREFIX {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr s(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("generated-prefix", s);
- ctx.leave();
- };
- // JSON entries for Dhcp4 and DhcpDdns
- dhcp6_json_object: DHCP6 {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON value {
- ctx.stack_.back()->set("Dhcp6", $4);
- ctx.leave();
- };
- dhcpddns_json_object: DHCPDDNS {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON value {
- ctx.stack_.back()->set("DhcpDdns", $4);
- ctx.leave();
- };
- control_agent_json_object: CONTROL_AGENT {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON value {
- ctx.stack_.back()->set("Control-agent", $4);
- ctx.leave();
- };
- // --- logging entry -----------------------------------------
- // This defines the top level "Logging" object. It parses
- // the following "Logging": { ... }. The ... is defined
- // by logging_params
- logging_object: LOGGING {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("Logging", m);
- ctx.stack_.push_back(m);
- ctx.enter(ctx.LOGGING);
- } COLON LCURLY_BRACKET logging_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // This defines the list of allowed parameters that may appear
- // in the top-level Logging object. It can either be a single
- // parameter or several parameters separated by commas.
- logging_params: logging_param
- | logging_params COMMA logging_param
- ;
- // There's currently only one parameter defined, which is "loggers".
- logging_param: loggers;
- // "loggers", the only parameter currently defined in "Logging" object,
- // is "Loggers": [ ... ].
- loggers: LOGGERS {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("loggers", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.LOGGERS);
- } COLON LSQUARE_BRACKET loggers_entries RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // These are the parameters allowed in loggers: either one logger
- // entry or multiple entries separate by commas.
- loggers_entries: logger_entry
- | loggers_entries COMMA logger_entry
- ;
- // This defines a single entry defined in loggers in Logging.
- logger_entry: LCURLY_BRACKET {
- ElementPtr l(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(l);
- ctx.stack_.push_back(l);
- } logger_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- logger_params: logger_param
- | logger_params COMMA logger_param
- ;
- logger_param: name
- | output_options_list
- | debuglevel
- | severity
- | unknown_map_entry
- ;
- debuglevel: DEBUGLEVEL COLON INTEGER {
- ElementPtr dl(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("debuglevel", dl);
- };
- severity: SEVERITY {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr sev(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("severity", sev);
- ctx.leave();
- };
- output_options_list: OUTPUT_OPTIONS {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("output_options", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.OUTPUT_OPTIONS);
- } COLON LSQUARE_BRACKET output_options_list_content RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- output_options_list_content: output_entry
- | output_options_list_content COMMA output_entry
- ;
- output_entry: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } output_params_list RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- output_params_list: output_params
- | output_params_list COMMA output_params
- ;
- output_params: output
- | flush
- | maxsize
- | maxver
- ;
- output: OUTPUT {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr sev(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("output", sev);
- ctx.leave();
- };
- flush: FLUSH COLON BOOLEAN {
- ElementPtr flush(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("flush", flush);
- }
- maxsize: MAXSIZE COLON INTEGER {
- ElementPtr maxsize(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("maxsize", maxsize);
- }
- maxver: MAXVER COLON INTEGER {
- ElementPtr maxver(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("maxver", maxver);
- }
- %%
- void
- isc::dhcp::Dhcp4Parser::error(const location_type& loc,
- const std::string& what)
- {
- ctx.error(loc, what);
- }
|