Search in sources :

Example 56 with DiameterAvp

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;
}
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 57 with DiameterAvp

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

Example 58 with DiameterAvp

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;
}
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 59 with DiameterAvp

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;
}
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)

Example 60 with DiameterAvp

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

Aggregations

DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)65 Message (org.jdiameter.api.Message)22 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)21 InternalException (org.jdiameter.api.InternalException)21 AvpSet (org.jdiameter.api.AvpSet)18 ArrayList (java.util.ArrayList)15 GroupedAvp (net.java.slee.resource.diameter.base.events.avp.GroupedAvp)15 NoSuchAvpException (net.java.slee.resource.diameter.base.NoSuchAvpException)12 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)9 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)6 AccountingRequest (net.java.slee.resource.diameter.base.events.AccountingRequest)3 VendorSpecificApplicationIdAvp (net.java.slee.resource.diameter.base.events.avp.VendorSpecificApplicationIdAvp)3 GxCreditControlMessage (net.java.slee.resource.diameter.gx.events.GxCreditControlMessage)3 GxReAuthMessage (net.java.slee.resource.diameter.gx.events.GxReAuthMessage)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 DiameterIdentity (net.java.slee.resource.diameter.base.events.avp.DiameterIdentity)2 CreditControlRequest (net.java.slee.resource.diameter.cca.events.CreditControlRequest)2 RoCreditControlMessage (net.java.slee.resource.diameter.ro.events.RoCreditControlMessage)2 ApplicationId (org.jdiameter.api.ApplicationId)2