Commit 8c2df1aa authored by Francis Dupont's avatar Francis Dupont

[30-implement-control-socket-for-ddns-2] Updated syntax

parent 23200e6a
......@@ -77,6 +77,11 @@ namespace d2 {
/// "interface" : "eth1" ,
/// "ip-address" : "192.168.1.33" ,
/// "port" : 88 ,
/// "control-socket":
/// {
/// "socket-type": "unix" ,
/// "socket-name": "/tmp/d2-ctrl-socket"
//// },
/// "tsig-keys":
//// [
/// {
......
......@@ -269,6 +269,7 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
case isc::d2::D2ParserContext::DNS_SERVERS:
case isc::d2::D2ParserContext::TSIG_KEY:
case isc::d2::D2ParserContext::TSIG_KEYS:
case isc::d2::D2ParserContext::CONTROL_SOCKET:
case isc::d2::D2ParserContext::LOGGERS:
return isc::d2::D2Parser::make_USER_CONTEXT(driver.loc_);
default:
......@@ -285,6 +286,7 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
case isc::d2::D2ParserContext::DNS_SERVERS:
case isc::d2::D2ParserContext::TSIG_KEY:
case isc::d2::D2ParserContext::TSIG_KEYS:
case isc::d2::D2ParserContext::CONTROL_SOCKET:
case isc::d2::D2ParserContext::LOGGERS:
return isc::d2::D2Parser::make_COMMENT(driver.loc_);
default:
......@@ -390,6 +392,33 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"control-socket\" {
switch(driver.ctx_) {
case isc::d2::D2ParserContext::DHCPDDNS:
return isc::d2::D2Parser::make_CONTROL_SOCKET(driver.loc_);
default:
return isc::d2::D2Parser::make_STRING("control-socket", driver.loc_);
}
}
\"socket-type\" {
switch(driver.ctx_) {
case isc::d2::D2ParserContext::CONTROL_SOCKET:
return isc::d2::D2Parser::make_SOCKET_TYPE(driver.loc_);
default:
return isc::d2::D2Parser::make_STRING("socket-type", driver.loc_);
}
}
\"socket-name\" {
switch(driver.ctx_) {
case isc::d2::D2ParserContext::CONTROL_SOCKET:
return isc::d2::D2Parser::make_SOCKET_NAME(driver.loc_);
default:
return isc::d2::D2Parser::make_STRING("socket-name", driver.loc_);
}
}
\"Logging\" {
switch(driver.ctx_) {
......
......@@ -75,6 +75,10 @@ using namespace std;
DIGEST_BITS "digest-bits"
SECRET "secret"
CONTROL_SOCKET "control-socket"
SOCKET_TYPE "socket-type"
SOCKET_NAME "socket-name"
LOGGING "Logging"
LOGGERS "loggers"
NAME "name"
......@@ -270,6 +274,7 @@ dhcpddns_param: ip_address
| forward_ddns
| reverse_ddns
| tsig_keys
| control_socket
| user_context
| comment
| unknown_map_entry
......@@ -665,6 +670,46 @@ tsig_key_secret: SECRET {
// --- end of tsig-keys ---------------------------------
// --- 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
| user_context
| comment
| unknown_map_entry
;
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();
};
// ----------------------------------------------------------------
dhcp6_json_object: DHCP6 {
ctx.enter(ctx.NO_KEYWORD);
......
......@@ -142,6 +142,8 @@ D2ParserContext::contextName()
return("dns-server");
case DNS_SERVERS:
return("dns-servers");
case CONTROL_SOCKET:
return("control-socket");
case LOGGING:
return ("Logging");
case LOGGERS:
......
// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2017-2018 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
......@@ -204,6 +204,9 @@ public:
///< Used while parsing content of list of dns-servers
DNS_SERVERS,
///< Used while parsing content of a control-socket
CONTROL_SOCKET,
///< Used while parsing content of Logging
LOGGING,
......
......@@ -128,9 +128,9 @@ TEST(ParserTest, keywordDhcpDdns) {
" \"ip-address\": \"192.168.77.1\", \n"
" \"port\": 777 , \n "
" \"ncr-protocol\": \"UDP\", \n"
"\"tsig-keys\": [], \n"
"\"forward-ddns\" : {}, \n"
"\"reverse-ddns\" : {} \n"
" \"tsig-keys\": [], \n"
" \"forward-ddns\" : {}, \n"
" \"reverse-ddns\" : {} \n"
"} \n"
"} \n";
testParser(txt, D2ParserContext::PARSER_DHCPDDNS);
......
{
"DhcpDdns": {
"control-socket": {
"socket-name": "/tmp/d2-ctrl-socket",
"socket-type": "unix"
},
"dns-server-timeout": 1000,
"forward-ddns": {
"ddns-domains": [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment