Commit 6dab65b1 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner

[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.
parent a8f2c7a5
......@@ -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);
......
......@@ -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";
}
}
......@@ -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"
}
}
......
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