Dynamic lib selection and deployment
[anna.git] / include / anna / diameter.comm / Message.hpp
index 99887b9..9fc265a 100644 (file)
@@ -1,37 +1,9 @@
-// ANNA - Anna is Not Nothingness Anymore
-//
-// (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
-//
-// https://bitbucket.org/testillano/anna
-//
-// 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 Google Inc. 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 //
 
 
 #ifndef anna_diameter_comm_Message_hpp
@@ -68,18 +40,19 @@ class ServerSession;
 
 /**
    Messages launched to diameter servers
+   Could be proxied (end-to-end kept) or not (by default).
 */
 class Message : public anna::comm::Message {
 public:
 
   /**
-   * Define las acciones a realizar en caso de que el temporizador de la petición expire.
+   * Define las acciones a realizar en caso de que el temporizador de la peticin expire.
    */
-  struct OnExpiry { enum _v { Abandon, Ignore }; };
+  struct OnExpiry { enum _v { Abandon, Ignore, Retransmit }; };
 
   /**
      Constructor.
-     \param onExpiry Indica la acción a realizar si el temporizador de esta transación expira.
+     \param onExpiry Indica la acci�n a realizar si el temporizador de esta transaci�n expira.
   */
   Message(const OnExpiry::_v onExpiry = OnExpiry::Ignore) : anna::comm::Message(StatusCodeBuffer::Reserve),
     a_classCode(ClassCode::ApplicationMessage),
@@ -92,16 +65,16 @@ public:
   const ClassCode::_v & getClassCode() const throw() { return a_classCode; }
 
   /**
-   * Devuelve la acción a realizar en caso de que el temporizador asociado a esta petición expire.
-   * \return la acción a realizar en caso de que el temporizador asociado a esta petición expire.
+   * Devuelve la acci�n a realizar en caso de que el temporizador asociado a esta petici�n expire.
+   * \return la acci�n a realizar en caso de que el temporizador asociado a esta petici�n expire.
    */
   OnExpiry::_v getOnExpiry() const throw() { return a_onExpiry; }
 
   /**
-   * Establece la acción a realizar en caso de que el temporizador asociado a esta petición expire.
-   * \param onExpiry Indica la acción a realizar en caso de que el temporizador asociado a esta petición expire.
+   * Establece la acci�n a realizar en caso de que el temporizador asociado a esta petici�n expire.
+   * \param onExpiry Indica la acci�n a realizar en caso de que el temporizador asociado a esta petici�n expire.
    *
-   * \warning Establecer el valor OnExpiry::Ignore podría causar pérdida de memoria y uso innecesario de recursos.
+   * \warning Establecer el valor OnExpiry::Ignore podr�a causar p�rdida de memoria y uso innecesario de recursos.
    */
   void setOnExpiry(const OnExpiry::_v onExpiry) throw() { a_onExpiry = onExpiry; }
 
@@ -132,8 +105,34 @@ public:
   void setRequestEndToEnd(EndToEnd ete) throw() { a_requestEndToEnd = ete; }
   CommandId getCommandId(bool &isRequest) const throw();
   CommandId getCommandId() const throw() { bool dummy; return getCommandId(dummy); }
+  ApplicationId getApplicationId() const throw();
+
+  bool fixRequestSequence(HopByHop hbh, EndToEnd ete) throw();
+
+  // http://diameter-protocol.blogspot.com.es/2011/05/diameter-message-structure-and-message.html
+
+  /**
+   * In general, diameter nodes will sequence the End-To-End value when sending new requests.
+   * A 'false' value stands for intermediate agents (must keep end-to-end during 4 minutes even upon reboots).
+   */
+  bool endToEndSequenced() const throw() { return a_endToEndSequenced; }
+
+  /**
+   * By default, the diameter::comm message will sequence the end-to-end increasing the initial value created
+   * during session establishment. Anyway you could change this behaviour with this method.
+   *
+   * @see sequenceEndToEnd
+   */
+  void forwardEndToEnd() throw() { a_endToEndSequenced = false; }
+
+  /**
+   * By default, the diameter::comm message will sequence the end-to-end increasing the initial value created
+   * during session establishment. Anyway you could set again this behaviour with this method.
+   *
+   * @see forwardEndToEnd
+   */
+  void sequenceEndToEnd() throw() { a_endToEndSequenced = true; }
 
-  bool fixRequestSequence(HopByHop hbh, EndToEnd ete, bool freezeEndToEnd) throw();
 
   // Statistics
   void updateRequestTimestampMs(void) throw() { a_request_timestamp_ms = anna::functions::millisecond(); }
@@ -155,11 +154,12 @@ public:
 
   /** Initializes class information */
   void initialize() throw() {
-    a_retries = 0;
+    a_retries = 1;
     a_requestServerSessionKey = -1; // means unknown/unset
     a_requestClientSessionKey = ""; // means unknown/unset
     a_requestHopByHop = 0;
     a_requestEndToEnd = 0;
+    a_endToEndSequenced = true;
   }
 
 
@@ -167,7 +167,7 @@ protected:
   /**
      Constructor.
      \param classCode Tipo de clase de esta peticion.
-     \param onExpiry Indica la acción a realizar si el temporizador de esta transación expira.
+     \param onExpiry Indica la acci�n a realizar si el temporizador de esta transaci�n expira.
   */
   Message(const ClassCode::_v & classCode, const OnExpiry::_v onExpiry = OnExpiry::Ignore) : anna::comm::Message(StatusCodeBuffer::Reserve),
     a_classCode(classCode),
@@ -183,6 +183,7 @@ private:
   std::string a_requestClientSessionKey;    // idem for request which was received from servers
   HopByHop a_requestHopByHop; // application backup for hop-by-hop in order to restore on answer receive
   EndToEnd a_requestEndToEnd; // application backup for end-to-end in order to restore on answer receive
+  bool a_endToEndSequenced; // end-to-end will be sequenced by default (true)
 
   void send(ClientSession&) const throw(anna::RuntimeException);
   void send(ServerSession&) const throw(anna::RuntimeException);