private void SetInformationAboutNetworkAdapters(SystemInformation systemInformation, IEnumerable<WmiObject> informationAboutNetworkAdapter)
 {
     if (!this.TheListIsEmpty(informationAboutNetworkAdapter))
     {
         WmiObject wmiObject = informationAboutNetworkAdapter.First();
         NetworkInterface networkInterface = new NetworkInterface();
         networkInterface.IpAddress = ((string[])wmiObject.GetValueOf("IPAddress"))[0];
         networkInterface.MacAddress = wmiObject.GetValueOf("MACAddress").ToString();
         networkInterface.Name = wmiObject.GetValueOf("Description").ToString();
         systemInformation.Interfaces.Add(networkInterface);
         
     }
 }
예제 #2
0
        private SystemInformation CreateSystemInformation()
        {
            SystemInformation systemInformation = new SystemInformation();
            systemInformation.SystemName = "unknown Service Pack 1";
            systemInformation.SystemVersion = "6.0.6001";
            systemInformation.PrimaryHostName = "mss-rj-007.mss.modulo.com.br";
            systemInformation.Architecture = "INTEL32";

            NetworkInterface networkInfterface = new NetworkInterface()
            {
                Name = "Intel(R) 82566DM Gigabit Network Connection",
                IpAddress = "172.16.3.33",
                MacAddress = "00-1E-C9-1D-72-4E"
            };

            systemInformation.Interfaces.Add(networkInfterface);

            return systemInformation;
        }
예제 #3
0
 public static IList<NetworkInterface> CiscoGetInterfaces(TelnetConnection tc)
 {
     List<NetworkInterface> retList = new List<NetworkInterface>();
     NetworkInterface curif = null;
     char[] lineseps = { '\r', '\n' };
     char[] fieldseps = { ' ', '\t' };
     string output = tc.CiscoCommand("show interfaces");
     string[] lines = output.Split(lineseps, StringSplitOptions.RemoveEmptyEntries);
     foreach (string line in lines)
     {
         string[] ifields = line.Split(fieldseps, StringSplitOptions.RemoveEmptyEntries);
         if (!char.IsWhiteSpace(line[0]))
         {
             if (curif != null)
             {
                 retList.Add(curif);
             }
             curif = new NetworkInterface();
             curif.Name = ifields[0];
         }
         else
         {
             if (String.Equals(ifields[0], "Internet", StringComparison.OrdinalIgnoreCase) &&
                 String.Equals(ifields[1], "address", StringComparison.OrdinalIgnoreCase) &&
                 String.Equals(ifields[2], "is", StringComparison.OrdinalIgnoreCase))
             {
                 string tmpIp = ifields[3];
                 string[] tmpIpParts = tmpIp.Split('/');
                 curif.IpAddress = tmpIpParts[0];
             }
             if (String.Equals(ifields[0], "Hardware", StringComparison.OrdinalIgnoreCase) &&
                 String.Equals(ifields[1], "is", StringComparison.OrdinalIgnoreCase))
             {
                 string tmpMac = "";
                 for (int i = 2; i < ifields.Length - 2; i++)
                 {
                     if (String.Equals(ifields[i], "address", StringComparison.OrdinalIgnoreCase) &&
                         String.Equals(ifields[i + 1], "is", StringComparison.OrdinalIgnoreCase))
                     {
                         tmpMac = ifields[i + 2];
                         break;
                     }
                 }
                 if (tmpMac.Length == 14)    // xxxx.xxxx.xxxx MAC format
                 {
                     tmpMac = tmpMac.Substring(0, 2) + ":" +
                              tmpMac.Substring(2, 2) + ":" +
                              tmpMac.Substring(5, 2) + ":" +
                              tmpMac.Substring(7, 2) + ":" +
                              tmpMac.Substring(10, 2) + ":" +
                              tmpMac.Substring(12, 2);
                 }
                 if (!String.IsNullOrEmpty(tmpMac))
                     curif.MacAddress = tmpMac;
             }
         }
     }
     if (curif != null)
     {
         retList.Add(curif);
     }
     return retList;
 }