Ejemplo n.º 1
0
 void Listening() // Lang nghe goi dhcp
 {
     while (true)
     {
         IPEndPoint IpEnd     = new IPEndPoint(IPAddress.Any, 0);
         Byte[]     recvBytes = udpclient.Receive(ref IpEnd);
         DHCPPacket packet    = new DHCPPacket();
         packet.BytesToDHCPPacket(recvBytes); // chuyen goi tin tu dang byte sang dang DHCPPacket
         ListPacket.Add(packet);
         Display_Message(packet);             // Hien thi goi len mang hinh
         HandlePacket(packet);                // xu li goi vua nhan
     }
 }
Ejemplo n.º 2
0
        HashSet <string> xid; // Cac  xid dang giao tiep

        void Listening()
        {
            while (true)
            {
                IPEndPoint IpEnd     = new IPEndPoint(IPAddress.Any, 0);
                Byte[]     recvBytes = udpclient.Receive(ref IpEnd);
                DHCPPacket packet    = new DHCPPacket();
                packet.BytesToDHCPPacket(recvBytes);
                ListPacket.Add(packet);
                DisplayPacket(packet);
                HandlePacket(packet);
            }
        }
Ejemplo n.º 3
0
 private void btnExtendIP_Click(object sender, EventArgs e) // Extend button
 {
     if (haveip)
     {
         Send_DHCPRequest(offer_saved, DHCPServer_IP, 2);
     }
     else
     {
         FileStream fs;
         try
         {
             fs = new FileStream("IP", FileMode.Open);
             byte[] load = new byte[376];
             fs.Read(load, 0, 376);
             fs.Close();
             offer_saved.BytesToDHCPPacket(load);
             List <byte[]> Option = offer_saved.optionsplit();
             for (int j = 0; j < Option.Count(); j++)
             {
                 if (Option[j][0] == 54) // server dhcp minh da chon
                 {
                     for (int z = 0; z < 4; z++)
                     {
                         DHCPServer_IP[z] = Option[j][z + 2];
                     }
                     break;
                 }
             }
             Send_DHCPRequest(offer_saved, DHCPServer_IP, 3);
         }
         catch (Exception z)
         {
             MessageBox.Show(z.Message);
             return;
         }
     }
 }