Esempio n. 1
0
        /// <summary> Called to create a AlertNotification object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> AlertNotification </returns>
        public static AlertNotification Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            AlertNotification alertNotification = new AlertNotification(defaultEncoding);

            try
            {
                int start_offset = offset;

                buf.ExtractHeader(alertNotification, ref offset);

                alertNotification.SourceAddrTon = buf.ExtractByte(ref offset);
                alertNotification.SourceAddrNpi = buf.ExtractByte(ref offset);
                alertNotification.SourceAddr = buf.ExtractCString(ref offset);
                alertNotification.EsmeAddrTon = buf.ExtractByte(ref offset);
                alertNotification.EsmeAddrNpi = buf.ExtractByte(ref offset);
                alertNotification.EsmeAddr = buf.ExtractCString(ref offset);

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

            catch
            {
                alertNotification = null;
            }

            return alertNotification;
        }
Esempio n. 2
0
        /// <summary> Called to create a GenericNack object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> GenericNack </returns>
        public static GenericNackSm Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            GenericNackSm genericNack = new GenericNackSm(defaultEncoding);

            try
            {
                buf.ExtractHeader(genericNack, ref offset);
            }

            catch
            {
                genericNack = null;
            }

            return genericNack;
        }
Esempio n. 3
0
        /// <summary> Called to create a PduUnBind object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> PduUnBind </returns>
        public static UnBindSm Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            UnBindSm unBind = new UnBindSm(defaultEncoding);

            try
            {
                buf.ExtractHeader(unBind, ref offset);
            }

            catch
            {
                unBind = null;
            }

            return unBind;
        }
Esempio n. 4
0
        /// <summary> Called to create a new EnquireLink object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> EnquireLink </returns>
        public static EnquireLinkSm Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            EnquireLinkSm enquireLink = new EnquireLinkSm(defaultEncoding);

            try
            {
                buf.ExtractHeader(enquireLink, ref offset);
            }

            catch
            {
                enquireLink = null;
            }

            return enquireLink;
        }
Esempio n. 5
0
        /// <summary> Called to create a CancelSm object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> CancelSm </returns>
        internal static CancelSm Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            CancelSm cancelSm = new CancelSm(defaultEncoding);

            try
            {
                buf.ExtractHeader(cancelSm, ref offset);

                cancelSm.ServiceType = buf.ExtractCString(ref offset);
                cancelSm.MessageId = buf.ExtractCString(ref offset);
                cancelSm.SourceTon = buf.ExtractByte(ref offset);
                cancelSm.SourceNpi = buf.ExtractByte(ref offset);
                cancelSm.SourceAddr = buf.ExtractCString(ref offset);
                cancelSm.DestTon = buf.ExtractByte(ref offset);
                cancelSm.DestNpi = buf.ExtractByte(ref offset);
                cancelSm.DestAddr = buf.ExtractCString(ref offset);
            }

            catch
            {
                cancelSm = null;
            }

            return cancelSm;
        }
