From: Eduardo Ramos Testillano Date: Wed, 29 Apr 2015 01:26:32 +0000 (+0200) Subject: Identify Avp Rule by AvpId to avoid name collision for avps renamed. Fix 3GPP-Rat... X-Git-Tag: REFACTORING_TESTING_LIBRARY~144 X-Git-Url: https://git.teslayout.com/public/public/public/?a=commitdiff_plain;h=24ef34af54c4a42fcbd65a0ef065bddaaf1bd096;p=anna.git Identify Avp Rule by AvpId to avoid name collision for avps renamed. Fix 3GPP-Rat-Type to 3GPP-RAT-Type anyway. --- diff --git a/include/anna/diameter/stack/AvpRule.hpp b/include/anna/diameter/stack/AvpRule.hpp index e31817f..ead1dc6 100644 --- a/include/anna/diameter/stack/AvpRule.hpp +++ b/include/anna/diameter/stack/AvpRule.hpp @@ -75,13 +75,12 @@ public: private: const Dictionary *a_dictionary; - std::string a_avpName; // reference + AvpId a_avpId; // reference Presence::_v a_presence; std::string a_qual; void _initialize(const Dictionary *d) throw() { a_dictionary = d; - a_avpName = ""; a_presence = Presence::None; a_qual = ""; } @@ -94,12 +93,12 @@ public: // get - const std::string & getAvpName(void) const throw() { return a_avpName; } + std::string getAvpName(void) const throw(); const Presence::_v & getPresence(void) const throw() { return a_presence; } const std::string & getQual(void) const throw() { return a_qual; } // helpers - AvpId getId(void) const throw(); + AvpId getId(void) const throw() { return a_avpId; } bool isAny(void) const throw(); // generic Avp bool isFixed(void) const throw() { return (a_presence == Presence::Fixed); } bool isMandatory(void) const throw() { return (a_presence == Presence::Mandatory); } @@ -114,7 +113,7 @@ public: // set void initialize(const Dictionary *d = NULL) throw() { _initialize(d); } - void setAvpName(const std::string & an) throw() { a_avpName = an; } + void setAvpId(const AvpId & ai) throw() { a_avpId = ai; } void setPresence(const Presence::_v & p) throw() { a_presence = p; } void setQual(const std::string & q) throw(anna::RuntimeException); }; diff --git a/source/diameter/stack/AvpRule.cpp b/source/diameter/stack/AvpRule.cpp index 68ba88b..bec3ec9 100644 --- a/source/diameter/stack/AvpRule.cpp +++ b/source/diameter/stack/AvpRule.cpp @@ -41,18 +41,18 @@ void anna::diameter::stack::AvpRule::setQual(const std::string & q) throw(anna:: //------------------------------------------------------------------------------ -//------------------------------------------------------------- AvpRule::getId() +//-------------------------------------------------------- AvpRule::getAvpName() //------------------------------------------------------------------------------ -anna::diameter::AvpId anna::diameter::stack::AvpRule::getId(void) const throw() { - const Avp * avp = a_dictionary->getAvp(a_avpName); - return avp->getId(); +std::string anna::diameter::stack::AvpRule::getAvpName(void) const throw() { + const Avp * avp = a_dictionary->getAvp(a_avpId); + return avp->getName(); } //------------------------------------------------------------------------------ //------------------------------------------------------------- AvpRule::isAny() //------------------------------------------------------------------------------ bool anna::diameter::stack::AvpRule::isAny(void) const throw() { - const Avp * avp = a_dictionary->getAvp(a_avpName); + const Avp * avp = a_dictionary->getAvp(a_avpId); const Format * format = a_dictionary->getFormat(avp->getFormatName()); return format->isAny(); } @@ -106,7 +106,7 @@ int anna::diameter::stack::AvpRule::getQualMax(void) const throw() { //------------------------------------------------------------------------------ std::string anna::diameter::stack::AvpRule::asString(bool showPair) const throw() { std::string trace = "No Avp rule defined"; - const Avp * avp = a_dictionary->getAvp(a_avpName); + const Avp * avp = a_dictionary->getAvp(a_avpId); if(avp) { trace = a_qual; @@ -119,7 +119,7 @@ std::string anna::diameter::stack::AvpRule::asString(bool showPair) const throw( if(isOptional()) { s_open = "["; s_close = "]"; } trace += s_open; - trace += a_avpName; + trace += getAvpName(); // anna::diameter::functions::avpIdAsPairString(a_avpId);; trace += s_close; if(!showPair) return trace; @@ -147,7 +147,7 @@ anna::xml::Node* anna::diameter::stack::AvpRule::asXML(anna::xml::Node* parent) // // anna::xml::Node* result = parent->createChild("avprule"); - result->createAttribute("id", a_avpName); + result->createAttribute("id", getAvpName()); std::string type; if(isFixed()) type = "Fixed"; diff --git a/source/diameter/stack/Dictionary.cpp b/source/diameter/stack/Dictionary.cpp index d5676a8..b94d46d 100644 --- a/source/diameter/stack/Dictionary.cpp +++ b/source/diameter/stack/Dictionary.cpp @@ -693,7 +693,7 @@ void Dictionary::extractAvps(const anna::xml::Node *rootNode) throw(anna::Runtim throw anna::RuntimeException(s_ex, ANNA_FILE_LOCATION); } - auxAvpRule.setAvpName(id); + auxAvpRule.setAvpId(avp->getId()); auxAvpRule.setPresence(AvpRule::Presence::asEnum(type)); auxAvpRule.setQual(qual ? (qual->getValue()) : ""); gavp->addAvpRule(auxAvpRule); @@ -795,7 +795,7 @@ void Dictionary::extractCommands(const anna::xml::Node *rootNode) throw(anna::Ru throw anna::RuntimeException(s_ex, ANNA_FILE_LOCATION); } - auxAvpRule.setAvpName(id); + auxAvpRule.setAvpId(avp->getId()); auxAvpRule.setPresence(AvpRule::Presence::asEnum(type)); auxAvpRule.setQual(qual ? (qual->getValue()) : ""); auxCommand.addAvpRule(auxAvpRule); diff --git a/source/diameter/stack/setups/avps_nokia.xml b/source/diameter/stack/setups/avps_nokia.xml index 6368584..090a0ed 100644 --- a/source/diameter/stack/setups/avps_nokia.xml +++ b/source/diameter/stack/setups/avps_nokia.xml @@ -14,7 +14,7 @@ -