1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
10 #include <sstream> // std::istringstream
11 #include <iostream> // std::cout
14 #include <anna/timex/Engine.hpp>
15 #include <anna/statistics/Engine.hpp>
16 #include <anna/diameter/codec/Engine.hpp>
17 #include <anna/http/Transport.hpp>
18 #include <anna/diameter/stack/Engine.hpp>
19 #include <anna/diameter/helpers/base/functions.hpp>
20 #include <anna/time/functions.hpp>
21 #include <anna/diameter.comm/ApplicationMessageOamModule.hpp>
22 #include <anna/xml/xml.hpp>
25 #include "Launcher.hpp"
26 #include "RealmNode.hpp"
27 #include "MyDiameterEngine.hpp"
30 #define SIGUSR2_TASKS_INPUT_FILENAME "./sigusr2.tasks.input"
31 #define SIGUSR2_TASKS_OUTPUT_FILENAME "./sigusr2.tasks.output"
34 const char *ServicesDTD = "\
35 <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
36 <!-- Diameter services DTD -->\n\
38 <!ELEMENT services (stack*, node*)>\n\
40 <!ELEMENT stack EMPTY>\n\
41 <!ATTLIST stack id CDATA #REQUIRED dictionary CDATA #REQUIRED>\n\
45 id: Normally the id corresponds to the Application-Id for which the dictionary provided is designed.\n\
46 (in multistack applications, it shall be mandatory respect such association to know the stack used\n\
47 for processed messages).\n\
48 dictionary: Path to the dictionary file\n\
51 <!ELEMENT node EMPTY>\n\
52 <!ATTLIST node originRealm CDATA #REQUIRED applicationId CDATA #REQUIRED originHost CDATA #IMPLIED cer CDATA #IMPLIED dwr CDATA #IMPLIED allowedInactivityTime CDATA #IMPLIED tcpConnectDelay CDATA #IMPLIED answersTimeout CDATA #IMPLIED ceaTimeout CDATA #IMPLIED watchdogPeriod CDATA #IMPLIED entity CDATA #IMPLIED entityServerSessions CDATA #IMPLIED diameterServer CDATA #IMPLIED diameterServerSessions CDATA #IMPLIED balance (yes | no) #IMPLIED sessionBasedModelsClientSocketSelection (SessionIdLowPart | SessionIdHighPart | SessionIdOptionalPart | RoundRobin) #IMPLIED retries CDATA #IMPLIED log CDATA #IMPLIED splitLog (yes | no) #IMPLIED detailedLog (yes | no) #IMPLIED dumpLog (yes | no) #IMPLIED burstLog (yes | no) #IMPLIED>\n\
56 originRealm: Node identifier (Origin-Realm name).\n\
57 applicationId: The Application-Id provided must exists as a registered 'stack id'.\n\
58 originHost: Diameter application host name (system name). If missing, process sets o.s. hostname\n\
59 Note that if you have two or more realms, the names must be different.\n\
60 cer: User defined CER path file to be encoded to establish diameter connections.\n\
61 If missing, will be harcoded\n\
62 dwr: User defined DWR path file to be encoded for diameter protocol keep alive.\n\
63 If missing, will be harcoded\n\
64 allowedInactivityTime: Milliseconds for the maximum allowed inactivity time on server sessions born over the\n\
65 local server before being reset. If missing, default value of 90000 will be assigned\n\
66 tcpConnectDelay: Milliseconds to wait TCP connect to any server. If missing, default value of 200 will\n\
68 answersTimeout: Milliseconds to wait pending application answers from diameter peers. If missing,\n\
69 default value of 10000 will be assigned\n\
70 ceaTimeout: Milliseconds to wait CEA from diameter server. If missing, default value of 'answersTimeout'\n\
72 watchdogPeriod: Milliseconds for watchdog timer (Tw) for diameter keep-alive procedure. If missing, default\n\
73 value of 30000 will be assigned\n\
74 entity: Target diameter entity (comma-separated '<address>:<port>' format).\n\
75 For example: 10.20.30.40:3868,10.20.30.41:3868. If missing, no entity will be enabled\n\
76 entityServerSessions: Diameter entity server sessions (0: diameter entity disabled). Default value of 1\n\
77 diameterServer: Diameter own server address in '<address>:<port>' format. For example: 10.20.30.40:3868.\n\
78 If missing, no local server will be enabled\n\
79 diameterServerSessions: Diameter own server available connections (0: diameter server disabled). Default value of 1\n\
80 balance: Balance over entity servers instead of doing standard behaviour (first primary, secondary\n\
81 if fails, etc.). Default value 'no'\n\
82 sessionBasedModelsClientSocketSelection: By default, round-robin will be applied for IEC model (SMS/MMS), and Session-Id Low Part\n\
83 will be analyzed for ECUR/SCUR model (data, voice and content). You could change ECUR/SCUR\n\
84 analysis behaviour providing 'SessionIdHighPart', 'SessionIdOptionalPart' (atoi applied;\n\
85 usually subscriber id data, i.e. MSISDN or IMSI) and 'RoundRobin' (also 'SessionIdLowPart')\n\
86 retries: Expired responses will cause a number of request retransmissions. Disabled by default (0 retries)\n\
87 log: Process log file (operations result, traffic log, etc.). By default '<originRealm>.launcher.log'.\n\
88 Empty string or \"null\" name, to disable. Warning: there is no rotation for log files\n\
89 (use logrotate or whatever you consider)\n\
90 splitLog: Splits log file (appends to log filename, extensions with the type of event: see help on\n\
91 startup information-level traces). No log files for code/decode and load operations are created.\n\
93 detailedLog: Insert detailed information at log files. Should be disabled on automatic tests. Useful on\n\
94 'balance' mode to know messages flow along the sockets. Default value 'no'\n\
95 dumpLog: Write to disk every incoming/outcoming message named as:\n\
96 '<originRealm>.<hop by hop>.<end to end>.<message code>.<request|answer>.<type of event>.xml'\n\
98 burstLog: Burst operations log file. By default '<originRealm>.launcher.burst'. Empty string or \"null\" name, to disable.\n\
99 Warning: there is no rotation for log files (use logrotate or whatever). Output: dot (.) for each\n\
100 burst message sent/pushed, cross (x) for popped ones, and order number when multiple of 1% of burst\n\
101 list size, plus OTA requests when changed\n\
108 Launcher::Launcher() : anna::comm::Application("launcher", "DiameterLauncher", "1.1"), a_communicator(NULL) {
109 a_codecEngine = new anna::diameter::codec::Engine("MyCodecEngine");
111 a_counterRecorder = NULL;
112 a_counterRecorderClock = NULL;
115 a_workingNode = NULL;
117 a_httpServerSocket = NULL;
123 void Launcher::servicesFromXML(const anna::xml::Node* servicesNode) throw(anna::RuntimeException) {
124 //<!ATTLIST stack id CDATA #REQUIRED dictionary CDATA #REQUIRED>
125 const anna::xml::Attribute *id, *dictionary;
127 // <!ATTLIST node originRealm CDATA #REQUIRED applicationId CDATA #REQUIRED originHost CDATA #IMPLIED cer CDATA #IMPLIED dwr CDATA #IMPLIED allowedInactivityTime CDATA #IMPLIED tcpConnectDelay CDATA #IMPLIED answersTimeout CDATA #IMPLIED ceaTimeout CDATA #IMPLIED watchdogPeriod CDATA #IMPLIED entity CDATA #IMPLIED entityServerSessions CDATA #IMPLIED diameterServer CDATA #IMPLIED diameterServerSessions CDATA #IMPLIED balance (yes | no) #IMPLIED sessionBasedModelsClientSocketSelection (SessionIdLowPart | SessionIdHighPart | SessionIdOptionalPart | RoundRobin) #IMPLIED retries CDATA #IMPLIED log CDATA #IMPLIED splitLog (yes | no) #IMPLIED detailedLog (yes | no) #IMPLIED dumpLog (yes | no) #IMPLIED burstLog (yes | no) #IMPLIED>
128 const anna::xml::Attribute *originRealm, *appId, *originHost, *cer, *dwr, *allowedInactivityTime, *tcpConnectDelay,
129 *answersTimeout, *ceaTimeout, *watchdogPeriod, *entity, *entityServerSessions,
130 *diameterServer, *diameterServerSessions, *balance, *sessionBasedModelsClientSocketSelection,
131 *retries, *log, *splitLog, *detailedLog, *dumpLog, *burstLog;
133 // Never clear services content from here (append new data from xml). At the moment no node removing is implemented in this process
136 anna::diameter::stack::Engine &stackEngine = anna::diameter::stack::Engine::instantiate();
137 anna::diameter::stack::Dictionary *d;
139 for(anna::xml::Node::const_child_iterator it = servicesNode->child_begin(); it != servicesNode->child_end(); it++) {
140 std::string nodeName = (*it)->getName();
142 if(nodeName == "stack") {
144 id = (*it)->getAttribute("id");
145 dictionary = (*it)->getAttribute("dictionary");
148 d = stackEngine.createDictionary(id->getIntegerValue(), dictionary->getValue());
149 getCodecEngine()->setDictionary(d);
150 } catch(anna::RuntimeException &ex) {
151 //_exit(ex.asString());
157 // Codec engine adjustments:
158 // Auto stack selection based on Application-ID:
159 bool multistack = (stackEngine.stack_size() > 1);
160 if (multistack) getCodecEngine()->selectStackWithApplicationId(true);
162 for(anna::xml::Node::const_child_iterator it = servicesNode->child_begin(); it != servicesNode->child_end(); it++) {
163 std::string nodeName = (*it)->getName();
165 if(nodeName == "node") {
167 originRealm = (*it)->getAttribute("originRealm");
168 appId = (*it)->getAttribute("applicationId");
169 originHost = (*it)->getAttribute("originHost", false /* no exception */);
170 cer = (*it)->getAttribute("cer", false /* no exception */);
171 dwr = (*it)->getAttribute("dwr", false /* no exception */);
172 allowedInactivityTime = (*it)->getAttribute("allowedInactivityTime", false /* no exception */);
173 tcpConnectDelay = (*it)->getAttribute("tcpConnectDelay", false /* no exception */);
174 answersTimeout = (*it)->getAttribute("answersTimeout", false /* no exception */);
175 ceaTimeout = (*it)->getAttribute("ceaTimeout", false /* no exception */);
176 watchdogPeriod = (*it)->getAttribute("watchdogPeriod", false /* no exception */);
177 entity = (*it)->getAttribute("entity", false /* no exception */);
178 entityServerSessions = (*it)->getAttribute("entityServerSessions", false /* no exception */);
179 diameterServer = (*it)->getAttribute("diameterServer", false /* no exception */);
180 diameterServerSessions = (*it)->getAttribute("diameterServerSessions", false /* no exception */);
181 balance = (*it)->getAttribute("balance", false /* no exception */); // (yes | no)
182 sessionBasedModelsClientSocketSelection = (*it)->getAttribute("sessionBasedModelsClientSocketSelection", false /* no exception */); // (SessionIdHighPart | SessionIdOptionalPart | RoundRobin)
183 retries = (*it)->getAttribute("retries", false /* no exception */);
184 log = (*it)->getAttribute("log", false /* no exception */);
185 splitLog = (*it)->getAttribute("splitLog", false /* no exception */); // (yes | no)
186 detailedLog = (*it)->getAttribute("detailedLog", false /* no exception */); // (yes | no)
187 dumpLog = (*it)->getAttribute("dumpLog", false /* no exception */); // (yes | no)
188 burstLog = (*it)->getAttribute("burstLog", false /* no exception */); // (yes | no)
191 if (stackEngine.getDictionary(appId->getIntegerValue()) == NULL) {
192 std::string msg = "Cannot found a registered stack id with the value of applicationId provided: "; msg += appId->getValue();
193 throw anna::RuntimeException(msg, ANNA_FILE_LOCATION);
195 realm_nodes_it nodeIt = a_nodes.find(originRealm->getValue());
196 if (nodeIt != a_nodes.end()) {
197 std::string msg = "Already registered node name (Origin-Realm): "; msg += originRealm->getValue();
198 throw anna::RuntimeException(msg, ANNA_FILE_LOCATION);
201 // Engine time measures checking & assignment:
202 anna::Millisecond allowedInactivityTimeMs(90000);
203 anna::Millisecond tcpConnectDelayMs(200);
204 anna::Millisecond answersTimeoutMs(10000);
205 anna::Millisecond ceaTimeoutMs(10000);
206 anna::Millisecond watchdogPeriodMs(30000);
208 if (allowedInactivityTime) allowedInactivityTimeMs = checkTimeMeasure("allowedInactivityTime", allowedInactivityTime->getValue());
209 if (tcpConnectDelay) tcpConnectDelayMs = checkTimeMeasure("tcpConnectDelay", tcpConnectDelay->getValue());
210 if (answersTimeout) answersTimeoutMs = checkTimeMeasure("answersTimeout", answersTimeout->getValue());
211 if (ceaTimeout) ceaTimeoutMs = checkTimeMeasure("ceaTimeout", ceaTimeout->getValue());
212 if (watchdogPeriod) watchdogPeriodMs = checkTimeMeasure("watchdogPeriod", watchdogPeriod->getValue());
214 // Checking command line parameters
215 std::string sessionBasedModelsType;
216 if(sessionBasedModelsClientSocketSelection) {
217 sessionBasedModelsType = sessionBasedModelsClientSocketSelection->getValue();
218 if((sessionBasedModelsType != "SessionIdHighPart") && (sessionBasedModelsType != "SessionIdOptionalPart") && (sessionBasedModelsType != "RoundRobin")) {
219 throw anna::RuntimeException("Parameter 'sessionBasedModelsClientSocketSelection' only accepts 'SessionIdHighPart'/'SessionIdOptionalPart'/'RoundRobin' as parameter values", ANNA_FILE_LOCATION);
223 int retransmissions = retries ? retries->getIntegerValue() : 0;
224 if(retransmissions < 0) {
225 throw anna::RuntimeException("Parameter 'retries' must be non-negative", ANNA_FILE_LOCATION);
228 // Create new Node instance /////////////////////////////////////////////////////////////////
229 a_workingNode = new RealmNode(originRealm->getValue(), appId->getIntegerValue(), a_codecEngine);
230 MyDiameterEngine *commEngine = a_workingNode->getMyDiameterEngine();
231 /////////////////////////////////////////////////////////////////////////////////////////////
234 commEngine->setMaxConnectionDelay(tcpConnectDelayMs);
235 commEngine->setWatchdogPeriod(watchdogPeriodMs);
237 // Realm information:
238 if (originHost) commEngine->setHost(originHost->getValue());
239 commEngine->setRealm(originRealm->getValue());
243 int sessions = entityServerSessions ? entityServerSessions->getIntegerValue() : 1;
246 // Number of sessions:
247 commEngine->setNumberOfClientSessionsPerServer(sessions);
249 // Client CER and DWR
250 std::string cerPathfile = cer ? cer->getValue() : "";
251 std::string dwrPathfile = dwr ? dwr->getValue() : "";
252 commEngine->setClientCERandDWR(cerPathfile, dwrPathfile);
254 // Register one entity for this engine:
255 a_workingNode->createEntity(entity->getValue(), ceaTimeoutMs, answersTimeoutMs);
256 a_workingNode->setRequestRetransmissions(retransmissions);
257 a_workingNode->getEntity()->setSessionBasedModelsType(sessionBasedModelsType);
258 a_workingNode->getEntity()->setBalance(balance ? (balance->getValue() == "yes") : false); // for sendings
264 int sessions = diameterServerSessions ? diameterServerSessions->getIntegerValue() : 1;
265 a_workingNode->startDiameterServer(diameterServer->getValue(), sessions, allowedInactivityTimeMs);
269 std::string realm = commEngine->getRealm();
270 std::string s_log = realm + ".launcher.log"; if (log) s_log = log->getValue();
271 bool b_splitLog = (splitLog ? (splitLog->getValue() == "yes") : false);
272 bool b_detailedLog = (detailedLog ? (detailedLog->getValue() == "yes") : false);
273 bool b_dumpLog = (dumpLog ? (dumpLog->getValue() == "yes") : false);
274 std::string s_burstLog = realm + ".launcher.burst"; if (burstLog) s_burstLog = burstLog->getValue();
275 a_workingNode->setLogs(s_log, b_splitLog, b_detailedLog, b_dumpLog, s_burstLog);
278 // New Node assignment //////////////////////////////////////////////////////////////////////
279 a_nodes[originRealm->getValue()] = a_workingNode;
280 /////////////////////////////////////////////////////////////////////////////////////////////
286 void Launcher::loadServices(const std::string & xmlPathFile) throw(anna::RuntimeException) {
289 std::string trace = "Loading ADML services file '";
290 trace += xmlPathFile;
292 anna::Logger::debug(trace, ANNA_FILE_LOCATION);
294 anna::xml::DocumentFile xmlDocument; // has private copy constructor defined but not implemented to avoid inhenrit/copy (is very heavy)
295 anna::xml::DTDMemory xmlDTD;
296 const anna::xml::Node *rootNode;
297 xmlDocument.initialize(xmlPathFile.c_str()); // fail here is i/o error
298 xmlDTD.initialize(ServicesDTD);
300 rootNode = xmlDocument.parse(xmlDTD); // Parsing: fail here if xml violates dtd
302 catch (anna::RuntimeException &ex) {
304 std::string msg = "Services DTD schema:\n\n";
306 anna::Logger::warning(msg, ANNA_FILE_LOCATION);
312 std::string trace = "Loaded XML file (";
313 trace += xmlPathFile;
315 trace += anna::xml::Compiler().apply(rootNode);
316 anna::Logger::debug(trace, ANNA_FILE_LOCATION);
318 servicesFromXML(rootNode);
322 anna::Millisecond Launcher::checkTimeMeasure(const std::string ¶meter, const std::string &value) throw(anna::RuntimeException) {
324 if(anna::functions::isLike("^[0-9]+$", value)) { // para incluir numeros decimales: ^[0-9]+(.[0-9]+)?$
326 std::istringstream ( value ) >> msecs;
328 if(msecs > a_timeEngine->getMaxTimeout()) { // 600000 ms
329 std::string msg = "Configuration value for '";
331 msg += "' ("; msg += value; msg += " msecs) is greater than allowed max timeout for timming engine: ";
332 msg += anna::functions::asString(a_timeEngine->getMaxTimeout());
333 throw RuntimeException(msg, ANNA_FILE_LOCATION);
337 std::string msg = "Configuration value for '";
339 msg += "' ("; msg += value; msg += " msecs) is perhaps very big (over 5 minutes).";
340 LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION));
343 if(msecs <= a_timeEngine->getResolution()) {
344 std::string msg = "Configuration value for '";
346 msg += "' ("; msg += value; msg += " msecs) as any other time measure, must be greater than timming engine resolution: ";
347 msg += anna::functions::asString(a_timeEngine->getResolution());
348 throw RuntimeException(msg, ANNA_FILE_LOCATION);
351 return (anna::Millisecond)msecs; // ok
354 // Non-integer exception:
355 std::string msg = "Configuration error for '";
359 msg += "': must be a non-negative integer number";
360 throw RuntimeException(msg, ANNA_FILE_LOCATION);
363 bool Launcher::setWorkingNode(const std::string &name) throw() {
366 realm_nodes_nc_it nodeIt = a_nodes.find(name);
367 if (nodeIt == a_nodes.end()) {
369 std::string msg = "Unknown node with name '"; msg += name; msg += "'. Ignoring ...";
370 anna::Logger::warning(msg, ANNA_FILE_LOCATION);
374 a_workingNode = nodeIt->second;
381 RealmNode *Launcher::getRealmNode(const std::string &realmName) const throw() {
382 for (realm_nodes_it it = a_nodes.begin(); it != a_nodes.end(); it++)
383 if(it->second->getMyDiameterEngine()->getRealm() == realmName) return it->second;
385 return NULL; // this never happens
388 void Launcher::initialize()
389 throw(anna::RuntimeException) {
390 anna::comm::Application::initialize();
391 CommandLine& cl(anna::CommandLine::instantiate());
392 anna::comm::Communicator::WorkMode::_v workMode(anna::comm::Communicator::WorkMode::Single);
393 a_communicator = new MyCommunicator(workMode);
395 //a_timeEngine = new anna::timex::Engine((anna::Millisecond)600000, anna::timex::Engine::minResolution);
396 a_timeEngine = new anna::timex::Engine((anna::Millisecond)600000, (anna::Millisecond)100); // puedo bajar hasta 10
398 // Counters record procedure:
399 const char *varname = "cntRecordPeriod";
400 anna::Millisecond cntRecordPeriod = (cl.exists(varname)) ? checkTimeMeasure(varname, cl.getValue(varname)) : (anna::Millisecond)300000;
401 if(cntRecordPeriod != 0) {
402 a_counterRecorderClock = new MyCounterRecorderClock("Counters record procedure clock", cntRecordPeriod); // clock
403 std::string cntDir = ".";
404 if(cl.exists("cntDir")) cntDir = cl.getValue("cntDir");
405 a_counterRecorder = new MyCounterRecorder(cntDir + anna::functions::asString("/Counters.Pid%d", (int)getPid()));
408 // Load launcher services:
409 loadServices(cl.getValue("services")); // before run (have components to be created)
411 // Show loaded stacks:
412 std::cout << "Stacks provided:" << std::endl;
413 std::cout << anna::functions::tab(anna::diameter::stack::Engine::instantiate().asString(false /* light */));
414 std::cout << std::endl;
418 throw(anna::RuntimeException) {
419 LOGMETHOD(anna::TraceMethod tm("Launcher", "run", ANNA_FILE_LOCATION));
420 CommandLine& cl(anna::CommandLine::instantiate());
421 anna::diameter::stack::Engine &stackEngine = anna::diameter::stack::Engine::instantiate();
424 a_start_time.setNow();
426 anna::statistics::Engine::instantiate().enable();
429 if(cl.exists("trace"))
430 anna::Logger::setLevel(anna::Logger::asLevel(cl.getValue("trace")));
433 // Help on startup traces:
434 anna::Logger::information(help(), ANNA_FILE_LOCATION);
435 // Test messages dtd:
436 std::string msg = "\n ------------- TESTMESSAGES DTD -------------\n";
437 msg += anna::diameter::codec::MessageDTD;
438 anna::Logger::information(msg, ANNA_FILE_LOCATION);
442 if(cl.exists("httpServer")) {
443 anna::comm::Network& network = anna::comm::Network::instantiate();
446 anna::functions::getAddressAndPortFromSocketLiteral(cl.getValue("httpServer"), address, port);
447 //const anna::comm::Device* device = network.find(Device::asAddress(address)); // here provide IP
448 const anna::comm::Device* device = *((network.resolve(address)->device_begin())); // trick to solve
449 a_httpServerSocket = new anna::comm::ServerSocket(anna::comm::INetAddress(device, port), cl.exists("httpServerShared") /* shared bind */, &anna::http::Transport::getFactory());
452 ///////////////////////////////
453 // Diameter library COUNTERS //
454 ///////////////////////////////
455 anna::diameter::comm::OamModule & oamDiameterComm = anna::diameter::comm::OamModule::instantiate();
456 oamDiameterComm.initializeCounterScope(1); // 1000 - 1999
457 oamDiameterComm.enableCounters();
458 oamDiameterComm.enableAlarms();
459 anna::diameter::codec::OamModule & oamDiameterCodec = anna::diameter::codec::OamModule::instantiate();
460 oamDiameterCodec.initializeCounterScope(2); // 2000 - 2999
461 oamDiameterCodec.enableCounters();
462 oamDiameterCodec.enableAlarms();
467 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RequestReceived, "" /* get defaults for enum type*/, 0 /*1000*/);
468 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::AnswerReceived, "", 1 /*1001*/);
469 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RequestReceivedOnClientSession, "", 2 /*1002*/);
470 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::AnswerReceivedOnClientSession, "", 3 /*1003*/);
471 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RequestReceivedOnServerSession, "", 4 /* etc. */);
472 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::AnswerReceivedOnServerSession, "", 5);
473 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RequestSentOK, "", 6);
474 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RequestSentNOK, "", 7);
475 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::AnswerSentOK, "", 8);
476 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::AnswerSentNOK, "", 9);
477 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RequestSentOnClientSessionOK, "", 10);
478 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RequestSentOnClientSessionNOK, "", 11);
479 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::AnswerSentOnClientSessionOK, "", 12);
480 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::AnswerSentOnClientSessionNOK, "", 13);
481 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RequestSentOnServerSessionOK, "", 14);
482 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RequestSentOnServerSessionNOK, "", 15);
483 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::AnswerSentOnServerSessionOK, "", 16);
484 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::AnswerSentOnServerSessionNOK, "", 17);
485 /* Diameter Base (capabilities exchange & keep alive) */
487 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::CERSentOK, "", 18);
488 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::CERSentNOK, "", 19);
489 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::CEAReceived, "", 20);
490 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::DWRSentOK, "", 21);
491 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::DWRSentNOK, "", 22);
492 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::DWAReceived, "", 23);
493 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::DPRSentOK, "", 24);
494 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::DPRSentNOK, "", 25);
495 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::DPAReceived, "", 26);
497 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::CERReceived, "", 27);
498 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::CEASentOK, "", 28);
499 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::CEASentNOK, "", 29);
500 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::DWRReceived, "", 30);
501 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::DWASentOK, "", 31);
502 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::DWASentNOK, "", 32);
503 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::DPRReceived, "", 33);
504 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::DPASentOK, "", 34);
505 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::DPASentNOK, "", 35);
506 /* server socket operations (enable/disable listening port for any local server) */
507 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::ServerSocketsOpened, "", 36);
508 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::ServerSocketsClosed, "", 37);
511 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::UnableToDeliverOverEntity, "", 38);
512 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::LostAvailabilityOverClientSession, "", 39);
513 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RecoveredAvailabilityOverClientSession, "", 40);
514 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::LostAvailabilityOverServer, "", 41);
515 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RecoveredAvailabilityOverServer, "", 42);
516 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::LostAvailabilityOverEntity, "", 43);
517 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RecoveredAvailabilityOverEntity, "", 44);
518 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::LostAvailabilityOverEngineForEntities, "", 45);
519 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RecoveredAvailabilityOverEngineForEntities, "", 46);
521 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::UnableToDeliverToClient, "", 47);
522 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::LostConnectionForServerSession, "", 48);
523 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::UnbindConnectionForServerSessionDueToInactivityTimeAnomaly, "", 49);
524 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::CreatedConnectionForServerSession, "", 50);
525 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::LostAvailabilityOverLocalServer, "", 51);
526 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RecoveredAvailabilityOverLocalServer, "", 52);
527 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::LostAvailabilityOverEngineForLocalServers, "", 53);
528 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RecoveredAvailabilityOverEngineForLocalServers, "", 54);
529 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RequestSentExpired, "", 55);
530 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RequestSentOnClientSessionExpired, "", 56);
531 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::RequestSentOnServerSessionExpired, "", 57);
532 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::AnswerReceivedUnknown, "", 58);
533 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::AnswerReceivedOnClientSessionUnknown, "", 59);
534 oamDiameterComm.registerCounter(anna::diameter::comm::OamModule::Counter::AnswerReceivedOnServerSessionUnknown, "", 60);
539 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::AvpDecode__NotEnoughBytesToCoverAvpHeaderLength, "", 0 /*2000*/);
540 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::AvpDecode__IncoherenceBetweenActivatedVBitAndZeroedVendorIDValueReceived, "", 1 /*2001*/);
541 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::AvpDecode__IncorrectLength, "", 2 /*2002*/);
542 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::AvpDecode__DataPartInconsistence, "", 3 /*2003*/);
543 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::AvpDecode__UnknownAvpWithMandatoryBit, "", 4 /*2004*/);
544 /* Message decoding */
545 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::MessageDecode__NotEnoughBytesToCoverMessageHeaderLength, "", 5 /*2005*/);
546 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::MessageDecode__NotEnoughBytesToCoverMessageLength, "", 6 /*2006*/);
548 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::AvpValidation__EnumeratedAvpWithValueDoesNotComplyRestriction, "", 10 /*2010*/);
549 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::AvpValidation__AvpFlagsDoesNotFulfillTheDefinedFlagRules, "", 11 /*2011*/);
550 /* Message validation */
551 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::MessageValidation__UnknownOperationUnableToValidate, "", 12 /*2012*/);
552 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::MessageValidation__OperationHaveIncoherentFlags, "", 13 /*2013*/);
553 /* Level validation */
554 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::LevelValidation__MissingFixedRule, "", 14 /*2014*/);
555 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::LevelValidation__FailedRuleForCardinality, "", 15 /*2015*/);
556 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::LevelValidation__FailedRuleForCardinalityLessThanNeeded, "", 16 /*2016*/);
557 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::LevelValidation__FailedRuleForCardinalityMoreThanNeeded, "", 17 /*2017*/);
558 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::LevelValidation__FailedGenericAvpRuleForCardinalityFoundDisregardedItem, "", 18 /*2018*/);
559 oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::LevelValidation__FoundDisregardedItemsAndGenericAVPWasNotSpecified, "", 19 /*2019*/);
560 ///////////////////////////////////////////
561 // APPLICATION MESSAGE OAM MODULE SCOPES //
562 ///////////////////////////////////////////
563 // We will register a scope per stack id registered. The counters will be dynamically registered at count method.
564 anna::diameter::comm::ApplicationMessageOamModule & appMsgOamModule = anna::diameter::comm::ApplicationMessageOamModule::instantiate();
566 for (anna::diameter::stack::Engine::const_stack_iterator it = stackEngine.stack_begin(); it != stackEngine.stack_end(); it++) {
567 appMsgOamModule.createStackCounterScope(scope_id, it->first);
570 appMsgOamModule.enableCounters(); // this special module is disabled by default (the only)
574 /////////////////////////////////
575 // Counter recorder associated //
576 /////////////////////////////////
577 if(a_counterRecorderClock) {
578 oamDiameterComm.setCounterRecorder(a_counterRecorder);
579 oamDiameterCodec.setCounterRecorder(a_counterRecorder);
580 appMsgOamModule.setCounterRecorder(a_counterRecorder);
581 a_timeEngine->activate(a_counterRecorderClock); // start clock
585 // Integration (validation 'Complete' for receiving messages) and debugging (validation also before encoding: 'Always').
586 // If missing 'integrationAndDebugging', default behaviour at engine is: mode 'AfterDecoding', depth 'FirstError':
587 if(cl.exists("integrationAndDebugging")) {
588 getCodecEngine()->setValidationMode(anna::diameter::codec::Engine::ValidationMode::Always);
589 getCodecEngine()->setValidationDepth(anna::diameter::codec::Engine::ValidationDepth::Complete);
593 if(cl.exists("fixMode")) { // BeforeEncoding(default), AfterDecoding, Always, Never
594 std::string fixMode = cl.getValue("fixMode");
595 anna::diameter::codec::Engine::FixMode::_v fm;
596 if (fixMode == "BeforeEncoding") fm = anna::diameter::codec::Engine::FixMode::BeforeEncoding;
597 else if (fixMode == "AfterDecoding") fm = anna::diameter::codec::Engine::FixMode::AfterDecoding;
598 else if (fixMode == "Always") fm = anna::diameter::codec::Engine::FixMode::Always;
599 else if (fixMode == "Never") fm = anna::diameter::codec::Engine::FixMode::Never;
600 else LOGINFORMATION(anna::Logger::information("Unreconized command-line fix mode. Assumed default 'BeforeEncoding'", ANNA_FILE_LOCATION));
601 getCodecEngine()->setFixMode(fm);
604 getCodecEngine()->ignoreFlagsOnValidation(cl.exists("ignoreFlags"));
607 // Log statistics concepts
608 if(cl.exists("logStatisticSamples")) {
609 std::string list = cl.getValue("logStatisticSamples");
610 anna::statistics::Engine &statEngine = anna::statistics::Engine::instantiate();
613 if(statEngine.enableSampleLog(/* -1: all concepts */))
614 LOGDEBUG(anna::Logger::debug("Sample log activation for all statistic concepts", ANNA_FILE_LOCATION));
617 lst.apply(cl.getValue("logStatisticSamples"), ",");
619 if(lst.size() >= 1) {
620 anna::Tokenizer::const_iterator tok_min(lst.begin());
621 anna::Tokenizer::const_iterator tok_max(lst.end());
622 anna::Tokenizer::const_iterator tok_iter;
625 for(tok_iter = tok_min; tok_iter != tok_max; tok_iter++) {
626 conceptId = atoi(anna::Tokenizer::data(tok_iter));
628 if(statEngine.enableSampleLog(conceptId))
629 LOGDEBUG(anna::Logger::debug(anna::functions::asString("Sample log activation for statistic concept id = %d", conceptId), ANNA_FILE_LOCATION));
636 // Start client connections //////////////////////////////////////////////////////////////////////////////////
637 MyDiameterEntity *entity;
638 for (realm_nodes_it it = a_nodes.begin(); it != a_nodes.end(); it++) {
639 entity = it->second->getEntity();
640 if (entity) entity->bind();
644 // Go into communicator poll
645 // Reconnection period (tcp reconnect retry time):
646 const char *varname = "reconnectionPeriod";
647 anna::Millisecond reconnectionPeriod = (cl.exists(varname)) ? checkTimeMeasure(varname, cl.getValue(varname)) : (anna::Millisecond)10000;
649 a_communicator->setRecoveryTime(reconnectionPeriod);
650 if(cl.exists("httpServer")) a_communicator->attach(a_httpServerSocket); // HTTP
651 a_communicator->accept();
654 bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) const throw() {
656 static char buffer[8192];
657 std::ifstream infile(pathfile.c_str(), std::ifstream::in);
659 if(infile.is_open()) {
661 std::string hexString(buffer, strlen(buffer));
662 // Allow colon separator in hex string: we have to remove them before processing with 'fromHexString':
663 hexString.erase(std::remove(hexString.begin(), hexString.end(), ':'), hexString.end());
665 std::string msg = "Hex string (remove colons if exists): ";
667 anna::Logger::debug(msg, ANNA_FILE_LOCATION);
669 anna::functions::fromHexString(hexString, db);
678 void Launcher::resetStatistics() throw() {
679 getWorkingNode()->getMyDiameterEngine()->resetStatistics();
682 void Launcher::resetCounters() throw() {
683 anna::diameter::comm::OamModule::instantiate().resetCounters();
684 anna::diameter::comm::ApplicationMessageOamModule::instantiate().resetCounters();
685 anna::diameter::codec::OamModule::instantiate().resetCounters();
688 void Launcher::signalUSR2() throw(anna::RuntimeException) {
690 std::string msg = "Captured signal SIGUSR2. Reading tasks at '";
691 msg += SIGUSR2_TASKS_INPUT_FILENAME;
692 msg += "' (results will be written at '";
693 msg += SIGUSR2_TASKS_OUTPUT_FILENAME;
695 anna::Logger::notice(msg, ANNA_FILE_LOCATION);
699 std::string response_content;
700 std::ifstream in_file(SIGUSR2_TASKS_INPUT_FILENAME);
701 std::ofstream out_file(SIGUSR2_TASKS_OUTPUT_FILENAME);
703 if(!in_file.is_open()) throw RuntimeException("Unable to read tasks", ANNA_FILE_LOCATION);
705 if(!out_file.is_open()) throw RuntimeException("Unable to write tasks", ANNA_FILE_LOCATION);
707 while(getline(in_file, line)) {
709 std::string msg = "Processing line: ";
711 anna::Logger::debug(msg, ANNA_FILE_LOCATION);
715 eventOperation(line, response_content);
716 } catch(RuntimeException &ex) {
720 out_file << response_content;
727 std::string Launcher::help() const throw() {
728 std::string result = "\n";
729 result += "\n ------------- HELP -------------\n";
731 result += "\nOVERVIEW";
732 result += "\n--------";
734 result += "\nThe ADML (ANNA Diameter Multirealm Launcher) process is a multi-realm node with client and server";
735 result += "\n capabilities as well as balancer (proxy) features. It could be used as diameter server (i.e. to";
736 result += "\n simulate PCRF nodes, OCS systems, etc.), as diameter client (GGSNs, DPIs, etc.), and balancer";
737 result += "\n systems to provide failover to external round-robin launchers. Also, auxiliary encoder/decoder/loader";
738 result += "\n function could be deployed to reinterpret certain external flow and send it to another process.";
740 result += "\nThe ANNA::diameter_comm built-in module provides a great set of characteristics as multiple connections";
741 result += "\n on both server and client side, definition for multiple-server entities (and not only two as standard";
742 result += "\n establish as minimum), separate statistics analyzer per each resource, automatic CER/CEA and DWR/DWA";
743 result += "\n generation, expiration control and many more features.";
745 result += "\nThe ADML process can easily configure a many realm nodes as needed, which will have own endpoints.";
746 result += "\nYou should avoid loop configurations (client and server for that client) because automatic forwarding,";
747 result += "\n is implemented and this would get in a never ending cycle when a request is sent.";
749 result += "\nProcess traces are dump on \"launcher.trace\" and could have any trace level (POSIX levels), usually";
750 result += "\n 'debug' or 'warning'. See ANNA documentation for more details.";
752 result += "\nAs any other ANNA process, context dump could be retrieved sending SIGUSR1 signal:";
753 result += "\n kill -10 <pid>";
755 result += "\n kill -s SIGUSR1 <pid>";
756 result += "\n and then";
757 result += "\n vi /var/tmp/anna.context.<pid>";
759 result += "\nA complete xml report will show all the context information (counters, alarms, statistics,";
760 result += "\n handlers, diameter stacks, etc.), and a powerful log module could dump all the events";
761 result += "\n processed and flow information. Statistics could be analized at context dump and optionally";
762 result += "\n written to disk as sample files (useful for graphs and spreadsheet reports) with all the";
763 result += "\n measurements.";
765 result += "\nAlso SIGUSR2 is handled for management purposes. We will talk later about this.";
768 result += "\nCOMMAND LINE";
769 result += "\n------------";
771 result += "\nStart the launcher process without arguments in order to see all the startup configuration";
772 result += "\n posibilities, many of which could be modified on the air through the management interface";
773 result += "\n (we will talk later about this great feature). Some of the more common parameters are:";
775 result += "\nAs mandatory, the stacks enabled given through the applicationId and the xml dictionary:";
776 result += "\n --stacks <appid1,dictionary1#appid2,dictionary2#...#appidN,dictionaryN>";
778 result += "\nActing as a diameter server (accepting i.e. 10 connections), you would have:";
779 result += "\n --diameterServer localhost:3868 --diameterServerSessions 10 --entityServerSessions 0";
781 result += "\nActing as a diameter client (launching i.e. 10 connections to each entity server), you would have:";
782 result += "\n --entity 192.168.12.11:3868,192.168.12.21:3868 --entityServerSessions 10 --diameterServerSessions 0";
784 result += "\nIf you act as a proxy or a translation agent, you need to combine both former setups, and probably";
785 result += "\n will need to program the answers to be replied through the operations interface. To balance the";
786 result += "\n traffic at your client side you shall use '--balance' and '--sessionBasedModelsClientSocketSelection'";
787 result += "\n arguments in order to define the balancing behaviour.";
789 result += "\nThe process builds automatically CER and DWR messages as a client, but you could specify your own";
790 result += "\n customized ones using '--cer <xml message file>' and '--dwr <xml message file>'.";
791 result += "\nThe process builds automatically CEA and DWA messages as a server, but you could program your own";
792 result += "\n customized ones using operations interface.";
795 result += "\nDYNAMIC OPERATIONS";
796 result += "\n------------------";
798 result += "\nADML supports several operations which could be reconized via HTTP interface or SIGUSR2 caugh.";
799 result += "\nAn operation is specified by mean a string containing the operation name and needed arguments";
800 result += "\n separated by pipes. These are the available commands:";
802 result += "\n--------------------------------------------------------------------------------------- General purpose";
804 result += "\nhelp This help. Startup information-level traces also dump this help.";
806 result += "\n---------------------------------------------------------------------------------------- Node selection";
808 result += "\nnode[|<name>] Select current working node by mean the registered name.";
809 result += "\n All the subsequent operations will be referred to this node.";
810 result += "\n Without argument, the current node is dumped on stdout.";
812 result += "\n------------------------------------------------------------------------------------ Parsing operations";
814 result += "\ncode|<source_file>|<target_file> Encodes source file (pathfile) into target file (pathfile).";
815 result += "\ndecode|<source_file>|<target_file> Decodes source file (pathfile) into target file (pathfile).";
816 result += "\nloadxml|<source_file> Reinterpret xml source file (pathfile).";
818 result += "\n------------------------------------------------------------------------------------------- Hot changes";
820 result += "\ndiameterServerSessions|<integer> Updates the maximum number of accepted connections to diameter";
821 result += "\n server socket.";
822 result += "\ncontext[|target file] Application context could also be written by mean this operation,";
823 result += "\n and not only through SIGUSR1. If optional path file is missing,";
824 result += "\n default '/var/tmp/anna.context.<pid>' will be used.";
825 result += "\ncollect Reset statistics and counters to start a new test stage of";
826 result += "\n performance measurement. Context data can be written at";
827 result += "\n '/var/tmp/anna.context.<pid>' by mean 'kill -10 <pid>'";
828 result += "\n or sending operation 'context|[target file]'.";
829 result += "\nforceCountersRecord Forces dump to file the current counters of the process.";
831 result += "\n<visibility action>[|<address>:<port>][|socket id]";
833 result += "\n Actions: hide, show (update state) and hidden, shown (query state).";
834 result += "\n Acts over a client session for messages delivery (except CER/A, DWR/A, DPR/A).";
835 result += "\n If missing server (first parameter) all applications sockets will be affected.";
836 result += "\n If missing socket (second parameter) for specific server, all its sockets will be affected.";
838 result += "\n All application client sessions are shown on startup, but standard delivery only use primary";
839 result += "\n server ones except if fails. Balance configuration use all the allowed sockets. You could also";
840 result += "\n use command line 'sessionBasedModelsClientSocketSelection' to force traffic flow over certain";
841 result += "\n client sessions, but for this, hide/show feature seems easier.";
843 result += "\n--------------------------------------------------------------------------------------- Flow operations";
845 result += "\nsendxml2e|<source_file> Sends xml source file (pathfile) through configured entity.";
846 result += "\nsendxml2c|<source_file> Sends xml source file (pathfile) to client.";
847 result += "\nsendxml|<source_file> Same as 'sendxml2e'.";
848 result += "\nanswerxml2e[|source_file] Answer xml source file (pathfile) for incoming request with same code from entity.";
849 result += "\n The answer is stored in a FIFO queue for a specific message code, then there are";
850 result += "\n as many queues as different message codes have been programmed.";
851 result += "\nanswerxml2c[|source_file] Answer xml source file (pathfile) for incoming request with same code from client.";
852 result += "\n The answer is stored in a FIFO queue for a specific message code, then there are";
853 result += "\n as many queues as different message codes have been programmed.";
854 result += "\nanswerxml[|source_file] Same as 'answerxml2c'.";
855 result += "\nanswerxml(2e/2c) List programmed answers (to entity/client) if no parameter provided.";
856 result += "\nanswerxml(2e/2c)|dump Write programmed answers (to entity/client) to file 'programmed_answer.<message code>.<sequence>',";
857 result += "\n where 'sequence' is the order of the answer in each FIFO code-queue of programmed answers.";
858 result += "\nanswerxml(2e/2c)|clear Clear programmed answers (to entity/client).";
859 result += "\nanswerxml(2e/2c)|exhaust Disable the corresponding queue rotation, which is the default behaviour.";
860 result += "\nanswerxml(2e/2c)|rotate Enable the corresponding queue rotation, useful in performance tests.";
861 result += "\n Rotation consists in add again to the queue, each element retrieved for answering.";
863 result += "\nSend operations are available using hexadecimal content (hex formatted files) which also allow to test";
864 result += "\nspecial scenarios (protocol errors):";
866 result += "\nsendhex2e|<source_file> Sends hex source file (pathfile) through configured entity.";
867 result += "\nsendhex2c|<source_file> Sends hex source file (pathfile) to client.";
868 result += "\nsendhex|<source_file> Same as 'sendhex2e'.";
870 result += "\nAnswer programming in hexadecimal is not really neccessary (you could use send primitives) and also";
871 result += "\n is intended to be used with decoded messages in order to replace things like hop by hop, end to end,";
872 result += "\n subscriber id, session id, etc. Anyway you could use 'decode' operation and then program the xml created.";
874 result += "\nIf a request is received, answer map (built with 'answerxml<[2c] or 2e>' operations) will be";
875 result += "\n checked to find a corresponding programmed answer to be replied(*). If no ocurrence is found,";
876 result += "\n or answer message was received, the message is forwarded to the other side (entity or client),";
877 result += "\n or nothing but trace when no peer at that side is configured. Answer to client have sense when";
878 result += "\n diameter server socket is configured, answer to entity have sense when entity does.";
880 result += "\nIn the most complete situation (process with both client and server side) there are internally";
881 result += "\n two maps with N FIFO queues, one for each different message code within programmed answers.";
882 result += "\nOne map is for answers towards the client, and the other is to react entity requests. Then in";
883 result += "\n each one we could program different answers corresponding to different request codes received.";
885 result += "\n(*) sequence values (hop-by-hop and end-to-end), Session-Id and Subscription-Id avps, are mirrored";
886 result += "\n to the peer which sent the request. If user wants to test a specific answer without changing it,";
887 result += "\n use sendxml/sendhex operations better than programming.";
889 result += "\nBalance ('--balance' command line parameter) could be used to forward server socket receptions through";
890 result += "\n entity servers by mean a round-robin algorithm. Both diameter server socket and entity targets should";
891 result += "\n have been configured, that is to say: launcher acts as client and server. If no balance is used, an";
892 result += "\n standard delivery is performed: first primary entity server, secondary when fails, etc.";
894 result += "\n--------------------------------------------------------------------------- Processing types (log tags)";
896 result += "\nUsed as log file extensions (when '--splitLog' is provided on command line) and context preffixes on log";
897 result += "\n details when unique log file is dumped:";
899 result += "\n [sent2e/send2eError] Send to entity (success/error)";
900 result += "\n [sent2c/send2cError] Send to client (success/error)";
901 result += "\n [fwd2e/fwd2eError] Forward to entity a reception from client (success/error)";
902 result += "\n [fwd2c/fwd2cError] Forward to client a reception from entity (success/error)";
903 result += "\n [recvfc] Reception from client";
904 result += "\n [recvfe] Reception from entity";
905 result += "\n [req2c-expired] A request sent to client has been expired";
906 result += "\n [req2e-expired] A request sent to entity has been expired";
907 result += "\n [recvfc-ans-unknown] Reception from client of an unknown answer (probably former [req2c-expired]";
908 result += "\n has been logged)";
909 result += "\n [recvfe-ans-unknown] Reception from entity of an unknown answer (probably former [req2e-expired]";
910 result += "\n has been logged)";
911 result += "\n [retry] Request retransmission";
913 result += "\n-------------------------------------------------------------------------------------------- Load tests";
915 result += "\nburst|<action>[|parameter] Used for performance testing, we first program diameter requests";
916 result += "\n messages in order to launch them from client side to the configured";
917 result += "\n diameter entity. We could start the burst with an initial load";
918 result += "\n (non-asynchronous sending), after this, a new request will be sent";
919 result += "\n per answer received or expired context. There are 10 actions: clear,";
920 result += "\n load, start, push, pop, stop, repeat, send, goto and look.";
922 result += "\n burst|clear Clears all loaded burst messages.";
923 result += "\n burst|load|<source_file> Loads the next diameter message into launcher burst.";
924 result += "\n burst|start|<initial load> Starts (or restarts if already in progress) the message sending with";
925 result += "\n a certain initial load.";
926 result += "\n burst|push|<load amount> Sends specific non-aynchronous load.";
927 result += "\n burst|pop|<release amount> Skip send burst messages in order to reduce over-the-air requests.";
928 result += "\n Popping all OTA requests implies burst stop because no more answer";
929 result += "\n will arrive to the process. Burst output file (--burstLog command";
930 result += "\n line parameter) shows popped messages with crosses (x). Each cross";
931 result += "\n represents one received answer for which no new request is sent.";
932 result += "\n burst|stop Stops the burst cycle. You can resume pushing 1 load amount.";
933 result += "\n burst|repeat[|[yes]|no] Restarts the burst launch when finish. If initial load or push load";
934 result += "\n amount is greater than burst list size, they will be limited when";
935 result += "\n the list is processed except when repeat mode is enabled.";
936 result += "\n burst|send|<amount> Sends messages from burst list. The main difference with start/push";
937 result += "\n operations is that burst won't be awaken. Externally we could control";
938 result += "\n sending time (no request will be sent for answers).";
939 result += "\n burst|goto|<order> Updates current burst pointer position.";
940 result += "\n burst|look|<order> Show programmed burst message for order provided.";
943 result += "\nUSING OPERATIONS INTERFACE";
944 result += "\n--------------------------";
946 result += "\n------------------------------------------------------------------------- Operations via HTTP interface";
948 result += "\nAll the operations described above can be used through the optional HTTP interface. You only have";
949 result += "\n to define the http server at the command line with something like: '--httpServer localhost:9000'.";
950 result += "\nTo send the task, we shall build the http request body with the operation string. Some examples";
951 result += "\n using curl client could be:";
953 result += "\n curl -m 1 --data \"diameterServerSessions|4\" localhost:9000";
954 result += "\n curl -m 1 --data \"code|ccr.xml\" localhost:9000";
955 result += "\n curl -m 1 --data \"decode|ccr.hex\" localhost:9000";
956 result += "\n curl -m 1 --data \"sendxml2e|ccr.xml\" localhost:9000";
959 result += "\n------------------------------------------------------------------------- Operations via SIGUSR2 signal";
961 result += "\nThe alternative using SIGUSR2 signal requires the creation of the task(s) file which will be read at";
962 result += "\n signal event:";
963 result += "\n echo \"<<operation>\" > "; result += SIGUSR2_TASKS_INPUT_FILENAME;
965 result += "\n kill -12 <pid>";
967 result += "\n kill -s SIGUSR2 <pid>";
968 result += "\n and then see the results:";
969 result += "\n cat "; result += SIGUSR2_TASKS_OUTPUT_FILENAME;
971 result += "\nYou could place more than one line (task) in the input file. Output reports will be appended in that";
972 result += "\n case over the output file. Take into account that all the content of the task file will be executed";
973 result += "\n sinchronously by the process. If you are planning traffic load, better use the asynchronous http";
974 result += "\n interface.";
980 void Launcher::eventOperation(const std::string &operation, std::string &response_content) throw(anna::RuntimeException) {
981 LOGMETHOD(anna::TraceMethod tm("Launcher", "eventOperation", ANNA_FILE_LOCATION));
982 CommandLine& cl(anna::CommandLine::instantiate());
983 LOGDEBUG(anna::Logger::debug(operation, ANNA_FILE_LOCATION));
984 response_content = "Operation processed with exception. See traces\n"; // supposed
985 std::string result = "";
986 anna::DataBlock db_aux(true);
987 anna::diameter::codec::Message codecMsg(getCodecEngine());
988 MyDiameterEntity *entity = getWorkingNode()->getEntity();
989 MyDiameterEngine *commEngine = getWorkingNode()->getMyDiameterEngine();
990 MyLocalServer *localServer = getWorkingNode()->getDiameterServer();
992 ///////////////////////////////////////////////////////////////////
993 // Simple operations without arguments:
996 if(operation == "help") {
997 std::string s_help = help();
998 std::cout << s_help << std::endl;
999 LOGINFORMATION(anna::Logger::information(s_help, ANNA_FILE_LOCATION));
1000 response_content = "Help dumped on stdout and information-level traces (launcher.trace file)\n";
1004 // Reset performance data:
1005 if(operation == "collect") {
1008 response_content = "All process counters & statistic information have been reset\n";
1012 // Counters dump on demand:
1013 if(operation == "forceCountersRecord") {
1014 forceCountersRecord();
1015 response_content = "Current counters have been dump to disk\n";
1019 ///////////////////////////////////////////////////////////////////
1020 // Tokenize operation
1022 params.apply(operation, "|");
1023 int numParams = params.size() - 1;
1025 // No operation has more than 2 arguments ...
1027 LOGWARNING(anna::Logger::warning(help(), ANNA_FILE_LOCATION));
1028 throw anna::RuntimeException("Wrong body content format on HTTP Request", ANNA_FILE_LOCATION);
1031 // Get the operation type:
1032 Tokenizer::const_iterator tok_iter = params.begin();
1033 std::string opType = Tokenizer::data(tok_iter);
1034 // Check the number of parameters:
1035 bool wrongBody = false;
1037 if((opType == "node") && (numParams > 1)) wrongBody = true;
1039 if(((opType == "code") || (opType == "decode")) && (numParams != 2)) wrongBody = true;
1041 if(((opType == "sendxml") || (opType == "sendxml2e") || (opType == "sendhex") || (opType == "sendhex2e")) && (numParams != 1)) wrongBody = true;
1043 if((opType == "burst") && (numParams < 1)) wrongBody = true;
1045 if(((opType == "sendxml2c") || (opType == "sendhex2c") || (opType == "loadxml") || (opType == "diameterServerSessions")) && (numParams != 1)) wrongBody = true;
1049 std::string msg = "Wrong body content format on HTTP Request for '";
1051 msg += "' operation (missing parameter/s)";
1052 throw anna::RuntimeException(msg, ANNA_FILE_LOCATION);
1056 std::string param1, param2;
1058 if(numParams >= 1) { tok_iter++; param1 = Tokenizer::data(tok_iter); }
1060 if(numParams == 2) { tok_iter++; param2 = Tokenizer::data(tok_iter); }
1063 if(opType == "context") {
1064 std::string contextFile = ((numParams == 1) ? param1 : anna::functions::asString("/var/tmp/anna.context.%05d", getPid()));
1065 writeContext(contextFile);
1066 response_content = anna::functions::asString("Context dumped on file '%s'\n", contextFile.c_str());
1071 if(opType == "node") {
1073 if (setWorkingNode(param1)) response_content = anna::functions::asString("Current node is now '%s'\n", param1.c_str());
1076 std::cout << getWorkingNode()->asXMLString() << std::endl;
1081 if(opType == "code") {
1082 codecMsg.loadXML(param1);
1083 std::string hexString = anna::functions::asHexString(codecMsg.code());
1085 std::ofstream outfile(param2.c_str(), std::ifstream::out);
1086 outfile.write(hexString.c_str(), hexString.size());
1088 } else if(opType == "decode") {
1089 // Get DataBlock from file with hex content:
1090 if(!getDataBlockFromHexFile(param1, db_aux))
1091 throw anna::RuntimeException("Error reading hex file provided", ANNA_FILE_LOCATION);
1094 try { codecMsg.decode(db_aux); } catch(anna::RuntimeException &ex) { ex.trace(); }
1096 std::string xmlString = codecMsg.asXMLString();
1098 std::ofstream outfile(param2.c_str(), std::ifstream::out);
1099 outfile.write(xmlString.c_str(), xmlString.size());
1101 } else if((opType == "hide") || (opType == "show") || (opType == "hidden") || (opType == "shown")) {
1102 if(!entity) throw anna::RuntimeException("No entity configured to send messages", ANNA_FILE_LOCATION);
1106 std::string key = param1;
1110 if(opType == "hide") commEngine->findClientSession(key)->hide();
1112 if(opType == "show") commEngine->findClientSession(key)->show();
1114 if(opType == "hidden") result = commEngine->findClientSession(key)->hidden() ? "true" : "false";
1116 if(opType == "shown") result = commEngine->findClientSession(key)->shown() ? "true" : "false";
1118 std::string address;
1120 anna::functions::getAddressAndPortFromSocketLiteral(param1, address, port);
1122 if(opType == "hide") commEngine->findServer(address, port)->hide();
1124 if(opType == "show") commEngine->findServer(address, port)->show();
1126 if(opType == "hidden") result = commEngine->findServer(address, port)->hidden() ? "true" : "false";
1128 if(opType == "shown") result = commEngine->findServer(address, port)->shown() ? "true" : "false";
1131 if(opType == "hide") entity->hide();
1133 if(opType == "show") entity->show();
1135 if(opType == "hidden") result = entity->hidden() ? "true" : "false";
1137 if(opType == "shown") result = entity->shown() ? "true" : "false";
1139 } else if((opType == "sendxml") || (opType == "sendxml2e") || (opType == "sendhex") || (opType == "sendhex2e")) {
1140 if(!entity) throw anna::RuntimeException("No entity configured to send the message", ANNA_FILE_LOCATION);
1141 anna::diameter::comm::Message *msg = getWorkingNode()->createCommMessage();
1143 if((opType == "sendxml") || (opType == "sendxml2e")) {
1144 codecMsg.loadXML(param1);
1146 try { codecMsg.valid(); } catch(anna::RuntimeException &ex) { ex.trace(); } // at least we need to see validation errors although it will continue sending (see validation mode configured in launcher)
1148 msg->setBody(codecMsg.code());
1150 // Get DataBlock from file with hex content:
1151 if(!getDataBlockFromHexFile(param1, db_aux))
1152 throw anna::RuntimeException("Error reading hex file provided", ANNA_FILE_LOCATION);
1154 msg->setBody(db_aux);
1157 bool success = entity->send(msg, cl.exists("balance"));
1158 getWorkingNode()->releaseCommMessage(msg);
1161 if(getWorkingNode()->logEnabled()) {
1162 anna::diameter::comm::Server *usedServer = entity->getLastUsedResource();
1163 anna::diameter::comm::ClientSession *usedClientSession = usedServer ? usedServer->getLastUsedResource() : NULL;
1164 std::string detail = usedClientSession ? usedClientSession->asString() : "<null client session>"; // esto no deberia ocurrir
1165 getWorkingNode()->writeLogFile(codecMsg, (success ? "sent2e" : "send2eError"), detail);
1167 } else if((opType == "burst")) {
1168 if(!entity) throw anna::RuntimeException("No entity configured to use burst feature", ANNA_FILE_LOCATION);
1170 // burst|clear clears all loaded burst messages.
1171 // burst|load|<source_file> loads the next diameter message into launcher burst.
1172 // burst|start|<initial load> starts the message sending with a certain initial load.
1173 // burst|push|<load amount> sends specific non-aynchronous load.
1174 // burst|stop stops the burst cycle.
1175 // burst|repeat|[[yes]|no] restarts the burst launch when finish.
1176 // burst|send|<amount> send messages from burst list. The main difference with
1177 // start/push operations is that burst won't be awaken.
1178 // Externally we could control sending time (no request
1179 // will be sent for answers).
1180 // burst|goto|<order> Updates current burst pointer position.
1181 // burst|look|<order> Show programmed burst message for order provided.
1183 if(param1 == "clear") {
1184 result = "Removed ";
1185 result += anna::functions::asString(getWorkingNode()->clearBurst());
1186 result += " elements.";
1187 } else if(param1 == "load") {
1188 if(param2 == "") throw anna::RuntimeException("Missing xml path file for burst load operation", ANNA_FILE_LOCATION);
1190 codecMsg.loadXML(param2);
1192 if(codecMsg.isAnswer()) throw anna::RuntimeException("Cannot load diameter answers for burst feature", ANNA_FILE_LOCATION);
1193 try { codecMsg.valid(); } catch(anna::RuntimeException &ex) { ex.trace(); } // at least we need to see validation errors although it will continue loading (see validation mode configured in launcher)
1195 int position = getWorkingNode()->loadBurstMessage(codecMsg.code());
1196 result = "Loaded '";
1198 result += "' file into burst list position ";
1199 result += anna::functions::asString(position);
1200 } else if(param1 == "start") {
1201 if(param2 == "") throw anna::RuntimeException("Missing initial load for burst start operation", ANNA_FILE_LOCATION);
1203 int initialLoad = atoi(param2.c_str());
1204 int processed = getWorkingNode()->startBurst(initialLoad);
1207 result = "Initial load completed for ";
1208 result += anna::functions::entriesAsString(processed, "message");
1211 } else if(param1 == "push") {
1212 if(param2 == "") throw anna::RuntimeException("Missing load amount for burst push operation", ANNA_FILE_LOCATION);
1214 int pushed = getWorkingNode()->pushBurst(atoi(param2.c_str()));
1218 result += anna::functions::entriesAsString(pushed, "message");
1221 } else if(param1 == "pop") {
1222 if(param2 == "") throw anna::RuntimeException("Missing amount for burst pop operation", ANNA_FILE_LOCATION);
1224 int releaseLoad = atoi(param2.c_str());
1225 int popped = getWorkingNode()->popBurst(releaseLoad);
1228 result = "Burst popped for ";
1229 result += anna::functions::entriesAsString(popped, "message");
1232 } else if(param1 == "stop") {
1233 int left = getWorkingNode()->stopBurst();
1236 result += anna::functions::entriesAsString(left, "message");
1237 result += " left to the end of the cycle.";
1239 } else if(param1 == "repeat") {
1240 if(param2 == "") param2 = "yes";
1242 bool repeat = (param2 == "yes");
1243 getWorkingNode()->repeatBurst(repeat);
1244 result += (repeat ? "Mode on." : "Mode off.");
1245 } else if(param1 == "send") {
1246 if(param2 == "") throw anna::RuntimeException("Missing amount for burst send operation", ANNA_FILE_LOCATION);
1248 int sent = getWorkingNode()->sendBurst(atoi(param2.c_str()));
1252 result += anna::functions::entriesAsString(sent, "message");
1255 } else if(param1 == "goto") {
1256 if(param2 == "") throw anna::RuntimeException("Missing order position for burst goto operation", ANNA_FILE_LOCATION);
1258 result = getWorkingNode()->gotoBurst(atoi(param2.c_str()));
1260 } else if(param1 == "look") {
1261 if(param2 == "") throw anna::RuntimeException("Missing order position for burst look operation", ANNA_FILE_LOCATION);
1264 result += getWorkingNode()->lookBurst(atoi(param2.c_str()));
1267 throw anna::RuntimeException("Wrong body content format on HTTP Request for 'burst' operation (unexpected action parameter). See help", ANNA_FILE_LOCATION);
1269 } else if((opType == "sendxml2c") || (opType == "sendhex2c")) {
1270 if(!localServer) throw anna::RuntimeException("No local server configured to send the message", ANNA_FILE_LOCATION);
1271 anna::diameter::comm::Message *msg = getWorkingNode()->createCommMessage();
1273 if(opType == "sendxml2c") {
1274 codecMsg.loadXML(param1);
1276 try { codecMsg.valid(); } catch(anna::RuntimeException &ex) { ex.trace(); } // at least we need to see validation errors although it will continue sending (see validation mode configured in launcher)
1278 msg->setBody(codecMsg.code());
1280 // Get DataBlock from file with hex content:
1281 if(!getDataBlockFromHexFile(param1, db_aux))
1282 throw anna::RuntimeException("Error reading hex file provided", ANNA_FILE_LOCATION);
1284 msg->setBody(db_aux);
1287 bool success = localServer->send(msg);
1288 getWorkingNode()->releaseCommMessage(msg);
1291 if(getWorkingNode()->logEnabled()) {
1292 anna::diameter::comm::ServerSession *usedServerSession = localServer->getLastUsedResource();
1293 std::string detail = usedServerSession ? usedServerSession->asString() : "<null server session>"; // esto no deberia ocurrir
1294 getWorkingNode()->writeLogFile(codecMsg, (success ? "sent2c" : "send2cError"), detail);
1296 } else if(opType == "loadxml") {
1297 codecMsg.loadXML(param1);
1298 std::string xmlString = codecMsg.asXMLString();
1299 std::cout << xmlString << std::endl;
1300 } else if(opType == "diameterServerSessions") {
1301 int diameterServerSessions = atoi(param1.c_str());
1304 localServer->setMaxConnections(diameterServerSessions);
1306 LOGWARNING(anna::Logger::warning("To update the number of sessions, you must configure the process diameter local server: you could also launch it with no sessions (disabled)", ANNA_FILE_LOCATION));
1308 } else if((opType == "answerxml") || (opType == "answerxml2c")) {
1310 throw anna::RuntimeException("Operation not applicable (no own diameter server has been configured)", ANNA_FILE_LOCATION);
1312 if(param1 == "") { // programmed answers FIFO's to stdout
1313 std::cout << localServer->getReactingAnswers()->asString("ANSWERS TO CLIENT") << std::endl;
1314 response_content = "Programmed answers dumped on stdout\n";
1316 } else if (param1 == "rotate") {
1317 localServer->getReactingAnswers()->rotate(true);
1318 } else if (param1 == "exhaust") {
1319 localServer->getReactingAnswers()->rotate(false);
1320 } else if (param1 == "clear") {
1321 localServer->getReactingAnswers()->clear();
1322 } else if (param1 == "dump") {
1323 localServer->getReactingAnswers()->dump();
1325 anna::diameter::codec::Message *message = getCodecEngine()->createMessage(param1); // // XXXXXXXXXXXXXX el del nodo de trabajo
1328 anna::Logger::debug(message->asXMLString(), ANNA_FILE_LOCATION);
1331 if(message->isRequest())
1332 throw anna::RuntimeException("Cannot program diameter requests. Answer type must be provided", ANNA_FILE_LOCATION);
1334 int code = message->getId().first;
1335 LOGDEBUG(anna::Logger::debug("Adding a new programed 'answer to client' to the FIFO queue corresponding to its message code ...", ANNA_FILE_LOCATION));
1336 localServer->getReactingAnswers()->addMessage(code, message);
1338 } else if(opType == "answerxml2e") {
1340 throw anna::RuntimeException("Operation not applicable (no diameter entity has been configured)", ANNA_FILE_LOCATION);
1342 if(param1 == "") { // programmed answers FIFO's to stdout
1343 std::cout << entity->getReactingAnswers()->asString("ANSWERS TO ENTITY") << std::endl;
1344 response_content = "Programmed answers dumped on stdout\n";
1346 } else if (param1 == "rotate") {
1347 entity->getReactingAnswers()->rotate(true);
1348 } else if (param1 == "exhaust") {
1349 entity->getReactingAnswers()->rotate(false);
1350 } else if (param1 == "clear") {
1351 entity->getReactingAnswers()->clear();
1352 } else if (param1 == "dump") {
1353 entity->getReactingAnswers()->dump();
1355 anna::diameter::codec::Message *message = getCodecEngine()->createMessage(param1); // XXXXXXXXXXXXXX el del nodo de trabajo
1358 anna::Logger::debug(message->asXMLString(), ANNA_FILE_LOCATION);
1361 if(message->isRequest())
1362 throw anna::RuntimeException("Cannot program diameter requests. Answer type must be provided", ANNA_FILE_LOCATION);
1364 int code = message->getId().first;
1365 LOGDEBUG(anna::Logger::debug("Adding a new programed 'answer to entity' to the FIFO queue corresponding to its message code ...", ANNA_FILE_LOCATION));
1366 entity->getReactingAnswers()->addMessage(code, message);
1369 LOGWARNING(anna::Logger::warning(help(), ANNA_FILE_LOCATION));
1370 throw anna::RuntimeException("Wrong body content format on HTTP Request. Unsupported/unrecognized operation type", ANNA_FILE_LOCATION);
1374 response_content = "Operation processed; ";
1376 if((opType == "decode") || (opType == "code")) {
1377 response_content += "File '";
1378 response_content += param2;
1379 response_content += "' created.";
1380 response_content += "\n";
1381 } else if((opType == "hide") || (opType == "show")) {
1382 response_content += "Resource '";
1383 response_content += ((param1 != "") ? param1 : "Entity");
1386 response_content += "|";
1387 response_content += param2;
1390 response_content += "' ";
1392 if(opType == "hide") response_content += "has been hidden.";
1394 if(opType == "show") response_content += "has been shown.";
1396 response_content += "\n";
1397 } else if((opType == "hidden") || (opType == "shown")) {
1398 response_content += "Result: ";
1399 response_content += result;
1400 response_content += "\n";
1401 } else if((opType == "sendxml") || (opType == "sendxml2e") || (opType == "sendhex") || (opType == "sendhex2e")) {
1402 response_content += "Message '";
1403 response_content += param1;
1404 response_content += "' sent to entity.";
1405 response_content += "\n";
1406 } else if(opType == "burst") {
1407 response_content += "Burst '";
1408 response_content += param1;
1409 response_content += "' executed. ";
1410 response_content += result;
1411 response_content += "\n";
1412 } else if((opType == "sendxml2c") || (opType == "sendhex2c")) {
1413 response_content += "Message '";
1414 response_content += param1;
1415 response_content += "' sent to client.";
1416 response_content += "\n";
1417 } else if(opType == "loadxml") {
1418 response_content += "Message '";
1419 response_content += param1;
1420 response_content += "' loaded.";
1421 response_content += "\n";
1422 } else if((opType == "answerxml") || (opType == "answerxml2c")) {
1423 response_content += "'";
1424 response_content += param1;
1425 response_content += "' applied on server FIFO queue";
1426 response_content += "\n";
1427 } else if(opType == "answerxml2e") {
1428 response_content += "'";
1429 response_content += param1;
1430 response_content += "' applied on client FIFO queue";
1431 response_content += "\n";
1432 } else if(opType == "diameterServerSessions") {
1433 response_content += "Maximum server socket connections updated to '";
1434 response_content += param1;
1435 response_content += "'.";
1436 response_content += "\n";
1440 anna::xml::Node* Launcher::asXML(anna::xml::Node* parent) const
1442 anna::xml::Node* result = parent->createChild("launcher");
1443 anna::comm::Application::asXML(result);
1445 result->createAttribute("StartTime", a_start_time.asString());
1446 result->createAttribute("SecondsLifeTime", anna::time::functions::lapsedMilliseconds() / 1000);
1448 getCodecEngine()->asXML(result);
1449 for (realm_nodes_it it = a_nodes.begin(); it != a_nodes.end(); it++) {
1450 it->second->asXML(result);
1454 anna::diameter::comm::OamModule::instantiate().asXML(result);
1455 anna::diameter::comm::ApplicationMessageOamModule::instantiate().asXML(result);
1456 anna::diameter::codec::OamModule::instantiate().asXML(result);
1458 anna::statistics::Engine::instantiate().asXML(result);