BIND 10 trac2737, updated. c178521c5c7133093866a8403b3d1d8af2cb6684 [2737] Use protocol constants in isc::config::ModuleConfigSession
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Mar 19 12:47:21 UTC 2013
The branch, trac2737 has been updated
via c178521c5c7133093866a8403b3d1d8af2cb6684 (commit)
from 60635a58548ae680058d67837e6ce1696c3b7faa (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 c178521c5c7133093866a8403b3d1d8af2cb6684
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Mar 19 13:45:39 2013 +0100
[2737] Use protocol constants in isc::config::ModuleConfigSession
-----------------------------------------------------------------------
Summary of changes:
src/lib/config/ccsession.cc | 45 ++++++++++++++++++++++++-------------------
src/lib/config/ccsession.h | 4 ++--
2 files changed, 27 insertions(+), 22 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/config/ccsession.cc b/src/lib/config/ccsession.cc
index 78432ab..533ecc6 100644
--- a/src/lib/config/ccsession.cc
+++ b/src/lib/config/ccsession.cc
@@ -57,10 +57,10 @@ namespace config {
/// Creates a standard config/command protocol answer message
ConstElementPtr
createAnswer() {
- ElementPtr answer = Element::fromJSON("{\"result\": [] }");
+ ElementPtr answer = Element::createMap();
ElementPtr answer_content = Element::createList();
- answer_content->add(Element::create(0));
- answer->set("result", answer_content);
+ answer_content->add(Element::create(isc::cc::CC_REPLY_SUCCESS));
+ answer->set(isc::cc::CC_PAYLOAD_RESULT, answer_content);
return (answer);
}
@@ -70,22 +70,22 @@ createAnswer(const int rcode, ConstElementPtr arg) {
if (rcode != 0 && (!arg || arg->getType() != Element::string)) {
isc_throw(CCSessionError, "Bad or no argument for rcode != 0");
}
- ElementPtr answer = Element::fromJSON("{\"result\": [] }");
+ ElementPtr answer = Element::createMap();
ElementPtr answer_content = Element::createList();
answer_content->add(Element::create(rcode));
answer_content->add(arg);
- answer->set("result", answer_content);
+ answer->set(isc::cc::CC_PAYLOAD_RESULT, answer_content);
return (answer);
}
ConstElementPtr
createAnswer(const int rcode, const std::string& arg) {
- ElementPtr answer = Element::fromJSON("{\"result\": [] }");
+ ElementPtr answer = Element::createMap();
ElementPtr answer_content = Element::createList();
answer_content->add(Element::create(rcode));
answer_content->add(Element::create(arg));
- answer->set("result", answer_content);
+ answer->set(isc::cc::CC_PAYLOAD_RESULT, answer_content);
return (answer);
}
@@ -94,8 +94,8 @@ ConstElementPtr
parseAnswer(int &rcode, ConstElementPtr msg) {
if (msg &&
msg->getType() == Element::map &&
- msg->contains("result")) {
- ConstElementPtr result = msg->get("result");
+ msg->contains(isc::cc::CC_PAYLOAD_RESULT)) {
+ ConstElementPtr result = msg->get(isc::cc::CC_PAYLOAD_RESULT);
if (result->getType() != Element::list) {
isc_throw(CCSessionError, "Result element in answer message is not a list");
} else if (result->get(0)->getType() != Element::integer) {
@@ -133,7 +133,7 @@ createCommand(const std::string& command, ConstElementPtr arg) {
if (arg) {
cmd_parts->add(arg);
}
- cmd->set("command", cmd_parts);
+ cmd->set(isc::cc::CC_PAYLOAD_COMMAND, cmd_parts);
return (cmd);
}
@@ -141,8 +141,8 @@ std::string
parseCommand(ConstElementPtr& arg, ConstElementPtr command) {
if (command &&
command->getType() == Element::map &&
- command->contains("command")) {
- ConstElementPtr cmd = command->get("command");
+ command->contains(isc::cc::CC_PAYLOAD_COMMAND)) {
+ ConstElementPtr cmd = command->get(isc::cc::CC_PAYLOAD_COMMAND);
if (cmd->getType() == Element::list &&
cmd->size() > 0 &&
cmd->get(0)->getType() == Element::string) {
@@ -463,10 +463,13 @@ ModuleCCSession::ModuleCCSession(
isc_throw(CCSessionInitError, answer->str());
}
- setLocalConfig(Element::fromJSON("{}"));
+ setLocalConfig(Element::createMap());
// get any stored configuration from the manager
if (config_handler_) {
- ConstElementPtr cmd = Element::fromJSON("{ \"command\": [\"get_config\", {\"module_name\":\"" + module_name_ + "\"} ] }");
+ ConstElementPtr cmd =
+ createCommand("get_config",
+ Element::fromJSON("{\"module_name\":\"" +
+ module_name_ + "\"}"));
seq = session_.group_sendmsg(cmd, "ConfigManager");
session_.group_recvmsg(env, answer, false, seq);
ConstElementPtr new_config = parseAnswer(rcode, answer);
@@ -608,14 +611,16 @@ ModuleCCSession::checkCommand() {
/* ignore result messages (in case we're out of sync, to prevent
* pingpongs */
- if (data->getType() != Element::map || data->contains("result")) {
+ if (data->getType() != Element::map ||
+ data->contains(isc::cc::CC_PAYLOAD_RESULT)) {
return (0);
}
ConstElementPtr arg;
ConstElementPtr answer;
try {
std::string cmd_str = parseCommand(arg, data);
- std::string target_module = routing->get("group")->stringValue();
+ std::string target_module =
+ routing->get(isc::cc::CC_HEADER_GROUP)->stringValue();
if (cmd_str == "config_update") {
answer = checkConfigUpdateCommand(target_module, arg);
} else {
@@ -832,19 +837,19 @@ bool
ModuleCCSession::requestMatch(const AsyncRecvRequest& request,
const ConstElementPtr& envelope) const
{
- if (request.is_reply != envelope->contains("reply")) {
+ if (request.is_reply != envelope->contains(isc::cc::CC_HEADER_REPLY)) {
// Wrong type of message
return (false);
}
if (request.is_reply &&
(request.seq == -1 ||
- request.seq == envelope->get("reply")->intValue())) {
+ request.seq == envelope->get(isc::cc::CC_HEADER_REPLY)->intValue())) {
// This is the correct reply
return (true);
}
if (!request.is_reply &&
- (request.recipient.empty() ||
- request.recipient == envelope->get("group")->stringValue())) {
+ (request.recipient.empty() || request.recipient ==
+ envelope->get(isc::cc::CC_HEADER_REPLY)->stringValue())) {
// This is the correct command
return (true);
}
diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h
index 2f8dd78..bae25bc 100644
--- a/src/lib/config/ccsession.h
+++ b/src/lib/config/ccsession.h
@@ -369,8 +369,8 @@ public:
*/
int groupSendMsg(isc::data::ConstElementPtr msg,
std::string group,
- std::string instance = "*",
- std::string to = "*",
+ std::string instance = isc::cc::CC_INSTANCE_WILDCARD,
+ std::string to = isc::cc::CC_TO_WILDCARD,
bool want_answer = false) {
return (session_.group_sendmsg(msg, group, instance, to, want_answer));
};
More information about the bind10-changes
mailing list