use of org.jdiameter.api.Message 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 org.jdiameter.api.Message in project jain-slee.diameter by RestComm.
the class GxMessageFactoryImpl method createGxCreditControlRequest.
private GxCreditControlMessage createGxCreditControlRequest(final DiameterHeader diameterHeader, final DiameterAvp[] avps) throws IllegalArgumentException {
boolean isRequest = false;
if (diameterHeader == null) {
isRequest = true;
}
GxCreditControlMessage msg = null;
if (!isRequest) {
final Message raw = createGxMessage(diameterHeader, avps, GxCreditControlRequest.commandCode);
raw.setProxiable(true);
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
msg = new GxCreditControlAnswerImpl(raw);
} else {
final Message raw = createGxMessage(null, avps, GxCreditControlRequest.commandCode);
raw.setProxiable(true);
raw.setRequest(true);
msg = new GxCreditControlRequestImpl(raw);
}
return msg;
}
use of org.jdiameter.api.Message 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 org.jdiameter.api.Message in project jain-slee.diameter by RestComm.
the class GxMessageFactoryImpl method createGxReAuthRequest.
private GxReAuthMessage createGxReAuthRequest(final DiameterHeader diameterHeader, final DiameterAvp[] avps) throws IllegalArgumentException {
boolean isRequest = false;
if (diameterHeader == null) {
isRequest = true;
}
GxReAuthMessage msg = null;
if (!isRequest) {
final Message raw = createGxMessage(diameterHeader, avps, GxReAuthAnswer.commandCode);
raw.setProxiable(true);
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
msg = new GxReAuthAnswerImpl(raw);
} else {
final Message raw = createGxMessage(null, avps, GxReAuthRequest.commandCode);
raw.setProxiable(true);
raw.setRequest(true);
msg = new GxReAuthRequestImpl(raw);
}
return msg;
}
use of org.jdiameter.api.Message 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;
}
Aggregations