Ejemplo n.º 1
0
        /// <summary> Called to return a list of property details from the PDU </summary>
        /// <returns> List PduPropertyDetail </returns>
        public List <PduPropertyDetail> Details()
        {
            List <PduPropertyDetail> details = null;

            try
            {
                int offset = 0;

                details = PduData.ExtractHeaderDetails(ref offset);

                details.Add(PduData.ExtractCString("ServiceType", ref offset));
                details.Add(PduData.ExtractByte("SourceTon", ref offset));
                details.Add(PduData.ExtractByte("SourceNpi", ref offset));
                details.Add(PduData.ExtractCString("SourceAddr", ref offset));
                details.Add(PduData.ExtractByte("DestTon", ref offset));
                details.Add(PduData.ExtractByte("DestNpi", ref offset));
                details.Add(PduData.ExtractCString("DestAddr", ref offset));

                PduPropertyDetail esmClass = PduData.ExtractByte("EsmClass", ref offset);
                details.Add(esmClass);

                details.Add(PduData.ExtractByte("EsmClass", ref offset));
                details.Add(PduData.ExtractByte("RegisteredDelivery", ref offset));
                details.Add(PduData.ExtractByte("DataCoding", ref offset));

                while (offset < PduData.Length)
                {
                    PduData.ExtractTLV(details, ref offset);

                    PduPropertyDetail tlvTag    = details[details.Count - 3];
                    PduPropertyDetail tlvLength = details[details.Count - 2];
                    PduPropertyDetail tlvValue  = details[details.Count - 1];

                    switch (tlvTag.ValueUShort)
                    {
                    case (ushort)OptionalTags.MessagePayload:
                        GSMSpecificFeatures messageFeature = (GSMSpecificFeatures)(esmClass.ValueByte & 0xc0);
                        SmppBuffer          userData       = new SmppBuffer(DefaultEncoding, tlvValue.DataBlock);
                        userData.ExtractUserData(details, messageFeature == GSMSpecificFeatures.UDHI, offset);
                        break;

                    case (ushort)OptionalTags.SarMsgRefNum:
                        tlvValue.PduDataType = PduDataTypes.UShort;
                        tlvValue.Name        = "SARReferenceNumber";
                        tlvValue.ValueUShort = SmppBuffer.BytesToShort(tlvValue.DataBlock, 0);
                        break;

                    case (ushort)OptionalTags.SarTotalSegments:
                        tlvValue.PduDataType = PduDataTypes.Byte;
                        tlvValue.Name        = "SARTotalSegments";
                        tlvValue.ValueByte   = tlvValue.DataBlock[0];
                        break;

                    case (ushort)OptionalTags.SarSegmentSeqnum:
                        tlvValue.PduDataType = PduDataTypes.Byte;
                        tlvValue.Name        = "SARSequenceNumber";
                        tlvValue.ValueByte   = tlvValue.DataBlock[0];
                        break;
                    }
                }
            }

            catch
            {
            }

            return(details);
        }
Ejemplo n.º 2
0
        /// <summary> Called to return a list of property details from the PDU </summary>
        /// <returns> List PduPropertyDetail </returns>
        public List <PduPropertyDetail> Details()
        {
            List <PduPropertyDetail> details = null;

            try
            {
                int offset = 0;

                details = PduData.ExtractHeaderDetails(ref offset);

                details.Add(PduData.ExtractCString("ServiceType", ref offset));
                details.Add(PduData.ExtractByte("SourceTon", ref offset));
                details.Add(PduData.ExtractByte("SourceNpi", ref offset));
                details.Add(PduData.ExtractCString("SourceAddr", ref offset));
                details.Add(PduData.ExtractByte("DestTon", ref offset));
                details.Add(PduData.ExtractByte("DestNpi", ref offset));
                details.Add(PduData.ExtractCString("DestAddr", ref offset));

                PduPropertyDetail esmClass = PduData.ExtractByte("EsmClass", ref offset);
                details.Add(esmClass);

                details.Add(PduData.ExtractByte("ProtocolId", ref offset));
                details.Add(PduData.ExtractByte("PriorityFlag", ref offset));
                details.Add(PduData.ExtractCString("ScheduleDeliveryTime", ref offset));
                details.Add(PduData.ExtractCString("ValidityPeriod", ref offset));
                details.Add(PduData.ExtractByte("RegisteredDelivery", ref offset));
                details.Add(PduData.ExtractByte("ReplaceIfPresent", ref offset));

                PduPropertyDetail dataCoding = PduData.ExtractByte("DataCoding", ref offset);
                details.Add(dataCoding);

                details.Add(PduData.ExtractByte("DefaultMsgId", ref offset));

                PduPropertyDetail messageLength = PduData.ExtractByte("ShortMessageLength", ref offset);
                details.Add(messageLength);

                if (messageLength.ValueByte > 0)
                {
                    PduPropertyDetail userDataProperty = PduData.ExtractByteArray("ShortMessage", ref offset, messageLength.ValueByte);
                    userDataProperty.PduDataType = PduDataTypes.EncodedString;

                    UserData userData = UserData.Create(new SmppBuffer(DefaultEncoding, userDataProperty.DataBlock), false);
                    userDataProperty.ValueString = userData.ShortMessageText(DefaultEncoding, (DataCodings)dataCoding.ValueByte);

                    details.Add(userDataProperty);
                }

                while (offset < PduData.Length)
                {
                    PduData.ExtractTLV(details, ref offset);

                    PduPropertyDetail tlvTag    = details[details.Count - 3];
                    PduPropertyDetail tlvLength = details[details.Count - 2];
                    PduPropertyDetail tlvValue  = details[details.Count - 1];

                    switch (tlvTag.ValueUShort)
                    {
                    case (ushort)OptionalTags.MessagePayload:
                        GSMSpecificFeatures messageFeature = (GSMSpecificFeatures)(esmClass.ValueByte & 0xc0);
                        SmppBuffer          userData       = new SmppBuffer(DefaultEncoding, tlvValue.DataBlock);
                        userData.ExtractUserData(details, messageFeature == GSMSpecificFeatures.UDHI, offset);
                        break;

                    case (ushort)OptionalTags.SarMsgRefNum:
                        tlvValue.PduDataType = PduDataTypes.UShort;
                        tlvValue.Name        = "SARReferenceNumber";
                        tlvValue.ValueUShort = SmppBuffer.BytesToShort(tlvValue.DataBlock, 0);
                        break;

                    case (ushort)OptionalTags.SarTotalSegments:
                        tlvValue.PduDataType = PduDataTypes.Byte;
                        tlvValue.Name        = "SARTotalSegments";
                        tlvValue.ValueByte   = tlvValue.DataBlock[0];
                        break;

                    case (ushort)OptionalTags.SarSegmentSeqnum:
                        tlvValue.PduDataType = PduDataTypes.Byte;
                        tlvValue.Name        = "SARSequenceNumber";
                        tlvValue.ValueByte   = tlvValue.DataBlock[0];
                        break;
                    }
                }
            }

            catch
            {
            }

            return(details);
        }