X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=source%2Fdiameter%2Fcodec%2FAvp.cpp;h=e39226838ee93c3b94afd27e6b4e8e8b66b97abb;hb=c68d53c4623b63ee20014a7eae0b9759a490c90e;hp=59cc6d76a9b0c6f3452d779304af256c1fb44934;hpb=4e12ac57e93c052f716a6305ad8fc099c45899d1;p=anna.git diff --git a/source/diameter/codec/Avp.cpp b/source/diameter/codec/Avp.cpp index 59cc6d7..e392268 100644 --- a/source/diameter/codec/Avp.cpp +++ b/source/diameter/codec/Avp.cpp @@ -1,8 +1,8 @@ -// ANNA - Anna is Not 'N' Anymore +// ANNA - Anna is Not Nothingness Anymore // // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo // -// https://bitbucket.org/testillano/anna +// http://redmine.teslayout.com/projects/anna-suite // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions @@ -14,7 +14,7 @@ // 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 +// * Neither the name of the copyright holder nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // @@ -1579,109 +1579,3 @@ std::string Avp::asXMLString() const throw() { return anna::xml::Compiler().apply(asXML(&root)); } - -///////////////////// -// FORMAT-SPECIFIC // -///////////////////// - - -//------------------------------------------------------------------------------ -//---------------------------------------------------- Avp::initializeByFormat() -//------------------------------------------------------------------------------ -void Avp::initializeByFormat() throw() { - a_ISDNNumber = NULL; - a_ISDNAddress = NULL; - a_Unsigned16 = NULL; -} - - -//------------------------------------------------------------------------------ -//--------------------------------------------------------- Avp::clearByFormat() -//------------------------------------------------------------------------------ -void Avp::clearByFormat() throw() { - delete a_ISDNNumber; - delete a_ISDNAddress; - delete a_Unsigned16; -} - - -//------------------------------------------------------------------------------ -//---------------------------------------------------- Avp::allocationByFormat() -//------------------------------------------------------------------------------ -void Avp::allocationByFormat(const stack::Format *stackFormat) throw() { - if(stackFormat->getName() == "ISDNNumber") a_ISDNNumber = new ISDNNumber(); - else if(stackFormat->getName() == "ISDNAddress") a_ISDNAddress = new ISDNAddress(); - else if(stackFormat->getName() == "Unsigned16") a_Unsigned16 = new Unsigned16(); -} - - -//------------------------------------------------------------------------------ -//----------------------------------------------------- Avp::getLengthByFormat() -//------------------------------------------------------------------------------ -U24 Avp::getLengthByFormat(const stack::Format *stackFormat) const throw() { - U24 result = 0; - - if(stackFormat->getName() == "ISDNNumber") result += a_ISDNNumber->getSize(); - else if(stackFormat->getName() == "ISDNAddress") result += a_ISDNAddress->getSize(); - else if(stackFormat->getName() == "Unsigned16") result += a_Unsigned16->getSize(); - - return result; -} - - -//------------------------------------------------------------------------------ -//------------------------------------------------ Avp::decodeDataPartByFormat() -//------------------------------------------------------------------------------ -void Avp::decodeDataPartByFormat(const char * buffer, int size, const stack::Format *stackFormat) throw(anna::RuntimeException) { - if(stackFormat->getName() == "ISDNNumber") a_ISDNNumber->decode(buffer, size); - else if(stackFormat->getName() == "ISDNAddress") a_ISDNAddress->decode(buffer, size); - else if(stackFormat->getName() == "Unsigned16") a_Unsigned16->decode(buffer, size); -} - - -//------------------------------------------------------------------------------ -//---------------------------------------------------------- Avp::codeByFormat() -//------------------------------------------------------------------------------ -void Avp::codeByFormat(char* dataPart, const stack::Format *stackFormat) const throw(anna::RuntimeException) { - int dataBytes; - - if(stackFormat->getName() == "ISDNNumber") a_ISDNNumber->code(dataPart, dataBytes); - else if(stackFormat->getName() == "ISDNAddress") a_ISDNAddress->code(dataPart, dataBytes); - else if(stackFormat->getName() == "Unsigned16") a_Unsigned16->code(dataPart, dataBytes); -} - - -//------------------------------------------------------------------------------ -//---------------------------------------------------- Avp::getXMLdataByFormat() -//------------------------------------------------------------------------------ -std::string Avp::getXMLdataByFormat(bool & isHex, const stack::Format *stackFormat) const throw() { - std::string result; - - if(stackFormat->getName() == "ISDNNumber") { - isHex = true; - return a_ISDNNumber->asHexString(); - } else if(stackFormat->getName() == "ISDNAddress") { - isHex = true; - return a_ISDNAddress->asHexString(); - } else if(stackFormat->getName() == "Unsigned16") return a_Unsigned16->asPrintableString(); - - return result; -} - - -//------------------------------------------------------------------------------ -//------------------------------------------------------- Avp::fromXMLByFormat() -//------------------------------------------------------------------------------ -void Avp::fromXMLByFormat(const anna::xml::Attribute* data, const anna::xml::Attribute* hexData, const stack::Format *stackFormat) throw(anna::RuntimeException) { - if(stackFormat->getName() == "ISDNNumber") { - if(data) a_ISDNNumber->fromPrintableString(data->getValue().c_str()); - else if(hexData) a_ISDNNumber->fromHexString(hexData->getValue()); - } else if(stackFormat->getName() == "ISDNAddress") { - if(data) a_ISDNAddress->fromPrintableString(data->getValue().c_str()); - else if(hexData) a_ISDNAddress->fromHexString(hexData->getValue()); - } else if(stackFormat->getName() == "Unsigned16") { - if(data) a_Unsigned16->fromPrintableString(data->getValue().c_str()); - else if(hexData) a_Unsigned16->fromHexString(hexData->getValue()); - } -} -