X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=source%2Fdiameter.comm%2FClientSession.cpp;h=83c286c0311f5de3843f16de9e7b172efb501517;hb=c8a0b8a8606f42cd2cc6cd14c7f180319f45bf85;hp=91aa8cfc47e45f11ffa78313ff32ad3721e26f13;hpb=6e1b37527452c6e59433144d6770db26253862eb;p=anna.git diff --git a/source/diameter.comm/ClientSession.cpp b/source/diameter.comm/ClientSession.cpp index 91aa8cf..83c286c 100644 --- a/source/diameter.comm/ClientSession.cpp +++ b/source/diameter.comm/ClientSession.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -41,7 +42,6 @@ #include - using namespace std; using namespace anna::diameter; using namespace anna::diameter::comm; @@ -153,6 +153,8 @@ const Response* ClientSession::send(const Message* message) throw(anna::RuntimeE // Command id: bool isRequest; diameter::CommandId cid = message->getCommandId(isRequest); + diameter::ApplicationId aid = message->getApplicationId(); + LOGDEBUG( std::string msg = "Sending diameter message: "; msg += anna::diameter::functions::commandIdAsPairString(cid); @@ -296,15 +298,21 @@ const Response* ClientSession::send(const Message* message) throw(anna::RuntimeE // updateOutgoingActivityTime(); // OAM - countSendings(cid, true /* send ok */); + countSendings(cid, aid, true /* send ok */); // Trace non-application messages: LOGDEBUG( - if((cid == helpers::base::COMMANDID__Capabilities_Exchange_Request) || (cid == helpers::base::COMMANDID__Device_Watchdog_Request) || - (cid == helpers::base::COMMANDID__Disconnect_Peer_Request)) { - anna::Logger::debug("Sent DataBlock to XML representation:", ANNA_FILE_LOCATION); - try { anna::diameter::codec::Message msg; msg.decode(message->getBody()); /* decode to be traced */ } catch(anna::RuntimeException&) {;} + (cid == helpers::base::COMMANDID__Disconnect_Peer_Request)) { + anna::Logger::debug("Sent DataBlock to XML representation:", ANNA_FILE_LOCATION); + try { + anna::diameter::codec::Message msg(a_engine->getBaseProtocolCodecEngine()); msg.decode(message->getBody()); /* decode to be traced */ + } + catch(anna::RuntimeException &ex) { + std::string msg = ex.getText(); + msg += " | Use diameter::comm::Engine::setBaseProtocolCodecEngine() to allow internal base protocol messages full tracing"; + anna::Logger::debug(msg, ANNA_FILE_LOCATION); + } } ); @@ -314,7 +322,7 @@ const Response* ClientSession::send(const Message* message) throw(anna::RuntimeE if(fixed) message_nc->restoreSequencesAfterFix(); // restore to application sequences after fix // OAM - countSendings(cid, false /* send no ok */); + countSendings(cid, aid, false /* send no ok */); throw; } @@ -439,6 +447,17 @@ void ClientSession::eventPeerShutdown() throw() { a_parent->eventPeerShutdown(this); } +void ClientSession::eventRequestRetransmission(Message *request) throw() { + + // OAM + OamModule &oamModule = OamModule::instantiate(); + oamModule.count(OamModule::Counter::RequestRetransmitted); + oamModule.count(OamModule::Counter::RequestRetransmittedOnClientSession); + + // Inform father server: + a_parent->eventRequestRetransmission(this, request); +} + void ClientSession::eventResponse(const Response& response) throw(anna::RuntimeException) { // Inform father server: a_parent->eventResponse(response); @@ -479,8 +498,17 @@ throw(anna::RuntimeException) { msg += anna::diameter::functions::commandIdAsPairString(cid); anna::Logger::debug(msg, ANNA_FILE_LOCATION); - if((cid == helpers::base::COMMANDID__Capabilities_Exchange_Answer) || (cid.first == helpers::base::COMMANDID__Device_Watchdog_Request.first)) - try { anna::diameter::codec::Message dmsg; dmsg.decode(db); /* decode to be traced */ } catch(anna::RuntimeException&) {;} + if( (cid == helpers::base::COMMANDID__Capabilities_Exchange_Answer) || + (cid.first == helpers::base::COMMANDID__Device_Watchdog_Request.first)) { + try { + anna::diameter::codec::Message dmsg(a_engine->getBaseProtocolCodecEngine()); dmsg.decode(db); /* decode to be traced */ + } + catch(anna::RuntimeException &ex) { + std::string msg = ex.getText(); + msg += " | Use diameter::comm::Engine::setBaseProtocolCodecEngine() to allow internal base protocol messages full tracing"; + anna::Logger::debug(msg, ANNA_FILE_LOCATION); + } + } ); // Main counters: OamModule &oamModule = OamModule::instantiate(); @@ -524,6 +552,9 @@ throw(anna::RuntimeException) { } try { + // application message counters + ApplicationMessageOamModule::instantiate().count(cid.first, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Request_Received_AsClient); + eventRequest(db); } catch(anna::RuntimeException& ex) { ex.trace(); @@ -624,6 +655,10 @@ throw(anna::RuntimeException) { oamModule.count(OamModule::Counter::AnswerReceivedUnknown); oamModule.count(OamModule::Counter::AnswerReceivedOnClientSessionUnknown); oamModule.activateAlarm(OamModule::Alarm::AnswerReceivedOnClientSessionUnknown); + + // application message counters + ApplicationMessageOamModule::instantiate().count(cid.first, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Answer_UnknownReceived_AsClient); + eventUnknownResponse(db); string msg(asString()); msg += anna::functions::asString(" | Response received from entity, for non registered context (HopByHop: %u)", hopByHop); @@ -669,6 +704,11 @@ throw(anna::RuntimeException) { ); diameter::codec::functions::setHopByHop((anna::DataBlock&)db, response->getRequest()->getRequestHopByHop()); diameter::codec::functions::setEndToEnd((anna::DataBlock&)db, response->getRequest()->getRequestEndToEnd()); + + // application message counters + if(cid != helpers::base::COMMANDID__Capabilities_Exchange_Answer) + ApplicationMessageOamModule::instantiate().count(cid.first, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Answer_Received_AsClient); + eventResponse(*response); } catch(anna::RuntimeException& ex) { ex.trace(); @@ -922,8 +962,10 @@ void ClientSession::updateOutgoingActivityTime(void) throw() { //------------------------------------------------------------------------------ //----------------------------------------------- ClientSession::countSendings() //------------------------------------------------------------------------------ -void ClientSession::countSendings(const diameter::CommandId & cid, bool ok)throw() { +void ClientSession::countSendings(const diameter::CommandId & cid, unsigned int aid, bool ok)throw() { OamModule &oamModule = OamModule::instantiate(); + ApplicationMessageOamModule &appMsgOamModule = ApplicationMessageOamModule::instantiate(); + bool isRequest = cid.second; if(ok) { @@ -936,6 +978,10 @@ void ClientSession::countSendings(const diameter::CommandId & cid, bool ok)throw else if(cid == helpers::base::COMMANDID__Device_Watchdog_Answer) oamModule.count(OamModule::Counter::DWASentOK); // not usual (dwr was received from server) else if(cid == helpers::base::COMMANDID__Disconnect_Peer_Request) oamModule.count(OamModule::Counter::DPRSentOK); else if(cid == helpers::base::COMMANDID__Disconnect_Peer_Answer) oamModule.count(OamModule::Counter::DPASentOK); + // Application messages: + else { + appMsgOamModule.count(cid.first, aid, isRequest ? ApplicationMessageOamModule::Counter::Request_SentOK_AsClient : ApplicationMessageOamModule::Counter::Answer_SentOK_AsClient); + } } else { // Main counters: oamModule.count(isRequest ? OamModule::Counter::RequestSentNOK : OamModule::Counter::AnswerSentNOK); @@ -946,6 +992,10 @@ void ClientSession::countSendings(const diameter::CommandId & cid, bool ok)throw else if(cid == helpers::base::COMMANDID__Device_Watchdog_Answer) oamModule.count(OamModule::Counter::DWASentNOK); // not usual (dwr was received from server) else if(cid == helpers::base::COMMANDID__Disconnect_Peer_Request) oamModule.count(OamModule::Counter::DPRSentNOK); else if(cid == helpers::base::COMMANDID__Disconnect_Peer_Answer) oamModule.count(OamModule::Counter::DPASentNOK); + // Application messages: + else { + appMsgOamModule.count(cid.first, aid, isRequest ? ApplicationMessageOamModule::Counter::Request_SentNOK_AsClient : ApplicationMessageOamModule::Counter::Answer_SentNOK_AsClient); + } } }