Пример #1
0
 public override void ToStream(Stream s)
 {
     ParseHelper.WriteUInt32(s, (uint)m_TimeSpan.TotalSeconds);
 }
Пример #2
0
        private DHCPMessage(Stream s) : this()
        {
            m_Opcode                = (TOpcode)s.ReadByte();
            m_HardwareType          = (THardwareType)s.ReadByte();
            m_ClientHardwareAddress = new byte[s.ReadByte()];
            m_Hops                = (byte)s.ReadByte();
            m_XID                 = ParseHelper.ReadUInt32(s);
            m_Secs                = ParseHelper.ReadUInt16(s);
            m_BroadCast           = ((ParseHelper.ReadUInt16(s) & 0x8000) == 0x8000);
            m_ClientIPAddress     = ParseHelper.ReadIPAddress(s);
            m_YourIPAddress       = ParseHelper.ReadIPAddress(s);
            m_NextServerIPAddress = ParseHelper.ReadIPAddress(s);
            m_RelayAgentIPAddress = ParseHelper.ReadIPAddress(s);
            s.Read(m_ClientHardwareAddress, 0, m_ClientHardwareAddress.Length);
            for (int t = m_ClientHardwareAddress.Length; t < 16; t++)
            {
                s.ReadByte();
            }

            byte[] serverHostNameBuffer = new byte[64];
            s.Read(serverHostNameBuffer, 0, serverHostNameBuffer.Length);

            byte[] bootFileNameBuffer = new byte[128];
            s.Read(bootFileNameBuffer, 0, bootFileNameBuffer.Length);

            // read options magic cookie
            if (s.ReadByte() != 99)
            {
                throw new IOException();
            }
            if (s.ReadByte() != 130)
            {
                throw new IOException();
            }
            if (s.ReadByte() != 83)
            {
                throw new IOException();
            }
            if (s.ReadByte() != 99)
            {
                throw new IOException();
            }

            byte[] optionsBuffer = new byte[s.Length - s.Position];
            s.Read(optionsBuffer, 0, optionsBuffer.Length);

            byte overload = ScanOverload(new MemoryStream(optionsBuffer));

            switch (overload)
            {
            default:
                m_ServerHostName = ParseHelper.ReadZString(new MemoryStream(serverHostNameBuffer));
                m_BootFileName   = ParseHelper.ReadZString(new MemoryStream(bootFileNameBuffer));
                m_Options        = ReadOptions(optionsBuffer, new byte[0], new byte[0]);
                break;

            case 1:
                m_ServerHostName = ParseHelper.ReadZString(new MemoryStream(serverHostNameBuffer));
                m_Options        = ReadOptions(optionsBuffer, bootFileNameBuffer, new byte[0]);
                break;

            case 2:
                m_BootFileName = ParseHelper.ReadZString(new MemoryStream(bootFileNameBuffer));
                m_Options      = ReadOptions(optionsBuffer, serverHostNameBuffer, new byte[0]);
                break;

            case 3:
                m_Options = ReadOptions(optionsBuffer, bootFileNameBuffer, serverHostNameBuffer);
                break;
            }
        }
Пример #3
0
 public override void ToStream(Stream s)
 {
     ParseHelper.WriteIPAddress(s, m_SubnetMask);
 }
Пример #4
0
 public override void ToStream(Stream s)
 {
     ParseHelper.WriteIPAddress(s, m_IPAddress);
 }
Пример #5
0
 public override void ToStream(Stream s)
 {
     ParseHelper.WriteUInt16(s, m_MaxSize);
 }
Пример #6
0
 public override void ToStream(Stream s)
 {
     ParseHelper.WriteString(s, ZeroTerminatedStrings, m_Name);
 }
Пример #7
0
 public override void ToStream(Stream s)
 {
     ParseHelper.WriteUInt8(s, (byte)m_HardwareType);
     s.Write(m_Data, 0, m_Data.Length);
 }