Esempio n. 1
0
        /// <summary> Constructor </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="commandStatus"></param>
        /// <param name="sequence"></param>
        /// <param name="messageId"></param>
        private SubmitMultiSmResp(DataCodings defaultEncoding, CommandStatus commandStatus, uint sequence, string messageId) : base(defaultEncoding, CommandSet.SubmitMultiSmResp, commandStatus, sequence)
        {
            MessageId = messageId;

            UnsuccessDestinationAddresses = new List <UnsuccessDestinationAddress>();
            Optional = new TLVCollection();
        }
Esempio n. 2
0
 /// <summary> Constructor </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="status"></param>
 /// <param name="sequence"></param>
 private GenericNackSm(DataCodings defaultEncoding, CommandStatus status, uint sequence) : base(defaultEncoding)
 {
     Length   = (uint)Header.HEADER_LENGTH;
     Command  = CommandSet.GenericNack;
     Status   = status;
     Sequence = sequence;
 }
Esempio n. 3
0
        /// <summary> Constructor </summary>
        /// <param name="defaultEncoding"></param>
        private SubmitSm(DataCodings defaultEncoding) : base(defaultEncoding, CommandSet.SubmitSm, SequenceGenerator.Counter)
        {
            Optional = new TLVCollection();

            ValidityPeriod = DateTime.Now.AddDays(2).ToString("yyMMddhhmmss000+");
            UserData       = UserData.Create();
        }
Esempio n. 4
0
 /// <summary> Called to create a DeliverSmResp object </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="commandStatus"></param>
 /// <returns> DeliverSmResp </returns>
 internal static DeliverSmResp Create(DataCodings defaultEncoding,
                                      CommandStatus commandStatus)
 {
     return(new DeliverSmResp(defaultEncoding,
                              commandStatus,
                              0));
 }
Esempio n. 5
0
 /// <summary> Called to create a DataSmResp object </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="status"></param>
 /// <returns> DataSmResp </returns>
 internal static DataSmResp Create(DataCodings defaultEncoding,
                                   CommandStatus status)
 {
     return(new DataSmResp(defaultEncoding,
                           status,
                           0));
 }
Esempio n. 6
0
        /// <summary> Constructor </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        public SmppBuffer(DataCodings defaultEncoding, byte[] buf)
        {
            DefaultEncoding = defaultEncoding;

            ListBuffer = new List<byte>();
            ListBuffer.AddRange(buf);
        }
