internal void ReadOptional(PduReader reader) { while (reader.SizeLeft > 0) { Optional.Add(new SMPPTLV(reader)); } }
private async Task <SMPPMessage> _recvMessage() { byte[] buf = new byte[16]; await _streamRead(buf, 0, buf.Length); UInt32 commandLength = PduReader.ParseInteger(buf, 0); if (commandLength < 16 || commandLength > (1 << 18)) { throw new SMPPException("Invalid command_length " + commandLength + "received."); } if (commandLength > 16) { Array.Resize(ref buf, (int)commandLength); await _streamRead(buf, 16, (int)commandLength - 16); } PduReader pduReader = new PduReader(buf); #if DEBUG Debug.WriteLine("SMPPConnection: RecvMessage size=" + pduReader.CommandLength + " id=" + pduReader.CommandId + " status=" + pduReader.CommandStatus + " seq=" + pduReader.CommandSequence); #endif try { switch (pduReader.CommandId) { case CommandSet.GenericNack: return(new SMPPGenericNack(pduReader)); case CommandSet.BindReceiverResp: return(new SMPPBindResp(CommandSet.BindReceiverResp, pduReader)); case CommandSet.BindTransceiverResp: return(new SMPPBindResp(CommandSet.BindTransceiverResp, pduReader)); case CommandSet.BindTransmitterResp: return(new SMPPBindResp(CommandSet.BindTransmitterResp, pduReader)); case CommandSet.SubmitSmResp: return(new SMPPSubmitSmResp(pduReader)); case CommandSet.DeliverSm: return(new SMPPDeliverSm(pduReader)); case CommandSet.EnquireLink: return(new SMPPEnquireLink(pduReader)); case CommandSet.EnquireLinkResp: return(new SMPPEnquireLinkResp(pduReader)); case CommandSet.Unbind: return(new SMPPUnbind(pduReader)); case CommandSet.UnbindResp: return(new SMPPUnbindResp(pduReader)); default: throw new SMPPException("Invalid command."); // TODO set nack } } catch (Exception err) { throw new SMPPPDUException("Error while parsing received PDU command " + pduReader.CommandId.ToString() + ".", buf, err); } }
internal SMPPDeliverSm(PduReader reader) : base(reader) { ServiceType = reader.ReadCStringAscii(); SourceTon = (TonType)reader.ReadByte(); SourceNpi = (NpiType)reader.ReadByte(); SourceAddr = reader.ReadCStringAscii(); DestTon = (TonType)reader.ReadByte(); DestNpi = (NpiType)reader.ReadByte(); DestAddr = reader.ReadCStringAscii(); EsmClass = (EmsClass)reader.ReadByte(); ProtocolId = reader.ReadByte(); PriorityFlag = (PriorityFlags)reader.ReadByte(); ScheduleDeliveryTime = reader.ReadCStringAscii(); ValidityPeriod = reader.ReadCStringAscii(); RegisteredDelivery = (RegisteredDeliveryFlags)reader.ReadByte(); ReplaceIfPresent = reader.ReadByte(); DataCoding = (DataCodings)reader.ReadByte(); DefaultMessageId = reader.ReadByte(); ShortMessage = reader.ReadBytes(reader.ReadByte()); ReadOptional(reader); }
internal SMPPGenericNack(PduReader reader) : base(reader) { }
internal SMPPMessageWithOptional(PduReader reader) : base(reader) { }
internal SMPPMessage(PduReader reader) { Status = reader.CommandStatus; Sequence = reader.CommandSequence; }
internal SMPPEnquireLink(PduReader reader) : base(reader) { }
internal SMPPUnbindResp(PduReader reader) : base(reader) { }
internal SMPPTLV(PduReader reader) { Tag = (OptionalTags)(reader.ReadInteger16()); Value = reader.ReadBytes(reader.ReadInteger16()); }
internal SMPPSubmitSmResp(PduReader reader) : base(reader) { MessageId = reader.ReadCStringAscii(); }
internal SMPPBindResp(CommandSet command, PduReader reader) : base(reader) { _command = command; SystemId = reader.ReadCStringAscii(); ReadOptional(reader); }