Skip to content

Commit

Permalink
Merge pull request RestComm#13 from gfigiel/Issue#12-SessionIDonceonly
Browse files Browse the repository at this point in the history
Guarantee only 1 occurrence of Session-Id will be present at message when adding it.

Fixes RestComm#12
  • Loading branch information
brainslog authored Aug 3, 2016
2 parents f07f690 + f6031b4 commit 5d6dacf
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
*
* @author <a href="mailto:[email protected]"> Bartosz Baranowski </a>
* @author <a href="mailto:[email protected]"> Alexandre Mendonca </a>
* @author <a href="mailto:[email protected]"> Grzegorz Figiel (ProIDS sp. z o.o.)</a>
*/
public class AvpUtilities {

Expand Down Expand Up @@ -224,6 +225,8 @@ public static void setAvpAsString(Object parent, int avpCode, long vendorId, boo

switch(avpCode) {
case Avp.SESSION_ID:
//(...) All messages pertaining to a specific session MUST include only one Session-Id AVP (...)
set.removeAvp(avpCode);
// (...) the Session-Id SHOULD appear immediately following the Diameter Header
set.insertAvp(0, avpCode, value, vendorId, isMandatory, isProtected, isOctetString);
break;
Expand Down Expand Up @@ -476,6 +479,8 @@ public static void setAvpAsUTF8String(Object parent, int avpCode, long vendorId,

switch(avpCode) {
case Avp.SESSION_ID:
//(...) All messages pertaining to a specific session MUST include only one Session-Id AVP (...)
set.removeAvp(avpCode);
// (...) the Session-Id SHOULD appear immediately following the Diameter Header
set.insertAvp(0, avpCode, value, vendorId, isMandatory, isProtected, false);
break;
Expand Down Expand Up @@ -1601,6 +1606,8 @@ public static void setAvpAsRaw(Object parent, int avpCode, long vendorId, AvpSet

switch(avpCode) {
case Avp.SESSION_ID:
//(...) All messages pertaining to a specific session MUST include only one Session-Id AVP (...)
set.removeAvp(avpCode);
// (...) the Session-Id SHOULD appear immediately following the Diameter Header
set.insertAvp(0, avpCode, value, vendorId, isMandatory, isProtected);
break;
Expand Down Expand Up @@ -2216,9 +2223,11 @@ private static void addAvpInternal(DiameterAvp avp, AvpSet set) {
}
else {
switch (avpCode) {
case Avp.SESSION_ID:
// (...) the Session-Id SHOULD appear immediately following the Diameter Header
set.insertAvp(0, avpCode, avp.byteArrayValue(), avp.getVendorId(), avp.getMandatoryRule() != DiameterAvp.FLAG_RULE_MUSTNOT, avp.getProtectedRule() == DiameterAvp.FLAG_RULE_MUST);
case Avp.SESSION_ID:
//(...) All messages pertaining to a specific session MUST include only one Session-Id AVP (...)
set.removeAvp(avpCode);
// (...) the Session-Id SHOULD appear immediately following the Diameter Header
set.insertAvp(0, avpCode, avp.byteArrayValue(), avp.getVendorId(), avp.getMandatoryRule() != DiameterAvp.FLAG_RULE_MUSTNOT, avp.getProtectedRule() == DiameterAvp.FLAG_RULE_MUST);
break;
case Avp.ORIGIN_HOST:
case Avp.ORIGIN_REALM:
Expand Down

0 comments on commit 5d6dacf

Please sign in to comment.