Esempio n. 7
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. 8
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. 9
0
        /// <summary> Called to create a SubmitSmResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> SubmitSmResp </returns>
        public static SubmitSmResp Create(DataCodings defaultEncoding,
                                          SmppBuffer buf,
                                          ref int offset)
        {
            var submitSmResp = new SubmitSmResp(defaultEncoding);

            try
            {
                var start_offset = offset;

                buf.ExtractHeader(submitSmResp,
                                  ref offset);

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

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

            catch { submitSmResp = null; }

            return(submitSmResp);
        }
Esempio n. 10
0
        /// <summary> Constructor </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="commandSet"></param>
        /// <param name="commandStatus"></param>
        /// <param name="sequence"></param>
        /// <param name="systemId"></param>
        private BindSmResp(DataCodings defaultEncoding,
                           CommandSet commandSet,
                           CommandStatus commandStatus,
                           uint sequence,
                           string systemId) : base(defaultEncoding,
                                                   commandSet,
                                                   commandStatus,
                                                   sequence)
        {
            SystemId = systemId;
            Optional = new TLVCollection();

            /*
             * // Optional Parameter for the Version
             * int version = 0x34;
             * byte[] b = System.BitConverter.GetBytes(version);
             *
             * if (System.BitConverter.IsLittleEndian)
             * {
             *  byte tmp = b[0];
             *  b[0] = b[3];
             *  b[3] = tmp;
             *
             *  tmp = b[1];
             *  b[1] = b[2];
             *  b[2] = tmp;
             * }
             *
             * Optional.Add(TLV.Create(OptionalTags.SCInterfaceVersion, Convert.ToUInt16(b.Length), b));
             */
        }
Esempio n. 11
0
 /// <summary> Constructor </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="messageId"></param>
 /// <param name="sourceTon"></param>
 /// <param name="sourceNpi"></param>
 /// <param name="sourceAddr"></param>
 private QuerySm(DataCodings defaultEncoding, string messageId, byte sourceTon, byte sourceNpi, string sourceAddr) : base(defaultEncoding, CommandSet.QuerySm, SequenceGenerator.Counter)
 {
     MessageId  = messageId;
     SourceTon  = sourceTon;
     SourceNpi  = sourceNpi;
     SourceAddr = sourceAddr;
 }
Esempio n. 12
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. 13
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)
        {
            var 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. 14
0
        /// <summary> Constructor </summary>
        /// <param name="defaultEncoding"></param>
        private SubmitMultiSm(DataCodings defaultEncoding) : base(defaultEncoding, CommandSet.SubmitMultiSm, SequenceGenerator.Counter)
        {
            DestinationAddresses = new List <DestinationAddress>();

            Optional = new TLVCollection();
            UserData = UserData.Create();
        }
Esempio n. 15
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. 16
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. 17
0
        /// <summary> Called to add a transmitter connection </summary>
        /// <param name="connectionId"></param>
        /// <param name="host"></param>
        /// <param name="port"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="logKey"></param>
        /// <param name="defaultEncoding"></param>
        private void AddTransmitterConnection(int connectionId,
                                              string host,
                                              int port,
                                              string userName,
                                              string password,
                                              string logKey,
                                              DataCodings defaultEncoding)
        {
            lock (Transmitters)
            {
                // Create the smppConnection object
                var smppConnection = new EsmeConnection(connectionId,
                                                        ShortLongCode,
                                                        ConnectionModes.Transmitter,
                                                        host,
                                                        port,
                                                        userName,
                                                        password,
                                                        logKey,
                                                        defaultEncoding,
                                                        ConnectionEventConnectionHandler,
                                                        null,
                                                        ReceivedGenericNackConnectionHandler,
                                                        SubmitMessageConnectionHandler,
                                                        QueryMessageConnectionHandler,
                                                        LogEventConnectionHandler,
                                                        PduDetailsConnectionHandler);

                // Add the connection to the list
                Transmitters.Add(connectionId,
                                 smppConnection);
            }
        }
Esempio n. 18
0
        /// <summary> Called to create a PduBindResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> PduBindResp </returns>
        public static BindSmResp Create(DataCodings defaultEncoding,
                                        SmppBuffer buf,
                                        ref int offset)
        {
            var bindResp = new BindSmResp(defaultEncoding);

            try
            {
                var start_offset = offset;

                buf.ExtractHeader(bindResp,
                                  ref offset);

                bindResp.SystemId = buf.ExtractCString(ref offset);

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

            catch { bindResp = null; }

            return(bindResp);
        }
Esempio n. 19
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. 20
0
 /// <summary> Constructor </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="messageId"></param>
 /// <param name="sourceTon"></param>
 /// <param name="sourceNpi"></param>
 /// <param name="sourceAddr"></param>
 private QuerySm(DataCodings defaultEncoding, string messageId, byte sourceTon, byte sourceNpi, string sourceAddr)
     : base(defaultEncoding, CommandSet.QuerySm, SequenceGenerator.Counter)
 {
     MessageId = messageId;
     SourceTon = sourceTon;
     SourceNpi = sourceNpi;
     SourceAddr = sourceAddr;
 }
Esempio n. 21
0
        /// <summary> Constructor </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="commandStatus"></param>
        /// <param name="sequence"></param>
        /// <param name="messageId"></param>
        private SubmitMultiSmResp(DataCodings defaultEncoding, CommandStatus commandStatus, uint sequence, string messageId)
            : base(defaultEncoding, CommandSet.SubmitMultiSmResp, commandStatus, sequence)
        {
            MessageId = messageId;

            UnsuccessDestinationAddresses = new List<UnsuccessDestinationAddress>();
            Optional = new TLVCollection();
        }
Esempio n. 22
0
        /// <summary> Constructor </summary>
        /// <param name="defaultEncoding"></param>
        private DeliverSm(DataCodings defaultEncoding)
            : base(defaultEncoding, CommandSet.DeliverSm, SequenceGenerator.Counter)
        {
            Optional = new TLVCollection();

            ValidityPeriod = DateTime.Now.AddDays(2).ToString("yyMMddhhmmss000+");
            UserData = UserData.Create();
        }
 /// <summary> Called to create a EnquireLinkResp object </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="enquireLink"></param>
 /// <param name="commandStatus"></param>
 /// <returns> EnquireLinkResp </returns>
 public static EnquireLinkSmResp Create(DataCodings defaultEncoding,
                                        EnquireLinkSm enquireLink,
                                        CommandStatus commandStatus)
 {
     return(new EnquireLinkSmResp(defaultEncoding,
                                  commandStatus,
                                  enquireLink.Sequence));
 }
 /// <summary> Called to create a EnquireLinkResp object </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="status"></param>
 /// <param name="sequence"></param>
 /// <returns> EnquireLinkResp </returns>
 public static EnquireLinkSmResp Create(DataCodings defaultEncoding,
                                        CommandStatus status,
                                        uint sequence)
 {
     return(new EnquireLinkSmResp(defaultEncoding,
                                  status,
                                  sequence));
 }
 /// <summary> Constructor </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="commandStatus"></param>
 /// <param name="sequence"></param>
 private EnquireLinkSmResp(DataCodings defaultEncoding,
                           CommandStatus commandStatus,
                           uint sequence) : base(defaultEncoding,
                                                 CommandSet.EnquireLinkResp,
                                                 commandStatus,
                                                 sequence)
 {
 }
Esempio n. 26
0
 /// <summary> Called to create a GenericNack object </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="status"></param>
 /// <param name="sequence"></param>
 /// <returns> GenericNack </returns>
 public static GenericNackSm Create(DataCodings defaultEncoding,
                                    CommandStatus status,
                                    uint sequence)
 {
     return(new GenericNackSm(defaultEncoding,
                              status,
                              sequence));
 }
Esempio n. 27
0
 /// <summary> Called to create a PduUnBindResp object </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="unBindSm"></param>
 /// <param name="commandStatus"></param>
 /// <returns> PduUnBindResp </returns>
 internal static UnBindSmResp Create(DataCodings defaultEncoding,
                                     UnBindSm unBindSm,
                                     CommandStatus commandStatus)
 {
     return(new UnBindSmResp(defaultEncoding,
                             commandStatus,
                             unBindSm.Sequence));
 }
Esempio n. 28
0
 /// <summary> Called to create a SubmitMultiResp object </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="commandStatus"></param>
 /// <param name="sequence"></param>
 /// <returns> UnBindSmResp </returns>
 public static UnBindSmResp Create(DataCodings defaultEncoding,
                                   CommandStatus commandStatus,
                                   uint sequence)
 {
     return(new UnBindSmResp(defaultEncoding,
                             commandStatus,
                             sequence));
 }
Esempio n. 29
0
 /// <summary> Constructor </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="commandStatus"></param>
 /// <param name="sequence"></param>
 private UnBindSmResp(DataCodings defaultEncoding,
                      CommandStatus commandStatus,
                      uint sequence) : base(defaultEncoding,
                                            CommandSet.UnbindResp,
                                            commandStatus,
                                            sequence)
 {
 }
Esempio n. 30
0
 /// <summary> Constructor </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="commandStatus"></param>
 /// <param name="sequence"></param>
 private CancelSmResp(DataCodings defaultEncoding,
                      CommandStatus commandStatus,
                      uint sequence) : base(defaultEncoding,
                                            CommandSet.CancelSmResp,
                                            commandStatus,
                                            sequence)
 {
 }
Esempio n. 31
0
        /// <summary> Constructor </summary>
        /// <param name="defaultEncoding"></param>
        private SubmitMultiSm(DataCodings defaultEncoding)
            : base(defaultEncoding, CommandSet.SubmitMultiSm, SequenceGenerator.Counter)
        {
            DestinationAddresses = new List<DestinationAddress>();

            Optional = new TLVCollection();
            UserData = UserData.Create();
        }
Esempio n. 32
0
 /// <summary> Called to create a CancelSmResp object </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="cancelSm"></param>
 /// <param name="status"></param>
 /// <returns> CancelSmResp </returns>
 public static CancelSmResp Create(DataCodings defaultEncoding,
                                   CancelSm cancelSm,
                                   CommandStatus status)
 {
     return(new CancelSmResp(defaultEncoding,
                             status,
                             cancelSm.Sequence));
 }
Esempio n. 33
0
 /// <summary> Called to create a SubmitSmResp object </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="status"></param>
 /// <param name="sequence"></param>
 /// <returns> SubmitSmResp </returns>
 public static SubmitSmResp Create(DataCodings defaultEncoding,
                                   CommandStatus status,
                                   uint sequence)
 {
     return(new SubmitSmResp(defaultEncoding,
                             status,
                             sequence));
 }
Esempio n. 34
0
 /// <summary> Constructor </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="status"></param>
 /// <param name="sequence"></param>
 private GenericNackSm(DataCodings defaultEncoding, CommandStatus status, uint sequence)
     : base(defaultEncoding)
 {
     Length = (uint) Header.HEADER_LENGTH;
     Command = CommandSet.GenericNack;
     Status = status;
     Sequence = sequence;
 }
Esempio n. 35
0
        /// <summary> Called to covnert the short message into a string </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="dataCoding"></param>
        /// <returns> string </returns>
        public string ShortMessageText(DataCodings defaultEncoding,
                                       DataCodings dataCoding)
        {
            var smppBuff = new SmppBuffer(defaultEncoding,
                                          ShortMessage);

            return(smppBuff.ExtractEncodedString(dataCoding));
        }
Esempio n. 36
0
 /// <summary> Constructor </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="commandStatus"></param>
 /// <param name="sequence"></param>
 private SubmitSmResp(DataCodings defaultEncoding,
                      CommandStatus commandStatus,
                      uint sequence) : base(defaultEncoding,
                                            CommandSet.SubmitSmResp,
                                            commandStatus,
                                            sequence)
 {
     Optional = new TLVCollection();
 }
Esempio n. 37
0
        /// <summary> Called to create a DeliverSmResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="deliverSm"></param>
        /// <param name="commandStatus"></param>
        /// <returns> DeliverSmResp </returns>
        public static DeliverSmResp Create(DataCodings defaultEncoding, DeliverSm deliverSm, CommandStatus commandStatus)
        {
            if (deliverSm.SourceAddr == string.Empty || deliverSm.SourceAddr == null)
            {
                commandStatus = CommandStatus.ESME_RINVSRCADR;
            }

            return(new DeliverSmResp(defaultEncoding, commandStatus, deliverSm.Sequence));
        }
Esempio n. 38
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);
        }
