Search in sources :

Example 11 with MAPApplicationContextVersion

use of org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion in project smscgateway by RestComm.

the class SMSCShellExecutor method setMapVersionCache.

/**
 * smsc mapcache set <msisdn> <version>
 *
 * msisdn is optional
 *
 * @param args
 * @return
 */
private String setMapVersionCache(String[] args) throws Exception {
    if (args.length != 5) {
        return SMSCOAMMessages.INVALID_COMMAND;
    }
    String msisdn = args[3];
    String version = args[4];
    MAPApplicationContextVersion mapApplicationContextVersion = MAPApplicationContextVersion.getInstance(Long.parseLong(version));
    if (mapApplicationContextVersion == null || mapApplicationContextVersion == MAPApplicationContextVersion.version4) {
        return SMSCOAMMessages.MAP_VERSION_CACHE_INVALID_VERSION;
    }
    mapVersionCache.forceMAPApplicationContextVersion(msisdn, mapApplicationContextVersion);
    return SMSCOAMMessages.MAP_VERSION_CACHE_SUCCESSFULLY_SET;
}
Also used : MAPApplicationContextVersion(org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion)

Example 12 with MAPApplicationContextVersion

use of org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion in project smscgateway by RestComm.

the class SMSCShellExecutor method getMapVersionCache.

/**
 * smsc mapcache get <msisdn>
 *
 * msisdn is optional
 *
 * @param args
 * @return
 */
private String getMapVersionCache(String[] args) throws Exception {
    if (args.length < 3 || args.length > 4) {
        return SMSCOAMMessages.INVALID_COMMAND;
    }
    if (args.length == 4) {
        String msisdn = args[3];
        MAPApplicationContextVersion mapApplicationContextVersion = mapVersionCache.getMAPApplicationContextVersion(msisdn);
        if (mapApplicationContextVersion != null) {
            return mapApplicationContextVersion.toString();
        } else {
            return SMSCOAMMessages.MAP_VERSION_CACHE_NOT_FOUND;
        }
    }
    FastMap<String, MapVersionNeg> cache = mapVersionCache.getMAPApplicationContextVersionCache();
    if (cache.size() == 0) {
        return SMSCOAMMessages.MAP_VERSION_CACHE_NOT_FOUND;
    }
    StringBuffer sb = new StringBuffer();
    for (FastMap.Entry<String, MapVersionNeg> e = cache.head(), end = cache.tail(); (e = e.getNext()) != end; ) {
        sb.append(e.getKey()).append(MAP_CACHE_KEY_VALUE_SEPARATOR).append(e.getValue().getCurVersion()).append(LINE_SEPARATOR);
    }
    return sb.toString();
}
Also used : FastMap(javolution.util.FastMap) MAPApplicationContextVersion(org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion)

Example 13 with MAPApplicationContextVersion

use of org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion in project smscgateway by RestComm.

the class MtCommonSbb method getSRIMAPApplicationContext.

protected MAPApplicationContext getSRIMAPApplicationContext(MAPApplicationContextVersion applicationContextVersion) {
    MAPApplicationContext mapApplicationContext = MAPApplicationContext.getInstance(MAPApplicationContextName.shortMsgGatewayContext, applicationContextVersion);
    this.setSriMapVersion(applicationContextVersion.getVersion());
    return mapApplicationContext;
}
Also used : MAPApplicationContext(org.restcomm.protocols.ss7.map.api.MAPApplicationContext)

Example 14 with MAPApplicationContextVersion

use of org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion in project smscgateway by RestComm.

the class MtSbb method onDialogReject.

