]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[30-implement-control-socket-for-ddns-2] Updated syntax
authorFrancis Dupont <fdupont@isc.org>
Thu, 27 Dec 2018 23:20:33 +0000 (00:20 +0100)
committerFrancis Dupont <fdupont@isc.org>
Thu, 3 Jan 2019 09:05:03 +0000 (04:05 -0500)
src/bin/d2/d2_config.h
src/bin/d2/d2_lexer.ll
src/bin/d2/d2_parser.yy
src/bin/d2/parser_context.cc
src/bin/d2/parser_context.h
src/bin/d2/tests/parser_unittest.cc
src/bin/d2/tests/testdata/get_config.json

index 97d754d04e5e0955633a28d6fa69c73cecac5695..e92bb9b263f6d3cd68892cef7d865fac764350f7 100644 (file)
@@ -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":
 //// [
 ///    {
index bc26b334bd61a89c3d5b031e7b123f11d070c499..df44c7e7fe22064e1c70b038467901fe80a757b1 100644 (file)
@@ -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_) {
index 5dfc152cb79a7bc6fd1f423a34f9d736e4f0126c..f3c770d7bd35d954cf13cec6e60fd1f2c7fc5178 100644 (file)
@@ -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);
index a88043a325bd575865fea8e90b568ded464f2f76..16caa286e47fc3ab250deb3ffc2b32b8688ea3f0 100644 (file)
@@ -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:
index cbb495c23b25fbc691225ecd6b97df004128af87..e1fc414e623a3850e140efc0df62e5de3c522cd2 100644 (file)
@@ -1,4 +1,4 @@
-// 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,
 
index 2bb62543f638f0d64dfc6c5a289d6c01f878b14d..37c454bf4ef5b8ed9277f9fa9b4c617ef28c46b5 100644 (file)
@@ -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);
index b040c058edf54ce31f631f0da07102eb4cbb3414..d0905d1e27d7cc07c6c1d60c74dbf757be63c399 100644 (file)
@@ -1,5 +1,9 @@
 {
     "DhcpDdns": {
+        "control-socket": {
+            "socket-name": "/tmp/d2-ctrl-socket",
+            "socket-type": "unix"
+        },
         "dns-server-timeout": 1000,
         "forward-ddns": {
             "ddns-domains": [