use of org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA in project smscgateway by RestComm.
the class MtTest method SuccessDeliveryUsimTest.
/**
* MAP V3, 1 message, 1 segment, USim message
*/
@Test(groups = { "Mt" })
public void SuccessDeliveryUsimTest() 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();
sd1.dataCodingScheme = 246;
sd1.esmClass = 0x43;
sd1.msg = "012345012345";
sd1.msgUdh = new byte[] { 2, 112, 0 };
lst.add(sd1);
SmsSet smsSet = prepareDatabase(lst);
// SmsSet smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
// assertNotNull(smsSetX);
// Sms smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
// assertEquals(smsX.getSmsSet().getInSystem(), 0);
// initial onSms message
SmsSetEvent event = new SmsSetEvent();
event.setSmsSet(smsSet);
this.sriSbb.onSms(event, null, null);
MAPDialogSmsProxy dlg = serviceSri.getLastMAPDialogSms();
// MAPApplicationContextVersion acv = dlg.getApplicationContext().getApplicationContextVersion();
// assertEquals(acv, MAPApplicationContextVersion.version3);
// assertNull(serviceMt.getLastMAPDialogSms());
// ArrayList<MAPTestEvent> lstEvt = dlg.getEventList();
// assertEquals(lstEvt.size(), 2);
// assertEquals(dlg.getLocalAddress().getGlobalTitle().getDigits(), smscPropertiesManagement.getServiceCenterGt());
// assertEquals(((GlobalTitle0100) dlg.getLocalAddress().getGlobalTitle()).getNumberingPlan(), org.restcomm.protocols.ss7.indicator.NumberingPlan.ISDN_TELEPHONY);
// assertEquals(((GlobalTitle0100) dlg.getLocalAddress().getGlobalTitle()).getNatureOfAddress(), NatureOfAddress.INTERNATIONAL);
// assertEquals(dlg.getRemoteAddress().getGlobalTitle().getDigits(), msdnDig);
// assertEquals(((GlobalTitle0100) dlg.getRemoteAddress().getGlobalTitle()).getNumberingPlan(), org.restcomm.protocols.ss7.indicator.NumberingPlan.ISDN_TELEPHONY);
// assertEquals(((GlobalTitle0100) dlg.getRemoteAddress().getGlobalTitle()).getNatureOfAddress(), NatureOfAddress.INTERNATIONAL);
//
// MAPTestEvent evt = lstEvt.get(0);
// assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
// SendRoutingInfoForSMRequest sriReq = (SendRoutingInfoForSMRequest) evt.event;
// assertEquals(sriReq.getMsisdn().getAddress(), msdnDig);
// assertEquals(sriReq.getMsisdn().getAddressNature(), AddressNature.international_number);
// assertEquals(sriReq.getMsisdn().getNumberingPlan(), org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan.ISDN);
// assertEquals(sriReq.getServiceCentreAddress().getAddress(), smscPropertiesManagement.getServiceCenterGt());
// assertEquals(sriReq.getServiceCentreAddress().getAddressNature(), AddressNature.international_number);
// assertEquals(sriReq.getServiceCentreAddress().getNumberingPlan(), org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan.ISDN);
// assertTrue(sriReq.getSm_RP_PRI());
// evt = lstEvt.get(1);
// assertEquals(evt.testEventType, MAPTestEventType.send);
// smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
// assertNotNull(smsSetX);
// smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
// assertEquals(smsX.getSmsSet().getInSystem(), 0);
// 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);
dlg = serviceMt.getLastMAPDialogSms();
// acv = dlg.getApplicationContext().getApplicationContextVersion();
// assertEquals(acv, MAPApplicationContextVersion.version3);
//
// lstEvt = dlg.getEventList();
// assertEquals(lstEvt.size(), 2);
dlg = serviceMt.getLastMAPDialogSms();
ArrayList<MAPTestEvent> lstEvt = dlg.getEventList();
assertEquals(lstEvt.size(), 2);
MAPTestEvent evt = lstEvt.get(0);
assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
MtForwardShortMessageRequestImpl mtFsmReq = (MtForwardShortMessageRequestImpl) evt.event;
assertFalse(mtFsmReq.getMoreMessagesToSend());
SM_RP_DA sm_RP_DA = mtFsmReq.getSM_RP_DA();
IMSI daImsi = sm_RP_DA.getIMSI();
assertEquals(daImsi.getData(), imsiDig);
SM_RP_OA sm_RP_OA = mtFsmReq.getSM_RP_OA();
AddressString scas = sm_RP_OA.getServiceCentreAddressOA();
assertEquals(scas.getAddress(), smscPropertiesManagement.getServiceCenterGt());
assertEquals(scas.getAddressNature(), AddressNature.international_number);
assertEquals(scas.getNumberingPlan(), org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan.ISDN);
SmsSignalInfo ssi = mtFsmReq.getSM_RP_UI();
SmsDeliverTpdu tpdu = (SmsDeliverTpdu) ssi.decodeTpdu(false);
// assertEquals(tpdu.getDataCodingScheme().getCode(), 16);
// assertFalse(tpdu.getForwardedOrSpawned());
// assertFalse(tpdu.getMoreMessagesToSend());
// assertEquals(tpdu.getOriginatingAddress().getAddressValue(), origDig);
// assertEquals(tpdu.getOriginatingAddress().getNumberingPlanIdentification(), NumberingPlanIdentification.ISDNTelephoneNumberingPlan);
// assertEquals(tpdu.getOriginatingAddress().getTypeOfNumber(), TypeOfNumber.InternationalNumber);
// assertEquals(tpdu.getProtocolIdentifier().getCode(), 7);
// assertFalse(tpdu.getReplyPathExists());
// assertEquals(tpdu.getServiceCentreTimeStamp().getDay(), curDate.getDate());
// int mon1 = tpdu.getServiceCentreTimeStamp().getMonth();
// int mon2 = curDate.getMonth() + 1;
// assertEquals(mon1, mon2);
// assertEquals(tpdu.getSmsTpduType(), SmsTpduType.SMS_DELIVER);
// assertFalse(tpdu.getStatusReportIndication());
// assertFalse(tpdu.getUserDataHeaderIndicator());
// UserData ud = tpdu.getUserData();
// ud.decode();
// assertNull(ud.getDecodedUserDataHeader());
// String msg1 = ud.getDecodedMessage();
// assertEquals(msg1, msgShort);
//
// // evt = lstEvt.get(1);
// // assertEquals(evt.testEventType, MAPTestEventType.send);
// // smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
// // assertNotNull(smsSetX);
// // smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
// // assertEquals(smsX.getSmsSet().getInSystem(), 0);
// //
// // UUID smsId = smsSet.getSms(0).getDbId();
// // SmsProxy smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
// // assertNull(smsx2);
//
// // Mt response
// MtForwardShortMessageResponseImpl evt2 = new MtForwardShortMessageResponseImpl(null, null);
// evt2.setMAPDialog(dlg);
// DialogAccept daevt = new DialogAccept(dlg, null);
// this.mtSbb.onDialogAccept(daevt, null);
// this.mtSbb.onMtForwardShortMessageResponse(evt2, null);
// DialogClose dcl = new DialogClose(dlg);
// this.mtSbb.onDialogClose(dcl, null);
// // smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
// // assertNull(smsSetX);
// // smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
// // assertNull(smsX);
//
// // dlg = serviceSri.getLastMAPDialogSms();
// // lstEvt = dlg.getEventList();
// // assertEquals(lstEvt.size(), 2);
// //
// // dlg = serviceMt.getLastMAPDialogSms();
// // lstEvt = dlg.getEventList();
// // assertEquals(lstEvt.size(), 2);
// //
// // int b1 = this.pers.checkSmsExists(procDueSlot, smsSet.getTargetId());
// // smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
// // assertNotNull(smsx2);
// //
// // dlg = serviceRsds.getLastMAPDialogSms();
// // assertNull(dlg);
}
use of org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA in project smscgateway by RestComm.
the class MtSbb method setupMtForwardShortMessageRequest.
// *********
// Main service methods
public void setupMtForwardShortMessageRequest(ISDNAddressString networkNode, String imsiData, LMSI lmsi, int networkId) {
if (this.logger.isFineEnabled()) {
this.logger.fine("mperforming setupMtForwardShortMessageRequest ISDNAddressString= " + networkNode);
}
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
markDeliveringIsEnded(true);
logger.severe("MtSbb.setupMtForwardShortMessageRequest(): CMP smsSet is missed");
return;
}
Sms sms0 = smsSet.getSms(0);
Integer mtRemoteSccpTt = sms0.getMtRemoteSccpTt();
SccpAddress networkNodeSccpAddress = this.getMSCSccpAddress(networkNode, mtRemoteSccpTt);
IMSI imsi = this.mapParameterFactory.createIMSI(imsiData);
SM_RP_DA sm_RP_DA = this.mapParameterFactory.createSM_RP_DA(imsi);
AddressString scAddress = this.getServiceCenterAddressString(networkId);
SM_RP_OA sm_RP_OA = this.mapParameterFactory.createSM_RP_OA_ServiceCentreAddressOA(scAddress);
if (sms0 != null) {
// we only set it for first sms in the list
sms0.setMtServiceCenterAddress(scAddress.getAddress());
}
this.setNnn(networkNode);
this.setNetworkNode(networkNodeSccpAddress);
this.setSmRpDa(sm_RP_DA);
this.setSmRpOa(sm_RP_OA);
// Set cache with MAP version
MAPApplicationContextVersion mapApplicationContextVersion = mapVersionCache.getMAPApplicationContextVersion(networkNode.getAddress());
if (mapApplicationContextVersion == null) {
mapApplicationContextVersion = MAPApplicationContextVersion.getInstance(smscPropertiesManagement.getMaxMapVersion());
} else {
this.setNegotiatedMapVersionUsing(true);
}
this.setMAPVersionTested(mapApplicationContextVersion);
// dropaftersri mproc rules
try {
if (this.getTotalUnsentMessageCount() > 0) {
ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
ArrayList<Sms> lstRerouted = new ArrayList<Sms>();
ArrayList<Integer> lstNewNetworkId = new ArrayList<Integer>();
TargetAddress lock = persistence.obtainSynchroObject(new TargetAddress(smsSet));
try {
synchronized (lock) {
this.applyMprocRulesOnImsiResponse(smsSet, lstPermFailured, lstRerouted, lstNewNetworkId, networkNode, imsiData);
this.onImsiDrop(smsSet, lstPermFailured, lstRerouted, lstNewNetworkId, networkNode, imsiData);
}
} finally {
persistence.releaseSynchroObject(lock);
}
}
} catch (Throwable e) {
}
if (this.getTotalUnsentMessageCount() == 0) {
setupReportSMDeliveryStatusRequestSuccess(smsSet, true);
smsSet.setStatus(ErrorCode.SUCCESS);
this.markDeliveringIsEnded(true);
} else {
try {
this.sendMtSms(this.getMtFoSMSMAPApplicationContext(mapApplicationContextVersion), MessageProcessingState.firstMessageSending, null, smsSet.getNetworkId());
} catch (SmscProcessingException e) {
String reason = "SmscPocessingException when invoking sendMtSms() from setupMtForwardShortMessageRequest()-firstMessageSending: " + 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);
} catch (Throwable e) {
String reason = "Exception when invoking sendMtSms() from setupMtForwardShortMessageRequest()-firstMessageSending: " + 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);
}
}
}
use of org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA in project smscgateway by RestComm.
the class MtSbb method sendMtSms.
private void sendMtSms(MAPApplicationContext mapApplicationContext, MessageProcessingState messageProcessingState, MAPDialogSms mapDialogSms, int networkId) throws SmscProcessingException {
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
throw new SmscProcessingException("CMP smsSet is missed", -1, -1, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
Sms sms = this.getMessageInSendingPool(0);
if (sms == null) {
throw new SmscProcessingException("sms is missed in CMP", -1, -1, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
boolean moreMessagesToSend = false;
try {
if (this.getTotalUnsentMessageCount() > 1) {
moreMessagesToSend = true;
}
} catch (Throwable e) {
}
try {
boolean newDialog = false;
if (mapDialogSms == null) {
newDialog = true;
String mtLocalSccpGt = sms.getMtLocalSccpGt();
SccpAddress originSccpAddress;
if (mtLocalSccpGt != null) {
originSccpAddress = this.getServiceCenterSccpAddress(mtLocalSccpGt, networkId);
} else {
originSccpAddress = this.getServiceCenterSccpAddress(networkId);
}
mapDialogSms = this.mapProvider.getMAPServiceSms().createNewDialog(mapApplicationContext, originSccpAddress, null, this.getNetworkNode(), null);
mapDialogSms.setNetworkId(networkId);
ActivityContextInterface mtFOSmsDialogACI = this.mapAcif.getActivityContextInterface(mapDialogSms);
mtFOSmsDialogACI.attach(this.sbbContext.getSbbLocalObject());
}
// setting TON / NPI to unknown for unsupported source TON / NPI
int sourceAddrTon = sms.getSourceAddrTon();
if (sourceAddrTon < 0 || sourceAddrTon > 6)
sourceAddrTon = 0;
int sourceAddrNpi = sms.getSourceAddrNpi();
if (sourceAddrTon == SmppConstants.TON_ALPHANUMERIC) {
sourceAddrNpi = SmppConstants.NPI_UNKNOWN;
} else {
if (sourceAddrNpi >= 0 && sourceAddrNpi <= 1 || sourceAddrNpi >= 3 && sourceAddrNpi <= 9 || sourceAddrNpi >= 10 && sourceAddrNpi <= 1 || sourceAddrNpi == 18) {
} else {
sourceAddrNpi = SmppConstants.NPI_UNKNOWN;
}
}
SM_RP_DA sm_RP_DA = this.getSmRpDa();
SM_RP_OA sm_RP_OA = this.getSmRpOa();
SmsSignalInfo smsSignalInfo;
if (messageProcessingState == MessageProcessingState.firstMessageSending) {
int dcs = sms.getDataCoding();
Tlv dest_addr_subunit = sms.getTlvSet().getOptionalParameter(SmppConstants.TAG_DEST_ADDR_SUBUNIT);
if (dest_addr_subunit != null) {
try {
int mclass = dest_addr_subunit.getValueAsByte();
if (mclass >= 1 && mclass <= 4) {
dcs |= (0x10 + (mclass - 1));
}
} catch (TlvConvertException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
DataCodingScheme dataCodingScheme = this.mapSmsTpduParameterFactory.createDataCodingScheme(dcs);
Tlv sarMsgRefNum = sms.getTlvSet().getOptionalParameter(SmppConstants.TAG_SAR_MSG_REF_NUM);
Tlv sarTotalSegments = sms.getTlvSet().getOptionalParameter(SmppConstants.TAG_SAR_TOTAL_SEGMENTS);
Tlv sarSegmentSeqnum = sms.getTlvSet().getOptionalParameter(SmppConstants.TAG_SAR_SEGMENT_SEQNUM);
SmsSignalInfo[] segments;
SmsDeliveryReportData smsDeliveryReportData = SmsDeliveryReportData.decodeFromString(sms.getShortMessageText());
if (smsDeliveryReportData != null) {
// this is SMS-STATUS-REPORT
segments = new SmsSignalInfo[1];
segments[0] = this.createSignalInfoStatusReport(sms, moreMessagesToSend, smsDeliveryReportData);
} else if ((sms.getEsmClass() & SmppConstants.ESM_CLASS_UDHI_MASK) != 0) {
// message already contains UDH - we can not slice it
segments = new SmsSignalInfo[1];
segments[0] = this.createSignalInfo(sms, sms.getShortMessageText(), sms.getShortMessageBin(), moreMessagesToSend, 0, 1, 1, dataCodingScheme, 0, 0, sourceAddrTon, sourceAddrNpi);
} else if (sarMsgRefNum != null && sarTotalSegments != null && sarSegmentSeqnum != null) {
// we have tlv's that define message count/number/reference
int messageSegmentCount = sarTotalSegments.getValueAsUnsignedByte();
int messageSegmentNumber = sarSegmentSeqnum.getValueAsUnsignedByte();
int messageReferenceNumber = sarMsgRefNum.getValueAsUnsignedShort();
segments = new SmsSignalInfo[1];
segments[0] = this.createSignalInfo(sms, sms.getShortMessageText(), null, moreMessagesToSend, messageReferenceNumber, messageSegmentCount, messageSegmentNumber, dataCodingScheme, sms.getNationalLanguageLockingShift(), sms.getNationalLanguageSingleShift(), sourceAddrTon, sourceAddrNpi);
} else {
// possible a big message and segmentation
String[] segmentsByte;
segmentsByte = MessageUtil.sliceMessage(sms.getShortMessageText(), dataCodingScheme, sms.getNationalLanguageLockingShift(), sms.getNationalLanguageSingleShift());
segments = new SmsSignalInfo[segmentsByte.length];
// TODO messageReferenceNumber should be generated
// int messageReferenceNumber = (int) (this.getCurrentMsgNumValue() + 1);
int messageReferenceNumber = (int) (this.getCurrentMsgNumValue());
for (int i1 = 0; i1 < segmentsByte.length; i1++) {
segments[i1] = this.createSignalInfo(sms, segmentsByte[i1], null, (i1 < segmentsByte.length - 1 ? true : moreMessagesToSend), messageReferenceNumber, segmentsByte.length, i1 + 1, dataCodingScheme, sms.getNationalLanguageLockingShift(), sms.getNationalLanguageSingleShift(), sourceAddrTon, sourceAddrNpi);
}
}
this.setSegments(segments);
smsSignalInfo = segments[0];
this.setMessageSegmentNumber(0);
if (segments.length > 1)
moreMessagesToSend = true;
} else {
int messageSegmentNumber = this.getMessageSegmentNumber();
SmsSignalInfo[] segments = this.getSegments();
smsSignalInfo = segments[messageSegmentNumber];
if (messageSegmentNumber < segments.length - 1)
moreMessagesToSend = true;
}
long invokeId = 0;
switch(mapDialogSms.getApplicationContext().getApplicationContextVersion()) {
case version3:
invokeId = mapDialogSms.addMtForwardShortMessageRequest(sm_RP_DA, sm_RP_OA, smsSignalInfo, moreMessagesToSend, null);
if (this.logger.isInfoEnabled()) {
this.logger.info("Sending: MtForwardShortMessageRequest: sm_RP_DA=" + sm_RP_DA + ", sm_RP_OA=" + sm_RP_OA + ", si=" + smsSignalInfo + ", moreMessagesToSend=" + moreMessagesToSend);
}
break;
case version2:
case version1:
invokeId = mapDialogSms.addForwardShortMessageRequest(sm_RP_DA, sm_RP_OA, smsSignalInfo, moreMessagesToSend);
if (this.logger.isInfoEnabled()) {
this.logger.info("Sending: ForwardShortMessageRequest: sm_RP_DA=" + sm_RP_DA + ", sm_RP_OA=" + sm_RP_OA + ", si=" + smsSignalInfo + ", moreMessagesToSend=" + moreMessagesToSend);
}
break;
default:
break;
}
int messageUserDataLengthOnSend = mapDialogSms.getMessageUserDataLengthOnSend();
int maxUserDataLength = mapDialogSms.getMaxUserDataLength();
if (mapDialogSms.getApplicationContext().getApplicationContextVersion() != MAPApplicationContextVersion.version1 && newDialog && messageUserDataLengthOnSend >= maxUserDataLength - SmscPropertiesManagement.getInstance().getMaxMessageLengthReducer()) {
mapDialogSms.cancelInvocation(invokeId);
this.setTcEmptySent(1);
} else {
this.setTcEmptySent(0);
}
mapDialogSms.send();
sms.putMsgPartDeliveryTime(getMessageSegmentNumber(), System.currentTimeMillis());
} catch (MAPException e) {
if (mapDialogSms != null)
mapDialogSms.release();
throw new SmscProcessingException("MAPException when sending MtForwardSM. Sms=" + sms, -1, -1, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e);
} catch (TlvConvertException e) {
if (mapDialogSms != null)
mapDialogSms.release();
throw new SmscProcessingException("TlvConvertException when sending MtForwardSM", -1, -1, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e);
}
}
use of org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA in project smscgateway by RestComm.
the class MtSbb method handleSmsResponse.
private void handleSmsResponse(MAPDialogSms mapDialogSms, boolean continueDialog) {
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
logger.severe("MtSbb.handleSmsResponse(): CMP smsSet is missed");
markDeliveringIsEnded(true);
return;
}
smscStatAggregator.updateMsgOutSentAll();
smscStatAggregator.updateMsgOutSentSs7();
Sms sms = this.getMessageInSendingPool(0);
// checking if there are yet message segments
int messageSegmentNumber = this.getMessageSegmentNumber();
SmsSignalInfo[] segments = this.getSegments();
if (segments != null && messageSegmentNumber < segments.length - 1) {
this.generateCDR(sms, CdrGenerator.CDR_PARTIAL, CdrGenerator.CDR_SUCCESS_NO_REASON, true, false, messageSegmentNumber);
// we have more message parts to be sent yet
messageSegmentNumber++;
this.setMessageSegmentNumber(messageSegmentNumber);
try {
smscStatAggregator.updateMsgOutTryAll();
smscStatAggregator.updateMsgOutTrySs7();
this.sendMtSms(mapDialogSms.getApplicationContext(), MessageProcessingState.nextSegmentSending, continueDialog ? mapDialogSms : null, smsSet.getNetworkId());
return;
} catch (SmscProcessingException e) {
this.logger.severe("SmscPocessingException when invoking sendMtSms() from handleSmsResponse()-nextSegmentSending: " + e.toString(), e);
this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SYSTEM_FAILURE, "Error sendMtSms in handleSmsResponse(): ", true, null, false, ProcessingType.SS7_MT);
return;
}
}
// current message is sent
// firstly sending of a positive response for transactional mode
this.sendTransactionalResponseSuccess(sms);
// mproc rules applying for delivery phase
this.applyMprocRulesOnSuccess(sms, ProcessingType.SS7_MT);
// Processing succeeded
sms.getSmsSet().setStatus(ErrorCode.SUCCESS);
this.postProcessSucceeded(sms, null, null);
// success CDR generating
boolean isPartial = MessageUtil.isSmsNotLastSegment(sms);
this.generateCDR(sms, isPartial ? CdrGenerator.CDR_PARTIAL : CdrGenerator.CDR_SUCCESS, CdrGenerator.CDR_SUCCESS_NO_REASON, segments != null, true, messageSegmentNumber);
// adding a success receipt if it is needed
this.generateSuccessReceipt(smsSet, sms);
TargetAddress lock = persistence.obtainSynchroObject(new TargetAddress(smsSet));
try {
synchronized (lock) {
// marking the message in cache as delivered
this.commitSendingPoolMsgCount();
// now we are trying to sent other messages
sms = obtainNextMessage(ProcessingType.SS7_MT);
if (sms != null) {
// dropaftersri pmproc rules
ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
ArrayList<Sms> lstRerouted = new ArrayList<Sms>();
ArrayList<Integer> lstNewNetworkId = new ArrayList<Integer>();
SM_RP_DA da = this.getSmRpDa();
ISDNAddressString networkNodeNumber = this.getNnn();
this.applyMprocRulesOnImsiResponse(smsSet, lstPermFailured, lstRerouted, lstNewNetworkId, networkNodeNumber, da.getIMSI().getData());
this.onImsiDrop(smsSet, lstPermFailured, lstRerouted, lstNewNetworkId, networkNodeNumber, da.getIMSI().getData());
}
sms = this.getMessageInSendingPool(0);
if (sms != null) {
try {
// sms.setDeliveryCount(sms.getDeliveryCount() + 1);
smscStatAggregator.updateMsgOutTryAll();
smscStatAggregator.updateMsgOutTrySs7();
this.sendMtSms(mapDialogSms.getApplicationContext(), MessageProcessingState.firstMessageSending, continueDialog ? mapDialogSms : null, smsSet.getNetworkId());
return;
} catch (SmscProcessingException e) {
this.logger.severe("SmscPocessingException when invoking sendMtSms() from handleSmsResponse(): " + e.toString(), e);
}
}
// more messages in a database
if (continueDialog) {
try {
mapDialogSms.close(false);
} catch (MAPException e) {
this.logger.severe("MAPException when closing MAP dialog from handleSmsResponse(): " + e.toString(), e);
}
}
// no more messages to send - remove smsSet
setupReportSMDeliveryStatusRequestSuccess(smsSet, mapDialogSms.getApplicationContext().getApplicationContextVersion() != MAPApplicationContextVersion.version1);
smsSet.setStatus(ErrorCode.SUCCESS);
this.markDeliveringIsEnded(true);
// this.freeSmsSetSucceded(smsSet, pers);
}
} finally {
persistence.releaseSynchroObject(lock);
}
}
use of org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA in project smscgateway by RestComm.
the class MoSbb method processMtMessage.
// *********
// incoming message processing
private Sms processMtMessage(SM_RP_OA smRPOA, SM_RP_DA smRPDA, SmsSignalInfo smsSignalInfo, int networkId, String originatorSccpAddress, boolean isMoOperation, MAPDialogSms dialog, SmsMessage evt, long invokeId) throws SmscProcessingException {
Sms sms = null;
smsSignalInfo.setGsm8Charset(isoCharset);
IMSI destinationImsi = smRPDA.getIMSI();
if (destinationImsi == null) {
throw new SmscProcessingException("Home routing: Mt DA IMSI is absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
// obtaining correlationId
String correlationID = destinationImsi.getData();
CorrelationIdValue civ;
try {
civ = SmsSetCache.getInstance().getCorrelationIdCacheElement(correlationID);
} catch (Exception e) {
throw new SmscProcessingException("Home routing: Error when getting of CorrelationIdCacheElement", SmppConstants.STATUS_SYSERR, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e);
}
if (civ == null) {
smscStatAggregator.updateHomeRoutingCorrIdFail();
throw new SmscProcessingException("Home routing: No data is found for: CorrelationId=" + correlationID, SmppConstants.STATUS_SYSERR, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
SmsTpdu smsTpdu = null;
try {
smsTpdu = smsSignalInfo.decodeTpdu(false);
logger.fine("Home routing: The SmsTpduType is " + smsTpdu.getSmsTpduType());
switch(smsTpdu.getSmsTpduType()) {
case SMS_DELIVER:
SmsDeliverTpdu smsDeliverTpdu = (SmsDeliverTpdu) smsTpdu;
if (this.logger.isInfoEnabled()) {
this.logger.info("Home routing: Received SMS_DELIVER = " + smsDeliverTpdu);
}
// AddressField af = smsSubmitTpdu.getDestinationAddress();
sms = this.handleSmsDeliverTpdu(smsDeliverTpdu, civ, networkId, originatorSccpAddress, isMoOperation, dialog, evt, invokeId);
break;
default:
this.logger.severe("Home routing: Received non SMS_DELIVER = " + smsTpdu);
break;
}
} catch (MAPException e1) {
logger.severe("Home routing: Error while decoding SmsSignalInfo ", e1);
}
return sms;
}
Aggregations