/// <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); }
/// <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 { var 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)); var 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)); var dataCoding = PduData.ExtractByte("DataCoding", ref offset); details.Add(dataCoding); details.Add(PduData.ExtractByte("DefaultMessageId", ref offset)); var messageLength = PduData.ExtractByte("ShortMessageLength", ref offset); details.Add(messageLength); if (messageLength.ValueByte > 0) { var userDataProperty = PduData.ExtractByteArray("ShortMessage", ref offset, messageLength.ValueByte); userDataProperty.PduDataType = PduDataTypes.EncodedString; var 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); var tlvTag = details[details.Count - 3]; var tlvLength = details[details.Count - 2]; var tlvValue = details[details.Count - 1]; switch (tlvTag.ValueUShort) { case (ushort)OptionalTags.MessagePayload: var messageFeature = (GSMSpecificFeatures)(esmClass.ValueByte & 0xc0); var 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); }
/// <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); }
/// <summary> Called to create a SubmitSm object </summary> /// <param name="defaultEncoding"></param> /// <param name="buf"></param> /// <param name="offset"></param> /// <returns> SubmitSm </returns> public static SubmitSm Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset) { SubmitSm submitSm = new SubmitSm(defaultEncoding); try { int start_offset = offset; buf.ExtractHeader(submitSm, ref offset); submitSm.ServiceType = buf.ExtractCString(ref offset); submitSm.SourceTon = buf.ExtractByte(ref offset); submitSm.SourceNpi = buf.ExtractByte(ref offset); submitSm.SourceAddr = buf.ExtractCString(ref offset); submitSm.DestTon = buf.ExtractByte(ref offset); submitSm.DestNpi = buf.ExtractByte(ref offset); submitSm.DestAddr = buf.ExtractCString(ref offset); submitSm.EsmClass = buf.ExtractByte(ref offset); submitSm.ProtocolId = buf.ExtractByte(ref offset); submitSm.PriorityFlag = buf.ExtractByte(ref offset); submitSm.ScheduleDeliveryTime = buf.ExtractCString(ref offset); submitSm.ValidityPeriod = buf.ExtractCString(ref offset); submitSm.RegisteredDelivery = buf.ExtractByte(ref offset); submitSm.ReplaceIfPresent = buf.ExtractByte(ref offset); submitSm.DataCoding = (DataCodings)buf.ExtractByte(ref offset); submitSm.DefaultMsgId = buf.ExtractByte(ref offset); submitSm.ShortMessageLength = buf.ExtractByte(ref offset); if (submitSm.ShortMessageLength > 0) { submitSm.UserDataBuffer = new SmppBuffer(defaultEncoding, buf.ExtractByteArray(ref offset, submitSm.ShortMessageLength)); } while (offset - start_offset < submitSm.Length) { submitSm.Optional.Add(buf.ExtractTLV(ref offset)); } if (submitSm.ShortMessageLength == 0) { if (submitSm.Optional != null && submitSm.Optional.Count > 0) { TLV tlv_payload = submitSm.Optional[OptionalTags.MessagePayload]; if (tlv_payload != null) { submitSm.UserDataBuffer = new SmppBuffer(defaultEncoding, tlv_payload.Value); } TLV tlv_globalSeq = submitSm.Optional[OptionalTags.SarMsgRefNum]; if (tlv_globalSeq != null) { submitSm.MessageReferenceNumber = SmppBuffer.BytesToShort(tlv_globalSeq.Value, 0); } TLV tlv_pocketsNumber = submitSm.Optional[OptionalTags.SarTotalSegments]; if (tlv_pocketsNumber != null) { submitSm.TotalSegments = tlv_pocketsNumber.Value[0]; } TLV tlv_localSeq = submitSm.Optional[OptionalTags.SarSegmentSeqnum]; if (tlv_localSeq != null) { submitSm.SeqmentNumber = tlv_localSeq.Value[0]; } } } if (submitSm.UserDataBuffer != null && submitSm.UserDataBuffer.Length > 0) { bool hasUDHI = submitSm.MessageFeature == GSMSpecificFeatures.UDHI || submitSm.MessageFeature == GSMSpecificFeatures.UDHIandReplyPath; submitSm.UserData = UserData.Create(submitSm.UserDataBuffer, hasUDHI); if (submitSm.UserData.Headers.Count > 0) { UserDataHeader udh = submitSm.UserData.Headers[InformationElementIdentifiers.ConcatenatedShortMessages8bit]; if (udh != null) { submitSm.MessageReferenceNumber = udh.Data[0]; submitSm.TotalSegments = udh.Data[1]; submitSm.SeqmentNumber = udh.Data[2]; } udh = submitSm.UserData.Headers[InformationElementIdentifiers.ConcatenatedShortMessage16bit]; if (udh != null) { submitSm.MessageReferenceNumber = SmppBuffer.BytesToShort(udh.Data, 0); submitSm.TotalSegments = udh.Data[2]; submitSm.SeqmentNumber = udh.Data[3]; } } } else { submitSm.UserData = UserData.Create(); } } catch { submitSm = null; } return(submitSm); }