use of org.mobicents.protocols.ss7.map.api.smstpdu.SmsSubmitTpdu in project smscgateway by RestComm.
the class MoSbb method createSmsEvent.
private Sms createSmsEvent(SmsSubmitTpdu smsSubmitTpdu, TargetAddress ta, PersistenceRAInterface store, AddressString callingPartyAddress, int networkId, String originatorSccpAddress) throws SmscProcessingException {
UserData userData = smsSubmitTpdu.getUserData();
try {
userData.decode();
} catch (MAPException e) {
throw new SmscProcessingException("MO MAPException when decoding user data", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
Sms sms = new Sms();
sms.setDbId(UUID.randomUUID());
sms.setOriginationType(OriginationType.SS7_MO);
// checking parameters first
if (callingPartyAddress == null || callingPartyAddress.getAddress() == null || callingPartyAddress.getAddress().isEmpty()) {
throw new SmscProcessingException("MO SourceAddress digits are absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
if (callingPartyAddress.getAddressNature() == null) {
throw new SmscProcessingException("MO SourceAddress AddressNature is absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
if (callingPartyAddress.getNumberingPlan() == null) {
throw new SmscProcessingException("MO SourceAddress NumberingPlan is absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
sms.setSourceAddr(callingPartyAddress.getAddress());
sms.setOriginatorSccpAddress(originatorSccpAddress);
sms.setSourceAddrTon(callingPartyAddress.getAddressNature().getIndicator());
sms.setSourceAddrNpi(callingPartyAddress.getNumberingPlan().getIndicator());
sms.setOrigNetworkId(networkId);
sms.setSubmitDate(new Timestamp(System.currentTimeMillis()));
int messageingMode = (smscPropertiesManagement.getMoDefaultMessagingMode() & 0x03);
sms.setEsmClass(messageingMode | (smsSubmitTpdu.getUserDataHeaderIndicator() ? SmppConstants.ESM_CLASS_UDHI_MASK : 0) | (smsSubmitTpdu.getReplyPathExists() ? SmppConstants.ESM_CLASS_REPLY_PATH_MASK : 0));
sms.setProtocolId(smsSubmitTpdu.getProtocolIdentifier().getCode());
sms.setPriority(0);
// TODO: do we need somehow care with RegisteredDelivery ?
sms.setReplaceIfPresent(smsSubmitTpdu.getRejectDuplicates() ? 2 : 0);
sms.setStatusReportRequest(smsSubmitTpdu.getStatusReportRequest());
DataCodingScheme dataCodingScheme = smsSubmitTpdu.getDataCodingScheme();
int dcs = dataCodingScheme.getCode();
String err = MessageUtil.checkDataCodingSchemeSupport(dcs);
if (err != null) {
throw new SmscProcessingException("MO DataCoding scheme does not supported: " + dcs + " - " + err, SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
sms.setDataCoding(dcs);
sms.setShortMessageText(userData.getDecodedMessage());
UserDataHeader udh = userData.getDecodedUserDataHeader();
if (udh != null) {
sms.setShortMessageBin(udh.getEncodedData());
}
// ValidityPeriod processing
ValidityPeriod vp = smsSubmitTpdu.getValidityPeriod();
ValidityPeriodFormat vpf = smsSubmitTpdu.getValidityPeriodFormat();
Date validityPeriod = null;
if (vp != null && vpf != null && vpf != ValidityPeriodFormat.fieldNotPresent) {
switch(vpf) {
case fieldPresentAbsoluteFormat:
AbsoluteTimeStamp ats = vp.getAbsoluteFormatValue();
Date dt = new Date(ats.getYear(), ats.getMonth(), ats.getDay(), ats.getHour(), ats.getMinute(), ats.getSecond());
int i1 = ats.getTimeZone() * 15 * 60;
int i2 = -new Date().getTimezoneOffset() * 60;
long i3 = (i2 - i1) * 1000;
validityPeriod = new Date(dt.getTime() + i3);
break;
case fieldPresentRelativeFormat:
validityPeriod = new Date(new Date().getTime() + (long) (vp.getRelativeFormatHours() * 3600 * 1000));
break;
case fieldPresentEnhancedFormat:
this.logger.info("Recieved unsupported ValidityPeriodFormat: PresentEnhancedFormat - we skip it");
break;
}
}
MessageUtil.applyValidityPeriod(sms, validityPeriod, false, smscPropertiesManagement.getMaxValidityPeriodHours(), smscPropertiesManagement.getDefaultValidityPeriodHours());
SmsSet smsSet;
smsSet = new SmsSet();
smsSet.setDestAddr(ta.getAddr());
smsSet.setDestAddrNpi(ta.getAddrNpi());
smsSet.setDestAddrTon(ta.getAddrTon());
smsSet.setNetworkId(networkId);
smsSet.addSms(sms);
long messageId = store.c2_getNextMessageId();
SmscStatProvider.getInstance().setCurrentMessageId(messageId);
sms.setMessageId(messageId);
sms.setMoMessageRef(smsSubmitTpdu.getMessageReference());
return sms;
}
use of org.mobicents.protocols.ss7.map.api.smstpdu.SmsSubmitTpdu in project smscgateway by RestComm.
the class MoSbb method processMoMessage.
private Sms processMoMessage(SM_RP_OA smRPOA, SM_RP_DA smRPDA, SmsSignalInfo smsSignalInfo, int networkId, String originatorSccpAddress, boolean isMoOperation, MAPDialogSms dialog, SmsMessage evt, long invokeId) throws SmscProcessingException {
// TODO: check if smRPDA contains local SMSC address and reject messages
// if not equal ???
Sms sms = null;
smsSignalInfo.setGsm8Charset(isoCharset);
ISDNAddressString callingPartyAddress = smRPOA.getMsisdn();
if (callingPartyAddress == null) {
throw new SmscProcessingException("MO callingPartyAddress is absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
SmsTpdu smsTpdu = null;
String origMoServiceCentreAddressDA = null;
if (smRPDA.getServiceCentreAddressDA() != null) {
origMoServiceCentreAddressDA = smRPDA.getServiceCentreAddressDA().getAddress();
}
try {
smsTpdu = smsSignalInfo.decodeTpdu(true);
switch(smsTpdu.getSmsTpduType()) {
case SMS_SUBMIT:
SmsSubmitTpdu smsSubmitTpdu = (SmsSubmitTpdu) smsTpdu;
if (this.logger.isInfoEnabled()) {
this.logger.info("Received SMS_SUBMIT = " + smsSubmitTpdu);
}
sms = this.handleSmsSubmitTpdu(smsSubmitTpdu, callingPartyAddress, networkId, originatorSccpAddress, isMoOperation, dialog, evt, invokeId, origMoServiceCentreAddressDA);
break;
case SMS_DELIVER_REPORT:
SmsDeliverReportTpdu smsDeliverReportTpdu = (SmsDeliverReportTpdu) smsTpdu;
if (this.logger.isInfoEnabled()) {
this.logger.info("Received SMS_DELIVER_REPORT = " + smsDeliverReportTpdu);
smscStatAggregator.updateMsgInFailedAll();
}
// callingPartyAddress);
break;
case SMS_COMMAND:
SmsCommandTpdu smsCommandTpdu = (SmsCommandTpdu) smsTpdu;
if (this.logger.isInfoEnabled()) {
this.logger.info("Received SMS_COMMAND = " + smsCommandTpdu);
smscStatAggregator.updateMsgInFailedAll();
}
// callingPartyAddress);
break;
// break;
default:
this.logger.severe("Received non SMS_SUBMIT or SMS_DELIVER_REPORT or SMS_COMMAND or SMS_DELIVER = " + smsTpdu);
smscStatAggregator.updateMsgInFailedAll();
break;
}
} catch (MAPException e1) {
logger.severe("Error while decoding SmsSignalInfo ", e1);
}
return sms;
}
use of org.mobicents.protocols.ss7.map.api.smstpdu.SmsSubmitTpdu in project smscgateway by RestComm.
the class MoSbb method handleSmsSubmitTpdu.
private Sms handleSmsSubmitTpdu(SmsSubmitTpdu smsSubmitTpdu, AddressString callingPartyAddress, int networkId, String originatorSccpAddress, boolean isMoOperation, MAPDialogSms dialog, SmsMessage evt, long invokeId, String origMoServiceCentreAddressDA) throws SmscProcessingException {
TargetAddress ta = createDestTargetAddress(smsSubmitTpdu.getDestinationAddress(), networkId);
Sms sms = this.createSmsEvent(smsSubmitTpdu, ta, persistence, callingPartyAddress, networkId, originatorSccpAddress);
sms.setOrigMoServiceCentreAddressDA(origMoServiceCentreAddressDA);
return sms;
// return this.processSms(sms, persistence, smscPropertiesManagement.getMoCharging(), isMoOperation, dialog, evt, invokeId);
}
use of org.mobicents.protocols.ss7.map.api.smstpdu.SmsSubmitTpdu in project smscgateway by RestComm.
the class MAPListener method onMoForwardShortMessageRequest.
@Override
public void onMoForwardShortMessageRequest(MoForwardShortMessageRequest request) {
if (logger.isDebugEnabled()) {
logger.debug("Rx : MoForwardShortMessageRequestIndication=" + request);
}
MAPDialogSms dialog = request.getMAPDialog();
try {
// TODO Should we add PENDING SMS TPDU here itself?
dialog.addMoForwardShortMessageResponse(request.getInvokeId(), null, null);
// dialog.close(false);
} catch (MAPException e) {
logger.error("Error while sending MoForwardShortMessageResponse ", e);
}
dialog.setUserObject(true);
try {
SmsSignalInfo smsSignalInfo = request.getSM_RP_UI();
SmsTpdu smsTpdu = smsSignalInfo.decodeTpdu(true);
if (smsTpdu.getSmsTpduType() != SmsTpduType.SMS_SUBMIT) {
// TODO : Error, we should always receive SMS_SUBMIT for
// MoForwardShortMessageRequestIndication
logger.error("Rx : MoForwardShortMessageRequestIndication, but SmsTpduType is not SMS_SUBMIT. SmsTpdu=" + smsTpdu);
return;
}
SmsSubmitTpdu smsSubmitTpdu = (SmsSubmitTpdu) smsTpdu;
AddressField destinationAddress = smsSubmitTpdu.getDestinationAddress();
// TODO Normalize
} catch (MAPException e1) {
logger.error("Error while decoding SmsSignalInfo ", e1);
}
}
Aggregations