void usage (std::string &response) {
response += "\n\nInvalid arguments. Provide these ones:";
response += "\n";
+ response += "\nSIGUSR2 Interface:";
response += "\n<initial sequence>|<final sequence>|<test timeout ms (0: no timeout step)>|<digits>|<CCR-I xml file>[|CCR-T xml file]";
response += "\n";
+ response += "\nREST Interface:";
+ response += "\n{";
+ response += "\n \"seqI\":\"<initial sequence>\"";
+ response += "\n ,\"seqF\":\"<final sequence>\"";
+ response += "\n ,\"msecsTimeout\":\"<test timeout ms (0: no timeout step)>\"";
+ response += "\n ,\"digits\":\"<digits>\"";
+ response += "\n ,\"ccrI\":\"<CCR-I xml file>\"";
+ response += "\n [,\"ccrT\":\"<CCR-T xml file>\"]";
+ response += "\n}";
+ response += "\n";
response += "\nSequences are parsed when needed, over AVPs or internal values:";
response += "\n";
response += "\nSession-Id: <DiameterIdentity>;<high 32 bits>;<low 32 bits>[;<optional value>]";
}
}
-void Procedure::execute(const std::string &args, std::string &response) throw(anna::RuntimeException) {
+void Procedure::execute(const std::string &args, std::string &response) noexcept(false) {
response = "Dynamic procedure failed to process '"; response += args; response += "': ";
anna::diameter::codec::Avp *ccri_originHost;
///////// CCR-Initial:
- ccri.loadXML(ccr_i);
+ ccri.loadXMLFile(ccr_i);
// Session-Id & Framed-Ip-Address AVPs
ccri_sessionId = ccri.getAvp("Session-Id");
///////// CCR-Termination:
if (haveTermination) {
- ccrt.loadXML(ccr_t);
+ ccrt.loadXMLFile(ccr_t);
// Session-Id & Framed-Ip-Address AVPs
ccrt_sessionId = ccrt.getAvp("Session-Id");
}
} // loop
- response = "Completed provision for pid "; response += anna::functions::asString(a_app->getPid()); response += "; range [";
+ response = "Completed provision: range [";
response += seq_i; response += ", "; response += seq_f; response += "]; scenary: ";
response += "CCR-Initial"; if (haveTermination) response += " + CCR-Termination";
}
+void Procedure::execute(const nlohmann::json &args, std::string &response) noexcept(false) {
+
+ // Build the arguments string and call the previous centralized logic procedure execution:
+ // <initial sequence>|<final sequence>|<test timeout ms (0: no timeout step)>|<digits>|<CCR-I xml file>[|CCR-T xml file]
+ const char *arg_names[6] = { "seqI", "seqF", "msecsTimeout", "digits", "ccrI", "ccrT" };
+ std::string args_string, arg, pipe("|");
+
+ for (int i = 0; i < 6; i++)
+ {
+ auto it = args.find(arg_names[i]);
+ arg = (it != args.end() && it->is_string()) ? *it : "";
+ if (arg != "") args_string += arg + pipe;
+ }
+
+ // Remove last 'pipe':
+ if (args_string != "")
+ args_string = args_string.substr(0, args_string.size()-1);
+
+ execute(args_string, response);
+}
+
+