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 //
10 #include <anna/diameter.comm/Transport.hpp>
12 #include <anna/core/tracing/Logger.hpp>
13 #include <anna/core/tracing/TraceMethod.hpp>
14 #include <anna/core/DataBlock.hpp>
15 #include <anna/comm/Message.hpp>
21 using namespace anna::diameter::comm;
23 anna::comm::TransportFactoryImpl <Transport> Transport::st_factory;
25 Transport::Transport() : anna::comm::Transport() {
26 setInputMessage(new anna::comm::Message());
29 Transport::~Transport() {
30 delete getInputMessage();
34 * La longitud se calcula con los primeros 4 bytes (el primer byte se ignora, pues es la version diameter)
36 int Transport::calculeSize(const anna::DataBlock& dataBlock)
37 throw(anna::RuntimeException) {
38 const int size = dataBlock.getSize();
43 const char* data = dataBlock.getData();
44 int result = (((unsigned int)data[1] << 16) & 0xFF0000) +
45 (((unsigned int)data[2] << 8) & 0x00FF00) +
46 (((unsigned int)data[3]) & 0x0000FF);
50 const anna::DataBlock& Transport::code(anna::comm::Message& message)
51 throw(anna::RuntimeException) {
52 LOGMETHOD(anna::TraceMethod ttmm(anna::Logger::Local7, "anna::diameter::comm::Transport", "code", ANNA_FILE_LOCATION));
53 a_forCode = message.code();
57 //--------------------------------------------------------------------------------
58 // Los 4 primeros bytes contienen la longitud del mensaje.
59 // Cada ClientSocket tiene su anna::diameter::comm::Transport asociado
60 //--------------------------------------------------------------------------------
61 const anna::comm::Message* Transport::decode(const anna::DataBlock& input)
62 throw(anna::RuntimeException) {
63 anna::comm::Message* inputMessage = static_cast <anna::comm::Message*>(getInputMessage());
64 inputMessage->setBody(input);