use of org.restcomm.protocols.ss7.map.api.MAPApplicationContext in project smscgateway by RestComm.
the class SriSbb method setupRoutingInfoForSMRequestIndication.
private MAPDialogSms setupRoutingInfoForSMRequestIndication(String destinationAddress, int ton, int npi, MAPApplicationContext mapApplicationContext, int networkId, String newMtLocalSccpGt, Integer newMtRemoteSccpTt) throws MAPException {
// this.mapParameterFactory.creat
String hlrAddress = destinationAddress;
String hrHlrNumber = smscPropertiesManagement.getHrHlrNumber(networkId);
if (hrHlrNumber != null && hrHlrNumber.length() > 0) {
hlrAddress = hrHlrNumber;
}
SccpAddress destinationAddr = this.convertAddressFieldToSCCPAddress(hlrAddress, ton, npi, newMtRemoteSccpTt);
SccpAddress originSccpAddress;
if (newMtLocalSccpGt != null) {
originSccpAddress = this.getServiceCenterSccpAddress(newMtLocalSccpGt, networkId);
} else {
originSccpAddress = this.getServiceCenterSccpAddress(networkId);
}
MAPDialogSms mapDialogSms = this.mapProvider.getMAPServiceSms().createNewDialog(mapApplicationContext, originSccpAddress, null, destinationAddr, null);
mapDialogSms.setNetworkId(networkId);
ISDNAddressString isdn = this.getCalledPartyISDNAddressString(destinationAddress, ton, npi);
AddressString serviceCenterAddress = this.getServiceCenterAddressString(networkId);
boolean sm_RP_PRI = true;
mapDialogSms.addSendRoutingInfoForSMRequest(isdn, sm_RP_PRI, serviceCenterAddress, null, false, null, null, null, false, null, false, false, null, null);
if (this.logger.isInfoEnabled())
this.logger.info("Sending: SendRoutingInfoForSMRequest: isdn=" + isdn + ", serviceCenterAddress=" + serviceCenterAddress + ", sm_RP_PRI=" + sm_RP_PRI);
return mapDialogSms;
}
use of org.restcomm.protocols.ss7.map.api.MAPApplicationContext in project smscgateway by RestComm.
the class SriSbb method sendSRI.
// *********
// Main service methods
private void sendSRI(SmsSet smsSet, String destinationAddress, int ton, int npi, MAPApplicationContext mapApplicationContext) {
// Send out SRI
MAPDialogSms mapDialogSms = null;
try {
Sms sms0 = smsSet.getSms(0);
String mtLocalSccpGt = null;
Integer mtRemoteSccpTt = null;
if (sms0 != null) {
mtLocalSccpGt = sms0.getMtLocalSccpGt();
mtRemoteSccpTt = sms0.getMtRemoteSccpTt();
}
// 1. Create Dialog first and add the SRI request to it
mapDialogSms = this.setupRoutingInfoForSMRequestIndication(destinationAddress, ton, npi, mapApplicationContext, smsSet.getNetworkId(), mtLocalSccpGt, mtRemoteSccpTt);
// 2. Create the ACI and attach this SBB
ActivityContextInterface sriDialogACI = this.mapAcif.getActivityContextInterface(mapDialogSms);
sriDialogACI.attach(this.sbbContext.getSbbLocalObject());
// 3. Finally send the request
mapDialogSms.send();
} catch (MAPException e) {
if (mapDialogSms != null) {
mapDialogSms.release();
}
String reason = "MAPException when sending SRI from sendSRI(): " + 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_SRI);
}
}
use of org.restcomm.protocols.ss7.map.api.MAPApplicationContext in project smscgateway by RestComm.
the class MoSbb method onForwardShortMessageRequest.
public void onForwardShortMessageRequest(ForwardShortMessageRequest evt, ActivityContextInterface aci) {
if (this.logger.isFineEnabled()) {
this.logger.fine("Received FORWARD_SHORT_MESSAGE_REQUEST = " + evt);
}
MAPDialogSms dialog = evt.getMAPDialog();
// checking if it is MO or MT
boolean isMt;
MAPApplicationContext act = dialog.getApplicationContext();
if (act.getApplicationContextVersion().getVersion() > 1) {
if (act.getApplicationContextName() == MAPApplicationContextName.shortMsgMORelayContext)
isMt = false;
else
isMt = true;
} else {
if (evt.getSM_RP_OA().getMsisdn() != null)
isMt = false;
else
isMt = true;
}
this.setProcessingState(MoProcessingState.OtherDataRecieved);
MoChargingType charging;
if (isMt) {
charging = smscPropertiesManagement.getHrCharging();
} else {
charging = smscPropertiesManagement.getMoCharging();
}
if (charging == MoChargingType.reject) {
try {
MAPErrorMessage errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageFacilityNotSup(null, null, null);
dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
if (this.logger.isInfoEnabled()) {
this.logger.info("Sent ErrorComponent = " + errorMessage);
}
this.logger.warning("************* 0001");
if (smscPropertiesManagement.isGenerateRejectionCdr()) {
this.logger.warning("************* 0002");
generateCDR(dialog.getNetworkId(), null, dialog.getLocalAddress(), isMt ? CdrGenerator.CDR_SUBMIT_FAILED_HR : CdrGenerator.CDR_SUBMIT_FAILED_MO, errorMessage.toString(), true);
this.logger.warning("************* 0003");
}
dialog.close(false);
return;
} catch (Throwable e) {
logger.severe("Error while sending Error message", e);
return;
}
}
Sms sms = null;
try {
String originatorSccpAddress = null;
SccpAddress sccpAddress = dialog.getRemoteAddress();
if (sccpAddress != null) {
GlobalTitle gt = dialog.getRemoteAddress().getGlobalTitle();
if (gt != null)
originatorSccpAddress = gt.getDigits();
}
if (isMt) {
sms = this.processMtMessage(evt.getSM_RP_OA(), evt.getSM_RP_DA(), evt.getSM_RP_UI(), dialog.getNetworkId(), originatorSccpAddress, false, evt.getMAPDialog(), evt, evt.getInvokeId());
} else {
sms = this.processMoMessage(evt.getSM_RP_OA(), evt.getSM_RP_DA(), evt.getSM_RP_UI(), dialog.getNetworkId(), originatorSccpAddress, false, evt.getMAPDialog(), evt, evt.getInvokeId());
}
if (sms != null) {
this.processSms(sms, persistence, charging, !isMt, dialog, evt, evt.getInvokeId());
}
} catch (SmscProcessingException e1) {
if (!e1.isSkipErrorLogging()) {
if (e1.isIsWarning()) {
this.logger.warning(e1.getMessage());
} else {
this.logger.severe(e1.getMessage(), e1);
}
smscStatAggregator.updateMsgInFailedAll();
}
try {
MAPErrorMessage errorMessage;
switch(e1.getMapErrorCode()) {
case MAPErrorCode.unexpectedDataValue:
errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageExtensionContainer((long) MAPErrorCode.unexpectedDataValue, null);
break;
case MAPErrorCode.systemFailure:
errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), null, null, null);
break;
case MAPErrorCode.resourceLimitation:
errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageExtensionContainer((long) MAPErrorCode.resourceLimitation, null);
break;
case MAPErrorCode.facilityNotSupported:
errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageFacilityNotSup(null, null, null);
break;
default:
errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), null, null, null);
break;
}
if (smscPropertiesManagement.isGenerateRejectionCdr() && !e1.isMessageRejectCdrCreated()) {
if (sms != null) {
generateCDR(sms, isMt ? CdrGenerator.CDR_SUBMIT_FAILED_HR : CdrGenerator.CDR_SUBMIT_FAILED_MO, e1.getMessage(), false, true);
} else {
generateCDR(dialog.getNetworkId(), null, dialog.getLocalAddress(), isMt ? CdrGenerator.CDR_SUBMIT_FAILED_HR : CdrGenerator.CDR_SUBMIT_FAILED_MO, errorMessage.toString(), true);
}
}
dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
if (this.logger.isInfoEnabled()) {
this.logger.info("Sent ErrorComponent = " + errorMessage);
}
dialog.close(false);
} catch (Throwable e) {
logger.severe("Error while sending Error message", e);
return;
}
return;
} catch (Throwable e1) {
this.logger.severe("Exception while processing MO message: " + e1.getMessage(), e1);
smscStatAggregator.updateMsgInFailedAll();
try {
MAPErrorMessage errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), null, null, null);
if (smscPropertiesManagement.isGenerateRejectionCdr()) {
generateCDR(dialog.getNetworkId(), null, dialog.getLocalAddress(), isMt ? CdrGenerator.CDR_SUBMIT_FAILED_HR : CdrGenerator.CDR_SUBMIT_FAILED_MO, errorMessage.toString(), true);
}
dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
dialog.close(false);
} catch (Throwable e) {
logger.severe("Error while sending Error message", e);
return;
}
return;
}
if (sms == null || sms.getMessageDeliveryResultResponse() == null) {
try {
dialog.addForwardShortMessageResponse(evt.getInvokeId());
if (this.logger.isFineEnabled()) {
this.logger.fine("Sent ForwardShortMessageResponse = " + evt);
}
dialog.close(false);
} catch (Throwable e) {
logger.severe("Error while sending ForwardShortMessageResponse ", e);
}
}
}
use of org.restcomm.protocols.ss7.map.api.MAPApplicationContext in project smscgateway by RestComm.
the class RsdsSbb method setupReportSMDeliveryStatusRequest.
// *********
// Main service methods
public void setupReportSMDeliveryStatusRequest(ISDNAddressString msisdn, AddressString serviceCentreAddress, SMDeliveryOutcome smDeliveryOutcome, SccpAddress destAddress, MAPApplicationContext mapApplicationContext, String targetId, int networkId, String mtLocalSccpGt) {
if (this.logger.isInfoEnabled()) {
this.logger.info("Received setupReportSMDeliveryStatus request msisdn= " + msisdn + ", serviceCentreAddress=" + serviceCentreAddress + ", sMDeliveryOutcome=" + smDeliveryOutcome + ", mapApplicationContext=" + mapApplicationContext);
}
this.setTargetId(targetId);
this.setSmDeliveryOutcome(smDeliveryOutcome);
MAPDialogSms mapDialogSms;
try {
SccpAddress originSccpAddress;
if (mtLocalSccpGt != null) {
originSccpAddress = this.getServiceCenterSccpAddress(mtLocalSccpGt, networkId);
} else {
originSccpAddress = this.getServiceCenterSccpAddress(networkId);
}
mapDialogSms = this.mapProvider.getMAPServiceSms().createNewDialog(mapApplicationContext, originSccpAddress, null, destAddress, null);
mapDialogSms.setNetworkId(networkId);
ActivityContextInterface mtFOSmsDialogACI = this.mapAcif.getActivityContextInterface(mapDialogSms);
mtFOSmsDialogACI.attach(this.sbbContext.getSbbLocalObject());
mapDialogSms.addReportSMDeliveryStatusRequest(msisdn, serviceCentreAddress, smDeliveryOutcome, null, null, false, false, null, null);
if (this.logger.isInfoEnabled())
this.logger.info("Sending: ReportSMDeliveryStatusRequest: msisdn=" + msisdn + ", serviceCenterAddress=" + serviceCentreAddress + ", smDeliveryOutcome=" + smDeliveryOutcome);
mapDialogSms.send();
} catch (MAPException e) {
this.logger.severe("MAPException when sending reportSMDeliveryStatusRequest: " + e.getMessage(), e);
}
}
use of org.restcomm.protocols.ss7.map.api.MAPApplicationContext in project smscgateway by RestComm.
the class MoSbbTest method testMo4_MProc.
@Test(groups = { "Mo" })
public void testMo4_MProc() throws Exception {
if (!this.cassandraDbInited)
return;
MProcManagement mProcManagement = MProcManagement.getInstance();
SmscManagement smscManagement = SmscManagement.getInstance("Test");
SmppManagement smppManagement = SmppManagement.getInstance("Test");
smscManagement.setSmppManagement(smppManagement);
mProcManagement.setSmscManagement(smscManagement);
smscManagement.registerRuleFactory(new MProcRuleFactoryDefault());
smscManagement.start();
try {
mProcManagement.destroyMProcRule(1);
} catch (Exception e) {
}
try {
mProcManagement.destroyMProcRule(2);
} catch (Exception e) {
}
mProcManagement.createMProcRule(1, MProcRuleFactoryDefault.RULE_CLASS_NAME, "desttonmask 1 destnpimask 1 originatingmask SS7_MO networkidmask 0 adddestdigprefix 47 makecopy true");
mProcManagement.createMProcRule(2, MProcRuleFactoryDefault.RULE_CLASS_NAME, "networkidmask 0 newnetworkid 5 newdestton 2 makecopy true");
// TODO: ***** make proper mproc rules testing
// MProcManagement.getInstance().createMProcRule(1, 1, 1, "-1", "SS7_MO", 0, -1, -1, -1, "47", true);
// MProcManagement.getInstance().createMProcRule(2, -1, -1, "-1", null, 0, 5, 2, -1, "-1", true);
// destTonMask, destNpiMask, destDigMask, originatingMask, networkIdMask, newNetworkId, newDestTon, newDestNpi, addDestDigPrefix, makeCopy
// TODO: ***** make proper mproc rules testing
SmppSessionsProxy smppServerSessions = new SmppSessionsProxy();
// this.sbb.setSmppServerSessions(smppServerSessions);
AddressString serviceCentreAddressDA = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "1111");
SM_RP_DA sm_RP_DA = new SM_RP_DAImpl(serviceCentreAddressDA);
ISDNAddressString msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "4444");
SM_RP_OAImpl sm_RP_OA = new SM_RP_OAImpl();
sm_RP_OA.setMsisdn(msisdn);
AddressField destinationAddress = new AddressFieldImpl(TypeOfNumber.InternationalNumber, NumberingPlanIdentification.ISDNTelephoneNumberingPlan, "5555");
ProtocolIdentifier protocolIdentifier = new ProtocolIdentifierImpl(12);
DataCodingScheme dataCodingScheme = new DataCodingSchemeImpl(8);
UserData userData = new UserDataImpl(new String("UCS2 USC2 USC2"), dataCodingScheme, null, null);
SmsTpdu tpdu = new SmsSubmitTpduImpl(false, false, false, 150, destinationAddress, protocolIdentifier, null, userData);
SmsSignalInfo sm_RP_UI = new SmsSignalInfoImpl(tpdu, null);
ForwardShortMessageRequest event = new ForwardShortMessageRequestImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, false);
long dueSlot = this.pers.c2_getDueSlotForTime(new Date());
PreparedStatementCollection psc = this.pers.getStatementCollection(new Date());
int b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
long b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
assertEquals(b1, 0);
assertEquals(b2, 0L);
MAPProviderProxy proxy = new MAPProviderProxy();
MAPDialogSmsProxy dialog = new MAPDialogSmsProxy(new MAPServiceSmsProxy(proxy), null, null, null);
event.setMAPDialog(dialog);
Date curDate = new Date();
MAPApplicationContext act = MAPApplicationContext.getInstance(MAPApplicationContextName.shortMsgMORelayContext, MAPApplicationContextVersion.version2);
dialog.setApplicationContext(act);
this.sbb.onForwardShortMessageRequest(event, null);
TargetAddress tax1 = new TargetAddress(1, 1, "475555", 0);
TargetAddress tax2 = new TargetAddress(2, 1, "475555", 5);
// int addrTon, int addrNpi, String addr, int networkId
b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
dueSlot = b2;
b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
assertEquals(b1, 1);
assertEquals(b2, dueSlot);
b2 = this.pers.c2_getDueSlotForTargetId(psc, tax1.getTargetId());
long dueSlot2 = b2;
b1 = this.pers.checkSmsExists(dueSlot, tax1.getTargetId());
assertEquals(b1, 1);
assertEquals(b2, dueSlot2);
long dueSlot3 = b2;
b1 = this.pers.checkSmsExists(dueSlot, tax1.getTargetId());
assertEquals(b1, 1);
assertEquals(b2, dueSlot3);
assertEquals(dialog.getResponseCount(), 1);
assertEquals(dialog.getErrorList().size(), 0);
SmsSet smsSet = this.pers.c2_getRecordListForTargeId(dueSlot, ta1.getTargetId());
SmsSet smsSet2 = this.pers.c2_getRecordListForTargeId(dueSlot2, tax1.getTargetId());
SmsSet smsSet3 = this.pers.c2_getRecordListForTargeId(dueSlot3, tax2.getTargetId());
assertEquals(smsSet.getDestAddr(), "5555");
assertEquals(smsSet.getDestAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(smsSet.getDestAddrNpi(), SmppConstants.NPI_E164);
assertEquals(smsSet.getNetworkId(), 0);
assertEquals(smsSet2.getDestAddr(), "475555");
assertEquals(smsSet2.getDestAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(smsSet2.getDestAddrNpi(), SmppConstants.NPI_E164);
assertEquals(smsSet2.getNetworkId(), 0);
assertEquals(smsSet3.getDestAddr(), "475555");
assertEquals(smsSet3.getDestAddrTon(), SmppConstants.TON_NATIONAL);
assertEquals(smsSet3.getDestAddrNpi(), SmppConstants.NPI_E164);
assertEquals(smsSet3.getNetworkId(), 5);
Sms sms = smsSet.getSms(0);
assertNotNull(sms);
assertEquals(sms.getSourceAddr(), "4444");
assertEquals(sms.getSourceAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(sms.getSourceAddrNpi(), SmppConstants.NPI_E164);
assertEquals(sms.getMessageId(), DBOperations.MESSAGE_ID_LAG + 1);
assertEquals(sms.getMoMessageRef(), 150);
assertEquals(sms.getDataCoding(), 8);
assertNull(sms.getOrigEsmeName());
assertNull(sms.getOrigSystemId());
assertNull(sms.getServiceType());
assertEquals(sms.getEsmClass() & 0xFF, 3);
assertEquals(sms.getRegisteredDelivery(), 0);
assertEquals(sms.getProtocolId(), 12);
assertEquals(sms.getPriority(), 0);
assertEquals(sms.getReplaceIfPresent(), 0);
assertEquals(sms.getDefaultMsgId(), 0);
assertEquals(sms.getTlvSet().getOptionalParameterCount(), 0);
assertNull(sms.getScheduleDeliveryTime());
assertDateEq(sms.getValidityPeriod(), MessageUtil.addHours(curDate, 24 * 3));
assertEquals(sms.getDeliveryCount(), 0);
assertEquals(sms.getShortMessageText(), "UCS2 USC2 USC2");
assertNull(sms.getShortMessageBin());
sms = smsSet2.getSms(0);
assertNotNull(sms);
assertEquals(sms.getSourceAddr(), "4444");
assertEquals(sms.getSourceAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(sms.getSourceAddrNpi(), SmppConstants.NPI_E164);
assertEquals(sms.getMessageId(), DBOperations.MESSAGE_ID_LAG + 1);
assertEquals(sms.getMoMessageRef(), 150);
assertEquals(sms.getDataCoding(), 8);
assertNull(sms.getOrigEsmeName());
assertNull(sms.getOrigSystemId());
assertNull(sms.getServiceType());
assertEquals(sms.getEsmClass() & 0xFF, 3);
assertEquals(sms.getRegisteredDelivery(), 0);
assertEquals(sms.getProtocolId(), 12);
assertEquals(sms.getPriority(), 0);
assertEquals(sms.getReplaceIfPresent(), 0);
assertEquals(sms.getDefaultMsgId(), 0);
assertEquals(sms.getTlvSet().getOptionalParameterCount(), 0);
assertNull(sms.getScheduleDeliveryTime());
assertDateEq(sms.getValidityPeriod(), MessageUtil.addHours(curDate, 24 * 3));
assertEquals(sms.getDeliveryCount(), 0);
assertEquals(sms.getShortMessageText(), "UCS2 USC2 USC2");
assertNull(sms.getShortMessageBin());
sms = smsSet3.getSms(0);
assertNotNull(sms);
assertEquals(sms.getSourceAddr(), "4444");
assertEquals(sms.getSourceAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(sms.getSourceAddrNpi(), SmppConstants.NPI_E164);
assertEquals(sms.getMessageId(), DBOperations.MESSAGE_ID_LAG + 1);
assertEquals(sms.getMoMessageRef(), 150);
assertEquals(sms.getDataCoding(), 8);
assertNull(sms.getOrigEsmeName());
assertNull(sms.getOrigSystemId());
assertNull(sms.getServiceType());
assertEquals(sms.getEsmClass() & 0xFF, 3);
assertEquals(sms.getRegisteredDelivery(), 0);
assertEquals(sms.getProtocolId(), 12);
assertEquals(sms.getPriority(), 0);
assertEquals(sms.getReplaceIfPresent(), 0);
assertEquals(sms.getDefaultMsgId(), 0);
assertEquals(sms.getTlvSet().getOptionalParameterCount(), 0);
assertNull(sms.getScheduleDeliveryTime());
assertDateEq(sms.getValidityPeriod(), MessageUtil.addHours(curDate, 24 * 3));
assertEquals(sms.getDeliveryCount(), 0);
assertEquals(sms.getShortMessageText(), "UCS2 USC2 USC2");
assertNull(sms.getShortMessageBin());
try {
MProcManagement.getInstance().destroyMProcRule(1);
MProcManagement.getInstance().destroyMProcRule(2);
// MProcManagement.getInstance().destroyMProcRule(3);
} catch (Exception e) {
}
}
Aggregations