Search in sources :

Example 1 with MoForwardShortMessageRequest

use of org.mobicents.protocols.ss7.map.api.service.sms.MoForwardShortMessageRequest in project smscgateway by RestComm.

the class MoSbb method onMoForwardShortMessageRequest.

// *********
// SMS Event Handlers
/**
 * Received incoming SMS for ACN v3. Send back ack
 *
 * @param evt
 * @param aci
 */
public void onMoForwardShortMessageRequest(MoForwardShortMessageRequest evt, ActivityContextInterface aci) {
    if (this.logger.isFineEnabled()) {
        this.logger.fine("\nReceived MO_FORWARD_SHORT_MESSAGE_REQUEST = " + evt);
    }
    this.setProcessingState(MoProcessingState.OtherDataRecieved);
    MAPDialogSms dialog = evt.getMAPDialog();
    if (smscPropertiesManagement.getMoCharging() == MoChargingType.reject) {
        try {
            MAPErrorMessage errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageFacilityNotSup(null, null, null);
            dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
            if (this.logger.isInfoEnabled()) {
                this.logger.info("\nSent ErrorComponent = " + errorMessage);
            }
            if (smscPropertiesManagement.isGenerateRejectionCdr()) {
                String imsiData = null;
                if (evt.getIMSI() != null) {
                    imsiData = evt.getIMSI().getData();
                }
                generateCDR(dialog.getNetworkId(), imsiData, dialog.getLocalAddress(), CdrGenerator.CDR_SUBMIT_FAILED_MO, errorMessage.toString(), true);
            }
            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 = sccpAddress.getGlobalTitle();
            if (gt != null)
                originatorSccpAddress = gt.getDigits();
        }
        sms = this.processMoMessage(evt.getSM_RP_OA(), evt.getSM_RP_DA(), evt.getSM_RP_UI(), dialog.getNetworkId(), originatorSccpAddress, true, evt.getMAPDialog(), evt, evt.getInvokeId());
        if (sms != null) {
            this.processSms(sms, persistence, smscPropertiesManagement.getMoCharging(), true, 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;
            }
            dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
            if (this.logger.isInfoEnabled()) {
                this.logger.info("\nSent ErrorComponent = " + errorMessage);
            }
            if (smscPropertiesManagement.isGenerateRejectionCdr() && !e1.isMessageRejectCdrCreated()) {
                if (sms != null) {
                    generateCDR(sms, CdrGenerator.CDR_SUBMIT_FAILED_MO, e1.getMessage(), false, true);
                } else {
                    generateCDR(dialog.getNetworkId(), evt.getIMSI().getData(), dialog.getLocalAddress(), CdrGenerator.CDR_SUBMIT_FAILED_MO, errorMessage.toString(), true);
                }
            }
            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);
            dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
            if (smscPropertiesManagement.isGenerateRejectionCdr()) {
                generateCDR(dialog.getNetworkId(), evt.getIMSI().getData(), dialog.getLocalAddress(), CdrGenerator.CDR_SUBMIT_FAILED_MO, errorMessage.toString(), true);
            }
            dialog.close(false);
        } catch (Throwable e) {
            logger.severe("Error while sending Error message", e);
            return;
        }
        return;
    }
    if (sms == null || sms.getMessageDeliveryResultResponse() == null) {
        try {
            dialog.addMoForwardShortMessageResponse(evt.getInvokeId(), null, null);
            if (this.logger.isFineEnabled()) {
                this.logger.fine("\nSent MoForwardShortMessageResponse = " + evt);
            }
            dialog.close(false);
        } catch (Throwable e) {
            logger.severe("Error while sending MoForwardShortMessageResponse ", e);
        }
    }
}
Also used : SccpAddress(org.mobicents.protocols.ss7.sccp.parameter.SccpAddress) GlobalTitle(org.mobicents.protocols.ss7.sccp.parameter.GlobalTitle) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) MAPErrorMessage(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessage)

Example 2 with MoForwardShortMessageRequest

use of org.mobicents.protocols.ss7.map.api.service.sms.MoForwardShortMessageRequest in project smscgateway by RestComm.

the class MoSbbTest method testMo1_Gsm7.

