Search in sources :

Example 1 with ApplicationId

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

the class DiameterMessageFactoryImpl method createAccountingRequest.

public AccountingRequest createAccountingRequest(DiameterAvp[] avps) throws AvpNotAllowedException {
    ApplicationId appId = getApplicationId(avps);
    AccountingRequest msg = (AccountingRequest) this.createDiameterMessage(null, avps, Message.ACCOUNTING_REQUEST, appId != null ? appId : BASE_ACCT_APP_ID);
    // Add Session-Id AVP if not present
    addSessionIdAvp(msg);
    return msg;
}
Also used : AccountingRequest(net.java.slee.resource.diameter.base.events.AccountingRequest) ApplicationId(org.jdiameter.api.ApplicationId)

Example 2 with ApplicationId

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

the class DiameterMessageFactoryImpl method getApplicationId.

private ApplicationId getApplicationId(DiameterAvp[] avps) {
    ApplicationId applicationId = null;
    long vendorId = 0L;
    // Try to get Application-Id from Message AVPs
    if (avps != null) {
        for (DiameterAvp avp : avps) {
            if (avp.getCode() == DiameterAvpCodes.VENDOR_ID) {
                vendorId = avp.intValue();
            }
            if (avp.getCode() == DiameterAvpCodes.VENDOR_SPECIFIC_APPLICATION_ID) {
                applicationId = getApplicationId(((GroupedAvp) avp).getExtensionAvps());
                break;
            }
            if (avp.getCode() == DiameterAvpCodes.ACCT_APPLICATION_ID) {
                applicationId = ApplicationId.createByAccAppId(vendorId, avp.intValue());
                break;
            } else if (avp.getCode() == DiameterAvpCodes.AUTH_APPLICATION_ID) {
                applicationId = ApplicationId.createByAuthAppId(vendorId, avp.intValue());
                break;
            }
        }
    }
    return applicationId;
}
Also used : GroupedAvp(net.java.slee.resource.diameter.base.events.avp.GroupedAvp) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) ApplicationId(org.jdiameter.api.ApplicationId)

Example 3 with ApplicationId

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

the class AccountingSessionFactory method registerListener.

public void registerListener(DiameterRAInterface ra, long messageTimeout, SessionFactory sessionFactory) {
    for (ApplicationId appId : ra.getSupportedApplications()) {
        this.ras.put(appId, ra);
    }
    this.messageTimeout = messageTimeout;
    this.sessionFactory = sessionFactory;
    super.setSessionFactory((ISessionFactory) sessionFactory);
}
Also used : ApplicationId(org.jdiameter.api.ApplicationId)

Example 4 with ApplicationId

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

the class AccountingSessionFactory method doFireEvent.

private void doFireEvent(AppSession appSession, Message message) {
    ApplicationId appId = null;
    for (ApplicationId curAppId : message.getApplicationIdAvps()) {
        if (curAppId.getAcctAppId() != ApplicationId.UNDEFINED_VALUE && this.ras.containsKey(curAppId)) {
            appId = curAppId;
            break;
        }
    }
    DiameterRAInterface ra = appId != null ? this.ras.get(appId) : this.ras.values().iterator().next();
    if (ra != null) {
        ra.fireEvent(appSession.getSessions().get(0).getSessionId(), message);
    } else {
    // TODO: tracer
    }
}
Also used : ApplicationId(org.jdiameter.api.ApplicationId)

Example 5 with ApplicationId

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

the class DiameterBaseResourceAdaptor method initStack.

// Private Methods -----------------------------------------------------
/**
 * Initializes the RA Diameter Stack.
 *
 * @throws Exception
 */
private synchronized void initStack() throws Exception {
    // Register in the Mux as app listener.
    List<ApplicationId> allAppIds = new ArrayList<ApplicationId>();
    allAppIds.addAll(authApplicationIds);
    allAppIds.addAll(acctApplicationIds);
    this.diameterMux.registerListener(this, allAppIds.toArray(new ApplicationId[allAppIds.size()]));
    // Get the stack (should not mess with)
    this.stack = this.diameterMux.getStack();
    this.messageTimeout = stack.getMetaData().getConfiguration().getLongValue(MessageTimeOut.ordinal(), (Long) MessageTimeOut.defValue());
    // Obtain parser and store it in AvpUtilities
    MessageParser parser = ((IContainer) stack).getAssemblerFacility().getComponentInstance(MessageParser.class);
    AvpUtilities.setParser(parser);
    AvpUtilities.setDictionary(stack.getDictionary());
    if (tracer.isInfoEnabled()) {
        tracer.info("Diameter Base RA :: Successfully initialized stack.");
    }
}
Also used : MessageParser(org.jdiameter.client.impl.parser.MessageParser) ArrayList(java.util.ArrayList) ApplicationId(org.jdiameter.api.ApplicationId)

Aggregations

ApplicationId (org.jdiameter.api.ApplicationId)103 Test (org.junit.Test)76 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)76 CxDxMessageFactoryImpl (org.mobicents.slee.resource.diameter.cxdx.CxDxMessageFactoryImpl)18 S6aMessageFactoryImpl (org.mobicents.slee.resource.diameter.s6a.S6aMessageFactoryImpl)16 RxMessageFactoryImpl (org.mobicents.slee.resource.diameter.rx.RxMessageFactoryImpl)12 ObjectName (javax.management.ObjectName)11 InvalidConfigurationException (javax.slee.resource.InvalidConfigurationException)11 CreateActivityException (net.java.slee.resource.diameter.base.CreateActivityException)11 AvpDataException (org.jdiameter.api.AvpDataException)11 ISessionFactory (org.jdiameter.client.api.ISessionFactory)11 DiameterStackMultiplexerMBean (org.mobicents.diameter.stack.DiameterStackMultiplexerMBean)11 DiameterAvpFactoryImpl (org.mobicents.slee.resource.diameter.base.DiameterAvpFactoryImpl)10 OperationNotSupportedException (javax.naming.OperationNotSupportedException)9 DiameterMessageFactoryImpl (org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl)8 GqMessageFactoryImpl (org.mobicents.slee.resource.diameter.gq.GqMessageFactoryImpl)8 IOException (java.io.IOException)7 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)7 InternalException (org.jdiameter.api.InternalException)7 ShServerMessageFactoryImpl (org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl)7