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