@Test(groups = { "Mo" })
public void testMo1_Gsm7() throws Exception {
    if (!this.cassandraDbInited)
        return;
    // this.clearDatabase();
    // 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);
    // 11==60min
    ValidityPeriod validityPeriod = new ValidityPeriodImpl(11);
    DataCodingScheme dataCodingScheme = new DataCodingSchemeImpl(0);
    UserDataHeader decodedUserDataHeader = new UserDataHeaderImpl();
    UserDataHeaderElement informationElement = new ConcatenatedShortMessagesIdentifierImpl(false, 55, 3, 1);
    decodedUserDataHeader.addInformationElement(informationElement);
    UserData userData = new UserDataImpl(new String("0123456789"), dataCodingScheme, decodedUserDataHeader, null);
    // userData.encode();
    // String decodedMessage, DataCodingScheme dataCodingScheme, UserDataHeader decodedUserDataHeader, Charset gsm8Charset
    SmsTpdu tpdu = new SmsSubmitTpduImpl(false, true, false, 150, destinationAddress, protocolIdentifier, validityPeriod, userData);
    // boolean rejectDuplicates, boolean replyPathExists, boolean statusReportRequest, int messageReference,
    // AddressField destinationAddress, ProtocolIdentifier protocolIdentifier, ValidityPeriod validityPeriod, UserData userData
    // tpdu.encodeData();
    SmsSignalInfo sm_RP_UI = new SmsSignalInfoImpl(tpdu, null);
    MoForwardShortMessageRequest event = new MoForwardShortMessageRequestImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, null, null);
    // ActivityContextInterface aci = new SmppTransactionProxy(esme);
    // Date curDate = new Date();
    // this.fillSm(event, curDate, true);
    // event.setShortMessage(msg);
    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();
    this.sbb.onMoForwardShortMessageRequest(event, null);
    b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
    dueSlot = b2;
    b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
    assertEquals(b1, 1);
    assertEquals(b2, dueSlot);
    assertEquals(dialog.getResponseCount(), 1);
    assertEquals(dialog.getErrorList().size(), 0);
    SmsSet smsSet = this.pers.c2_getRecordListForTargeId(dueSlot, ta1.getTargetId());
    assertEquals(smsSet.getDestAddr(), "5555");
    assertEquals(smsSet.getDestAddrTon(), SmppConstants.TON_INTERNATIONAL);
    assertEquals(smsSet.getDestAddrNpi(), SmppConstants.NPI_E164);
    assertEquals(smsSet.getInSystem(), 0);
    assertEquals(smsSet.getDueDelay(), 0);
    assertNull(smsSet.getStatus());
    assertFalse(smsSet.isAlertingSupported());
    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(), 0);
    assertNull(sms.getOrigEsmeName());
    assertNull(sms.getOrigSystemId());
    assertNull(sms.getServiceType());
    assertEquals(sms.getEsmClass() & 0xFF, 195);
    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, 1));
    assertEquals(sms.getDeliveryCount(), 0);
    // assertDateEq(smsSet.getDueDate(), new Date(curDate.getTime() + 1 * 60 * 1000));
    assertEquals(sms.getShortMessageText(), "0123456789");
    assertEquals(sms.getShortMessageBin(), decodedUserDataHeader.getEncodedData());
}
Also used : DataCodingScheme(org.mobicents.protocols.ss7.map.api.smstpdu.DataCodingScheme) UserDataHeaderImpl(org.mobicents.protocols.ss7.map.smstpdu.UserDataHeaderImpl) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) UserData(org.mobicents.protocols.ss7.map.api.smstpdu.UserData) SmsTpdu(org.mobicents.protocols.ss7.map.api.smstpdu.SmsTpdu) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) SmsSignalInfoImpl(org.mobicents.protocols.ss7.map.service.sms.SmsSignalInfoImpl) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) DataCodingSchemeImpl(org.mobicents.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) MoForwardShortMessageRequestImpl(org.mobicents.protocols.ss7.map.service.sms.MoForwardShortMessageRequestImpl) ProtocolIdentifierImpl(org.mobicents.protocols.ss7.map.smstpdu.ProtocolIdentifierImpl) SmsSignalInfo(org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo) UserDataHeaderElement(org.mobicents.protocols.ss7.map.api.smstpdu.UserDataHeaderElement) UserDataImpl(org.mobicents.protocols.ss7.map.smstpdu.UserDataImpl) MAPProviderProxy(org.mobicents.smsc.slee.resources.persistence.MAPProviderProxy) ProtocolIdentifier(org.mobicents.protocols.ss7.map.api.smstpdu.ProtocolIdentifier) MoForwardShortMessageRequest(org.mobicents.protocols.ss7.map.api.service.sms.MoForwardShortMessageRequest) UserDataHeader(org.mobicents.protocols.ss7.map.api.smstpdu.UserDataHeader) ISDNAddressStringImpl(org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl) AddressStringImpl(org.mobicents.protocols.ss7.map.primitives.AddressStringImpl) AddressField(org.mobicents.protocols.ss7.map.api.smstpdu.AddressField) ConcatenatedShortMessagesIdentifierImpl(org.mobicents.protocols.ss7.map.smstpdu.ConcatenatedShortMessagesIdentifierImpl) SM_RP_DAImpl(org.mobicents.protocols.ss7.map.service.sms.SM_RP_DAImpl) AddressFieldImpl(org.mobicents.protocols.ss7.map.smstpdu.AddressFieldImpl) ValidityPeriodImpl(org.mobicents.protocols.ss7.map.smstpdu.ValidityPeriodImpl) SM_RP_OAImpl(org.mobicents.protocols.ss7.map.service.sms.SM_RP_OAImpl) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) ISDNAddressStringImpl(org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl) Sms(org.mobicents.smsc.library.Sms) ValidityPeriod(org.mobicents.protocols.ss7.map.api.smstpdu.ValidityPeriod) SM_RP_DA(org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_DA) SmsSet(org.mobicents.smsc.library.SmsSet) SmsSubmitTpduImpl(org.mobicents.protocols.ss7.map.smstpdu.SmsSubmitTpduImpl) Test(org.testng.annotations.Test)

