using PlcSiemens.O;

namespace PlcSiemens.Protocol.Header
{
    // TPKT Header - ISO on TCP - RFC 1006 (4 bytes)
    // Packet length : min 7 max 65535
    public class TpktHeader
    {
        public byte Version { get; set; }   // Always 3 for RFC 1006
        public byte Reserved { get; set; }  // 0
        public ushort Length { get; set; } //整个数据包的长度

        public ushort PacketLength
        { get { return 0x04; } }

        public void GetByteBuffer(ByteBuffer buffer)
        {
            buffer.Push(Version);
            buffer.Push(Reserved);
            buffer.Push(Length);
        }

        public void InitByBuffer(ByteBuffer buffer)
        {
            Version = buffer.PopByte();
            Reserved = buffer.PopByte();
            Length = buffer.PopUshort();
        }
    }
}
