X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2Fmain.cpp;h=5a8422d8503ca8c04a05fa7656fd5ba8db1dfeac;hb=d05828d1ebfc81da3041e8ac474057fc0e453f0c;hp=c0d4d37f1000bae06c661dec11831a599634811d;hpb=bed9cb7ee096fbd3981de37972c86bce00840022;p=anna.git diff --git a/example/diameter/launcher/main.cpp b/example/diameter/launcher/main.cpp index c0d4d37..5a8422d 100644 --- a/example/diameter/launcher/main.cpp +++ b/example/diameter/launcher/main.cpp @@ -358,11 +358,19 @@ public: bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) const throw() { // Get hex string - static char buffer[2048]; + static char buffer[8192]; std::ifstream infile(pathfile.c_str(), std::ifstream::in); if(infile.is_open()) { infile >> buffer; std::string hexString(buffer, strlen(buffer)); + // Allow colon separator in hex string: we have to remove them before processing with 'fromHexString': + hexString.erase(std::remove(hexString.begin(), hexString.end(), ':'), hexString.end()); + LOGDEBUG( + std::string msg = "Hex string (remove colons if exists): "; + msg += hexString; + anna::Logger::debug(msg, ANNA_FILE_LOCATION); + ); + anna::functions::fromHexString(hexString, db); // Close file infile.close(); @@ -452,7 +460,7 @@ int Launcher::pushBurst(int loadAmount) throw() { } a_burstActive = true; - register int count; + int count; for (count = 0; count < loadAmount; count++) if (!sendBurstMessage()) break; @@ -476,7 +484,7 @@ int Launcher::sendBurst(int loadAmount) throw() { return -2; } - register int count; + int count; for (count = 0; count < loadAmount; count++) if (!sendBurstMessage(true /* anyway */)) break; @@ -517,7 +525,7 @@ bool Launcher::sendBurstMessage(bool anyway) throw() { if (a_burstRepeat) { a_burstCycle++; - if (burstLogEnabled()) writeBurstLogFile(anna::functions::asString(("\nCompleted burst cycle. Starting again (repeat mode) on cycle %d.\n", a_burstCycle))); + if (burstLogEnabled()) writeBurstLogFile(anna::functions::asString("\nCompleted burst cycle. Starting again (repeat mode) on cycle %d.\n", a_burstCycle)); } else { if (burstLogEnabled()) writeBurstLogFile("\nCompleted burst cycle. Burst finished (repeat mode disabled).\n"); @@ -757,20 +765,18 @@ std::string Launcher::help() const throw() { result += "\nanswerxml|[source_file] Same as 'answerxml2c'."; result += "\n List programmed answers if no parameter provided."; result += "\n"; - result += "\nSame operations are available using hexadecimal content (hex formatted files) which also allow to test"; + result += "\nSend operations are available using hexadecimal content (hex formatted files) which also allow to test"; result += "\nspecial scenarios (protocol errors):"; result += "\n"; result += "\nsendhex2e| Sends hex source file (pathfile) through configured entity."; result += "\nsendhex2c| Sends hex source file (pathfile) to client."; result += "\nsendhex| Same as 'sendhex2e'."; - result += "\nanswerhex2e|[source_file] Answer hex source file (pathfile) for corresponding request from entity."; - result += "\nanswerhex2c|[source_file] Answer hex source file (pathfile) for corresponding request from client."; - result += "\nanswerhex|[source_file] Same as 'answerhex2c'."; - result += "\n List programmed answers if no parameter provided."; - result += "\n"; result += "\n"; + result += "\nAnswer programming in hexadecimal is not really neccessary (you could use send primitives) and also"; + result += "\nis intended to be used with decoded messages in order to replace things like hop by hop, end to end,"; + result += "\nsubscriber id, session id, etc."; result += "\n"; - result += "\nIf a request is received, answer map (built with 'answerxml/hex<[2c] or 2e>' operations) will be"; + result += "\nIf a request is received, answer map (built with 'answerxml<[2c] or 2e>' operations) will be"; result += "\n checked to find a corresponding programmed answer to be replied(*). If no ocurrence is found,"; result += "\n or answer message was received, the message is forwarded to the other side (entity or client),"; result += "\n or nothing but trace when no peer at that side is configured. Answer to client have sense when"; @@ -1468,8 +1474,8 @@ throw(anna::RuntimeException) { std::string address; int port; anna::functions::getAddressAndPortFromSocketLiteral(cl.getValue("httpServer"), address, port); - //const anna::comm::Device* device = network.find(Device::asAddress(address)); // aqui hay que proporcionar una IP ! - const anna::comm::Device* device = *((network.resolve(address)->device_begin())); // ArtimaƱa para resolver (IP o hostname) + //const anna::comm::Device* device = network.find(Device::asAddress(address)); // here provide IP + const anna::comm::Device* device = *((network.resolve(address)->device_begin())); // trick to solve a_httpServerSocket = new anna::comm::ServerSocket(anna::comm::INetAddress(device, port), cl.exists("httpServerShared") /* shared bind */, &anna::http::Transport::getFactory()); } @@ -1958,7 +1964,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons startDiameterServer(diameterServerSessions); else getDiameterLocalServer()->setMaxConnections(diameterServerSessions); - } else if ((opType == "answerxml") || (opType == "answerxml2c") || (opType == "answerhex") || (opType == "answerhex2c")) { + } else if ((opType == "answerxml") || (opType == "answerxml2c")) { anna::diameter::comm::LocalServer *localServer = getDiameterLocalServer(); if (!localServer) @@ -1989,7 +1995,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons response_content = "Programmed answers dumped on stdout\n"; return; } - } else if ((opType == "answerxml2e") || (opType == "answerhex2e")) { + } else if (opType == "answerxml2e") { anna::diameter::comm::Entity *entity = getEntity(); if (!entity) @@ -2074,12 +2080,12 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons response_content += param1; response_content += "' loaded."; response_content += "\n"; - } else if ((opType == "answerxml") || (opType == "answerxml2c") || (opType == "answerhex") || (opType == "answerhex2c")) { + } else if ((opType == "answerxml") || (opType == "answerxml2c")) { response_content += "Answer to client '"; response_content += param1; response_content += "' programmed."; response_content += "\n"; - } else if ((opType == "answerxml2e") || (opType == "answerhex2e")) { + } else if (opType == "answerxml2e") { response_content += "Answer to entity '"; response_content += param1; response_content += "' programmed.";