@Override
public void onDialogReject(DialogReject evt, ActivityContextInterface aci) {
    try {
        SmsSet smsSet = getSmsSet();
        if (smsSet == null) {
            logger.severe("MtSbb.onDialogReject(): CMP smsSet is missed");
            markDeliveringIsEnded(true);
            return;
        }
        MAPRefuseReason mapRefuseReason = evt.getRefuseReason();
        if (mapRefuseReason == MAPRefuseReason.PotentialVersionIncompatibility && evt.getMAPDialog().getApplicationContext().getApplicationContextVersion() != MAPApplicationContextVersion.version1) {
            if (logger.isWarningEnabled()) {
                this.logger.warning("Rx : Mt onDialogReject / PotentialVersionIncompatibility=" + evt);
            }
            MAPApplicationContextVersion newMAPApplicationContextVersion = MAPApplicationContextVersion.version1;
            if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
                // If version1 already tried this is error
                String reason = "Error condition when invoking sendMtSms() from onDialogReject()." + newMAPApplicationContextVersion + " already tried and DialogReject again suggests Version1";
                this.logger.severe(reason);
                ErrorCode smStatus = ErrorCode.MAP_SERVER_VERSION_ERROR;
                this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
                return;
            }
            this.setNegotiatedMapVersionUsing(false);
            this.setMAPVersionTested(newMAPApplicationContextVersion);
            mapVersionCache.setMAPApplicationContextVersion(this.getNetworkNode().getGlobalTitle().getDigits(), newMAPApplicationContextVersion);
            // Now send new ForwardSM with supported ACN (MAP V1)
            try {
                // Update cache
                this.sendMtSms(this.getMtFoSMSMAPApplicationContext(MAPApplicationContextVersion.version1), MessageProcessingState.resendAfterMapProtocolNegotiation, null, smsSet.getNetworkId());
                return;
            } catch (SmscProcessingException e) {
                String reason = "SmscPocessingException when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
                this.logger.severe(reason, e);
                ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
                try {
                    smStatus = ErrorCode.fromInt(e.getSmppErrorCode());
                } catch (IllegalArgumentException e1) {
                }
                this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
                return;
            } catch (Throwable e) {
                String reason = "Exception when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
                this.logger.severe(reason, e);
                ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
                this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
                return;
            }
        }
        // If ACN not supported, lets use the new one suggested
        if (mapRefuseReason == MAPRefuseReason.ApplicationContextNotSupported) {
            String nodeDigits = this.getNetworkNode().getGlobalTitle().getDigits();
            if (logger.isWarningEnabled()) {
                this.logger.warning("Rx : Mt onDialogReject / ApplicationContextNotSupported for node " + nodeDigits + " Event=" + evt);
            }
            // Now send new MtSMS with supported ACN
            ApplicationContextName tcapApplicationContextName = evt.getAlternativeApplicationContext();
            MAPApplicationContext supportedMAPApplicationContext = MAPApplicationContext.getInstance(tcapApplicationContextName.getOid());
            MAPApplicationContextVersion supportedMAPApplicationContextVersion = supportedMAPApplicationContext.getApplicationContextVersion();
            MAPApplicationContextVersion newMAPApplicationContextVersion = supportedMAPApplicationContextVersion;
            if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
                newMAPApplicationContextVersion = MAPApplicationContextVersion.version3;
                if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
                    newMAPApplicationContextVersion = MAPApplicationContextVersion.version2;
                    if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
                        newMAPApplicationContextVersion = MAPApplicationContextVersion.version1;
                        if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
                            // If all versions are already tried this is
                            // error
                            String reason = "Error condition when invoking sendMtSms() from onDialogReject()." + " all MAP versions are already tried and DialogReject again suggests Version1";
                            this.logger.severe(reason);
                            ErrorCode smStatus = ErrorCode.MAP_SERVER_VERSION_ERROR;
                            this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
                            return;
                        }
                    }
                }
            }
            this.setNegotiatedMapVersionUsing(false);
            this.setMAPVersionTested(newMAPApplicationContextVersion);
            mapVersionCache.setMAPApplicationContextVersion(this.getNetworkNode().getGlobalTitle().getDigits(), newMAPApplicationContextVersion);
            try {
                this.sendMtSms(this.getMtFoSMSMAPApplicationContext(newMAPApplicationContextVersion), MessageProcessingState.resendAfterMapProtocolNegotiation, null, smsSet.getNetworkId());
                return;
            } catch (SmscProcessingException e) {
                String reason = "SmscPocessingException when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
                this.logger.severe(reason, e);
                ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
                try {
                    smStatus = ErrorCode.fromInt(e.getSmppErrorCode());
                } catch (IllegalArgumentException e1) {
                }
                this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
                return;
            } catch (Throwable e) {
                String reason = "Exception when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
                this.logger.severe(reason, e);
                ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
                this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
                return;
            }
        }
        super.onDialogReject(evt, aci);
        this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.MSC_REFUSES_SM, "onDialogReject after MT Request: " + mapRefuseReason != null ? mapRefuseReason.toString() : "", true, null, false, ProcessingType.SS7_MT);
    } catch (Throwable e1) {
        logger.severe("Exception in MtSbb.onDialogReject() when fetching records and issuing events: " + e1.getMessage(), e1);
        markDeliveringIsEnded(true);
    }
}
Also used : MAPApplicationContextName(org.restcomm.protocols.ss7.map.api.MAPApplicationContextName) ApplicationContextName(org.restcomm.protocols.ss7.tcap.asn.ApplicationContextName) MAPRefuseReason(org.restcomm.protocols.ss7.map.api.dialog.MAPRefuseReason) SmscProcessingException(org.mobicents.smsc.library.SmscProcessingException) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) ErrorCode(org.mobicents.smsc.library.ErrorCode) MAPErrorCode(org.restcomm.protocols.ss7.map.api.errors.MAPErrorCode) SmsSet(org.mobicents.smsc.library.SmsSet) MAPApplicationContext(org.restcomm.protocols.ss7.map.api.MAPApplicationContext) MAPApplicationContextVersion(org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion)

