-->\n\
\n\
<!ELEMENT node EMPTY>\n\
-<!ATTLIST node originHost CDATA #REQUIRED applicationId CDATA #REQUIRED originRealm 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\
+<!ATTLIST node originHost CDATA #REQUIRED applicationId CDATA #REQUIRED originRealm CDATA #IMPLIED cer CDATA #IMPLIED dwr CDATA #IMPLIED cea 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\
<!--\n\
Node record\n\
\n\
originHost: Node identifier as diameter application host name.\n\
applicationId: The Application-Id provided must exists as a registered 'stack id'.\n\
originRealm: Origin-Realm (domain-name internally used by default).\n\
+\n\
+\n\
+ - Diameter clients:\n\
+\n\
+ entity: Target diameter entity (comma-separated '<address>:<port>' format).\n\
+ For example: 10.20.30.40:3868,10.20.30.41:3868. If missing, no entity will be enabled.\n\
+ entityServerSessions: Diameter entity server sessions (0: diameter entity disabled). Default value of 1.\n\
cer: User defined CER path file to be encoded to establish diameter connections.\n\
If missing, will be harcoded.\n\
dwr: User defined DWR path file to be encoded for diameter protocol keep alive.\n\
If missing, will be harcoded.\n\
- allowedInactivityTime: Milliseconds for the maximum allowed inactivity time on server sessions born over the\n\
- local server before being reset. If missing, default value of 90000 will be assigned.\n\
tcpConnectDelay: Milliseconds to wait TCP connect to any server. If missing, default value of 200 will\n\
be assigned\n\
- answersTimeout: Milliseconds to wait pending application answers from diameter peers. If missing,\n\
- default value of 10000 will be assigned.\n\
ceaTimeout: Milliseconds to wait CEA from diameter server. If missing, default value of 'answersTimeout'\n\
will be assigned.\n\
watchdogPeriod: Milliseconds for watchdog timer (Tw) for diameter keep-alive procedure. If missing, default\n\
value of 30000 will be assigned.\n\
- entity: Target diameter entity (comma-separated '<address>:<port>' format).\n\
- For example: 10.20.30.40:3868,10.20.30.41:3868. If missing, no entity will be enabled.\n\
- entityServerSessions: Diameter entity server sessions (0: diameter entity disabled). Default value of 1.\n\
- diameterServer: Diameter own server address in '<address>:<port>' format. For example: 10.20.30.40:3868.\n\
- If missing, no local server will be enabled.\n\
- diameterServerSessions: Diameter own server available connections (0: diameter server disabled). Default value of 1.\n\
- Negative value implies no limit accepting incoming connections.\n\
balance: Balance over entity servers instead of doing standard behaviour (first primary, secondary\n\
if fails, etc.). Default value 'no'.\n\
sessionBasedModelsClientSocketSelection: By default, round-robin will be applied for IEC model (SMS/MMS), and Session-Id Low Part\n\
will be analyzed for ECUR/SCUR model (data, voice and content). You could change ECUR/SCUR\n\
analysis behaviour providing 'SessionIdHighPart', 'SessionIdOptionalPart' (atoi applied;\n\
usually subscriber id data, i.e. MSISDN or IMSI) and 'RoundRobin' (also 'SessionIdLowPart').\n\
+\n\
+\n\
+ - Diameter servers:\n\
+\n\
+ diameterServer: Diameter own server address in '<address>:<port>' format. For example: 10.20.30.40:3868.\n\
+ If missing, no local server will be enabled.\n\
+ diameterServerSessions: Diameter own server available connections (0: diameter server disabled). Default value of 1.\n\
+ Negative value implies no limit accepting incoming connections.\n\
+ cea: User defined CEA path file to be encoded to answer client CERs.\n\
+ If missing, will be harcoded.\n\
+ allowedInactivityTime: Milliseconds for the maximum allowed inactivity time on server sessions born over the\n\
+ local server before being reset. If missing, default value of 90000 will be assigned.\n\
+\n\
+\n\
+ - General:\n\
+\n\
+ answersTimeout: Milliseconds to wait pending application answers from diameter peers. If missing,\n\
+ default value of 10000 will be assigned.\n\
retries: Expired responses will cause a number of request retransmissions. Disabled by default (0 retries).\n\
log: Process log file (operations result, traffic log, etc.). By default '<originHost>.launcher.log'.\n\
Empty string or \"null\" name, to disable. Warning: there is no rotation for log files\n\
const anna::xml::Attribute *id, *dictionary;
// <!ATTLIST node originHost CDATA #REQUIRED applicationId CDATA #REQUIRED 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>
- const anna::xml::Attribute *originHost, *appId, *originRealm, *cer, *dwr, *allowedInactivityTime, *tcpConnectDelay,
+ const anna::xml::Attribute *originHost, *appId, *originRealm, *cer, *dwr, *cea, *allowedInactivityTime, *tcpConnectDelay,
*answersTimeout, *ceaTimeout, *watchdogPeriod, *entity, *entityServerSessions,
*diameterServer, *diameterServerSessions, *balance, *sessionBasedModelsClientSocketSelection,
*retries, *log, *splitLog, *detailedLog, *dumpLog, *burstLog;
originRealm = (*it)->getAttribute("originRealm", false /* no exception */);
cer = (*it)->getAttribute("cer", false /* no exception */);
dwr = (*it)->getAttribute("dwr", false /* no exception */);
+ cea = (*it)->getAttribute("cea", false /* no exception */);
allowedInactivityTime = (*it)->getAttribute("allowedInactivityTime", false /* no exception */);
tcpConnectDelay = (*it)->getAttribute("tcpConnectDelay", false /* no exception */);
answersTimeout = (*it)->getAttribute("answersTimeout", false /* no exception */);
// Diameter Server:
if(diameterServer) {
+ // Server CEA
+ std::string ceaPathfile = cea ? cea->getValue() : "";
+
int sessions = diameterServerSessions ? diameterServerSessions->getIntegerValue() : 1;
- a_workingNode->startDiameterServer(diameterServer->getValue(), sessions, allowedInactivityTimeMs);
+ a_workingNode->startDiameterServer(diameterServer->getValue(), sessions, allowedInactivityTimeMs, answersTimeoutMs, ceaPathfile);
}
// Logs:
--- /dev/null
+// 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 //
+
+
+// Project
+#include <anna/core/core.hpp>
+#include <anna/diameter/codec/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 <MyDiameterEngine.hpp>
+
+
+void MyDiameterEngine::readCEA(anna::DataBlock &cea, const anna::DataBlock & cer) throw() {
+
+ LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEngine", "readCEA", ANNA_FILE_LOCATION));
+
+ // Default implementation:
+ if (a_ceaPathfile == "")
+ return anna::diameter::comm::Engine::readCEA(cea, cer);
+
+// if(codec::functions::getCommandId(cer) != helpers::base::COMMANDID__Capabilities_Exchange_Answer) {
+//throw anna::RuntimeException("The message provided as 'CEA' is not a Capabilities-Exchange-Answer",
+//}
+
+ anna::diameter::codec::Message diameterCEA(getBaseProtocolCodecEngine());
+ try {
+ diameterCEA.loadXML(a_ceaPathfile);
+ diameterCEA.setHopByHop(anna::diameter::codec::functions::getHopByHop(cer));
+ diameterCEA.setEndToEnd(anna::diameter::codec::functions::getEndToEnd(cer));
+ cea = diameterCEA.code();
+
+ } catch(anna::RuntimeException &ex) {
+ ex.trace();
+ LOGWARNING(anna::Logger::warning("CEA file not found or unable to parse. Encoding harcoded default version ...", ANNA_FILE_LOCATION));
+ //return anna::diameter::comm::Engine::readCEA(cea, cer);
+ // will fail with empty cea
+ }
+}
+
#include <MyDiameterEntity.hpp>
#include <MyLocalServer.hpp>
+// Standard
+#include <string>
+
namespace anna {
namespace diameter {
// Default implementation is enough
// void readDPA(anna::DataBlock &dpa, const anna::DataBlock & dpr) throw() {;} // DPA is not replied
-// void readCEA(anna::DataBlock &cea, const anna::DataBlock & cer) throw() {;} // CEA is not replied
+ void setCEA(const std::string &ceaPathfile) throw() { a_ceaPathfile = ceaPathfile; }
+ void readCEA(anna::DataBlock &cea, const anna::DataBlock & cer) throw();
// void readDWA(anna::DataBlock &dwa, const anna::DataBlock & dwr) throw() {;} // DWA is not replied
private:
MyLocalServer* aux = static_cast <MyLocalServer*>(localServer);
a_localServersRecycler.release(aux);
}
+
+ std::string a_ceaPathfile; // path file to optional CEA (diameter local server configuration)
};
#endif
a_entity->setClassCodeTimeout(anna::diameter::comm::ClassCode::ApplicationMessage, applicationTimeout);
}
-void OriginHost::startDiameterServer(const std::string &serverRepresentation, int sessions, const anna::Millisecond &inactivityTimeout) throw(anna::RuntimeException) {
+void OriginHost::startDiameterServer(const std::string &serverRepresentation, int sessions, const anna::Millisecond &inactivityTimeout, const anna::Millisecond &applicationTimeout, const std::string &ceaPathfile) throw(anna::RuntimeException) {
//if(sessions <= 0) return; negative implies no limit for accepted connections
std::string address; int port;
anna::functions::getAddressAndPortFromSocketLiteral(serverRepresentation, address, port);
std::string serverDescription = "Launcher diameter local server for "; serverDescription += a_originHost;
+ a_commEngine->setCEA(ceaPathfile);
a_diameterServer = (MyLocalServer*)(a_commEngine->createLocalServer(address, port, sessions));
// we could set sessions = 0, and after application run(), use setMaxConnections(real sessions)
// over the local server in order to start it.
a_diameterServer->setDescription(serverDescription);
a_diameterServer->setAllowedInactivityTime(inactivityTimeout);
+ a_diameterServer->setClassCodeTimeout(anna::diameter::comm::ClassCode::ApplicationMessage, applicationTimeout);
}
anna::diameter::comm::Message *OriginHost::createCommMessage() throw(anna::RuntimeException) {
void createEntity(const std::string &entityRepresentation, const anna::Millisecond &bindTimeout, const anna::Millisecond &applicationTimeout) throw(anna::RuntimeException);
MyDiameterEntity *getEntity() const throw() { return a_entity; }
- void startDiameterServer(const std::string &serverRepresentation, int sessions, const anna::Millisecond &inactivityTimeout) throw(anna::RuntimeException);
+ void startDiameterServer(const std::string &serverRepresentation, int sessions, const anna::Millisecond &inactivityTimeout, const anna::Millisecond &applicationTimeout, const std::string &ceaPathfile) throw(anna::RuntimeException);
MyLocalServer* getDiameterServer() throw() { return a_diameterServer; }
void setRequestRetransmissions(int r) throw() { if (r >= 0) a_requestRetransmissions = r; }
-->
<!ELEMENT node EMPTY>
-<!ATTLIST node originHost CDATA #REQUIRED applicationId CDATA #REQUIRED originRealm 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>
+<!ATTLIST node originHost CDATA #REQUIRED applicationId CDATA #REQUIRED originRealm CDATA #IMPLIED cer CDATA #IMPLIED dwr CDATA #IMPLIED cea 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>
<!--
Node record
originHost: Node identifier as diameter application host name.
applicationId: The Application-Id provided must exists as a registered 'stack id'.
originRealm: Origin-Realm (domain-name internally used by default).
+
+
+ - Diameter clients:
+
+ entity: Target diameter entity (comma-separated '<address>:<port>' format).
+ For example: 10.20.30.40:3868,10.20.30.41:3868. If missing, no entity will be enabled.
+ entityServerSessions: Diameter entity server sessions (0: diameter entity disabled). Default value of 1.
cer: User defined CER path file to be encoded to establish diameter connections.
If missing, will be harcoded.
dwr: User defined DWR path file to be encoded for diameter protocol keep alive.
If missing, will be harcoded.
- allowedInactivityTime: Milliseconds for the maximum allowed inactivity time on server sessions born over the
- local server before being reset. If missing, default value of 90000 will be assigned.
tcpConnectDelay: Milliseconds to wait TCP connect to any server. If missing, default value of 200 will
- be assigned.
- answersTimeout: Milliseconds to wait pending application answers from diameter peers. If missing,
- default value of 10000 will be assigned.
+ be assigned
ceaTimeout: Milliseconds to wait CEA from diameter server. If missing, default value of 'answersTimeout'
will be assigned.
watchdogPeriod: Milliseconds for watchdog timer (Tw) for diameter keep-alive procedure. If missing, default
value of 30000 will be assigned.
- entity: Target diameter entity (comma-separated '<address>:<port>' format).
- For example: 10.20.30.40:3868,10.20.30.41:3868. If missing, no entity will be enabled.
- entityServerSessions: Diameter entity server sessions (0: diameter entity disabled). Default value of 1.
- diameterServer: Diameter own server address in '<address>:<port>' format. For example: 10.20.30.40:3868.
- If missing, no local server will be enabled.
- diameterServerSessions: Diameter own server available connections (0: diameter server disabled). Default value of 1.
- Negative value implies no limit accepting incoming connections.
balance: Balance over entity servers instead of doing standard behaviour (first primary, secondary
if fails, etc.). Default value 'no'.
sessionBasedModelsClientSocketSelection: By default, round-robin will be applied for IEC model (SMS/MMS), and Session-Id Low Part
will be analyzed for ECUR/SCUR model (data, voice and content). You could change ECUR/SCUR
analysis behaviour providing 'SessionIdHighPart', 'SessionIdOptionalPart' (atoi applied;
- usually subscriber id data, i.e. MSISDN or IMSI) and 'RoundRobin' (also 'SessionIdLowPart')
+ usually subscriber id data, i.e. MSISDN or IMSI) and 'RoundRobin' (also 'SessionIdLowPart').
+
+
+ - Diameter servers:
+
+ diameterServer: Diameter own server address in '<address>:<port>' format. For example: 10.20.30.40:3868.
+ If missing, no local server will be enabled.
+ diameterServerSessions: Diameter own server available connections (0: diameter server disabled). Default value of 1.
+ Negative value implies no limit accepting incoming connections.
+ cea: User defined CEA path file to be encoded to answer client CERs.
+ If missing, will be harcoded.
+ allowedInactivityTime: Milliseconds for the maximum allowed inactivity time on server sessions born over the
+ local server before being reset. If missing, default value of 90000 will be assigned.
+
+
+ - General:
+
+ answersTimeout: Milliseconds to wait pending application answers from diameter peers. If missing,
+ default value of 10000 will be assigned.
retries: Expired responses will cause a number of request retransmissions. Disabled by default (0 retries).
log: Process log file (operations result, traffic log, etc.). By default '<originHost>.launcher.log'.
- Empty string or "null" name, to disable. Warning: there is no rotation for log files
+ Empty string or \"null\" name, to disable. Warning: there is no rotation for log files
(use logrotate or whatever you consider).
splitLog: Splits log file (appends to log filename, extensions with the type of event: see help on
startup information-level traces). No log files for code/decode and load operations are created.
dumpLog: Write to disk every incoming/outcoming message named as:
'<unix ms timestamp>.<originHost>.<hop by hop>.<end to end>.<message code>.<request|answer>.<type of event>.xml'
Default value 'no'.
- burstLog: Burst operations log file. By default '<originHost>.launcher.burst'. Empty string or "null" name, to disable.
+ burstLog: Burst operations log file. By default '<originHost>.launcher.burst'. Empty string or \"null\" name, to disable.
Warning: there is no rotation for log files (use logrotate or whatever). Output: dot (.) for each
burst message sent/pushed, cross (x) for popped ones, and order number when multiple of 1% of burst
list size, plus OTA requests when changed.
*/
virtual void releaseLocalServer(LocalServer*) throw() {;}
+ // Gets the base protocol codec engine used internally.
+ // This engine is initializaed on constructor with the base protocol dictionary.
+ // The reason to not reuse any other codec engine from the application is to have this one isolated with no interference
+ // regarding configuration changes (validation depth/mode, fix mode, etc.).
+ //
+ // @return Pointer to the internal base protocol codec engine
+ codec::Engine *getBaseProtocolCodecEngine() const throw() { return const_cast<codec::Engine *>(&a_baseProtocolCodecEngine); }
private:
void assertBaseProtocolHealth() throw(anna::RuntimeException); // checks the dictionary
- // Gets the base protocol codec engine used internally.
- // This engine is initializaed on constructor with the base protocol dictionary.
- // The reason to not reuse any other codec engine from the application is to have this one isolated with no interference
- // regarding configuration changes (validation depth/mode, fix mode, etc.).
- //
- // @return Pointer to the internal base protocol codec engine
- codec::Engine *getBaseProtocolCodecEngine() const throw() { return const_cast<codec::Engine *>(&a_baseProtocolCodecEngine); }
-
//////////////////////////
// CLIENT FUNCTIONALITY //
//////////////////////////
*/
void setDescription(const std::string description) throw() { a_description = description; }
+ /**
+ Set timeout to consider failed a request.
+ \param v Requests class code.
+ \param millisecond Milliseconds wait before considering the requests failed.
+
+ Timers are internally managed and automatically activated.
+ */
+ void setClassCodeTimeout(const ClassCode::_v v, const anna::Millisecond & millisecond) throw();
/**
Sets the server socket optional category
int vendorId = anna::diameter::helpers::VENDORID__tgpp; // Unsigned32
diameterCEA.addAvp(anna::diameter::helpers::base::AVPID__Vendor_Id)->getUnsigned32()->setValue(vendorId);
// Product-Name
- std::string productName = "OCS Diameter Server"; // UTF8String
+ std::string productName = "Diameter Server"; // UTF8String
diameterCEA.addAvp(anna::diameter::helpers::base::AVPID__Product_Name)->getUTF8String()->setValue(productName);
// Encode
cea = diameterCEA.code();
closeServerSession(serverSession(it));
}
+void LocalServer::setClassCodeTimeout(const ClassCode::_v v, const anna::Millisecond & millisecond) throw() {
+ LOGMETHOD(anna::TraceMethod tttm("diameter::comm::LocalServer", "setClassCodeTimeout", ANNA_FILE_LOCATION));
+
+ for(serverSession_iterator it = serverSession_begin(); it != serverSession_end(); it++) {
+ try {
+ serverSession(it)->setClassCodeTimeout(v, millisecond);
+ } catch(anna::RuntimeException &ex) {
+ ex.trace();
+ }
+ }
+}
void LocalServer::setMaxConnections(int maxConnections) throw(anna::RuntimeException) {
- LOGMETHOD(anna::TraceMethod tttm("anna::diameter::comm::LocalServer", "setMaxConnections", ANNA_FILE_LOCATION));
+ LOGMETHOD(anna::TraceMethod tttm("diameter::comm::LocalServer", "setMaxConnections", ANNA_FILE_LOCATION));
// Negative & initial
if(maxConnections < 0) {