Beispiel #1
0
        public void ToStream(Stream s, int minimumPacketSize)
        {
            s.WriteByte((byte)m_Opcode);
            s.WriteByte((byte)m_HardwareType);
            s.WriteByte((byte)m_ClientHardwareAddress.Length);
            s.WriteByte((byte)m_Hops);
            ParseHelper.WriteUInt32(s, m_XID);
            ParseHelper.WriteUInt16(s, m_Secs);
            ParseHelper.WriteUInt16(s, m_BroadCast ? (ushort)0x8000 : (ushort)0x0);
            ParseHelper.WriteIPAddress(s, m_ClientIPAddress);
            ParseHelper.WriteIPAddress(s, m_YourIPAddress);
            ParseHelper.WriteIPAddress(s, m_NextServerIPAddress);
            ParseHelper.WriteIPAddress(s, m_RelayAgentIPAddress);
            s.Write(m_ClientHardwareAddress, 0, m_ClientHardwareAddress.Length);
            for (int t = m_ClientHardwareAddress.Length; t < 16; t++)
            {
                s.WriteByte(0);
            }
            ParseHelper.WriteZString(s, m_ServerHostName, 64); // BOOTP legacy
            ParseHelper.WriteZString(s, m_BootFileName, 128);  // BOOTP legacy
            s.Write(new byte[] { 99, 130, 83, 99 }, 0, 4);     // options magic cookie
            // write options
            foreach (IDHCPOption option in m_Options)
            {
                MemoryStream optionStream = new MemoryStream();
                option.ToStream(optionStream);
                s.WriteByte((byte)option.OptionType);
                s.WriteByte((byte)optionStream.Length);
                optionStream.Position = 0;
                CopyBytes(optionStream, s, (int)optionStream.Length);
            }
            // write end option
            s.WriteByte(255);
            s.Flush();

            while (s.Length < minimumPacketSize)
            {
                s.WriteByte(0);
            }

            s.Flush();
        }
Beispiel #2
0
 public override void ToStream(Stream s)
 {
     ParseHelper.WriteUInt32(s, (uint)m_LeaseTime.TotalSeconds);
 }