Search in sources :

Example 46 with DiameterAvp

use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.

the class CreditControlMessageFactoryImpl method createCreditControlRequest.

/*
   * (non-Javadoc)
   * 
   * @see net.java.slee.resource.diameter.cca.CreditControlMessageFactory#createCreditControlRequest()
   */
public CreditControlRequest createCreditControlRequest() {
    CreditControlRequest req = (CreditControlRequest) createCreditControlMessage(null, new DiameterAvp[0]);
    req.setOriginRealm(new DiameterIdentity(stack.getMetaData().getLocalPeer().getRealmName()));
    req.setOriginHost(new DiameterIdentity(stack.getMetaData().getLocalPeer().getUri().getFQDN().toString()));
    if (session != null) {
        req.setSessionId(session.getSessionId());
    }
    return req;
}
Also used : DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) DiameterIdentity(net.java.slee.resource.diameter.base.events.avp.DiameterIdentity) CreditControlRequest(net.java.slee.resource.diameter.cca.events.CreditControlRequest)

Example 47 with DiameterAvp

use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.

the class CreditControlMessageFactoryImpl method addAvp.

protected void addAvp(DiameterAvp avp, AvpSet set) {
    // proper function?
    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)

Example 48 with DiameterAvp

use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.

the class CreditControlMessageFactoryImpl method createCreditControlAnswer.

/*
   * (non-Javadoc)
   * 
   * @see net.java.slee.resource.diameter.cca.CreditControlMessageFactory#createCreditControlAnswer
   * (net.java.slee.resource.diameter.cca.events.CreditControlRequest)
   */
public CreditControlAnswer createCreditControlAnswer(CreditControlRequest request) {
    // Create the answer from the request
    CreditControlRequestImpl ccr = (CreditControlRequestImpl) request;
    // DiameterAvp sessionIdAvp = null;
    // try {
    // sessionIdAvp = creditControlAvpFactory.getBaseFactory().createAvp(0, DiameterAvpCodes.SESSION_ID, this.session.getSessionId());
    // }
    // catch (NoSuchAvpException e1) {
    // logger.error("Session-Id AVP not found in message", e1);
    // }
    CreditControlAnswerImpl msg = (CreditControlAnswerImpl) createCreditControlMessage(ccr.getHeader(), new DiameterAvp[0]);
    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
    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 : DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) CreditControlRequestImpl(org.mobicents.slee.resource.diameter.cca.events.CreditControlRequestImpl) CreditControlAnswerImpl(org.mobicents.slee.resource.diameter.cca.events.CreditControlAnswerImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) InternalException(org.jdiameter.api.InternalException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) NoSuchAvpException(net.java.slee.resource.diameter.base.NoSuchAvpException)

Example 49 with DiameterAvp

use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.

the class CxDxClientSessionImpl method createRegistrationTerminationAnswer.

/* (non-Javadoc)
   * @see net.java.slee.resource.diameter.cxdx.CxDxClientSession#createRegistrationTerminationRequest()
   */
public RegistrationTerminationAnswer createRegistrationTerminationAnswer() {
    // Make sure we have the correct type of Request
    if (!(lastRequest instanceof RegistrationTerminationRequest)) {
        logger.warn("Invalid type of answer for this activity.");
        return null;
    }
    try {
        // Create the answer
        RegistrationTerminationAnswer rta = (RegistrationTerminationAnswer) this.cxdxMessageFactory.createCxDxMessage(lastRequest.getHeader(), new DiameterAvp[] {}, RegistrationTerminationAnswer.COMMAND_CODE, cxdxMessageFactory.getApplicationId());
        // Fill session related AVPs, if present
        fillSessionAVPs(rta);
        return rta;
    } catch (InternalException e) {
        logger.error("Failed to create Registration-Termination-Answer.", e);
    }
    return null;
}
Also used : RegistrationTerminationAnswer(net.java.slee.resource.diameter.cxdx.events.RegistrationTerminationAnswer) RegistrationTerminationRequest(net.java.slee.resource.diameter.cxdx.events.RegistrationTerminationRequest) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) InternalException(org.jdiameter.api.InternalException)

Example 50 with DiameterAvp

use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.

the class CxDxServerSessionImpl method createLocationInfoAnswer.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diameter.cxdx.CxDxServerSession#createLocationInfoAnswer()
   */
public LocationInfoAnswer createLocationInfoAnswer() {
    // Make sure we have the correct type of Request
    if (!(lastRequest instanceof LocationInfoRequest)) {
        logger.warn("Invalid type of answer for this activity.");
        return null;
    }
    try {
        // Create the answer
        LocationInfoAnswer lia = (LocationInfoAnswer) this.cxdxMessageFactory.createCxDxMessage(lastRequest.getHeader(), new DiameterAvp[] {}, LocationInfoAnswer.COMMAND_CODE, cxdxMessageFactory.getApplicationId());
        // Fill session related AVPs, if present
        fillSessionAVPs(lia);
        return lia;
    } catch (InternalException e) {
        logger.error("Failed to create Location-Info-Answer.", e);
    }
    return null;
}
Also used : LocationInfoRequest(net.java.slee.resource.diameter.cxdx.events.LocationInfoRequest) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) LocationInfoAnswer(net.java.slee.resource.diameter.cxdx.events.LocationInfoAnswer) InternalException(org.jdiameter.api.InternalException)

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