use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class ShClientMessageFactoryImpl method createUserDataRequest.
public UserDataRequest createUserDataRequest() {
DiameterAvp[] avps = new DiameterAvp[0];
if (session != null) {
try {
DiameterAvp sessionIdAvp = null;
sessionIdAvp = baseAvpFactory.createAvp(0, DiameterAvpCodes.SESSION_ID, session.getSessionId());
avps = new DiameterAvp[] { sessionIdAvp };
} catch (NoSuchAvpException e) {
logger.error("Unexpected failure trying to create Session-Id AVP.", e);
}
}
Message msg = createShMessage(null, avps, UserDataRequest.commandCode);
UserDataRequestImpl udr = new UserDataRequestImpl(msg);
addOrigin(udr);
return udr;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class GxMessageFactoryImpl method addAvp.
protected void addAvp(final DiameterAvp avp, final AvpSet set) {
// FIXME: alexandre: Should we look at the types and add them with proper function?
if (avp instanceof GroupedAvp) {
final AvpSet avpSet = set.addGroupedAvp(avp.getCode(), avp.getVendorId(), avp.getMandatoryRule() == 1, avp.getProtectedRule() == 1);
final DiameterAvp[] groupedAVPs = ((GroupedAvp) avp).getExtensionAvps();
for (DiameterAvp avpFromGroup : groupedAVPs) {
addAvp(avpFromGroup, avpSet);
}
} else if (avp != null) {
set.addAvp(avp.getCode(), avp.byteArrayValue(), avp.getVendorId(), avp.getMandatoryRule() == 1, avp.getProtectedRule() == 1);
}
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class GxMessageFactoryImpl method createGxMessage.
public Message createGxMessage(final DiameterHeader header, final DiameterAvp[] avps, int commandCode) throws AvpNotAllowedException {
final Message msg = createRawMessage(header, commandCode);
final AvpSet set = msg.getAvps();
for (DiameterAvp avp : avps) {
addAvp(avp, set);
}
return msg;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class GxMessageFactoryImpl method createGxReAuthAnswer.
public GxReAuthAnswer createGxReAuthAnswer(final GxReAuthRequest request) {
// Create the answer from the request
final GxReAuthRequestImpl rar = (GxReAuthRequestImpl) request;
// final GxReAuthAnswerImpl msg = new GxReAuthAnswerImpl(createMessage(rar.getHeader(), new DiameterAvp[]{}));
final Message raw = this.createGxMessage(rar.getHeader(), new DiameterAvp[] {}, GxReAuthAnswer.commandCode);
raw.setProxiable(rar.getHeader().isProxiable());
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
final GxReAuthAnswerImpl msg = new GxReAuthAnswerImpl(raw);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.DESTINATION_HOST);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.DESTINATION_REALM);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.ORIGIN_HOST);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.ORIGIN_REALM);
msg.setSessionId(request.getSessionId());
// Now copy the needed AVPs
final DiameterAvp[] messageAvps = request.getAvps();
if (messageAvps != null) {
for (DiameterAvp a : messageAvps) {
try {
if (ids.contains(a.getCode())) {
msg.addAvp(a);
}
} catch (Exception e) {
logger.error("Failed to add AVP to answer. Code[" + a.getCode() + "]", e);
}
}
}
addOrigin(msg);
return msg;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class GqMessageFactoryImpl method addAvp.
protected void addAvp(DiameterAvp avp, AvpSet set) {
if (avp instanceof GroupedAvp) {
AvpSet avpSet = set.addGroupedAvp(avp.getCode(), avp.getVendorId(), avp.getMandatoryRule() == 1, avp.getProtectedRule() == 1);
DiameterAvp[] groupedAVPs = ((GroupedAvp) avp).getExtensionAvps();
for (DiameterAvp avpFromGroup : groupedAVPs) {
addAvp(avpFromGroup, avpSet);
}
} else if (avp != null) {
set.addAvp(avp.getCode(), avp.byteArrayValue(), avp.getVendorId(), avp.getMandatoryRule() == 1, avp.getProtectedRule() == 1);
}
}
Aggregations