Esempio n. 39
0
        /// <summary> Called to create a DataSmResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="submitSm"></param>
        /// <param name="commandStatus"></param>
        /// <param name="messageId"></param>
        /// <returns> DataSmResp </returns>
        public static SubmitSmResp Create(DataCodings defaultEncoding, SubmitSm submitSm, CommandStatus commandStatus, string messageId)
        {
            if (submitSm.DestAddr == string.Empty || submitSm.DestAddr == null)
            {
                commandStatus = CommandStatus.ESME_RINVDSTADR;
            }

            return(new SubmitSmResp(defaultEncoding, commandStatus, submitSm.Sequence, messageId));
        }
Esempio n. 40
0
        /// <summary> Called to create a DataSmResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="submitSm"></param>
        /// <param name="commandStatus"></param>
        /// <param name="messageId"></param>
        /// <returns> DataSmResp </returns>
        public static SubmitSmResp Create(DataCodings defaultEncoding, SubmitSm submitSm, CommandStatus commandStatus, string messageId)
        {
            if (submitSm.DestAddr == string.Empty || submitSm.DestAddr == null)
            {
                commandStatus = CommandStatus.ESME_RINVDSTADR;
            }

            return new SubmitSmResp(defaultEncoding, commandStatus, submitSm.Sequence, messageId);
        }
