Ejemplo n.º 1
0
 public MXNetAddress(MXNetAddress ip, MXNetAddress mask)
 {
     for (int i = 0; i < 4; i++)
     {
         bytes[i] = (byte)(ip.bytes[i] & mask.bytes[i]);
     }
     value   = ip.value & mask.value;
     address = bytes[0].ToString() + '.' +
               bytes[1].ToString() + '.' +
               bytes[2].ToString() + '.' +
               bytes[3].ToString();
 }
Ejemplo n.º 2
0
 public MXNetworkAdapter(string rawIpConfig)
 {
     using (System.IO.StringReader reader = new System.IO.StringReader(rawIpConfig))
     {
         string line;
         while ((line = reader.ReadLine()) != null)
         {
             if (line.Contains("adapter"))
             {
                 this.name = line.Replace(":", "");
             }
             else if (line.Contains("IPv4 Address"))
             {
                 ipv4_Addr = new MXNetAddress(line.Remove(0, line.IndexOf(':') + 2));
             }
             else if (line.Contains("Subnet Mask"))
             {
                 subnetMask = new MXNetAddress(line.Remove(0, line.IndexOf(':') + 2));
             }
         }
     }
 }
Ejemplo n.º 3
0
            public List <string> GetDevices()
            {
                List <string> rawResult = new List <string>();
                string        arpResult = "";

                for (var ip = new MXNetAddress(ipv4_Addr, subnetMask); ip.value < (ipv4_Addr.value | ~subnetMask.value); ip.inc())
                {
                    arpResult = Cmd("arp -a " + ip.address);
                    var temp = arpResult.Split('\n');
                    if (temp.Length < 3)
                    {
                        rawResult.Add(temp[0]);
                    }
                    else
                    {
                        rawResult.Add(temp[3]);
                    }
                }

                List <string> result = new List <string>();

                foreach (var item in rawResult)
                {
                    if (!item.Contains("Entries"))
                    {
                        result.Add(item);
                    }
                }

                if (result.Count == 0)
                {
                    result.Add("No ARP Entries Found");
                }

                return(result);
            }
Ejemplo n.º 4
0
 public MXNetworkAdapter(string name, string ip, string mask, string defGateway)
 {
     this.name  = name;
     ipv4_Addr  = new MXNetAddress(ip);
     subnetMask = new MXNetAddress(mask);
 }