Search in sources :

Example 26 with Message

use of org.jdiameter.api.Message in project jain-slee.diameter by RestComm.

the class RoMessageFactoryImpl method createRoCreditControlRequest.

private RoCreditControlMessage createRoCreditControlRequest(DiameterHeader diameterHeader, DiameterAvp[] avps) throws IllegalArgumentException {
    // List<DiameterAvp> list = (List<DiameterAvp>) this.avpList.clone();
    boolean isRequest = diameterHeader == null;
    RoCreditControlMessage msg = null;
    if (!isRequest) {
        Message raw = createMessage(diameterHeader, avps);
        raw.setProxiable(diameterHeader.isProxiable());
        raw.setRequest(false);
        // just in case. answers never have T flag set
        raw.setReTransmitted(false);
        msg = new RoCreditControlAnswerImpl(raw);
    } else {
        Message raw = createMessage(null, avps);
        raw.setProxiable(true);
        raw.setRequest(true);
        msg = new RoCreditControlRequestImpl(raw);
    }
    return msg;
}
Also used : RoCreditControlMessage(net.java.slee.resource.diameter.ro.events.RoCreditControlMessage) RoCreditControlRequestImpl(org.mobicents.slee.resource.diameter.ro.events.RoCreditControlRequestImpl) Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) RoCreditControlMessage(net.java.slee.resource.diameter.ro.events.RoCreditControlMessage) RoCreditControlAnswerImpl(org.mobicents.slee.resource.diameter.ro.events.RoCreditControlAnswerImpl)

Example 27 with Message

use of org.jdiameter.api.Message in project jain-slee.diameter by RestComm.

the class RoMessageFactoryImpl method createMessage.

public Message createMessage(DiameterHeader header, DiameterAvp[] avps) throws AvpNotAllowedException {
    Message msg = createRawMessage(header);
    AvpSet set = msg.getAvps();
    for (DiameterAvp avp : avps) {
        addAvp(avp, set);
    }
    return msg;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) RoCreditControlMessage(net.java.slee.resource.diameter.ro.events.RoCreditControlMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) AvpSet(org.jdiameter.api.AvpSet)

Example 28 with Message

use of org.jdiameter.api.Message in project jain-slee.diameter by RestComm.

the class RoSessionActivityImpl 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 RoCreditControlRequest.commandCode:
                        answer = new RoCreditControlAnswerImpl(receivedMessage);
                        break;
                    default:
                        logger.error("Received an unknown type of Message for Ro 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) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) RoCreditControlAnswerImpl(org.mobicents.slee.resource.diameter.ro.events.RoCreditControlAnswerImpl) ErrorAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl)

Example 29 with Message

use of org.jdiameter.api.Message in project jain-slee.diameter by RestComm.

the class RxMessageFactoryImpl method createDiameterMessage.

protected DiameterMessage createDiameterMessage(DiameterHeader diameterHeader, DiameterAvp[] avps, int _commandCode, ApplicationId appId) throws IllegalArgumentException {
    boolean creatingRequest = diameterHeader == null;
    Message msg = null;
    if (!creatingRequest) {
        Message raw = createMessage(diameterHeader, avps, 0, appId);
        raw.setRequest(false);
        // just in case. answers never have T flag set
        raw.setReTransmitted(false);
        msg = raw;
    } else {
        Message raw = createMessage(diameterHeader, avps, _commandCode, appId);
        raw.setRequest(true);
        msg = raw;
    }
    int commandCode = creatingRequest ? _commandCode : diameterHeader.getCommandCode();
    DiameterMessage diamMessage = null;
    switch(commandCode) {
        case AARequest.commandCode:
            diamMessage = creatingRequest ? new AARequestImpl(msg) : new AAAnswerImpl(msg);
            break;
        case Message.ABORT_SESSION_REQUEST:
            diamMessage = creatingRequest ? new AbortSessionRequestImpl(msg) : new AbortSessionAnswerImpl(msg);
            break;
        case Message.RE_AUTH_REQUEST:
            diamMessage = creatingRequest ? new ReAuthRequestImpl(msg) : new ReAuthAnswerImpl(msg);
            break;
        case Message.SESSION_TERMINATION_REQUEST:
            diamMessage = creatingRequest ? new SessionTerminationRequestImpl(msg) : new SessionTerminationAnswerImpl(msg);
            break;
        default:
            throw new IllegalArgumentException();
    }
    // Finally, add Origin-Host and Origin-Realm, if not present.
    addOriginHostAndRealm(diamMessage);
    return diamMessage;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) AbortSessionAnswerImpl(org.mobicents.slee.resource.diameter.rx.events.AbortSessionAnswerImpl) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ReAuthRequestImpl(org.mobicents.slee.resource.diameter.rx.events.ReAuthRequestImpl) AbortSessionRequestImpl(org.mobicents.slee.resource.diameter.rx.events.AbortSessionRequestImpl) SessionTerminationAnswerImpl(org.mobicents.slee.resource.diameter.rx.events.SessionTerminationAnswerImpl) AAAnswerImpl(org.mobicents.slee.resource.diameter.rx.events.AAAnswerImpl) ReAuthAnswerImpl(org.mobicents.slee.resource.diameter.rx.events.ReAuthAnswerImpl) AARequestImpl(org.mobicents.slee.resource.diameter.rx.events.AARequestImpl) SessionTerminationRequestImpl(org.mobicents.slee.resource.diameter.rx.events.SessionTerminationRequestImpl)

Example 30 with Message

use of org.jdiameter.api.Message in project jain-slee.diameter by RestComm.

the class RxSessionActivityImpl method sendSyncMessage.

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 274:
                        answer = new AbortSessionAnswerImpl(receivedMessage);
                        break;
                    case 258:
                        answer = new ReAuthAnswerImpl(receivedMessage);
                        break;
                    case 275:
                        answer = new SessionTerminationAnswerImpl(receivedMessage);
                        break;
                    case AARequest.commandCode:
                        answer = new AAAnswerImpl(receivedMessage);
                    default:
                        logger.error((new StringBuilder()).append("Received an unknown type of Message for Base Activity: ").append(receivedMessage).toString());
                        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) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ErrorAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl)

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