BIND 10 trac1914, updated. 6dab65b159cc406f375c2bc504a3622b628e6879 [1924] Use constants when building CC message in C++

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Feb 4 15:25:23 UTC 2013


The branch, trac1914 has been updated
       via  6dab65b159cc406f375c2bc504a3622b628e6879 (commit)
      from  a8f2c7a54ea5061e3b4d5ee48fb2e2fd2455c75d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6dab65b159cc406f375c2bc504a3622b628e6879
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Feb 4 17:21:48 2013 +0100

    [1924] Use constants when building CC message in C++
    
    Use the newly introduced constants in the group_sendmsg method. Other
    methods still need to be ported, but leaving that to other ticket.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/cc/session.cc       |   23 +++++++++++++----------
 src/lib/util/common_defs.cc |    4 ++++
 src/lib/util/common_defs.h  |   19 ++++++++++++-------
 3 files changed, 29 insertions(+), 17 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/cc/session.cc b/src/lib/cc/session.cc
index 47923f0..1e71656 100644
--- a/src/lib/cc/session.cc
+++ b/src/lib/cc/session.cc
@@ -30,6 +30,11 @@
 #include <asio/deadline_timer.hpp>
 #include <asio/system_error.hpp>
 
+#include <cc/data.h>
+#include <cc/session.h>
+
+#include <util/common_defs.h>
+
 #include <cstdio>
 #include <vector>
 #include <iostream>
@@ -44,9 +49,6 @@
 
 #include <exceptions/exceptions.h>
 
-#include <cc/data.h>
-#include <cc/session.h>
-
 using namespace std;
 using namespace isc::cc;
 using namespace isc::data;
@@ -480,13 +482,14 @@ Session::group_sendmsg(ConstElementPtr msg, std::string group,
     ElementPtr env = Element::createMap();
     long int nseq = ++impl_->sequence_;
 
-    env->set("type", Element::create("send"));
-    env->set("from", Element::create(impl_->lname_));
-    env->set("to", Element::create(to));
-    env->set("group", Element::create(group));
-    env->set("instance", Element::create(instance));
-    env->set("seq", Element::create(nseq));
-    env->set("want_answer", Element::create(want_answer));
+    env->set(isc::util::CC_HEADER_TYPE,
+             Element::create(isc::util::CC_COMMAND_SEND));
+    env->set(isc::util::CC_HEADER_FROM, Element::create(impl_->lname_));
+    env->set(isc::util::CC_HEADER_TO, Element::create(to));
+    env->set(isc::util::CC_HEADER_GROUP, Element::create(group));
+    env->set(isc::util::CC_HEADER_INSTANCE, Element::create(instance));
+    env->set(isc::util::CC_HEADER_SEQ, Element::create(nseq));
+    env->set(isc::util::CC_HEADER_WANT_ANSWER, Element::create(want_answer));
 
     sendmsg(env, msg);
     return (nseq);
diff --git a/src/lib/util/common_defs.cc b/src/lib/util/common_defs.cc
index 81416d4..3e9b16f 100644
--- a/src/lib/util/common_defs.cc
+++ b/src/lib/util/common_defs.cc
@@ -22,6 +22,8 @@ namespace util {
 // keep the syntax here simple and check the generated file
 // (lib/python/isc/util/common_defs.py) is correct and sane.
 
+// The constants used in the CC protocol
+// First the header names
 const char* CC_HEADER_TYPE = "type";
 const char* CC_HEADER_FROM = "from";
 const char* CC_HEADER_TO = "to";
@@ -29,6 +31,8 @@ const char* CC_HEADER_GROUP = "group";
 const char* CC_HEADER_INSTANCE = "instance";
 const char* CC_HEADER_SEQ = "seq";
 const char* CC_HEADER_WANT_ANSWER = "want_answer";
+// The commands in the "type" header
+const char* CC_COMMAND_SEND = "send";
 
 }
 }
diff --git a/src/lib/util/common_defs.h b/src/lib/util/common_defs.h
index c9dca08..8a86830 100644
--- a/src/lib/util/common_defs.h
+++ b/src/lib/util/common_defs.h
@@ -26,15 +26,20 @@ namespace util {
 // one process to another. Since the names should be self-explanatory and
 // the variables here are used mostly to synchronize the same values across
 // multiple programs, separate documentation for each variable is not provided.
+//
+// \todo Generate this header from the .cc file too. It should be simple.
 
 // Constants used in the CC protocol (sent through MSGQ)
-extern const char* CC_HEADER_TYPE;
-extern const char* CC_HEADER_FROM;
-extern const char* CC_HEADER_TO;
-extern const char* CC_HEADER_GROUP;
-extern const char* CC_HEADER_INSTANCE;
-extern const char* CC_HEADER_SEQ;
-extern const char* CC_HEADER_WANT_ANSWER;
+// First the header names.
+extern const char* CC_HEADER_TYPE; // "type"
+extern const char* CC_HEADER_FROM; // "from"
+extern const char* CC_HEADER_TO; // "to"
+extern const char* CC_HEADER_GROUP; // "group"
+extern const char* CC_HEADER_INSTANCE; // "instance"
+extern const char* CC_HEADER_SEQ; // "seq"
+extern const char* CC_HEADER_WANT_ANSWER; // "want_answer"
+// Then the commands used in the CC_HEADER_TYPE header
+extern const char* CC_COMMAND_SEND; // "send"
 
 }
 }



More information about the bind10-changes mailing list