Example 15 with MAPApplicationContextVersion

use of org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion in project smscgateway by RestComm.

the class MtTest method MapVersionNegotiationTest.

/**
 * MAP V3 -> MAP V3 -> MAP V1 (Reject - Alternative ANC)
 */
@Test(groups = { "Mt" })
public void MapVersionNegotiationTest() throws Exception {
    if (!this.cassandraDbInited)
        return;
    MAPServiceSmsProxy serviceSri = (MAPServiceSmsProxy) this.sriSbb.mapProvider.getMAPServiceSms();
    MAPServiceSmsProxy serviceMt = (MAPServiceSmsProxy) this.mtSbb.mapProvider.getMAPServiceSms();
    MAPServiceSmsProxy serviceRsds = (MAPServiceSmsProxy) this.rsdsSbb.mapProvider.getMAPServiceSms();
    SmscPropertiesManagement smscPropertiesManagement = SmscPropertiesManagement.getInstance();
    MProcManagement.getInstance("Test");
    ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
    SmsDef sd1 = new SmsDef();
    lst.add(sd1);
    SmsSet smsSet = prepareDatabase(lst);
    Sms sms1 = smsSet.getSms(0);
    UUID smsId = sms1.getDbId();
    SmsProxy smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx1);
    SmsSet smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNotNull(smsSetX);
    Sms smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
    // initial onSms message
    SmsSetEvent event = new SmsSetEvent();
    event.setSmsSet(smsSet);
    this.sriSbb.onSms(event, null, null);
    MAPDialogSmsProxy dlg = serviceSri.getLastMAPDialogSms();
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
    assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
    // SRI response
    IMSI imsi = new IMSIImpl(imsiDig);
    ISDNAddressString networkNodeNumber = new ISDNAddressStringImpl(AddressNature.international_number, org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan.ISDN, nnnDig);
    LocationInfoWithLMSI locationInfoWithLMSI = new LocationInfoWithLMSIImpl(networkNodeNumber, null, null, false, null);
    SendRoutingInfoForSMResponse evt1 = new SendRoutingInfoForSMResponseImpl(imsi, locationInfoWithLMSI, null, null, null);
    evt1.setMAPDialog(dlg);
    this.sriSbb.onSendRoutingInfoForSMResponse(evt1, null);
    this.sriSbb.onDialogDelimiter(null, null);
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
    assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
    assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
    dlg = serviceMt.getLastMAPDialogSms();
    MAPApplicationContextVersion vers = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(vers, MAPApplicationContextVersion.version3);
    ApplicationContextNameImpl acn = new ApplicationContextNameImpl();
    acn.setOid(new long[] { 0, 4, 0, 0, 1, 0, 25, 2 });
    DialogReject evt5 = new DialogReject(dlg, MAPRefuseReason.ApplicationContextNotSupported, acn, null);
    this.mtSbb.onDialogReject(evt5, null);
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
    assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
    assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
    assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
    dlg = serviceMt.getLastMAPDialogSms();
    vers = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(vers, MAPApplicationContextVersion.version2);
    acn = new ApplicationContextNameImpl();
    acn.setOid(new long[] { 0, 4, 0, 0, 1, 0, 25, 2 });
    evt5 = new DialogReject(dlg, MAPRefuseReason.ApplicationContextNotSupported, acn, null);
    this.mtSbb.onDialogReject(evt5, null);
    assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
    assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
    assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
    assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
    dlg = serviceMt.getLastMAPDialogSms();
    vers = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(vers, MAPApplicationContextVersion.version1);
}
Also used : LocationInfoWithLMSI(org.restcomm.protocols.ss7.map.api.service.sms.LocationInfoWithLMSI) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) SmsSetEvent(org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent) IMSIImpl(org.restcomm.protocols.ss7.map.primitives.IMSIImpl) DialogReject(org.restcomm.slee.resource.map.events.DialogReject) ArrayList(java.util.ArrayList) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) LocationInfoWithLMSIImpl(org.restcomm.protocols.ss7.map.service.sms.LocationInfoWithLMSIImpl) SendRoutingInfoForSMResponse(org.restcomm.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse) MAPApplicationContextVersion(org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion) SendRoutingInfoForSMResponseImpl(org.restcomm.protocols.ss7.map.service.sms.SendRoutingInfoForSMResponseImpl) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) ISDNAddressStringImpl(org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl) SmscPropertiesManagement(org.mobicents.smsc.domain.SmscPropertiesManagement) SmsProxy(org.mobicents.smsc.slee.resources.persistence.SmsProxy) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) Sms(org.mobicents.smsc.library.Sms) IMSI(org.restcomm.protocols.ss7.map.api.primitives.IMSI) ApplicationContextNameImpl(org.restcomm.protocols.ss7.tcap.asn.ApplicationContextNameImpl) UUID(java.util.UUID) SmsSet(org.mobicents.smsc.library.SmsSet) Test(org.testng.annotations.Test)

