Search in sources :

Example 6 with Message

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;
}
Also used : DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) Message(org.jdiameter.api.Message) GxReAuthRequestImpl(org.mobicents.slee.resource.diameter.gx.events.GxReAuthRequestImpl) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) GxCreditControlRequestImpl(org.mobicents.slee.resource.diameter.gx.events.GxCreditControlRequestImpl) ErrorAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl)

Example 7 with Message

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;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) InternalException(org.jdiameter.api.InternalException)

Example 8 with Message

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;
}
Also used : GqReAuthAnswerImpl(org.mobicents.slee.resource.diameter.gq.events.GqReAuthAnswerImpl) Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage)

Example 9 with Message

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;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) GqAAAnswerImpl(org.mobicents.slee.resource.diameter.gq.events.GqAAAnswerImpl)

Example 10 with Message

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());
    }
}
Also used : Message(org.jdiameter.api.Message) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) ArrayList(java.util.ArrayList) GxCreditControlRequest(net.java.slee.resource.diameter.gx.events.GxCreditControlRequest) GxCreditControlAnswer(net.java.slee.resource.diameter.gx.events.GxCreditControlAnswer) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) Test(org.junit.Test)

Aggregations

Message (org.jdiameter.api.Message)61 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)56 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)22 NoSuchAvpException (net.java.slee.resource.diameter.base.NoSuchAvpException)10 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)10 AvpSet (org.jdiameter.api.AvpSet)8 ArrayList (java.util.ArrayList)7 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)7 InternalException (org.jdiameter.api.InternalException)7 ErrorAnswerImpl (org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl)7 GxCreditControlMessage (net.java.slee.resource.diameter.gx.events.GxCreditControlMessage)5 GxReAuthMessage (net.java.slee.resource.diameter.gx.events.GxReAuthMessage)5 RoCreditControlMessage (net.java.slee.resource.diameter.ro.events.RoCreditControlMessage)4 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)4 ExtensionDiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl)4 IOException (java.io.IOException)3 AccountingAnswerImpl (org.mobicents.slee.resource.diameter.base.events.AccountingAnswerImpl)3 GqAARequestImpl (org.mobicents.slee.resource.diameter.gq.events.GqAARequestImpl)3 GqAbortSessionRequestImpl (org.mobicents.slee.resource.diameter.gq.events.GqAbortSessionRequestImpl)3 GqReAuthRequestImpl (org.mobicents.slee.resource.diameter.gq.events.GqReAuthRequestImpl)3