Пример #1
0
 public DHCPDatagram(byte[] bytes)
 {
     op     = bytes[0];
     htype  = bytes[1];
     hlen   = bytes[2];
     hops   = bytes[3];
     xid    = BitConverter.ToUInt32(bytes, 4);
     secs   = BitConverter.ToUInt16(bytes, 8);
     flags  = BitConverter.ToUInt16(bytes, 10);
     ciaddr = new IP(bytes, 12);
     if (ciaddr == IP.Zero)
     {
         ciaddr = null;
     }
     yiaddr = new IP(bytes, 16);
     if (yiaddr == IP.Zero)
     {
         yiaddr = null;
     }
     siaddr = new IP(bytes, 20);
     if (siaddr == IP.Zero)
     {
         siaddr = null;
     }
     giaddr = new IP(bytes, 24);
     if (giaddr == IP.Zero)
     {
         giaddr = null;
     }
     chaddr = new MAC(bytes, 28);
     sname  = new List <byte>(new ArraySegment <byte>(bytes, 34, 64)).ToArray();
     file   = new List <byte>(new ArraySegment <byte>(bytes, 98, 128)).ToArray();
     byte[] optionbytes = new byte[bytes.Length - 226];
     optionbytes = new List <byte>(new ArraySegment <byte>(bytes, 226, bytes.Length - 226)).ToArray();
     options     = new Optionlist(optionbytes);
 }
Пример #2
0
 public DHCPDatagram(byte op, UInt32 xid, byte htype = 1, byte hlen = 10, byte hops = 0, UInt16 secs = 0, bool Broadcast = false, IP ClientIP = null, IP YourIP = null, IP ServerIP = null, IP RelayIP = null,
                     MAC ClientMAC = null, Optionlist options       = null)
 {
     this.op     = op;
     this.xid    = xid;
     this.htype  = htype;
     this.hlen   = hlen;
     this.hops   = hops;
     this.secs   = secs;
     this.B      = Broadcast;
     this.ciaddr = ClientIP;
     this.yiaddr = YourIP;
     this.siaddr = ServerIP;
     this.giaddr = RelayIP;
     this.chaddr = ClientMAC;
     if (options == null)
     {
         this.options = new Optionlist();
     }
     else
     {
         this.options = options;
     }
 }