From: Michal 'vorner' Vaner Date: Mon, 4 Feb 2013 16:21:48 +0000 (+0100) Subject: [1924] Use constants when building CC message in C++ X-Git-Tag: bind10-1.1.0beta1-release~104^2~22^2~15 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6dab65b159cc406f375c2bc504a3622b628e6879;p=thirdparty%2Fkea.git [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. --- diff --git a/src/lib/cc/session.cc b/src/lib/cc/session.cc index 47923f023f..1e71656b75 100644 --- a/src/lib/cc/session.cc +++ b/src/lib/cc/session.cc @@ -30,6 +30,11 @@ #include #include +#include +#include + +#include + #include #include #include @@ -44,9 +49,6 @@ #include -#include -#include - 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 81416d454a..3e9b16f71f 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 c9dca089e2..8a86830b44 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" } }