projects
/
anna.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix nswering procedure: have to use source resource.
[anna.git]
/
example
/
diameter
/
launcher
/
MyDiameterEntity.cpp
diff --git
a/example/diameter/launcher/MyDiameterEntity.cpp
b/example/diameter/launcher/MyDiameterEntity.cpp
index
6a27607
..
50a9663
100644
(file)
--- a/
example/diameter/launcher/MyDiameterEntity.cpp
+++ b/
example/diameter/launcher/MyDiameterEntity.cpp
@@
-11,12
+11,17
@@
#include <anna/diameter/functions.hpp>
#include <anna/time/functions.hpp>
#include <anna/diameter.comm/Response.hpp>
#include <anna/diameter/functions.hpp>
#include <anna/time/functions.hpp>
#include <anna/diameter.comm/Response.hpp>
+#include <anna/diameter.comm/ClientSession.hpp>
#include <anna/diameter/helpers/base/functions.hpp>
#include <anna/diameter/helpers/dcca/functions.hpp>
// Process
#include <anna/diameter/helpers/base/functions.hpp>
#include <anna/diameter/helpers/dcca/functions.hpp>
// Process
-#include "MyDiameterEntity.hpp"
-#include "Launcher.hpp"
+#include <MyDiameterEngine.hpp>
+#include <MyDiameterEntity.hpp>
+#include <MyLocalServer.hpp>
+#include <Launcher.hpp>
+#include <RealmNode.hpp>
+#include <TestManager.hpp>
void MyDiameterEntity::eventRequestRetransmission(const anna::diameter::comm::ClientSession* clientSession, anna::diameter::comm::Message *request) throw() {
void MyDiameterEntity::eventRequestRetransmission(const anna::diameter::comm::ClientSession* clientSession, anna::diameter::comm::Message *request) throw() {
@@
-28,7
+33,7
@@
void MyDiameterEntity::eventRequestRetransmission(const anna::diameter::comm::Cl
// Performance stats:
Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
// Performance stats:
Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
-
CommandLine& cl(anna::CommandLine::instantiate
());
+
RealmNode * my_node = my_app.getRealmNode(getEngine()->getRealm
());
// CommandId:
anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(request->getBody());
LOGDEBUG
// CommandId:
anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(request->getBody());
LOGDEBUG
@@
-43,15
+48,13
@@
void MyDiameterEntity::eventRequestRetransmission(const anna::diameter::comm::Cl
);
// Write retransmission
);
// Write retransmission
- if(my_
app.logEnabled()) my_app.writeLogFile(request->getBody(), "retry", clientSession->asString(), a_codecEngine
);
+ if(my_
node->logEnabled()) my_node->writeLogFile(request->getBody(), "retry", clientSession->asString()
);
}
int MyDiameterEntity::readSocketId(const anna::diameter::comm::Message* message, int maxClientSessions) const throw() {
}
int MyDiameterEntity::readSocketId(const anna::diameter::comm::Message* message, int maxClientSessions) const throw() {
- CommandLine& cl(anna::CommandLine::instantiate());
- std::string sessionBasedModelsType = (cl.exists("sessionBasedModelsClientSocketSelection") ? cl.getValue("sessionBasedModelsClientSocketSelection") : "SessionIdLowPart");
- if(sessionBasedModelsType == "RoundRobin") return -1; // IEC also would return -1
+ if(
a_
sessionBasedModelsType == "RoundRobin") return -1; // IEC also would return -1
try {
// Service-Context-Id:
try {
// Service-Context-Id:
@@
-68,11
+71,11
@@
int MyDiameterEntity::readSocketId(const anna::diameter::comm::Message* message,
anna::U32 high, low;
anna::diameter::helpers::base::functions::decodeSessionId(sid, diameterIdentity, high, low /* context-teid */, optional);
anna::U32 high, low;
anna::diameter::helpers::base::functions::decodeSessionId(sid, diameterIdentity, high, low /* context-teid */, optional);
- if(sessionBasedModelsType == "SessionIdLowPart") return (low % maxClientSessions);
+ if(
a_
sessionBasedModelsType == "SessionIdLowPart") return (low % maxClientSessions);
- if(sessionBasedModelsType == "SessionIdHighPart") return (high % maxClientSessions);
+ if(
a_
sessionBasedModelsType == "SessionIdHighPart") return (high % maxClientSessions);
- if(sessionBasedModelsType == "SessionIdOptionalPart") return (atoi(optional.c_str()) % maxClientSessions);
+ if(
a_
sessionBasedModelsType == "SessionIdOptionalPart") return (atoi(optional.c_str()) % maxClientSessions);
}
case anna::diameter::helpers::dcca::ChargingContext::SMS:
case anna::diameter::helpers::dcca::ChargingContext::MMS:
}
case anna::diameter::helpers::dcca::ChargingContext::SMS:
case anna::diameter::helpers::dcca::ChargingContext::MMS:
@@
-96,7
+99,11
@@
throw(anna::RuntimeException) {
LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventRequest", ANNA_FILE_LOCATION));
// Performance stats:
Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventRequest", ANNA_FILE_LOCATION));
// Performance stats:
Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
- CommandLine& cl(anna::CommandLine::instantiate());
+ RealmNode * my_node = my_app.getRealmNode(getEngine()->getRealm());
+
+ // Testing:
+ TestManager::instantiate().receiveMessage(message, clientSession);
+
// CommandId:
anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(message);
LOGDEBUG
// CommandId:
anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(message);
LOGDEBUG
@@
-111,7
+118,7
@@
throw(anna::RuntimeException) {
);
// Write reception
);
// Write reception
- if(my_
app.logEnabled()) my_app.writeLogFile(message, "recvfe", clientSession->asString(), a_codecEngine
);
+ if(my_
node->logEnabled()) my_node->writeLogFile(message, "recvfe", clientSession->asString()
);
// Lookup reacting answers list:
int code = cid.first;
// Lookup reacting answers list:
int code = cid.first;
@@
-119,20
+126,23
@@
throw(anna::RuntimeException) {
if (answer_message) {
// Prepare answer:
my_app.getCommunicator()->prepareAnswer(answer_message, message);
if (answer_message) {
// Prepare answer:
my_app.getCommunicator()->prepareAnswer(answer_message, message);
+ anna::diameter::comm::Message *msg;
try {
try {
-
anna::diameter::comm::Message *msg = my_app.
createCommMessage();
+
msg = my_node->
createCommMessage();
msg->setBody(answer_message->code());
/* response = NULL =*/clientSession->send(msg);
msg->setBody(answer_message->code());
/* response = NULL =*/clientSession->send(msg);
- my_app.releaseCommMessage(msg);
- if(my_
app.logEnabled()) my_app.
writeLogFile(*answer_message, "sent2e", clientSession->asString());
+ if(my_
node->logEnabled()) my_node->
writeLogFile(*answer_message, "sent2e", clientSession->asString());
} catch(anna::RuntimeException &ex) {
ex.trace();
} catch(anna::RuntimeException &ex) {
ex.trace();
- if(my_
app.logEnabled()) my_app.
writeLogFile(*answer_message, "send2eError", clientSession->asString());
+ if(my_
node->logEnabled()) my_node->
writeLogFile(*answer_message, "send2eError", clientSession->asString());
}
}
+ // release msg
+ my_node->releaseCommMessage(msg);
+
// Pop front the reacting answer:
a_reactingAnswers.nextMessage(code);
return;
// Pop front the reacting answer:
a_reactingAnswers.nextMessage(code);
return;
@@
-147,21
+157,21
@@
throw(anna::RuntimeException) {
// not found: forward to client (if exists)
// Forward to client:
// not found: forward to client (if exists)
// Forward to client:
-
anna::diameter::comm::LocalServer *localServer = my_app.getDiameterLocal
Server();
+
MyLocalServer *localServer = my_node->getDiameter
Server();
if(localServer && (cid != anna::diameter::helpers::base::COMMANDID__Capabilities_Exchange_Request) /* don't forward CER */) {
try {
if(localServer && (cid != anna::diameter::helpers::base::COMMANDID__Capabilities_Exchange_Request) /* don't forward CER */) {
try {
- anna::diameter::comm::Message *msg = my_
app.
createCommMessage();
+ anna::diameter::comm::Message *msg = my_
node->
createCommMessage();
msg->forwardEndToEnd(); // end-to-end will be kept
msg->setBody(message);
msg->setRequestClientSessionKey(clientSession->getKey());
bool success = localServer->send(msg);
// Detailed log:
msg->forwardEndToEnd(); // end-to-end will be kept
msg->setBody(message);
msg->setRequestClientSessionKey(clientSession->getKey());
bool success = localServer->send(msg);
// Detailed log:
- if(my_
app.
logEnabled()) {
+ if(my_
node->
logEnabled()) {
anna::diameter::comm::ServerSession *usedServerSession = localServer->getLastUsedResource();
std::string detail = usedServerSession ? usedServerSession->asString() : "<null server session>"; // esto no deberia ocurrir
anna::diameter::comm::ServerSession *usedServerSession = localServer->getLastUsedResource();
std::string detail = usedServerSession ? usedServerSession->asString() : "<null server session>"; // esto no deberia ocurrir
- my_
app.writeLogFile(message, (success ? "fwd2c" : "fwd2cError"), detail, a_codecEngine
);
+ my_
node->writeLogFile(message, (success ? "fwd2c" : "fwd2cError"), detail
);
}
} catch(anna::RuntimeException &ex) {
ex.trace();
}
} catch(anna::RuntimeException &ex) {
ex.trace();
@@
-173,7
+183,7
@@
void MyDiameterEntity::eventResponse(const anna::diameter::comm::Response &respo
throw(anna::RuntimeException) {
LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventResponse", ANNA_FILE_LOCATION));
Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
throw(anna::RuntimeException) {
LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventResponse", ANNA_FILE_LOCATION));
Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
-
CommandLine& cl(anna::CommandLine::instantiate
());
+
RealmNode * my_node = my_app.getRealmNode(getEngine()->getRealm
());
anna::diameter::comm::ClassCode::_v code = response.getClassCode();
anna::diameter::comm::Response::ResultCode::_v result = response.getResultCode();
anna::diameter::comm::Message* request = const_cast<anna::diameter::comm::Message*>(response.getRequest());
anna::diameter::comm::ClassCode::_v code = response.getClassCode();
anna::diameter::comm::Response::ResultCode::_v result = response.getResultCode();
anna::diameter::comm::Message* request = const_cast<anna::diameter::comm::Message*>(response.getRequest());
@@
-184,6
+194,10
@@
throw(anna::RuntimeException) {
bool contextExpired = (result == anna::diameter::comm::Response::ResultCode::Timeout);
bool isUnavailable = (result == anna::diameter::comm::Response::ResultCode::DiameterUnavailable);
bool isOK = (result == anna::diameter::comm::Response::ResultCode::Success);
bool contextExpired = (result == anna::diameter::comm::Response::ResultCode::Timeout);
bool isUnavailable = (result == anna::diameter::comm::Response::ResultCode::DiameterUnavailable);
bool isOK = (result == anna::diameter::comm::Response::ResultCode::Success);
+
+ // Testing:
+ TestManager::instantiate().receiveMessage(*message, clientSession);
+
// CommandId:
anna::diameter::CommandId request_cid = request->getCommandId();
LOGDEBUG
// CommandId:
anna::diameter::CommandId request_cid = request->getCommandId();
LOGDEBUG
@@
-209,7
+223,7
@@
throw(anna::RuntimeException) {
LOGWARNING(anna::Logger::warning("Context Expired for Diameter Request which was sent to the entity", ANNA_FILE_LOCATION));
if(request_cid != anna::diameter::helpers::base::COMMANDID__Capabilities_Exchange_Request) { // don't trace CEA
LOGWARNING(anna::Logger::warning("Context Expired for Diameter Request which was sent to the entity", ANNA_FILE_LOCATION));
if(request_cid != anna::diameter::helpers::base::COMMANDID__Capabilities_Exchange_Request) { // don't trace CEA
- if(my_
app.logEnabled()) my_app.writeLogFile(*request, "req2e-expired", clientSession->asString(), a_codecEngine
);
+ if(my_
node->logEnabled()) my_node->writeLogFile(*request, "req2e-expired", clientSession->asString()
);
}
}
}
}
@@
-222,38
+236,42
@@
throw(anna::RuntimeException) {
// Write reception
if(request_cid != anna::diameter::helpers::base::COMMANDID__Capabilities_Exchange_Request) { // don't trace CEA
// Write reception
if(request_cid != anna::diameter::helpers::base::COMMANDID__Capabilities_Exchange_Request) { // don't trace CEA
- if(my_
app.
logEnabled()) {
- my_
app.writeLogFile(*message, "recvfe", clientSession->asString(), a_codecEngine
);
+ if(my_
node->
logEnabled()) {
+ my_
node->writeLogFile(*message, "recvfe", clientSession->asString()
);
}
}
// Forward to client:
}
}
// Forward to client:
-
anna::diameter::comm::LocalServer *localServer = my_app.getDiameterLocal
Server();
+
MyLocalServer *localServer = my_node->getDiameter
Server();
if(localServer && (request_cid != anna::diameter::helpers::base::COMMANDID__Capabilities_Exchange_Request) /* don't forward CEA */) {
if(localServer && (request_cid != anna::diameter::helpers::base::COMMANDID__Capabilities_Exchange_Request) /* don't forward CEA */) {
+ anna::diameter::comm::Message *msg;
+
try {
try {
-
anna::diameter::comm::Message *msg = my_app.
createCommMessage();
+
msg = my_node->
createCommMessage();
msg->forwardEndToEnd(); // end-to-end will be kept
msg->setBody(*message);
bool success = localServer->send(msg, request->getRequestServerSessionKey());
msg->forwardEndToEnd(); // end-to-end will be kept
msg->setBody(*message);
bool success = localServer->send(msg, request->getRequestServerSessionKey());
- my_app.releaseCommMessage(msg);
- my_app.releaseCommMessage(request);
// Detailed log:
// Detailed log:
- anna::diameter::comm::ServerSession *usedServerSession = my_
app.
getMyDiameterEngine()->findServerSession(request->getRequestServerSessionKey());
+ anna::diameter::comm::ServerSession *usedServerSession = my_
node->
getMyDiameterEngine()->findServerSession(request->getRequestServerSessionKey());
std::string detail = usedServerSession ? usedServerSession->asString() : "<null server session>"; // esto no deberia ocurrir
std::string detail = usedServerSession ? usedServerSession->asString() : "<null server session>"; // esto no deberia ocurrir
- if(my_
app.
logEnabled()) {
- my_
app.writeLogFile(*message, (success ? "fwd2c" : "fwd2cError"), detail, a_codecEngine
);
+ if(my_
node->
logEnabled()) {
+ my_
node->writeLogFile(*message, (success ? "fwd2c" : "fwd2cError"), detail
);
}
} catch(anna::RuntimeException &ex) {
ex.trace();
}
}
} catch(anna::RuntimeException &ex) {
ex.trace();
}
+
+ // release msgs
+ my_node->releaseCommMessage(msg);
+ my_node->releaseCommMessage(request);
}
}
// Triggering burst:
}
}
// Triggering burst:
- if(isOK || contextExpired) my_
app.
sendBurstMessage();
+ if(isOK || contextExpired) my_
node->
sendBurstMessage();
}
void MyDiameterEntity::eventUnknownResponse(anna::diameter::comm::ClientSession *clientSession, const anna::DataBlock &message)
}
void MyDiameterEntity::eventUnknownResponse(anna::diameter::comm::ClientSession *clientSession, const anna::DataBlock &message)
@@
-261,6
+279,7
@@
throw(anna::RuntimeException) {
LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventUnknownResponse", ANNA_FILE_LOCATION));
// Performance stats:
Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventUnknownResponse", ANNA_FILE_LOCATION));
// Performance stats:
Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
+ RealmNode * my_node = my_app.getRealmNode(getEngine()->getRealm());
// CommandId:
anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(message);
LOGDEBUG
// CommandId:
anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(message);
LOGDEBUG
@@
-275,7
+294,7
@@
throw(anna::RuntimeException) {
);
// Write reception
);
// Write reception
- if(my_
app.logEnabled()) my_app.writeLogFile(message, "recvfe-ans-unknown", clientSession->asString(), a_codecEngine
);
+ if(my_
node->logEnabled()) my_node->writeLogFile(message, "recvfe-ans-unknown", clientSession->asString()
);
}
void MyDiameterEntity::eventDPA(anna::diameter::comm::ClientSession *clientSession, const anna::DataBlock &message)
}
void MyDiameterEntity::eventDPA(anna::diameter::comm::ClientSession *clientSession, const anna::DataBlock &message)
@@
-283,6
+302,7
@@
throw(anna::RuntimeException) {
LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventDPA", ANNA_FILE_LOCATION));
// Performance stats:
Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventDPA", ANNA_FILE_LOCATION));
// Performance stats:
Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
+ RealmNode * my_node = my_app.getRealmNode(getEngine()->getRealm());
// CommandId:
anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(message);
LOGDEBUG
// CommandId:
anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(message);
LOGDEBUG
@@
-297,5
+317,5
@@
throw(anna::RuntimeException) {
);
// Write reception
);
// Write reception
- if(my_
app.logEnabled()) my_app.writeLogFile(message, "recvfe", clientSession->asString(), a_codecEngine
);
+ if(my_
node->logEnabled()) my_node->writeLogFile(message, "recvfe", clientSession->asString()
);
}
}