Esempio n. 41
0
        /// <summary> Called to create a DeliverSmResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="deliverSm"></param>
        /// <param name="commandStatus"></param>
        /// <returns> DeliverSmResp </returns>
        public static DeliverSmResp Create(DataCodings defaultEncoding, DeliverSm deliverSm, CommandStatus commandStatus)
        {
            if (deliverSm.SourceAddr == string.Empty || deliverSm.SourceAddr == null)
            {
                commandStatus = CommandStatus.ESME_RINVSRCADR;
            }

            return new DeliverSmResp(defaultEncoding, commandStatus, deliverSm.Sequence);
        }
Esempio n. 42
0
        /// <summary> Constructor </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="bytes"></param>
        /// <param name="length"></param>
        public SmppBuffer(DataCodings defaultEncoding, byte[] bytes, int length)
        {
            DefaultEncoding = defaultEncoding;

            byte[] b = new byte[length];
            Array.Copy(bytes, b, length);

            ListBuffer = new List<byte>();
            ListBuffer.AddRange(b);
        }
Esempio n. 43
0
        /// <summary> Constructor
        /// BindSmResp requires this because we don't know the command set until later </summary>
        /// <param name="defaultEncoding"></param>
        public Header(DataCodings defaultEncoding)
        {
            DefaultEncoding = defaultEncoding;

            PduData = null;
            ExternalId = null;

            Length = HEADER_LENGTH;
            Status = CommandStatus.ESME_ROK;
            Sequence = 0;
        }
