Fixed multiple AVP error. Missing fix RFC 6733 section 7.5 regarding avps within...
[anna.git] / include / anna / diameter / codec / Message.hpp
index 5944c63..fb519b5 100644 (file)
@@ -146,7 +146,9 @@ class Message {
   bool flagsOK(int &rc) const throw(); // flags coherence regarding dictionary. Only must be called when Message is identified at the dictionary.
   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);
-  Avp * addFailedAVP() throw(); // returns Failed-AVP if exists, creates it when missing
+  Avp * addTheFailedAVP() throw(); // returns the Failed-AVP if exists, creates it when missing. The method could be named 'addFailedAVP'
+                                      // but we consider this better because only one instance (as RFC 6733 says in section 7.5) will be
+                                      // added by internal procedures (although, the application could obviously add more).
 
 protected:
 
@@ -406,32 +408,31 @@ public:
 
 
   /**
-     Adds a new AVP within a Failed-AVP over an answer message (for requests, do nothing).
+     Adds the wrong AVP within the Failed-AVP over an answer message (for requests, do nothing).
      If Failed-AVP AVP doesn't exists, is added and then filled (added within) with the value provided (empty AVP id representantion).
-     If Failed-AVP AVP already exists, is filled (added within) with the value provided (empty AVP id representantion).
+     If Failed-AVP AVP already exists, is probably filled by a previous found error, but anyway this is verified and if empty then is
+     filled (added within) with the value provided (empty AVP id representantion).
 
-     This method is internally used during #decode and/or #valid procedures in order to build automatic answers.
+     This method is internally used during #decode and/or #valid procedures in order to build automatic answers, but application
+     could call this for set another Failed-AVP content no detected by these methods, for example: DIAMETER_CONTRADICTING_AVPS or
+     DIAMETER_INVALID_AVP_BIT_COMBO). Also, application could add more Failed-AVP avps with other wrong avps, or accumulate wrong
+     avps inside the one and only Failed-AVP managed by the stack (see section 7.5 of RFC 6733).
 
      @param id Avp identifier as pair (code,vendor-id).
 
-     @return Pointer to the new AVP added within Failed-AVP, to make easy data-part accessif needed.
+     @return Pointer to the new AVP added within Failed-AVP, to make easy data-part access if needed.
   */
-  Avp * setNewFailedAvp(AvpId id) throw(anna::RuntimeException) { if(isRequest()) return NULL; return (addFailedAVP()->addAvp(id)); }
+  Avp * setFailedAvp(AvpId id) throw(anna::RuntimeException);
 
   /**
-     Adds a new AVP within a Failed-AVP over an answer message (for requests, do nothing).
-     If Failed-AVP AVP doesn't exists, is added and then filled (added within) with the value provided (empty AVP id representantion).
-     If Failed-AVP AVP already exists, is filled (added within) with the value provided (empty AVP id representantion).
-
-     This method is internally used during #decode and/or #valid procedures in order to build automatic answers, but application
-     could call this for set another Failed-AVP content no detected by these methods, for example: DIAMETER_CONTRADICTING_AVPS or
-     DIAMETER_INVALID_AVP_BIT_COMBO).
+     Same as #setFailedAvp(AvpId id) but providing an avp pointer with the needed information
 
-     @param id Avp identifier as pair (code,vendor-id).
+     @param avp Pointer to the added wrong avp
 
-     @return Pointer to the new AVP added within Failed-AVP, to make easy data-part accessif needed.
+     @return Pointer to the new AVP added within Failed-AVP, to make easy data-part access if needed.
   */
-  Avp * setNewFailedAvp(Avp *avp) throw() { if(!avp || isRequest()) return NULL; return (addFailedAVP()->addAvp(avp)); }
+  Avp * setFailedAvp(Avp *avp) throw(anna::RuntimeException);
+
 
 
   /**