1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
9 #ifndef anna_diameter_comm_OriginHost_hpp
10 #define anna_diameter_comm_OriginHost_hpp
17 #include <anna/core/util/Millisecond.hpp>
18 #include <anna/core/util/Recycler.hpp>
19 #include <anna/core/DataBlock.hpp>
20 #include <anna/diameter/codec/Message.hpp>
21 #include <anna/diameter.comm/Message.hpp>
35 * OriginHost with single access point for client and server
39 anna::diameter::comm::Engine *a_commEngine;
40 anna::diameter::comm::Entity *a_entity; // we could get it finding the unique instante within comm engine, but it is more comfortable assign here.
41 anna::diameter::comm::LocalServer* a_diameterServer; // idem
42 anna::diameter::codec::Engine *a_codecEngine;
45 int a_requestRetransmissions;
46 anna::Recycler<anna::diameter::comm::Message> a_commMessages;
49 unsigned int a_applicationId;
52 std::string a_logFile;
53 bool a_splitLog, a_detailedLog, a_dumpLog;
54 std::string a_burstLogFile;
55 std::ofstream a_burstLogStream;
59 std::map < int /* dummy, p.e. used for order number */, anna::diameter::comm::Message* > a_burstMessages;
61 std::map<int, anna::diameter::comm::Message*>::const_iterator a_burstDeliveryIt;
63 int a_burstPopCounter;
66 OriginHost(anna::diameter::comm::Engine* commEngine, unsigned int applicationId);
70 const std::string &getName() const throw();
73 anna::diameter::comm::Engine* getCommEngine() const throw() { return a_commEngine; }
74 unsigned int getApplicationId() const throw() { return a_applicationId; }
75 anna::diameter::codec::Engine *getCodecEngine() const throw() { return a_codecEngine; }
77 void createEntity(const std::string &entityRepresentation, const anna::Millisecond &bindTimeout, const anna::Millisecond &applicationTimeout) throw(anna::RuntimeException);
78 anna::diameter::comm::Entity *getEntity() const throw() { return a_entity; }
80 void createDiameterServer(const std::string &serverRepresentation, int sessions, const anna::Millisecond &inactivityTimeout, const anna::Millisecond &applicationTimeout, const std::string &ceaPathfile) throw(anna::RuntimeException);
81 anna::diameter::comm::LocalServer* getDiameterServer() throw() { return a_diameterServer; }
82 void setRequestRetransmissions(int r) throw() { if (r >= 0) a_requestRetransmissions = r; }
85 anna::diameter::comm::Message *createCommMessage() throw(anna::RuntimeException);
86 void releaseCommMessage(anna::diameter::comm::Message*) throw();
88 // Traffic logs & burst:
89 void setLogs(const std::string &log, bool splitLog, bool detailedLog, bool dumpLog, const std::string &burstLog) throw() {
91 a_splitLog = splitLog;
92 a_detailedLog = detailedLog;
94 a_burstLogFile = burstLog;
97 bool logEnabled() const throw() { return (((a_logFile == "") || (a_logFile == "null")) ? false : true); }
98 void writeLogFile(const anna::DataBlock & db, const std::string &logExtension, const std::string &detail) const throw();
99 void writeLogFile(const anna::diameter::codec::Message & decodedMessage, const std::string &logExtension, const std::string &detail) const throw();
100 void writeBurstLogFile(const std::string &buffer) throw();
101 bool burstLogEnabled() const throw() { return (((a_burstLogFile == "") || (a_burstLogFile == "null")) ? false : true); }
102 int clearBurst() throw(); // returns removed
103 int loadBurstMessage(const anna::DataBlock & db) throw(anna::RuntimeException);
104 void repeatBurst(bool repeat) throw() { a_burstRepeat = repeat; }
105 int startBurst(int initialLoad) throw(); // return processed on start, or -1 if burst list is empty, -2 if invalid initial load (0 or negative)
106 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)
107 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)
108 int popBurst(int releaseAmount) throw(); // returns popped (perhaps is less than provided because of OTA request), or -1 if burst stopped
109 int stopBurst() throw(); // returns remaining on cycle, or -1 if burst already stopped
110 bool burstActive() const throw() { return a_burstActive; }
111 bool sendBurstMessage(bool anyway = false) throw();
112 std::string lookBurst(int order = -1) const throw();
113 std::string gotoBurst(int order) throw();
115 anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
116 std::string asXMLString() const throw();