Search in sources :

Example 16 with MAPException

use of org.restcomm.protocols.ss7.map.api.MAPException 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;
}
Also used : DataCodingScheme(org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme) AbsoluteTimeStamp(org.restcomm.protocols.ss7.map.api.smstpdu.AbsoluteTimeStamp) UserData(org.restcomm.protocols.ss7.map.api.smstpdu.UserData) MAPException(org.restcomm.protocols.ss7.map.api.MAPException) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) Timestamp(java.sql.Timestamp) Date(java.util.Date) ValidityPeriodFormat(org.restcomm.protocols.ss7.map.api.smstpdu.ValidityPeriodFormat) MAPDialogSms(org.restcomm.protocols.ss7.map.api.service.sms.MAPDialogSms) ValidityPeriod(org.restcomm.protocols.ss7.map.api.smstpdu.ValidityPeriod) UserDataHeader(org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader)

Example 17 with MAPException

use of org.restcomm.protocols.ss7.map.api.MAPException in project smscgateway by RestComm.

the class MoSbb method onDialogDelimiter.

public void onDialogDelimiter(DialogDelimiter evt, ActivityContextInterface aci) {
    super.onDialogDelimiter(evt, aci);
    if (this.getProcessingState() == MoProcessingState.OnlyRequestRecieved) {
        this.setProcessingState(null);
        if (this.logger.isFineEnabled())
            this.logger.fine("MoSBB: onDialogDelimiter - sending empty TC-CONTINUE for " + evt);
        evt.getMAPDialog();
        MAPDialog dialog = evt.getMAPDialog();
        try {
            dialog.send();
        } catch (MAPException e) {
            logger.severe("Error while sending Continue", e);
        }
    }
}
Also used : MAPException(org.restcomm.protocols.ss7.map.api.MAPException) MAPDialog(org.restcomm.protocols.ss7.map.api.MAPDialog)

Example 18 with MAPException

use of org.restcomm.protocols.ss7.map.api.MAPException in project smscgateway by RestComm.

the class MoSbb method createSmsEvent.

