X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=dynamic%2Flauncher%2Fgx%2F00001%2FProcedure.cpp;h=03e02eb57b3fafeee4237d1eae4d946160c2268a;hb=5a6cba5fde2b2f538a7515f8293cc0a8d9589dfa;hp=99a87fe10fe0b8b4b3a630a48298995e635ae8c0;hpb=2e2f6d4e2ffe1c8b86c812807f0e501ab78f56f9;p=anna.git diff --git a/dynamic/launcher/gx/00001/Procedure.cpp b/dynamic/launcher/gx/00001/Procedure.cpp index 99a87fe..03e02eb 100644 --- a/dynamic/launcher/gx/00001/Procedure.cpp +++ b/dynamic/launcher/gx/00001/Procedure.cpp @@ -28,8 +28,19 @@ namespace { void usage (std::string &response) { response += "\n\nInvalid arguments. Provide these ones:"; response += "\n"; + response += "\nSIGUSR2 Interface:"; response += "\n||||[|CCR-T xml file]"; response += "\n"; + response += "\nREST Interface:"; + response += "\n{"; + response += "\n \"seqI\":\"\""; + response += "\n ,\"seqF\":\"\""; + response += "\n ,\"msecsTimeout\":\"\""; + response += "\n ,\"digits\":\"\""; + response += "\n ,\"ccrI\":\"\""; + response += "\n [,\"ccrT\":\"\"]"; + response += "\n}"; + response += "\n"; response += "\nSequences are parsed when needed, over AVPs or internal values:"; response += "\n"; response += "\nSession-Id: ;;[;]"; @@ -48,7 +59,7 @@ namespace { } } -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 += "': "; @@ -97,7 +108,7 @@ void Procedure::execute(const std::string &args, std::string &response) throw(a 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"); @@ -134,7 +145,7 @@ void Procedure::execute(const std::string &args, std::string &response) throw(a ///////// CCR-Termination: if (haveTermination) { - ccrt.loadXML(ccr_t); + ccrt.loadXMLFile(ccr_t); // Session-Id & Framed-Ip-Address AVPs ccrt_sessionId = ccrt.getAvp("Session-Id"); @@ -278,8 +289,30 @@ void Procedure::execute(const std::string &args, std::string &response) throw(a } } // 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: + // ||||[|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); +} + +