Esempio n. 1
0
        private int LoadBootP(byte[] bytes, int index)
        {
            if (bytes == null || bytes != null && bytes.Length < 240)
            {
                IsActualDhcp = false;
                return(0);
            }

            BootPMessageType = bytes[index++];
            HType            = (HardwareType)bytes[index++];
            HLen             = bytes[index++];
            Hops             = bytes[index++];
            XId        = BitConverter.ToUInt32(new[] { bytes[index + 3], bytes[index + 2], bytes[index + 1], bytes[index] }, 0);
            index     += 4;
            Secs       = BitConverter.ToUInt16(new[] { bytes[index + 1], bytes[index] }, 0);
            index     += 2;
            BootPFlags = BitConverter.ToUInt16(new[] { bytes[index + 1], bytes[index] }, 0);
            index     += 2;
            CIAddr     = new IPAddress(new byte[] { bytes[index], bytes[index + 1], bytes[index + 2], bytes[index + 3] });
            index     += 4;
            YIAddr     = new IPAddress(new byte[] { bytes[index], bytes[index + 1], bytes[index + 2], bytes[index + 3] });
            index     += 4;
            SIAddr     = new IPAddress(new byte[] { bytes[index], bytes[index + 1], bytes[index + 2], bytes[index + 3] });
            index     += 4;
            GIAddr     = new IPAddress(new byte[] { bytes[index], bytes[index + 1], bytes[index + 2], bytes[index + 3] });
            index     += 4;

            CHAddr = new byte[16];
            var tempAddr = new byte[6];

            for (byte i = 0; i < 16; i++)
            {
                CHAddr[i] = bytes[index + i];
                if (i < 6)
                {
                    tempAddr[i] = bytes[index + i];
                }
            }
            index          += 16;
            CHAddrTruncated = new MacAddress(tempAddr);

            ServerName = ByteOps.GetAsciiString(bytes, index, 64);
            index     += 64;

            BootFileName = ByteOps.GetAsciiString(bytes, index, 128);
            index       += 128;

            MagicCookie  = BitConverter.ToUInt32(new[] { bytes[index + 3], bytes[index + 2], bytes[index + 1], bytes[index] }, 0);
            IsActualDhcp = MagicCookie == 0x63825363;
            return(index);
        }
Esempio n. 2
0
 public virtual string GetStringValue()
 {
     return(ByteOps.GetAsciiString(Value, 0, Value.Length));
 }