Example 3 with MoForwardShortMessageRequest

use of org.mobicents.protocols.ss7.map.api.service.sms.MoForwardShortMessageRequest 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);
    }
}
Also used : AddressField(org.mobicents.protocols.ss7.map.api.smstpdu.AddressField) SmsSignalInfo(org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) MAPException(org.mobicents.protocols.ss7.map.api.MAPException) SmsTpdu(org.mobicents.protocols.ss7.map.api.smstpdu.SmsTpdu) SmsSubmitTpdu(org.mobicents.protocols.ss7.map.api.smstpdu.SmsSubmitTpdu)

Aggregations

AddressString (org.mobicents.protocols.ss7.map.api.primitives.AddressString)2 ISDNAddressString (org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString)2 MAPDialogSms (org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms)2 SmsSignalInfo (org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo)2 AddressField (org.mobicents.protocols.ss7.map.api.smstpdu.AddressField)2 SmsTpdu (org.mobicents.protocols.ss7.map.api.smstpdu.SmsTpdu)2 Date (java.util.Date)1 MAPException (org.mobicents.protocols.ss7.map.api.MAPException)1 MAPErrorMessage (org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessage)1 MoForwardShortMessageRequest (org.mobicents.protocols.ss7.map.api.service.sms.MoForwardShortMessageRequest)1 SM_RP_DA (org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_DA)1 DataCodingScheme (org.mobicents.protocols.ss7.map.api.smstpdu.DataCodingScheme)1 ProtocolIdentifier (org.mobicents.protocols.ss7.map.api.smstpdu.ProtocolIdentifier)1 SmsSubmitTpdu (org.mobicents.protocols.ss7.map.api.smstpdu.SmsSubmitTpdu)1 UserData (org.mobicents.protocols.ss7.map.api.smstpdu.UserData)1 UserDataHeader (org.mobicents.protocols.ss7.map.api.smstpdu.UserDataHeader)1 UserDataHeaderElement (org.mobicents.protocols.ss7.map.api.smstpdu.UserDataHeaderElement)1 ValidityPeriod (org.mobicents.protocols.ss7.map.api.smstpdu.ValidityPeriod)1 AddressStringImpl (org.mobicents.protocols.ss7.map.primitives.AddressStringImpl)1 ISDNAddressStringImpl (org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl)1