use of org.jdiameter.api.Message in project jain-slee.diameter by RestComm.
the class GxSessionActivityImpl method sendSyncMessage.
@Override
public DiameterMessage sendSyncMessage(DiameterMessage message) {
DiameterMessage answer = null;
Message receivedMessage = doSendMessage(message);
if (receivedMessage != null) {
if (!receivedMessage.isRequest()) {
if (receivedMessage.isError()) {
answer = new ErrorAnswerImpl(receivedMessage);
} else {
switch(receivedMessage.getCommandCode()) {
case GxCreditControlRequest.commandCode:
answer = new GxCreditControlRequestImpl(receivedMessage);
break;
case GxReAuthRequest.commandCode:
answer = new GxReAuthRequestImpl(receivedMessage);
break;
default:
logger.error("Received an unknown type of Message for Gx Activity: " + receivedMessage);
break;
}
}
} else {
logger.error("Received a REQUEST message when expecting an ANSWER.");
}
} else {
logger.debug("No answer received. Returning null.");
}
return answer;
}
use of org.jdiameter.api.Message in project jain-slee.diameter by RestComm.
the class GqMessageFactoryImpl method createRawMessage.
protected Message createRawMessage(DiameterHeader header) {
if (header == null) {
return null;
}
int commandCode = 0;
long endToEndId = 0;
long hopByHopId = 0;
boolean isRequest = true;
boolean isProxiable = true;
boolean isError = false;
boolean isPotentiallyRetransmitted = false;
commandCode = header.getCommandCode();
endToEndId = header.getEndToEndId();
hopByHopId = header.getHopByHopId();
isRequest = header.isRequest();
isProxiable = header.isProxiable();
isError = header.isError();
isPotentiallyRetransmitted = header.isPotentiallyRetransmitted();
Message msg = null;
try {
msg = stack.getSessionFactory().getNewRawSession().createMessage(commandCode, gqAppId, hopByHopId, endToEndId);
// Set the message flags from header (or default)
msg.setRequest(isRequest);
msg.setProxiable(isProxiable);
msg.setError(isError);
msg.setReTransmitted(isRequest && isPotentiallyRetransmitted);
} catch (IllegalDiameterStateException e) {
logger.error("Failed to get session factory for message creation.", e);
} catch (InternalException e) {
logger.error("Failed to create new raw session for message creation.", e);
}
return msg;
}
use of org.jdiameter.api.Message in project jain-slee.diameter by RestComm.
the class GqMessageFactoryImpl method createGqReAuthAnswer.
@Override
public GqReAuthAnswer createGqReAuthAnswer(GqReAuthRequest rar) {
Message raw = createMessage(rar.getHeader(), new DiameterAvp[] {});
// this should be different ...
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
GqReAuthAnswerImpl raa = new GqReAuthAnswerImpl(raw);
raa.getGenericData().getAvps().removeAvp(DiameterAvpCodes.DESTINATION_HOST);
raa.getGenericData().getAvps().removeAvp(DiameterAvpCodes.DESTINATION_REALM);
raa.getGenericData().getAvps().removeAvp(DiameterAvpCodes.ORIGIN_HOST);
raa.getGenericData().getAvps().removeAvp(DiameterAvpCodes.ORIGIN_REALM);
raa.setSessionId(rar.getSessionId());
addOrigin(raa);
return raa;
}
use of org.jdiameter.api.Message in project jain-slee.diameter by RestComm.
the class GqMessageFactoryImpl method createGqAAAnswer.
@Override
public GqAAAnswer createGqAAAnswer(GqAARequest aar) {
Message raw = createMessage(aar.getHeader(), new DiameterAvp[] {});
// this should be different ...
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
GqAAAnswerImpl aaa = new GqAAAnswerImpl(raw);
aaa.getGenericData().getAvps().removeAvp(DiameterAvpCodes.DESTINATION_HOST);
aaa.getGenericData().getAvps().removeAvp(DiameterAvpCodes.DESTINATION_REALM);
aaa.getGenericData().getAvps().removeAvp(DiameterAvpCodes.ORIGIN_HOST);
aaa.getGenericData().getAvps().removeAvp(DiameterAvpCodes.ORIGIN_REALM);
aaa.setSessionId(aar.getSessionId());
addOrigin(aaa);
return aaa;
}
use of org.jdiameter.api.Message in project jain-slee.diameter by RestComm.
the class AvpFlagsTest method testCorrectFlagsSupportedFeatures.
@Test
public void testCorrectFlagsSupportedFeatures() {
List<DiameterAvp> avps = new ArrayList<DiameterAvp>();
DiameterAvp avpFeatureListID = AvpUtilities.createAvp(Avp.FEATURE_LIST_ID, TGPP_VENDOR_ID, 1);
avps.add(AvpUtilities.createAvp(Avp.SUPPORTED_FEATURES, TGPP_VENDOR_ID, new DiameterAvp[] { avpFeatureListID }));
GxCreditControlRequest ccr = gxMessageFactory.createGxCreditControlRequest();
GxCreditControlAnswer cca = gxMessageFactory.createGxCreditControlAnswer(ccr);
cca.setExtensionAvps(avps.toArray(avps.toArray(new DiameterAvp[avps.size()])));
Message msg = ((DiameterMessageImpl) cca).getGenericData();
AvpUtilities.addAvp(msg, Avp.SUPPORTED_FEATURES, TGPP_VENDOR_ID, msg.getAvps(), new DiameterAvp[] { avpFeatureListID });
// Attribute Name AVP Code Section Value Type Must May Should not Must not May Encr.
// Supported-Features 628 6.3.29 Grouped V M - - - No
ArrayList<String> failures = checkAvpFlags(msg.getAvps());
if (failures.size() > 0) {
System.err.println("The following AVPs flags have failed to check against dictionary:");
for (String failure : failures) {
System.err.println(failure);
}
Assert.fail(failures.toString());
}
}
Aggregations