use of org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString in project smscgateway by RestComm.
the class HrSriServerSbb method onSriSuccess.
/**
* HrSriResultInterface
*/
@Override
public void onSriSuccess(CorrelationIdValue correlationIdValue, boolean sriBypass) {
MAPDialogSms dlg = this.getActivity();
if (dlg == null) {
this.logger.severe("Home routing: can not get MAPDialog for sending SRI positive Response");
return;
}
if (!sriBypass) {
smscStatAggregator.updateMsgInHrSriPosReq();
StringBuilder sb = new StringBuilder();
sb.append("Home routing: positive SRI response from HLR: transaction: ");
sb.append(correlationIdValue);
if (this.logger.isInfoEnabled())
this.logger.info(sb.toString());
}
// storing correlationId into a cache
try {
SmsSetCache.getInstance().putCorrelationIdCacheElement(correlationIdValue, smscPropertiesManagement.getCorrelationIdLiveTime());
} catch (Exception e1) {
if (dlg != null) {
dlg.release();
}
String reason = "Home routing: Exception when ImsiCacheElement : " + e1.toString();
this.logger.severe(reason, e1);
return;
}
// sending positive SRI response
try {
String smscAddressForCountryCode = this.getSmscAddressForCountryCode();
ISDNAddressString networkNodeNumber;
if (smscAddressForCountryCode != null) {
networkNodeNumber = this.mapParameterFactory.createISDNAddressString(AddressNature.international_number, NumberingPlan.ISDN, smscAddressForCountryCode);
} else {
networkNodeNumber = getNetworkNodeNumber(correlationIdValue.getNetworkId());
}
LocationInfoWithLMSI li = this.mapParameterFactory.createLocationInfoWithLMSI(networkNodeNumber, null, null, false, null);
this.doSendResponse(correlationIdValue, dlg, correlationIdValue.getCorrelationID(), li);
} catch (MAPException e) {
if (dlg != null) {
dlg.release();
}
String reason = "Home routing: MAPException when sending SRI positive Response : " + e.toString();
this.logger.severe(reason, e);
}
}
use of org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString 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.primitives.ISDNAddressString 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.primitives.ISDNAddressString 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.primitives.ISDNAddressString in project smscgateway by RestComm.
the class SmsSetCasheTest method testSmppShellExecutor.
@Test(groups = { "SmsSet" })
public void testSmppShellExecutor() throws Exception {
int correlationIdLiveTime = 2;
int sriResponseLiveTime = 3;
int deliveredMsgLiveTime = 3;
SmsSetCache.start(correlationIdLiveTime, sriResponseLiveTime, deliveredMsgLiveTime);
SmsSetCache ssc = SmsSetCache.getInstance();
String remoteMessageId = "0000100001";
String destId = "esme_33";
Long messageId = 3000031L;
String correlationID = "000000000011111";
ISDNAddressString msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "11111111");
AddressString serviceCentreAddress = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22222222");
CorrelationIdValue elem = new CorrelationIdValue(correlationID, msisdn, serviceCentreAddress, 0, null);
ssc.putCorrelationIdCacheElement(elem, correlationIdLiveTime);
Sms sms = new Sms();
long mId = 222L;
sms.setMessageId(mId);
sms.setShortMessageText("textxxx");
ssc.putDeliveredMsgValue(sms, deliveredMsgLiveTime);
ssc.putDeliveredRemoteMsgIdValue(remoteMessageId, destId, messageId, deliveredMsgLiveTime);
String targetID = "22222_1_1_2";
LocationInfoWithLMSI locationInfoWithLMSI = null;
SriResponseValue srv = new SriResponseValue(targetID, 2, "22222", 1, 1, locationInfoWithLMSI, "0000011111000000");
ssc.putSriResponseValue(srv, sriResponseLiveTime);
Thread.sleep(2500);
CorrelationIdValue v1 = ssc.getCorrelationIdCacheElement(correlationID);
assertNotNull(v1);
SriResponseValue vv1 = ssc.getSriResponseValue(targetID);
assertNotNull(vv1);
Sms sms2 = ssc.getDeliveredMsgValue(mId);
assertNotNull(sms2);
Long msgId2 = ssc.getDeliveredRemoteMsgIdValue(remoteMessageId, destId);
assertEquals((long) msgId2, (long) messageId);
Thread.sleep(2500);
CorrelationIdValue v2 = ssc.getCorrelationIdCacheElement(correlationID);
assertNull(v2);
SriResponseValue vv2 = ssc.getSriResponseValue(targetID);
assertNotNull(vv2);
sms2 = ssc.getDeliveredMsgValue(mId);
assertNotNull(sms2);
msgId2 = ssc.getDeliveredRemoteMsgIdValue(remoteMessageId, destId);
assertEquals((long) msgId2, (long) messageId);
Thread.sleep(2000);
CorrelationIdValue v3 = ssc.getCorrelationIdCacheElement(correlationID);
assertNull(v3);
SriResponseValue vv3 = ssc.getSriResponseValue(targetID);
assertNull(vv3);
sms2 = ssc.getDeliveredMsgValue(mId);
assertNull(sms2);
msgId2 = ssc.getDeliveredRemoteMsgIdValue(remoteMessageId, destId);
assertNull(msgId2);
SmsSetCache.stop();
}
Aggregations