Improvement: show avp name if known (validation)
authorEduardo Ramos Testillano <eduardo.ramos.testillano@ericsson.com>
Sun, 22 Mar 2015 20:07:48 +0000 (21:07 +0100)
committerEduardo Ramos Testillano <eduardo.ramos.testillano@ericsson.com>
Sun, 22 Mar 2015 20:07:48 +0000 (21:07 +0100)
include/anna/diameter/codec/Message.hpp
source/diameter/codec/Avp.cpp
source/diameter/codec/Message.cpp

index 3f17e09..87e1012 100644 (file)
@@ -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:
       //
index aa52c5f..1a4378d 100644 (file)
@@ -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()));
index 3a989cf..6f906f8 100644 (file)
@@ -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();