From: Eduardo Ramos Testillano Date: Sun, 22 Mar 2015 20:07:48 +0000 (+0100) Subject: Improvement: show avp name if known (validation) X-Git-Tag: REFACTORING_TESTING_LIBRARY~213 X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=commitdiff_plain;h=08bdffbddf4bc0938eadec51af88de18734beda3 Improvement: show avp name if known (validation) --- diff --git a/include/anna/diameter/codec/Message.hpp b/include/anna/diameter/codec/Message.hpp index 3f17e09..87e1012 100644 --- a/include/anna/diameter/codec/Message.hpp +++ b/include/anna/diameter/codec/Message.hpp @@ -147,7 +147,7 @@ class Message { int addChild(Avp *avp) throw() { return Avp::addChild(a_avps, a_insertionPositionForChilds, avp); } const anna::diameter::stack::Command *getStackCommand(CommandId id) const throw(anna::RuntimeException); - void setFailedAvp(const parent_t &parent, AvpId wrong) throw(anna::RuntimeException); + void setFailedAvp(const parent_t &parent, AvpId wrong, const char *wrongName = NULL) throw(anna::RuntimeException); // During message decoding and validation, the first wrong avp is stored and all the tracking is managed to find out its // nested path for the case of grouped avps with wrong avps inside. Remember the RFC 6733, section 7.5: // diff --git a/source/diameter/codec/Avp.cpp b/source/diameter/codec/Avp.cpp index aa52c5f..1a4378d 100644 --- a/source/diameter/codec/Avp.cpp +++ b/source/diameter/codec/Avp.cpp @@ -1115,7 +1115,7 @@ bool Avp::valid(const parent_t & parent, Message *answer) const throw(anna::Runt if(answer) { answer->setResultCode(helpers::base::AVPVALUES__Result_Code::DIAMETER_INVALID_AVP_BITS); - answer->setFailedAvp(parent, a_id); // RFC 6733 says nothing about Failed-AVP in this case... + answer->setFailedAvp(parent, a_id, stackAvp->getName().c_str()); // RFC 6733 says nothing about Failed-AVP in this case... } getEngine()->validationAnomaly(anna::functions::asString("The AVP %s flags (%d) does not fulfill the defined flag rules: %s", STRING_WITH_QUOTATION_MARKS__C_STR(me.asString()), (int)a_flags, STRING_WITH_QUOTATION_MARKS__C_STR(stackAvp->getFlagRulesDescription()))); @@ -1133,7 +1133,7 @@ bool Avp::valid(const parent_t & parent, Message *answer) const throw(anna::Runt if(answer) { answer->setResultCode(helpers::base::AVPVALUES__Result_Code::DIAMETER_INVALID_AVP_VALUE); - answer->setFailedAvp(parent, a_id); + answer->setFailedAvp(parent, a_id, stackAvp->getName().c_str()); } getEngine()->validationAnomaly(anna::functions::asString("Enumerated AVP %s with value %d does not comply to restriction: %s", STRING_WITH_QUOTATION_MARKS__C_STR(me.asString()), a_Enumerated->getValue(), stackAvp->getEnums())); diff --git a/source/diameter/codec/Message.cpp b/source/diameter/codec/Message.cpp index 3a989cf..6f906f8 100644 --- a/source/diameter/codec/Message.cpp +++ b/source/diameter/codec/Message.cpp @@ -460,7 +460,7 @@ int Message::getResultCode() const throw() { //------------------------------------------------------------------------------ //------------------------------------------------------ Message::setFailedAvp() //------------------------------------------------------------------------------ -void Message::setFailedAvp(const parent_t &parent, AvpId wrong) throw(anna::RuntimeException) { +void Message::setFailedAvp(const parent_t &parent, AvpId wrong, const char *wrongName) throw(anna::RuntimeException) { if(isRequest()) return; @@ -495,7 +495,7 @@ void Message::setFailedAvp(const parent_t &parent, AvpId wrong) throw(anna::Runt LOGDEBUG( std::string msg = "Adding to Failed-AVP, the wrong avp "; - msg += anna::diameter::functions::avpIdAsPairString(wrong); + msg += wrongName ? wrongName : (anna::diameter::functions::avpIdAsPairString(wrong)); msg += " found inside "; msg += parent.asString();