}
}
-\"name\" {
+\"socket-type\" {
switch(driver.ctx_) {
case ParserContext::CONTROL_SOCKET:
- case ParserContext::LOGGERS:
- return NetconfParser::make_NAME(driver.loc_);
+ return NetconfParser::make_SOCKET_TYPE(driver.loc_);
default:
- return NetconfParser::make_STRING("name", driver.loc_);
+ return NetconfParser::make_STRING("socket-type", driver.loc_);
}
}
-\"type\" {
+\"socket-name\" {
switch(driver.ctx_) {
case ParserContext::CONTROL_SOCKET:
- return NetconfParser::make_TYPE(driver.loc_);
+ return NetconfParser::make_SOCKET_NAME(driver.loc_);
default:
- return NetconfParser::make_STRING("type", driver.loc_);
+ return NetconfParser::make_STRING("socket-name", driver.loc_);
}
}
-\"host\" {
+\"socket-url\" {
switch(driver.ctx_) {
case ParserContext::CONTROL_SOCKET:
- return NetconfParser::make_HOST(driver.loc_);
+ return NetconfParser::make_SOCKET_URL(driver.loc_);
default:
- return NetconfParser::make_STRING("host", driver.loc_);
- }
-}
-
-\"port\" {
- switch(driver.ctx_) {
- case ParserContext::CONTROL_SOCKET:
- return NetconfParser::make_PORT(driver.loc_);
- default:
- return NetconfParser::make_STRING("port", driver.loc_);
+ return NetconfParser::make_STRING("socket-url", driver.loc_);
}
}
}
}
+\"name\" {
+ switch(driver.ctx_) {
+ case ParserContext::LOGGERS:
+ return NetconfParser::make_NAME(driver.loc_);
+ default:
+ return NetconfParser::make_STRING("name", driver.loc_);
+ }
+}
+
\"output_options\" {
switch(driver.ctx_) {
case ParserContext::LOGGERS:
}
}
-\"Dhcp4\" {
- switch(driver.ctx_) {
- case ParserContext::CONFIG:
- return NetconfParser::make_DHCP4(driver.loc_);
- default:
- return NetconfParser::make_STRING("Dhcp4", driver.loc_);
- }
-}
-
-\"Dhcp6\" {
- switch(driver.ctx_) {
- case ParserContext::CONFIG:
- return NetconfParser::make_DHCP6(driver.loc_);
- default:
- return NetconfParser::make_STRING("Dhcp6", driver.loc_);
- }
-}
-
-\"DhcpDdns\" {
- switch(driver.ctx_) {
- case ParserContext::CONFIG:
- return NetconfParser::make_DHCPDDNS(driver.loc_);
- default:
- return NetconfParser::make_STRING("DhcpDdns", driver.loc_);
- }
-}
-
-\"Control-agent\" {
- switch(driver.ctx_) {
- case ParserContext::CONFIG:
- return NetconfParser::make_CONTROL_AGENT(driver.loc_);
- default:
- return NetconfParser::make_STRING("Control-agent", driver.loc_);
- }
-}
-
{JSONString} {
/* A string has been matched. It contains the actual string and single quotes.
We need to get those quotes out of the way and just use its content, e.g.
CA_SERVER "ca"
MODEL "model"
CONTROL_SOCKET "control-socket"
- TYPE "type"
+ SOCKET_TYPE "socket-type"
UNIX "unix"
HTTP "http"
STDOUT "stdout"
- NAME "name"
- HOST "host"
- PORT "port"
+ SOCKET_NAME "socket-name"
+ SOCKET_URL "socket-url"
HOOKS_LIBRARIES "hooks-libraries"
LIBRARY "library"
LOGGING "Logging"
LOGGERS "loggers"
+ NAME "name"
OUTPUT_OPTIONS "output_options"
OUTPUT "output"
DEBUGLEVEL "debuglevel"
MAXSIZE "maxsize"
MAXVER "maxver"
- DHCP4 "Dhcp4"
- DHCP6 "Dhcp6"
- DHCPDDNS "DhcpDdns"
- CONTROL_AGENT "Control-agent"
-
// Not real tokens, just a way to signal what the parser is expected to
// parse. This define the starting point. It either can be full grammar
// (START_NETCONF), part of the grammar related to control-netconf (START_SUB_NETCONF)
"got unexpected keyword \"" + keyword + "\" in " + where + " map.");
};
-// This defines the top-level { } that holds Netconf, Dhcp6, Dhcp4,
-// DhcpDdns, Control-agent or Logging objects.
+// This defines the top-level { } that holds Netconf or Logging objects.
netconf_syntax_map: LCURLY_BRACKET {
// This code is executed when we're about to start parsing
// the content of the map
// This represents a single top level entry, e.g. Control-netconf, Dhcp6 or DhcpDdns.
global_object: netconf_object
| logging_object
- | dhcp4_json_object
- | dhcp6_json_object
- | dhcpddns_json_object
- | control_agent_object
| unknown_map_entry
;
ctx.leave();
};
-global_params: global_param
- | global_params COMMA global_param
+global_params: %empty
+ | not_empty_global_params
;
+not_empty_global_params: global_param
+ | not_empty_global_params COMMA global_param
+ ;
+
// These are the parameters that are allowed in the top-level for
// Netconf.
global_param: managed_servers
;
control_socket_param: socket_type
- | name
- | host
- | port
+ | socket_name
+ | socket_url
| user_context
| comment
| unknown_map_entry
;
-socket_type: TYPE {
+socket_type: SOCKET_TYPE {
ctx.enter(ctx.SOCKET_TYPE);
} COLON socket_type_value {
- ctx.stack_.back()->set("type", $4);
+ ctx.stack_.back()->set("socket-type", $4);
ctx.leave();
};
| STDOUT { $$ = ElementPtr(new StringElement("stdout", ctx.loc2pos(@1))); }
;
// Unix name.
-name: NAME {
+socket_name: SOCKET_NAME {
ctx.enter(ctx.NO_KEYWORDS);
} COLON STRING {
ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("name", name);
+ ctx.stack_.back()->set("socket-name", name);
ctx.leave();
};
-// HTTP host.
-host: HOST {
+// HTTP url.
+socket_url: SOCKET_URL {
ctx.enter(ctx.NO_KEYWORDS);
} COLON STRING {
- ElementPtr host(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("host", host);
+ ElementPtr url(new StringElement($4, ctx.loc2pos(@4)));
+ ctx.stack_.back()->set("socket-url", url);
ctx.leave();
};
-// HTTP PORT
-port: PORT COLON INTEGER {
- ElementPtr port(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("port", port);
-};
-
// --- managed-servers end here ------------------------------------------------
-// JSON entries for other global objects (Dhcp4,Dhcp6 and DhcpDdns)
-dhcp4_json_object: DHCP4 {
- ctx.enter(ctx.NO_KEYWORDS);
-} COLON value {
- ctx.stack_.back()->set("Dhcp4", $4);
- ctx.leave();
-};
-
-dhcp6_json_object: DHCP6 {
- ctx.enter(ctx.NO_KEYWORDS);
-} COLON value {
- ctx.stack_.back()->set("Dhcp6", $4);
- ctx.leave();
-};
-
-dhcpddns_json_object: DHCPDDNS {
- ctx.enter(ctx.NO_KEYWORDS);
-} COLON value {
- ctx.stack_.back()->set("DhcpDdns", $4);
- ctx.leave();
-};
-
-control_agent_object: CONTROL_AGENT {
- ctx.enter(ctx.NO_KEYWORDS);
-} COLON value {
- ctx.stack_.back()->set("Control-agent", $4);
- ctx.leave();
-};
-
-
// --- Logging starts here -----------------------------------------------------
// This defines the top level "Logging" object. It parses
| unknown_map_entry
;
+name: NAME {
+ ctx.enter(ctx.NO_KEYWORDS);
+} COLON STRING {
+ ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));
+ ctx.stack_.back()->set("name", name);
+ ctx.leave();
+};
+
debuglevel: DEBUGLEVEL COLON INTEGER {
ElementPtr dl(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("debuglevel", dl);
testParser(txt, ParserContext::PARSER_JSON);
}
-// This test checks that the DhcpDdns configuration is accepted
-// by the parser.
-TEST(ParserTest, keywordDhcpDdns) {
- string txt =
- "{ \"DhcpDdns\" : \n"
- "{ \n"
- " \"ip-address\": \"192.168.77.1\", \n"
- " \"port\": 777 , \n "
- " \"ncr-protocol\": \"UDP\", \n"
- "\"tsig-keys\": [], \n"
- "\"forward-ddns\" : {}, \n"
- "\"reverse-ddns\" : {} \n"
- "} \n"
- "} \n";
- testParser(txt, ParserContext::PARSER_NETCONF);
-}
-
-// This test checks that the Dhcp6 configuration is accepted
-// by the parser.
-TEST(ParserTest, keywordDhcp6) {
- string txt = "{ \"Dhcp6\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"type\", \"htype\" ] },\n"
- "\"preferred-lifetime\": 3000,\n"
- "\"rebind-timer\": 2000, \n"
- "\"renew-timer\": 1000, \n"
- "\"subnet6\": [ { "
- " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
- " \"subnet\": \"2001:db8:1::/48\", "
- " \"interface\": \"test\" } ],\n"
- "\"valid-lifetime\": 4000 } }";
- testParser(txt, ParserContext::PARSER_NETCONF);
-}
-
-// This test checks that the Dhcp4 configuration is accepted
-// by the parser.
-TEST(ParserTest, keywordDhcp4) {
- string txt = "{ \"Dhcp4\": { \"interfaces-config\": {"
- " \"interfaces\": [ \"type\", \"htype\" ] },\n"
- "\"rebind-timer\": 2000, \n"
- "\"renew-timer\": 1000, \n"
- "\"subnet4\": [ { "
- " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
- " \"subnet\": \"192.0.2.0/24\", "
- " \"interface\": \"test\" } ],\n"
- "\"valid-lifetime\": 4000 } }";
- testParser(txt, ParserContext::PARSER_NETCONF);
-}
-
-// This test checks that the Control-agent configuration is accepted
-// by the parser.
-TEST(ParserTest, keywordControlAgent) {
- string txt = "{ \"Control-agent\": {\n"
- " \"http-host\": \"localhost\",\n"
- " \"http-port\": 8000,\n"
- " \"control-sockets\": {"
- " \"dhcp4\": {"
- " \"socket-type\": \"unix\","
- " \"socket-name\": \"/path/to/the/unix/socket-v4\""
- " },"
- " \"dhcp6\": {"
- " \"socket-type\": \"unix\","
- " \"socket-name\": \"/path/to/the/unix/socket-v6\""
- " },"
- " \"d2\": {"
- " \"socket-type\": \"unix\","
- " \"socket-name\": \"/path/to/the/unix/socket-d2\""
- " }"
- " }"
- "} }";
- testParser(txt, ParserContext::PARSER_NETCONF);
-}
-
// This test checks if full config (with top level and Netconf objects) can
// be parsed with syntactic checking (and as pure JSON).
TEST(ParserTest, keywordNetconf) {
" \"dhcp4\": {"
" \"model\": \"kea-dhcp4-server\","
" \"control-socket\": {"
- " \"type\": \"unix\","
- " \"name\": \"/path/to/the/unix/socket-v4\""
+ " \"socket-type\": \"unix\","
+ " \"socket-name\": \"/path/to/the/unix/socket-v4\""
" }"
" },"
" \"dhcp6\": {"
" \"model\": \"kea-dhcp6-server\","
" \"control-socket\": {"
- " \"type\": \"http\","
- " \"host\": \"127.0.0.1\","
- " \"port\": 12345"
+ " \"socket-type\": \"http\","
+ " \"socket-url\": \"http://127.0.0.1:12345/\""
" }"
" },"
" \"d2\": {"
" \"model\": \"kea-dhcp-ddns\","
" \"control-socket\": {"
- " \"type\": \"stdout\""
+ " \"socket-type\": \"stdout\""
" }"
" },"
" \"ca\": {"
" \"model\": \"kea-ctrl-agent\","
" \"control-socket\": {"
- " \"type\": \"http\","
+ " \"socket-type\": \"http\","
" \"user-context\": { \"use default\": true }"
" }"
" }"
" \"dhcp4\": {"
" \"model\": \"kea-dhcp4-server\","
" \"control-socket\": {"
- " \"type\": \"unix\","
- " \"name\": \"/path/to/the/unix/socket-v4\""
+ " \"socket-type\": \"unix\","
+ " \"socket-name\": \"/path/to/the/unix/socket-v4\""
" }"
" },"
" \"dhcp6\": {"
" \"model\": \"kea-dhcp6-server\","
" \"control-socket\": {"
- " \"type\": \"http\","
- " \"host\": \"127.0.0.1\","
- " \"port\": 12345"
+ " \"socket-type\": \"http\","
+ " \"socket-url\": \"http://127.0.0.1:12345/\""
" }"
" },"
" \"d2\": {"
" \"model\": \"kea-dhcp-ddns\","
" \"control-socket\": {"
- " \"type\": \"stdout\""
+ " \"socket-type\": \"stdout\""
" }"
" },"
" \"ca\": {"
" \"model\": \"kea-ctrl-agent\","
" \"model\": \"kea-dhcp6-server\","
" \"control-socket\": {"
- " \"type\": \"http\","
+ " \"socket-type\": \"http\","
" \"user-context\": { \"use default\": true }"
" }"
" }"
" \"model\": \"foo\",\n"
" \"control-socket\": {\n"
"# this is a comment\n"
- "\"type\": \"unix\", \n"
+ "\"socket-type\": \"unix\", \n"
"# This socket is mine. I can name it whatever\n"
"# I like, ok?\n"
- "\"name\": \"Hector\" \n"
+ "\"socket-name\": \"Hector\" \n"
"} } } } }";
testParser(txt, ParserContext::PARSER_NETCONF);
}
" \"d2\": {\n"
" \"model\": \"foo\",\n"
" \"control-socket\": {\n"
- "\"type\": \"unix\", \n"
- "\"name\": \"Hector\" \n"
+ "\"socket-type\": \"unix\", \n"
+ "\"socket-name\": \"Hector\" \n"
"} } } } }";
testParser(txt, ParserContext::PARSER_NETCONF, false);
" \"d2\": {\n"
" \"model\": \"foo\",\n"
" \"control-socket\": {\n"
- "\"type\": \"unix\", # Maybe Hector is not really a \n"
- "\"name\": \"Hector\" # Unix process?\n"
+ "\"socket-type\": \"unix\", # Maybe Hector is not really a \n"
+ "\"socket-name\": \"Hector\" # Unix process?\n"
"# Oh no! He's a windows one and just pretending!\n"
"} } } } }";
testParser(txt, ParserContext::PARSER_NETCONF, false);
" \"dhcp4\": {\n"
" \"model\": \"foo\",\n"
" \"control-socket\": {\n"
- " \"type\": \"stdout\"\n"
+ " \"socket-type\": \"stdout\"\n"
" }\n"
" }\n"
" /* Ok, forget about it. If Hector doesn't want to talk,\n"
" /* \"d2\": {"
" \"model\": \"bar\",\n"
" \"control-socket\": {\n"
- " \"type\": \"unix\",\n"
- "\"name\": \"Hector\"\n"
+ " \"socket-type\": \"unix\",\n"
+ "\"socket-name\": \"Hector\"\n"
"} }*/ } } }";
testParser(txt, ParserContext::PARSER_NETCONF, false);
}
" \"dhcp4\": {\n"
" \"control-socket\": {\n"
" \"user-context\": { \"comment\": \"indirect\" },\n"
- " \"type\": \"stdout\"\n"
+ " \"socket-type\": \"stdout\"\n"
" } } },\n"
" \"user-context\": { \"compatible\": true }\n"
"} }";