private Sms createSmsEvent(SmsDeliverTpdu smsDeliverTpdu, TargetAddress ta, PersistenceRAInterface store, CorrelationIdValue civ, int networkId, String originatorSccpAddress) throws SmscProcessingException {
    UserData userData = smsDeliverTpdu.getUserData();
    try {
        userData.decode();
    } catch (MAPException e) {
        throw new SmscProcessingException("MT 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_HR);
    AddressField callingPartyAddress = smsDeliverTpdu.getOriginatingAddress();
    // checking parameters first
    if (callingPartyAddress == null || callingPartyAddress.getAddressValue() == null || callingPartyAddress.getAddressValue().isEmpty()) {
        throw new SmscProcessingException("Home routing: TPDU OriginatingAddress digits are absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    if (callingPartyAddress.getTypeOfNumber() == null) {
        throw new SmscProcessingException("Home routing: TPDU OriginatingAddress TypeOfNumber is absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    if (callingPartyAddress.getNumberingPlanIdentification() == null) {
        throw new SmscProcessingException("Home routing: TPDU OriginatingAddress NumberingPlanIdentification is absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    sms.setSourceAddr(callingPartyAddress.getAddressValue());
    sms.setOriginatorSccpAddress(originatorSccpAddress);
    if (callingPartyAddress.getTypeOfNumber() == TypeOfNumber.Alphanumeric) {
        sms.setSourceAddrTon(TypeOfNumber.Alphanumeric.getCode());
        sms.setSourceAddrNpi(NumberingPlanIdentification.Unknown.getCode());
    } else {
        sms.setSourceAddrTon(callingPartyAddress.getTypeOfNumber().getCode());
        sms.setSourceAddrNpi(callingPartyAddress.getNumberingPlanIdentification().getCode());
    }
    sms.setOrigNetworkId(networkId);
    sms.setSubmitDate(new Timestamp(System.currentTimeMillis()));
    int messageingMode = (smscPropertiesManagement.getHrDefaultMessagingMode() & 0x03);
    sms.setEsmClass(messageingMode | (smsDeliverTpdu.getUserDataHeaderIndicator() ? SmppConstants.ESM_CLASS_UDHI_MASK : 0) | (smsDeliverTpdu.getReplyPathExists() ? SmppConstants.ESM_CLASS_REPLY_PATH_MASK : 0));
    sms.setProtocolId(smsDeliverTpdu.getProtocolIdentifier().getCode());
    sms.setPriority(0);
    // TODO: do we need somehow care with RegisteredDelivery ?
    sms.setReplaceIfPresent(0);
    // TODO: care with smsSubmitTpdu.getStatusReportRequest() parameter
    // sending back SMS_STATUS_REPORT tpdu ?
    DataCodingScheme dataCodingScheme = smsDeliverTpdu.getDataCodingScheme();
    int dcs = dataCodingScheme.getCode();
    String err = MessageUtil.checkDataCodingSchemeSupport(dcs);
    if (err != null) {
        throw new SmscProcessingException("Home routing: 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
    MessageUtil.applyValidityPeriod(sms, null, 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.setCorrelationId(civ.getCorrelationID());
    smsSet.setImsi(civ.getImsi());
    smsSet.setLocationInfoWithLMSI(civ.getLocationInfoWithLMSI());
    smsSet.addSms(sms);
    sms.setSmsSet(smsSet);
    long messageId = store.c2_getNextMessageId();
    SmscStatProvider.getInstance().setCurrentMessageId(messageId);
    sms.setMessageId(messageId);
    return sms;
}
Also used : AddressField(org.restcomm.protocols.ss7.map.api.smstpdu.AddressField) DataCodingScheme(org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme) UserData(org.restcomm.protocols.ss7.map.api.smstpdu.UserData) MAPException(org.restcomm.protocols.ss7.map.api.MAPException) MAPDialogSms(org.restcomm.protocols.ss7.map.api.service.sms.MAPDialogSms) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) Timestamp(java.sql.Timestamp) UserDataHeader(org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader)

Example 19 with MAPException

use of org.restcomm.protocols.ss7.map.api.MAPException in project smscgateway by RestComm.

the class MtSbb method onDialogDelimiter.

@Override
public void onDialogDelimiter(DialogDelimiter evt, ActivityContextInterface aci) {
    super.onDialogDelimiter(evt, aci);
    SmsSet smsSet = getSmsSet();
    if (smsSet == null) {
        logger.severe("MtSbb.onDialogDelimiter(): CMP smsSet is missed");
        markDeliveringIsEnded(true);
        return;
    }
    try {
        if (this.getTcEmptySent() != 0) {
            // Empty TC-BEGIN has been sent
            // We are sending MtForwardSM
            this.setTcEmptySent(0);
            SmsSignalInfo[] segments = this.getSegments();
            int messageSegmentNumber = this.getMessageSegmentNumber();
            if (messageSegmentNumber >= 0 && segments != null && messageSegmentNumber < segments.length) {
                SmsSignalInfo si = segments[messageSegmentNumber];
                if (si != null) {
                    try {
                        MAPDialogSms mapDialogSms = (MAPDialogSms) evt.getMAPDialog();
                        SM_RP_DA sm_RP_DA = this.getSmRpDa();
                        SM_RP_OA sm_RP_OA = this.getSmRpOa();
                        boolean moreMessagesToSend = false;
                        if (messageSegmentNumber < segments.length - 1) {
                            moreMessagesToSend = true;
                        }
                        try {
                            if (this.getTotalUnsentMessageCount() > 1) {
                                moreMessagesToSend = true;
                            }
                        } catch (Throwable e) {
                        }
                        switch(mapDialogSms.getApplicationContext().getApplicationContextVersion()) {
                            case version3:
                                mapDialogSms.addMtForwardShortMessageRequest(sm_RP_DA, sm_RP_OA, si, moreMessagesToSend, null);
                                if (this.logger.isInfoEnabled()) {
                                    this.logger.info("Sending: MtForwardShortMessageRequest: sm_RP_DA=" + sm_RP_DA + ", sm_RP_OA=" + sm_RP_OA + ", si=" + si + ", moreMessagesToSend=" + moreMessagesToSend);
                                }
                                break;
                            case version2:
                            case version1:
                                mapDialogSms.addForwardShortMessageRequest(sm_RP_DA, sm_RP_OA, si, moreMessagesToSend);
                                if (this.logger.isInfoEnabled()) {
                                    this.logger.info("Sending: ForwardShortMessageRequest: sm_RP_DA=" + sm_RP_DA + ", sm_RP_OA=" + sm_RP_OA + ", si=" + si + ", moreMessagesToSend=" + moreMessagesToSend);
                                }
                                break;
                            default:
                                break;
                        }
                        mapDialogSms.send();
                    } catch (MAPException e) {
                        logger.severe("Error while trying to send MtForwardShortMessageRequest", e);
                    }
                }
            }
        } else if (this.getResponseReceived() == 1) {
            this.setResponseReceived(0);
            this.handleSmsResponse((MAPDialogSms) evt.getMAPDialog(), true);
        }
    } catch (Throwable e1) {
        String s = "Exception in MtSbb.onDialogDelimiter() when fetching records and issuing events: " + e1.getMessage();
        logger.severe(s, e1);
        markDeliveringIsEnded(true);
    // this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SC_SYSTEM_ERROR, s, true, null, false);
    }
}
Also used : SmsSignalInfo(org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo) MAPDialogSms(org.restcomm.protocols.ss7.map.api.service.sms.MAPDialogSms) MAPException(org.restcomm.protocols.ss7.map.api.MAPException) SM_RP_OA(org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_OA) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) SmsSet(org.mobicents.smsc.library.SmsSet) SM_RP_DA(org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA)

Example 20 with MAPException

use of org.restcomm.protocols.ss7.map.api.MAPException in project smscgateway by RestComm.

the class MtSbb method createSignalInfoStatusReport.

protected SmsSignalInfo createSignalInfoStatusReport(Sms sms, boolean moreMessagesToSend, SmsDeliveryReportData smsDeliveryReportData) throws MAPException {
    // TODO : TimeZone should be configurable
    Date submitDate = sms.getSubmitDate();
    AbsoluteTimeStamp submitTimeStamp = this.mapSmsTpduParameterFactory.createAbsoluteTimeStamp((submitDate.getYear() % 100), (submitDate.getMonth() + 1), submitDate.getDate(), submitDate.getHours(), submitDate.getMinutes(), submitDate.getSeconds(), -(submitDate.getTimezoneOffset() / 15));
    Date deliveryDate = smsDeliveryReportData.getDeliveryDate();
    AbsoluteTimeStamp deliveryTimeStamp = this.mapSmsTpduParameterFactory.createAbsoluteTimeStamp((deliveryDate.getYear() % 100), (deliveryDate.getMonth() + 1), deliveryDate.getDate(), deliveryDate.getHours(), deliveryDate.getMinutes(), deliveryDate.getSeconds(), -(deliveryDate.getTimezoneOffset() / 15));
    Status status = this.mapSmsTpduParameterFactory.createStatus(smsDeliveryReportData.getStatusVal());
    SmsStatusReportTpdu smsStatusReportTpdu = this.mapSmsTpduParameterFactory.createSmsStatusReportTpdu(moreMessagesToSend, false, smsDeliveryReportData.getStatusReportQualifier(), sms.getMoMessageRef(), this.getSmsTpduOriginatingAddress(sms.getSourceAddrTon(), sms.getSourceAddrNpi(), sms.getSourceAddr()), submitTimeStamp, deliveryTimeStamp, status, this.mapSmsTpduParameterFactory.createProtocolIdentifier(sms.getProtocolId()), null);
    SmsSignalInfo smsSignalInfo = this.mapParameterFactory.createSmsSignalInfo(smsStatusReportTpdu, isoCharset);
    return smsSignalInfo;
}
Also used : SmsSignalInfo(org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo) Date(java.util.Date)

Aggregations

MAPException (org.restcomm.protocols.ss7.map.api.MAPException)22 MAPDialogSms (org.restcomm.protocols.ss7.map.api.service.sms.MAPDialogSms)21 ISDNAddressString (org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString)16 AddressString (org.restcomm.protocols.ss7.map.api.primitives.AddressString)14 SmsSignalInfo (org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo)6 Date (java.util.Date)4 ActivityContextInterface (javax.slee.ActivityContextInterface)4 Sms (org.mobicents.smsc.library.Sms)4 SmsSet (org.mobicents.smsc.library.SmsSet)4 SccpAddress (org.restcomm.protocols.ss7.sccp.parameter.SccpAddress)4 MAPErrorMessage (org.restcomm.protocols.ss7.map.api.errors.MAPErrorMessage)3 MAPErrorMessageSubscriberBusyForMtSms (org.restcomm.protocols.ss7.map.api.errors.MAPErrorMessageSubscriberBusyForMtSms)3 IMSI (org.restcomm.protocols.ss7.map.api.primitives.IMSI)3 SM_RP_DA (org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA)3 SmsTpdu (org.restcomm.protocols.ss7.map.api.smstpdu.SmsTpdu)3 UserData (org.restcomm.protocols.ss7.map.api.smstpdu.UserData)3 Timestamp (java.sql.Timestamp)2 ArrayList (java.util.ArrayList)2 SmscProcessingException (org.mobicents.smsc.library.SmscProcessingException)2 TargetAddress (org.mobicents.smsc.library.TargetAddress)2