Esempio n. 6
0
        /// <summary> Parses the smpp buffer to a DeliverSm object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> DeliverSm </returns>
        public static DeliverSm Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            DeliverSm deliverSm = new DeliverSm(defaultEncoding);

            try
            {
                int start_offset = offset;

                buf.ExtractHeader(deliverSm, ref offset);

                deliverSm.ServiceType = buf.ExtractCString(ref offset);
                deliverSm.SourceTon = buf.ExtractByte(ref offset);
                deliverSm.SourceNpi = buf.ExtractByte(ref offset);
                deliverSm.SourceAddr = buf.ExtractCString(ref offset);
                deliverSm.DestTon = buf.ExtractByte(ref offset);
                deliverSm.DestNpi = buf.ExtractByte(ref offset);
                deliverSm.DestAddr = buf.ExtractCString(ref offset);
                deliverSm.EsmClass = buf.ExtractByte(ref offset);
                deliverSm.ProtocolId = buf.ExtractByte(ref offset);
                deliverSm.PriorityFlag = buf.ExtractByte(ref offset);
                deliverSm.ScheduleDeliveryTime = buf.ExtractCString(ref offset);
                deliverSm.ValidityPeriod = buf.ExtractCString(ref offset);
                deliverSm.RegisteredDelivery = buf.ExtractByte(ref offset);
                deliverSm.ReplaceIfPresent = buf.ExtractByte(ref offset);
                deliverSm.DataCoding = (DataCodings) buf.ExtractByte(ref offset);
                deliverSm.DefaultMessageId = buf.ExtractByte(ref offset);
                deliverSm.ShortMessageLength = buf.ExtractByte(ref offset);

                if (deliverSm.ShortMessageLength > 0)
                {
                    deliverSm.UserDataBuffer = new SmppBuffer(defaultEncoding, buf.ExtractByteArray(ref offset, deliverSm.ShortMessageLength));
                }

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

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

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

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

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

                if (deliverSm.UserDataBuffer != null && deliverSm.UserDataBuffer.Length > 0)
                {
                    bool hasUDHI = deliverSm.MessageFeature == GSMSpecificFeatures.UDHI || deliverSm.MessageFeature == GSMSpecificFeatures.UDHIandReplyPath;
                    deliverSm.UserData = UserData.Create(deliverSm.UserDataBuffer, hasUDHI);

                    if (deliverSm.UserData.Headers.Count > 0)
                    {
                        UserDataHeader udh = deliverSm.UserData.Headers[InformationElementIdentifiers.ConcatenatedShortMessages8bit];
                        if (udh != null)
                        {
                            deliverSm.MessageReferenceNumber = udh.Data[0];
                            deliverSm.TotalSegments = udh.Data[1];
                            deliverSm.SeqmentNumber = udh.Data[2];
                        }

                        udh = deliverSm.UserData.Headers[InformationElementIdentifiers.ConcatenatedShortMessage16bit];
                        if (udh != null)
                        {
                            deliverSm.MessageReferenceNumber = SmppBuffer.BytesToShort(udh.Data, 0);
                            deliverSm.TotalSegments = udh.Data[2];
                            deliverSm.SeqmentNumber = udh.Data[3];
                        }
                    }
                }
                else
                {
                    deliverSm.UserData = UserData.Create();
                }
            }

            catch
            {
                deliverSm = null;
            }

            return deliverSm;
        }
Esempio n. 7
0
        /// <summary> Called to create a PduUnBindResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> PduUnBindResp </returns>
        internal static UnBindSmResp Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            UnBindSmResp res = new UnBindSmResp(defaultEncoding);

            try
            {
                buf.ExtractHeader(res, ref offset);
            }

            catch
            {
                res = null;
            }

            return res;
        }
Esempio n. 8
0
        /// <summary> Called to create a DeliverSmResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> DeliverSmResp </returns>
        public static DeliverSmResp Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            DeliverSmResp deliverSmResp = new DeliverSmResp(defaultEncoding);

            try
            {
                int start_offset = offset;

                buf.ExtractHeader(deliverSmResp, ref offset);

                if (deliverSmResp.Length > Header.HEADER_LENGTH)
                {
                    deliverSmResp.MessageId = buf.ExtractCString(ref offset);

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

            catch
            {
                deliverSmResp = null;
            }

            return deliverSmResp;
        }
Esempio n. 9
0
        /// <summary> Called to create a PduBind object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> BindSm </returns>
        public static BindSm Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            BindSm bindSm = new BindSm(defaultEncoding);

            try
            {
                int start_offset = offset;

                buf.ExtractHeader(bindSm, ref offset);

                bindSm.SystemId = buf.ExtractCString(ref offset);
                bindSm.Password = buf.ExtractCString(ref offset);
                bindSm.SystemType = buf.ExtractCString(ref offset);
                bindSm.InterfaceVersion = buf.ExtractByte(ref offset);
                bindSm.AddrTon = buf.ExtractByte(ref offset);
                bindSm.AddrNpi = buf.ExtractByte(ref offset);
                bindSm.AddressRange = buf.ExtractCString(ref offset);
            }

            catch
            {
                bindSm = null;
            }

            return bindSm;
        }
