1 // ANNA - Anna is Not Nothingness Anymore
3 // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
5 // http://redmine.teslayout.com/projects/anna-suite
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
17 // * Neither the name of the copyright holder nor the names of its
18 // contributors may be used to endorse or promote products derived from
19 // this software without specific prior written permission.
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 // Authors: eduardo.ramos.testillano@gmail.com
34 // cisco.tierra@gmail.com
37 #ifndef anna_diameter_comm_Response_hpp
38 #define anna_diameter_comm_Response_hpp
41 #include <anna/core/util/Recycler.hpp>
42 #include <anna/core/Allocator.hpp>
43 #include <anna/core/RuntimeException.hpp>
46 #include <anna/diameter/defines.hpp>
47 #include <anna/diameter.comm/ClassCode.hpp>
66 Answers that we could receive from diameter servers.
68 La respuesta correspondiente a una peticion se genera automaticamente al invocar a diameter::comm::Session::send.
69 ANNA::diameter::comm notifies el resultado de la operacion solicitada mediante la invocacion
70 al metodo-menejador diameter::comm::Session::eventResponse de nuestra sesion.
79 Timeout, /**< answer timeout from peer, or transport failure with OTA request notification of timeout event deferred by configurtion */
80 DiameterUnavailable /**< Diameter server was unavailable and notification is not deferred to timeout event for OTA requests */
85 Devuelve el tipo de la clase de esta respuesta.
86 \return El tipo de la clase de esta respuesta.
88 const ClassCode::_v & getClassCode() const throw() { return a_classCode; }
91 Devuelve la identificacion del mensaje diameter.
92 Esta identificacion sera generada automaticamente al enviar la peticion.
93 \return Identificacion del mensaje asociado a esta peticion/respuesta.
94 \see diameter::comm::Session::send
96 HopByHop getHopByHop() const throw() { return a_hopByHop; }
99 Devuelve la sesion que genera esta respuesta.
100 \return La instancia de la sesion que genera esta respuesta.
102 const Session* getSession() const throw() { return a_session; }
105 Devuelve la sesion que origino la creacion de esta respuesta.
106 \return La sesion que origino la creacion de esta respuesta.
108 Session* getSession() throw() { return a_session; }
112 Devuelve el resultado de la peticion diameter solicitada.
113 \return El resultado de la peticion diameter solicitada.
115 const ResultCode::_v & getResultCode() const throw() { return a_resultCode; }
119 Returns original request for the response received from the network.
120 \see diameter::comm::Session::send
122 const Message* getRequest() const throw() { return a_request; }
125 Returns message received from the network.
126 \see diameter::comm::Session::send
128 const anna::DataBlock *getMessage() const throw() { return a_message; }
133 // Reponse regarding diameter keepalive
135 // bool isKeepAlive() const throw();
138 Devuelve una cadena con la informacion relevante sobre esta instancia.
139 \return Una cadena con la informacion relevante sobre esta instancia.
141 std::string asString() const throw();
144 ClassCode::_v a_classCode;
147 ResultCode::_v a_resultCode;
149 const Message* a_request; // associated original request
150 const anna::DataBlock *a_message; // received datablock from server
152 typedef anna::Recycler<Response> response_pool;
153 static response_pool st_responses;
157 static Response* instance(const ClassCode::_v &, const HopByHop) throw(anna::RuntimeException);
158 static void release(Response* response) throw();
160 void clear() throw();
162 void setSession(Session* session) throw() { a_session = session; }
163 void setRequest(const Message* request) throw() { a_request = request; }
164 void setMessage(const anna::DataBlock *message) throw() { a_message = message; }
165 void activateTimer() throw(anna::RuntimeException);
166 void cancelTimer() throw();
167 void setResultCode(const ResultCode::_v & resultCode) throw() { a_resultCode = resultCode; }
169 static const char* asText(const ResultCode::_v) throw();
171 friend class Session;
172 friend class ClientSession;
173 friend class ServerSession;
175 friend class anna::Allocator<Response>;