Esempio n. 44
0
        /// <summary> Constructor </summary>
        /// <param name="commandSet"></param>
        /// <param name="sequence"></param>
        /// <param name="defaultEncoding"></param>
        public Header(DataCodings defaultEncoding, CommandSet commandSet, uint sequence)
        {
            DefaultEncoding = defaultEncoding;

            PduData = null;

            Length = HEADER_LENGTH;
            Command = commandSet;
            Status = CommandStatus.ESME_ROK;
            Sequence = sequence;
        }
Esempio n. 45
0
        /// <summary> Constructor </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="serviceType"></param>
        /// <param name="sourceTon"></param>
        /// <param name="sourceNpi"></param>
        /// <param name="sourceAddr"></param>
        /// <param name="destinationAddresses"></param>
        private SubmitMultiSm(DataCodings defaultEncoding, string serviceType, byte sourceTon, byte sourceNpi, string sourceAddr, List<DestinationAddress> destinationAddresses)
            : base(defaultEncoding, CommandSet.SubmitMultiSm, SequenceGenerator.Counter)
        {
            Optional = new TLVCollection();
            UserData = UserData.Create();

            ServiceType = serviceType;
            SourceTon = sourceTon;
            SourceNpi = sourceNpi;
            SourceAddr = sourceAddr;
            DestinationAddresses = destinationAddresses;
        }
Esempio n. 46
0
        /// <summary> Constructor </summary>
        /// <param name="commandSet"></param>
        /// <param name="commandStatus"></param>
        /// <param name="defaultEncoding"></param>
        public Header(DataCodings defaultEncoding, CommandSet commandSet, CommandStatus commandStatus)
        {
            DefaultEncoding = defaultEncoding;

            PduData = null;
            ExternalId = null;

            Length = HEADER_LENGTH;
            Command = commandSet;
            Status = commandStatus;
            Sequence = 0;
        }
Esempio n. 47
0
 /// <summary> Constructor </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="serviceType"></param>
 /// <param name="messageId"></param>
 /// <param name="srcTon"></param>
 /// <param name="srcNpi"></param>
 /// <param name="srcAddr"></param>
 /// <param name="dstTon"></param>
 /// <param name="dstNpi"></param>
 /// <param name="dstAddr"></param>
 private CancelSm(DataCodings defaultEncoding, string serviceType, string messageId, byte srcTon, byte srcNpi, string srcAddr, byte dstTon, byte dstNpi, string dstAddr)
     : this(defaultEncoding)
 {
     ServiceType = serviceType;
     MessageId = messageId;
     SourceTon = srcTon;
     SourceNpi = srcNpi;
     SourceAddr = srcAddr;
     DestTon = dstTon;
     DestNpi = dstNpi;
     DestAddr = dstAddr;
 }
