Beispiel #1
0
        /// <summary> Called to create a DataSmResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="dataSm"></param>
        /// <param name="commandStatus"></param>
        /// <param name="messageId"></param>
        /// <returns> DataSmResp </returns>
        public static DataSmResp Create(DataCodings defaultEncoding, DataSm dataSm, CommandStatus commandStatus, string messageId)
        {
            if (dataSm.SourceAddr == string.Empty || dataSm.SourceAddr == null)
            {
                commandStatus = CommandStatus.ESME_RINVSRCADR;
            }

            return new DataSmResp(defaultEncoding, commandStatus, dataSm.Sequence, messageId);
        }
Beispiel #2
0
        /// <summary> Called to create a DataSmResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="dataSm"></param>
        /// <param name="commandStatus"></param>
        /// <param name="messageId"></param>
        /// <returns> DataSmResp </returns>
        public static DataSmResp Create(DataCodings defaultEncoding, DataSm dataSm, CommandStatus commandStatus, string messageId)
        {
            if (dataSm.SourceAddr == string.Empty || dataSm.SourceAddr == null)
            {
                commandStatus = CommandStatus.ESME_RINVSRCADR;
            }

            return(new DataSmResp(defaultEncoding, commandStatus, dataSm.Sequence, messageId));
        }
Beispiel #3
0
        /// <summary> Called to create a DataSm object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> DataSm </returns>
        public static DataSm Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            DataSm dataSm = new DataSm(defaultEncoding);

            try
            {
                int start_offset = offset;

                buf.ExtractHeader(dataSm, ref offset);

                dataSm.ServiceType        = buf.ExtractCString(ref offset);
                dataSm.SourceTon          = buf.ExtractByte(ref offset);
                dataSm.SourceNpi          = buf.ExtractByte(ref offset);
                dataSm.SourceAddr         = buf.ExtractCString(ref offset);
                dataSm.DestTon            = buf.ExtractByte(ref offset);
                dataSm.DestNpi            = buf.ExtractByte(ref offset);
                dataSm.DestAddr           = buf.ExtractCString(ref offset);
                dataSm.EsmClass           = buf.ExtractByte(ref offset);
                dataSm.RegisteredDelivery = buf.ExtractByte(ref offset);
                dataSm.DataCoding         = (DataCodings)buf.ExtractByte(ref offset);

                if (offset - start_offset < dataSm.Length)
                {
                    if (dataSm.Optional == null)
                    {
                        dataSm.Optional = new TLVCollection();
                    }

                    while (offset - start_offset < dataSm.Length)
                    {
                        dataSm.Optional.Add(buf.ExtractTLV(ref offset));
                    }
                }

                if (dataSm.Optional != null && dataSm.Optional.Count > 0)
                {
                    TLV tlv_payload = dataSm.Optional[OptionalTags.MessagePayload];
                    if (tlv_payload != null)
                    {
                        dataSm.UserDataBuffer = new SmppBuffer(defaultEncoding, tlv_payload.Value);
                    }

                    TLV tlv_globalSeq = dataSm.Optional[OptionalTags.SarMsgRefNum];
                    if (tlv_globalSeq != null)
                    {
                        dataSm.MessageReferenceNumber = SmppBuffer.BytesToShort(tlv_globalSeq.Value, 0);
                    }

                    TLV tlv_pocketsNumber = dataSm.Optional[OptionalTags.SarTotalSegments];
                    if (tlv_pocketsNumber != null)
                    {
                        dataSm.TotalSegments = tlv_pocketsNumber.Value[0];
                    }

                    TLV tlv_localSeq = dataSm.Optional[OptionalTags.SarSegmentSeqnum];
                    if (tlv_localSeq != null)
                    {
                        dataSm.SequenceNumber = tlv_localSeq.Value[0];
                    }
                }

                if (dataSm.UserDataBuffer != null && dataSm.UserDataBuffer.Length > 0)
                {
                    dataSm.UserData = UserData.Create(dataSm.UserDataBuffer, dataSm.MessageFeature == GSMSpecificFeatures.UDHI);
                }
                else
                {
                    dataSm.UserData = UserData.Create();
                }
            }

            catch
            {
                dataSm = null;
            }

            return(dataSm);
        }
Beispiel #4
0
        /// <summary> Called to fire the data pdu event </summary>
        /// <param name="data"></param>
        /// <param name="messageId"></param>
        /// <returns> CommandStatus </returns>
        internal CommandStatus OnDataSm(DataSm data, out string messageId)
        {
            CommandStatus commandStatus = CommandStatus.ESME_ROK;
            messageId = null;

            try
            {
                if (DataSmEvent != null)
                {
                    commandStatus = DataSmEvent(this, data, out messageId);
                }
            }

            catch
            {
            }

            return commandStatus;
        }
Beispiel #5
0
        /// <summary> Called to create a DataSm object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> DataSm </returns>
        public static DataSm Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            DataSm dataSm = new DataSm(defaultEncoding);

            try
            {
                int start_offset = offset;

                buf.ExtractHeader(dataSm, ref offset);

                dataSm.ServiceType = buf.ExtractCString(ref offset);
                dataSm.SourceTon = buf.ExtractByte(ref offset);
                dataSm.SourceNpi = buf.ExtractByte(ref offset);
                dataSm.SourceAddr = buf.ExtractCString(ref offset);
                dataSm.DestTon = buf.ExtractByte(ref offset);
                dataSm.DestNpi = buf.ExtractByte(ref offset);
                dataSm.DestAddr = buf.ExtractCString(ref offset);
                dataSm.EsmClass = buf.ExtractByte(ref offset);
                dataSm.RegisteredDelivery = buf.ExtractByte(ref offset);
                dataSm.DataCoding = (DataCodings) buf.ExtractByte(ref offset);

                if (offset - start_offset < dataSm.Length)
                {
                    if (dataSm.Optional == null)
                    {
                        dataSm.Optional = new TLVCollection();
                    }

                    while (offset - start_offset < dataSm.Length)
                    {
                        dataSm.Optional.Add(buf.ExtractTLV(ref offset));
                    }
                }

                if (dataSm.Optional != null && dataSm.Optional.Count > 0)
                {
                    TLV tlv_payload = dataSm.Optional[OptionalTags.MessagePayload];
                    if (tlv_payload != null)
                    {
                        dataSm.UserDataBuffer = new SmppBuffer(defaultEncoding, tlv_payload.Value);
                    }

                    TLV tlv_globalSeq = dataSm.Optional[OptionalTags.SarMsgRefNum];
                    if (tlv_globalSeq != null)
                    {
                        dataSm.MessageReferenceNumber = SmppBuffer.BytesToShort(tlv_globalSeq.Value, 0);
                    }

                    TLV tlv_pocketsNumber = dataSm.Optional[OptionalTags.SarTotalSegments];
                    if (tlv_pocketsNumber != null)
                    {
                        dataSm.TotalSegments = tlv_pocketsNumber.Value[0];
                    }

                    TLV tlv_localSeq = dataSm.Optional[OptionalTags.SarSegmentSeqnum];
                    if (tlv_localSeq != null)
                    {
                        dataSm.SequenceNumber = tlv_localSeq.Value[0];
                    }
                }

                if (dataSm.UserDataBuffer != null && dataSm.UserDataBuffer.Length > 0)
                {
                    dataSm.UserData = UserData.Create(dataSm.UserDataBuffer, dataSm.MessageFeature == GSMSpecificFeatures.UDHI);
                }
                else
                {
                    dataSm.UserData = UserData.Create();
                }
            }

            catch
            {
                dataSm = null;
            }

            return dataSm;
        }