--- /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 //
+
+
+#ifndef example_diameter_launcher_OriginHost_hpp
+#define example_diameter_launcher_OriginHost_hpp
+
+// Standard
+#include <string>
+#include <fstream>
+
+// Project
+#include <anna/core/util/Millisecond.hpp>
+#include <anna/core/util/Recycler.hpp>
+#include <anna/core/DataBlock.hpp>
+#include <anna/diameter/codec/Message.hpp>
+
+
+namespace anna {
+ namespace diameter {
+ namespace codec {
+ class Engine;
+ }
+ namespace stack {
+ class Dictionary;
+ }
+ namespace comm {
+ class Message;
+ }
+ }
+}
+
+
+class MyDiameterEntity;
+class MyDiameterEngine;
+class MyLocalServer;
+
+
+class OriginHost {
+
+ MyDiameterEngine *a_commEngine;
+ MyDiameterEntity *a_entity; // we could get it finding the unique instante within comm engine, but it is more comfortable assign here.
+ MyLocalServer* a_diameterServer; // idem
+ anna::diameter::codec::Engine *a_codecEngine;
+
+ // resources
+ int a_requestRetransmissions;
+ anna::Recycler<anna::diameter::comm::Message> a_commMessages;
+
+ // main
+ std::string a_originHost;
+ unsigned int a_applicationId;
+
+ // Timming
+ anna::Millisecond a_allowedInactivityTime;
+ anna::Millisecond a_tcpConnectDelay;
+ anna::Millisecond a_answersTimeout;
+ anna::Millisecond a_ceaTimeout;
+ anna::Millisecond a_watchdogPeriod;
+
+ // Logs & burst
+ std::string a_logFile;
+ bool a_splitLog, a_detailedLog, a_dumpLog;
+ std::string a_burstLogFile;
+ std::ofstream a_burstLogStream;
+ int a_burstCycle;
+ bool a_burstRepeat;
+ bool a_burstActive;
+ std::map < int /* dummy, p.e. used for order number */, anna::diameter::comm::Message* > a_burstMessages;
+ int a_burstLoadIndx;
+ std::map<int, anna::diameter::comm::Message*>::const_iterator a_burstDeliveryIt;
+ int a_otaRequest;
+ int a_burstPopCounter;
+
+public:
+ OriginHost(const std::string &originHost, unsigned int applicationId, const anna::diameter::stack::Dictionary *baseProtocolDictionary);
+ ~OriginHost() {;}
+
+ const std::string &getName() const throw() { return a_originHost; }
+
+ // Core resources:
+ MyDiameterEngine* getMyDiameterEngine() const throw() { return a_commEngine; }
+ unsigned int getApplicationId() const throw() { return a_applicationId; }
+ anna::diameter::codec::Engine *getCodecEngine() const throw() { return a_codecEngine; }
+
+ 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);
+ MyLocalServer* getDiameterServer() throw() { return a_diameterServer; }
+ void setRequestRetransmissions(int r) throw() { if (r >= 0) a_requestRetransmissions = r; }
+
+ // Messages factory:
+ anna::diameter::comm::Message *createCommMessage() throw(anna::RuntimeException);
+ void releaseCommMessage(anna::diameter::comm::Message*) throw();
+
+ // Traffic logs & burst:
+ void setLogs(const std::string &log, bool splitLog, bool detailedLog, bool dumpLog, const std::string &burstLog) throw() {
+ a_logFile = log;
+ a_splitLog = splitLog;
+ a_detailedLog = detailedLog;
+ a_dumpLog = dumpLog;
+ a_burstLogFile = burstLog;
+ }
+
+ bool logEnabled() const throw() { return (((a_logFile == "") || (a_logFile == "null")) ? false : true); }
+ void writeLogFile(const anna::DataBlock & db, const std::string &logExtension, const std::string &detail) const throw();
+ void writeLogFile(const anna::diameter::codec::Message & decodedMessage, const std::string &logExtension, const std::string &detail) const throw();
+ void writeBurstLogFile(const std::string &buffer) throw();
+ bool burstLogEnabled() const throw() { return (((a_burstLogFile == "") || (a_burstLogFile == "null")) ? false : true); }
+ int clearBurst() throw(); // returns removed
+ int loadBurstMessage(const anna::DataBlock & db) throw(anna::RuntimeException);
+ void repeatBurst(bool repeat) throw() { a_burstRepeat = repeat; }
+ int startBurst(int initialLoad) throw(); // return processed on start, or -1 if burst list is empty, -2 if invalid initial load (0 or negative)
+ int pushBurst(int loadAmount) throw(); // returns pushed (perhaps is less than provided because of no repeat mode and burst list exhausted), or -1 if burst list is empty, -2 if invalid load (0 or negative)
+ int sendBurst(int loadAmount) throw(); // returns sent (burst always cycled using send), returns -1 if burst list is empty, -2 if invalid load (0 or negative)
+ int popBurst(int releaseAmount) throw(); // returns popped (perhaps is less than provided because of OTA request), or -1 if burst stopped
+ int stopBurst() throw(); // returns remaining on cycle, or -1 if burst already stopped
+ bool burstActive() const throw() { return a_burstActive; }
+ bool sendBurstMessage(bool anyway = false) throw();
+ std::string lookBurst(int order = -1) const throw();
+ std::string gotoBurst(int order) throw();
+
+ anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
+ std::string asXMLString() const throw();
+};
+
+#endif