Esempio n. 10
0
        /// <summary> Called to create a QuerySm object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> QuerySm </returns>
        public static QuerySm Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            QuerySm querySm = new QuerySm(defaultEncoding);

            try
            {
                buf.ExtractHeader(querySm, ref offset);

                querySm.MessageId = buf.ExtractCString(ref offset);
                querySm.SourceTon = buf.ExtractByte(ref offset);
                querySm.SourceNpi = buf.ExtractByte(ref offset);
                querySm.SourceAddr = buf.ExtractCString(ref offset);
            }

            catch
            {
                querySm = null;
            }

            return querySm;
        }
Esempio n. 11
0
        /// <summary> Called to create a SubmitMultiResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> SubmitMultiResp </returns>
        public static SubmitMultiSmResp Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            SubmitMultiSmResp submitMultiResp = new SubmitMultiSmResp(defaultEncoding);

            try
            {
                int start_offset = offset;

                buf.ExtractHeader(submitMultiResp, ref offset);

                if (submitMultiResp.Length > Header.HEADER_LENGTH)
                {
                    submitMultiResp.MessageId = buf.ExtractCString(ref offset);
                    submitMultiResp.UnsuccessDestinationAddresses = buf.ExtractUnsuccessDestinationAddresses(ref offset);

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

            catch
            {
                submitMultiResp = null;
            }

            return submitMultiResp;
        }
Esempio n. 12
0
        /// <summary> Called to create a QuerySmResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> QuerySmResp </returns>
        public static QuerySmResp Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            QuerySmResp querySmResp = new QuerySmResp(defaultEncoding);

            try
            {
                buf.ExtractHeader(querySmResp, ref offset);

                querySmResp.MessageId = buf.ExtractCString(ref offset);
                querySmResp.FinalDateString = buf.ExtractCString(ref offset);
                querySmResp.MessageState = (MessageState) buf.ExtractByte(ref offset);
                querySmResp.ErrorCode = buf.ExtractByte(ref offset);
            }

            catch
            {
                querySmResp = null;
            }

            return querySmResp;
        }
Esempio n. 13
0
        /// <summary> Called to create a CancelSmResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> CancelSmResp </returns>
        internal static CancelSmResp Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            CancelSmResp cancelSmResp = new CancelSmResp(defaultEncoding);

            try
            {
                buf.ExtractHeader(cancelSmResp, ref offset);
            }

            catch
            {
                cancelSmResp = null;
            }

            return cancelSmResp;
        }
Esempio n. 14
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;
        }
Esempio n. 15
0
        /// <summary> Called to create a SubmitMulti object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> SubmitMulti </returns>
        public static SubmitMultiSm Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            SubmitMultiSm submitMulti = new SubmitMultiSm(defaultEncoding);

            try
            {
                int start_offset = offset;

                buf.ExtractHeader(submitMulti, ref offset);

                submitMulti.ServiceType = buf.ExtractCString(ref offset);
                submitMulti.SourceTon = buf.ExtractByte(ref offset);
                submitMulti.SourceNpi = buf.ExtractByte(ref offset);
                submitMulti.SourceAddr = buf.ExtractCString(ref offset);
                submitMulti.DestinationAddresses = buf.ExtractDestinationAddresses(ref offset);
                submitMulti.EsmClass = buf.ExtractByte(ref offset);
                submitMulti.ProtocolId = buf.ExtractByte(ref offset);
                submitMulti.PriorityFlag = buf.ExtractByte(ref offset);
                submitMulti.ScheduleDeliveryTime = buf.ExtractCString(ref offset);
                submitMulti.ValidityPeriod = buf.ExtractCString(ref offset);
                submitMulti.RegisteredDelivery = buf.ExtractByte(ref offset);
                submitMulti.ReplaceIfPresent = buf.ExtractByte(ref offset);
                submitMulti.DataCoding = (DataCodings) buf.ExtractByte(ref offset);
                submitMulti.DefaultMsgId = buf.ExtractByte(ref offset);
                submitMulti.ShortMessageLength = buf.ExtractByte(ref offset);

                if (submitMulti.ShortMessageLength > 0)
                {
                    submitMulti.UserDataBuffer = new SmppBuffer(defaultEncoding, buf.ExtractByteArray(ref offset, submitMulti.ShortMessageLength));
                }

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

            catch
            {
                submitMulti = null;
            }

            return submitMulti;
        }