-// ANNA - Anna is Not Nothingness Anymore
-//
-// (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
-//
-// http://redmine.teslayout.com/projects/anna-suite
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of the copyright holder nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Authors: eduardo.ramos.testillano@gmail.com
-// cisco.tierra@gmail.com
+// ANNA - Anna is Not Nothingness Anymore //
+// //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
+// //
+// See project site at http://redmine.teslayout.com/projects/anna-suite //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
#include <anna/core/functions.hpp>
#include <anna/diameter.comm/Response.hpp>
#include <anna/diameter.comm/Message.hpp>
#include <anna/diameter.comm/OamModule.hpp>
+#include <anna/diameter.comm/ApplicationMessageOamModule.hpp>
#include <anna/diameter.comm/TimerManager.hpp>
#include <anna/diameter.comm/Timer.hpp>
#include <anna/diameter.comm/ClientSessionReceiver.hpp>
#include <time.h>
-
using namespace std;
using namespace anna::diameter;
using namespace anna::diameter::comm;
// Tekelec PCRF
a_engine->bindingClientSession(this);
- // OAM Lo comento, porque no se contabilizan los reintentos y por lo tanto no son muy útiles.
+ // OAM Lo comento, porque no se contabilizan los reintentos y por lo tanto no son muy �tiles.
// OamModule &oamModule = OamModule::instantiate();
// oamModule.count(a_server->isAvailable() ? OamModule::Counter::TCPConnectOK:OamModule::Counter::TCPConnectNOK);
// Application bind
// 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);
}
// Fixing indicator:
- fixed = message_nc->fixRequestSequence(a_nextHopByHop, a_nextEndToEnd, a_engine->getFreezeEndToEndOnSending());
+ fixed = message_nc->fixRequestSequence(a_nextHopByHop, a_nextEndToEnd);
message_nc->updateRequestTimestampMs(); // statistics purposes (processing time for request type)
}
//
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);
+ }
}
);
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;
}
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);
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();
}
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();
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);
);
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();
//------------------------------------------------------------------------------
//----------------------------------------------- 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) {
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);
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);
+ }
}
}