diff --git a/resources/diameter-base/common/events/src/main/java/net/java/slee/resource/diameter/base/events/avp/AvpUtilities.java b/resources/diameter-base/common/events/src/main/java/net/java/slee/resource/diameter/base/events/avp/AvpUtilities.java index ade0a8377..2382bb29c 100644 --- a/resources/diameter-base/common/events/src/main/java/net/java/slee/resource/diameter/base/events/avp/AvpUtilities.java +++ b/resources/diameter-base/common/events/src/main/java/net/java/slee/resource/diameter/base/events/avp/AvpUtilities.java @@ -52,6 +52,7 @@ * * @author Bartosz Baranowski * @author Alexandre Mendonca + * @author Grzegorz Figiel (ProIDS sp. z o.o.) */ public class AvpUtilities { @@ -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; @@ -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; @@ -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; @@ -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: