Search in sources :

Example 41 with Message

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

Example 42 with Message

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

Example 43 with Message

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;
}
Also used : Message(org.jdiameter.api.Message) GxCreditControlMessage(net.java.slee.resource.diameter.gx.events.GxCreditControlMessage) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) GxReAuthMessage(net.java.slee.resource.diameter.gx.events.GxReAuthMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) AvpSet(org.jdiameter.api.AvpSet)

Example 44 with Message

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

Example 45 with Message

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;
}
Also used : GxReAuthRequestImpl(org.mobicents.slee.resource.diameter.gx.events.GxReAuthRequestImpl) Message(org.jdiameter.api.Message) GxCreditControlMessage(net.java.slee.resource.diameter.gx.events.GxCreditControlMessage) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) GxReAuthMessage(net.java.slee.resource.diameter.gx.events.GxReAuthMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) GxReAuthAnswerImpl(org.mobicents.slee.resource.diameter.gx.events.GxReAuthAnswerImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) InternalException(org.jdiameter.api.InternalException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException)

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