Aggregations

MAPApplicationContextVersion (org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion)22 SmsSet (org.mobicents.smsc.library.SmsSet)20 Test (org.testng.annotations.Test)20 ArrayList (java.util.ArrayList)19 SmscPropertiesManagement (org.mobicents.smsc.domain.SmscPropertiesManagement)18 Sms (org.mobicents.smsc.library.Sms)18 MAPDialogSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy)18 MAPServiceSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy)18 SmsSetEvent (org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent)18 ISDNAddressString (org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString)18 ISDNAddressStringImpl (org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl)18 IMSI (org.restcomm.protocols.ss7.map.api.primitives.IMSI)17 UUID (java.util.UUID)16 SmsProxy (org.mobicents.smsc.slee.resources.persistence.SmsProxy)16 LocationInfoWithLMSI (org.restcomm.protocols.ss7.map.api.service.sms.LocationInfoWithLMSI)16 SendRoutingInfoForSMResponse (org.restcomm.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse)16 IMSIImpl (org.restcomm.protocols.ss7.map.primitives.IMSIImpl)16 LocationInfoWithLMSIImpl (org.restcomm.protocols.ss7.map.service.sms.LocationInfoWithLMSIImpl)16 SendRoutingInfoForSMResponseImpl (org.restcomm.protocols.ss7.map.service.sms.SendRoutingInfoForSMResponseImpl)16 MAPTestEvent (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy.MAPTestEvent)15