Esempio n. 48
0
        /// <summary> Constructor </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="header"></param>
        public SmppBuffer(DataCodings defaultEncoding, Header header)
        {
            DefaultEncoding = defaultEncoding;

            ListBuffer = new List<byte>();

            AddUInt((uint) header.Command);
            AddUInt((uint) header.Status);
            AddUInt((uint) header.Sequence);

            // Use AddFinalLength to add the length to the
            // beginning of the buffer
        }
Esempio n. 49
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. 50
0
        /// <summary> Constructor</summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="serviceType"></param>
        /// <param name="sourceTon"></param>
        /// <param name="sourceNpi"></param>
        /// <param name="sourceAddr"></param>
        /// <param name="destTon"></param>
        /// <param name="destNpi"></param>
        /// <param name="destAddr"></param>
        private DeliverSm(DataCodings defaultEncoding, string serviceType, byte sourceTon, byte sourceNpi, string sourceAddr, byte destTon, byte destNpi, string destAddr)
            : base(defaultEncoding, CommandSet.DeliverSm, SequenceGenerator.Counter)
        {
            Optional = new TLVCollection();

            ValidityPeriod = DateTime.Now.AddDays(2).ToString("yyMMddhhmmss000+");
            UserData = UserData.Create();

            ServiceType = serviceType;
            SourceTon = sourceTon;
            SourceNpi = sourceNpi;
            SourceAddr = sourceAddr;
            DestTon = destTon;
            DestNpi = destNpi;
            DestAddr = destAddr;
        }
Esempio n. 51
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. 52
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. 53
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. 54
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. 55
0
 /// <summary> Called to create a CancelSm object </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="serviceType"></param>
 /// <param name="messageId"></param>
 /// <param name="srcTon"></param>
 /// <param name="srcNpi"></param>
 /// <param name="srcAddr"></param>
 /// <param name="dstTon"></param>
 /// <param name="dstNpi"></param>
 /// <param name="dstAddr"></param>
 /// <returns> CancelSm </returns>
 internal static CancelSm Create(DataCodings defaultEncoding, string serviceType, string messageId, byte srcTon, byte srcNpi, string srcAddr, byte dstTon, byte dstNpi, string dstAddr)
 {
     return new CancelSm(defaultEncoding, serviceType, messageId, srcTon, srcNpi, srcAddr, dstTon, dstNpi, dstAddr);
 }
Esempio n. 56
0
 /// <summary> Constructor </summary>
 /// <param name="defaultEncoding"></param>
 private CancelSm(DataCodings defaultEncoding)
     : base(defaultEncoding, CommandSet.CancelSm, SequenceGenerator.Counter)
 {
 }
Esempio n. 57
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. 58
0
 /// <summary> Called to create a DeliverSm object </summary>
 /// <param name="defaultEncoding"></param>
 /// <param name="serviceType"></param>
 /// <param name="sourceTon"></param>
 /// <param name="sourceNpi"></param>
 /// <param name="sourceAddr"></param>
 /// <param name="destTon"></param>
 /// <param name="destNpi"></param>
 /// <param name="destAddr"></param>
 /// <returns> SubmitSm </returns>
 public static DeliverSm Create(DataCodings defaultEncoding, string serviceType, byte sourceTon, byte sourceNpi, string sourceAddr, byte destTon, byte destNpi, string destAddr)
 {
     return new DeliverSm(defaultEncoding, serviceType, sourceTon, sourceNpi, sourceAddr, destTon, destNpi, destAddr);
 }
Esempio n. 59
0
 /// <summary> Called to create a DeliverSm object </summary>
 /// <param name="defaultEncoding"></param>
 /// <returns> DeliverSm </returns>
 public static DeliverSm Create(DataCodings defaultEncoding)
 {
     return new DeliverSm(defaultEncoding);
 }
Esempio n. 60
0
        /// <summary> Constructor </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="header"></param>
        public Header(DataCodings defaultEncoding, Header header)
        {
            DefaultEncoding = defaultEncoding;

            PduData = null;

            Length = header.Length;
            Command = header.Command;
            Status = header.Status;
            Sequence = header.Sequence;
        }