private static void getInterfacesAIX(SshExec exec, SysInfo mySysInfo)
 {
     uint ifIndex = 0;
     InterfaceState curif = null;
     char[] lineseps = { '\r', '\n' };
     char[] fieldseps = { ' ', '\t' };
     string output = exec.RunCommand("ifconfig -a");
     string[] lines = output.Split(lineseps, StringSplitOptions.RemoveEmptyEntries);
     foreach (string line in lines)
     {
         if (!char.IsWhiteSpace(line[0]))
         {
             if (curif != null)
             {
                 getMACAIX(exec, curif);
                 mySysInfo.Interfaces.Add(curif);
             }
             curif = new InterfaceState();
             curif.InetAddr = new List<InterfaceState.IPInfo>();
             curif.Index = ifIndex++;
             string[] ifields = line.Split(fieldseps, StringSplitOptions.RemoveEmptyEntries);
             curif.Name = ifields[0].Replace(":", "");
             string iflags = ifields[1].Replace("<", ",").Replace(">", ",");
             if (iflags.Contains(",LOOPBACK,"))
             {
                 curif.Type = InterfaceState.stateInterfaceType.MIB_IF_TYPE_LOOPBACK;
                 curif.IsPhysical = false;
             }
             else if (curif.Name.StartsWith("en") || curif.Name.StartsWith("et"))
             {
                 curif.Type = InterfaceState.stateInterfaceType.MIB_IF_TYPE_ETHERNET;
                 curif.IsPhysical = true;
             }
             else
             {
                 curif.Type = InterfaceState.stateInterfaceType.MIB_IF_TYPE_OTHER;
             }
         }
         else
         {
             string[] pfields = line.Split(fieldseps, StringSplitOptions.RemoveEmptyEntries);
             if (pfields[0] == "inet")
             {
                 InterfaceState.IPInfo curip = new InterfaceState.IPInfo();
                 curip.IPAddr = pfields[1];
                 if ((pfields.Length > 5) && (pfields[4] == "broadcast"))
                     curip.IPBcast = pfields[5];
                 else
                     curip.IPBcast = "";
                 if ((pfields.Length > 3) && (pfields[2] == "netmask"))
                 {
                     if (pfields[3].Contains("."))
                         curip.IPMask = pfields[3];
                     else if (pfields[3].StartsWith("0x"))
                     {
                         UInt32 masknum = Convert.ToUInt32(pfields[3].Substring(2), 16);
                         curip.IPMask = String.Format("{0}.{1}.{2}.{3}",
                             masknum >> 24, (masknum >> 16) & 0x00FF, (masknum >> 8) & 0x00FF, masknum & 0x00FF);
                     }
                 }
                 else
                     curip.IPMask = "";
                 curip.AddrType = InterfaceState.stateAddrType.MIB_IPADDR_PRIMARY;
                 curif.InetAddr.Add(curip);
             }
         }
     }
     if (curif != null)
         mySysInfo.Interfaces.Add(curif);
 }
        private static void getInterfacesSolaris(SshCommandLineRunner commandRunner, SysInfo mySysInfo)
        {
            uint ifIndex = 0;
            InterfaceState curif = null;
            char[] fieldseps = { ' ', '\t' };
            var commandOutputLines = commandRunner.ExecuteCommand("/sbin/ifconfig -a").SplitStringByDefaultNewLine();

            foreach (var line in commandOutputLines)
            {
                if (!char.IsWhiteSpace(line[0]))
                {
                    if (curif != null)
                    {
                        getMACAIX(commandRunner, curif);
                        mySysInfo.Interfaces.Add(curif);
                    }
                    curif = new InterfaceState();
                    curif.InetAddr = new List<InterfaceState.IPInfo>();
                    curif.Index = ifIndex++;
                    string[] ifields = line.Split(fieldseps, StringSplitOptions.RemoveEmptyEntries);
                    curif.Name = ifields[0].Replace(":", "");
                    string iflags = ifields[1].Replace("<", ",").Replace(">", ",");
                    if (iflags.Contains(",LOOPBACK,"))
                    {
                        curif.Type = InterfaceState.stateInterfaceType.MIB_IF_TYPE_LOOPBACK;
                        curif.IsPhysical = false;
                    }
                    else if (iflags.Contains(",VIRTUAL,"))
                    {
                        curif.Type = InterfaceState.stateInterfaceType.MIB_IF_TYPE_OTHER;
                        curif.IsPhysical = false;
                    }
                    else
                    {
                        curif.Type = InterfaceState.stateInterfaceType.MIB_IF_TYPE_OTHER;
                        curif.IsPhysical = true;
                    }
                }
                else
                {
                    string[] pfields = line.Split(fieldseps, StringSplitOptions.RemoveEmptyEntries);
                    if (pfields[0] == "ether")
                    {
                        curif.Type = InterfaceState.stateInterfaceType.MIB_IF_TYPE_ETHERNET;
                        string[] macParts = pfields[1].Split(':');
                        if (macParts.Length == 6)
                        {
                            for (int i = 0; i < macParts.Length; i++)
                            {
                                if (macParts[i].Length == 1)
                                    macParts[i] = "0" + macParts[i];
                            }
                            curif.HWAddr = String.Join(":", macParts);
                        }
                    }
                    else if (pfields[0] == "inet")
                    {
                        InterfaceState.IPInfo curip = new InterfaceState.IPInfo();
                        curip.IPAddr = pfields[1];
                        if ((pfields.Length > 5) && (pfields[4] == "broadcast"))
                            curip.IPBcast = pfields[5];
                        else
                            curip.IPBcast = "";
                        if ((pfields.Length > 3) && (pfields[2] == "netmask"))
                        {
                            if (pfields[3].Contains("."))
                                curip.IPMask = pfields[3];
                            else
                            {
                                if (pfields[3].StartsWith("0x"))
                                    pfields[3] = pfields[3].Substring(2);
                                UInt32 masknum = Convert.ToUInt32(pfields[3], 16);
                                curip.IPMask = String.Format("{0}.{1}.{2}.{3}",
                                    masknum >> 24, (masknum >> 16) & 0x00FF, (masknum >> 8) & 0x00FF, masknum & 0x00FF);
                            }
                        }
                        else
                            curip.IPMask = "";
                        curip.AddrType = InterfaceState.stateAddrType.MIB_IPADDR_PRIMARY;
                        curif.InetAddr.Add(curip);
                    }
                }
            }
            if (curif != null)
                mySysInfo.Interfaces.Add(curif);
        }
        private static void getInterfacesAIX(SshCommandLineRunner commandRunner, SysInfo mySysInfo)
        {
            uint           ifIndex = 0;
            InterfaceState curif   = null;

            char[] fieldseps = { ' ', '\t' };
            var    output    = commandRunner.ExecuteCommand("ifconfig -a").SplitStringByDefaultNewLine();

            foreach (var line in output)
            {
                if (!char.IsWhiteSpace(line[0]))
                {
                    if (curif != null)
                    {
                        getMACAIX(commandRunner, curif);
                        mySysInfo.Interfaces.Add(curif);
                    }
                    curif          = new InterfaceState();
                    curif.InetAddr = new List <InterfaceState.IPInfo>();
                    curif.Index    = ifIndex++;
                    string[] ifields = line.Split(fieldseps, StringSplitOptions.RemoveEmptyEntries);
                    curif.Name = ifields[0].Replace(":", "");
                    string iflags = ifields[1].Replace("<", ",").Replace(">", ",");
                    if (iflags.Contains(",LOOPBACK,"))
                    {
                        curif.Type       = InterfaceState.stateInterfaceType.MIB_IF_TYPE_LOOPBACK;
                        curif.IsPhysical = false;
                    }
                    else if (curif.Name.StartsWith("en") || curif.Name.StartsWith("et"))
                    {
                        curif.Type       = InterfaceState.stateInterfaceType.MIB_IF_TYPE_ETHERNET;
                        curif.IsPhysical = true;
                    }
                    else
                    {
                        curif.Type = InterfaceState.stateInterfaceType.MIB_IF_TYPE_OTHER;
                    }
                }
                else
                {
                    string[] pfields = line.Split(fieldseps, StringSplitOptions.RemoveEmptyEntries);
                    if (pfields[0] == "inet")
                    {
                        InterfaceState.IPInfo curip = new InterfaceState.IPInfo();
                        curip.IPAddr = pfields[1];
                        if ((pfields.Length > 5) && (pfields[4] == "broadcast"))
                        {
                            curip.IPBcast = pfields[5];
                        }
                        else
                        {
                            curip.IPBcast = "";
                        }
                        if ((pfields.Length > 3) && (pfields[2] == "netmask"))
                        {
                            if (pfields[3].Contains("."))
                            {
                                curip.IPMask = pfields[3];
                            }
                            else if (pfields[3].StartsWith("0x"))
                            {
                                UInt32 masknum = Convert.ToUInt32(pfields[3].Substring(2), 16);
                                curip.IPMask = String.Format("{0}.{1}.{2}.{3}",
                                                             masknum >> 24, (masknum >> 16) & 0x00FF, (masknum >> 8) & 0x00FF, masknum & 0x00FF);
                            }
                        }
                        else
                        {
                            curip.IPMask = "";
                        }
                        curip.AddrType = InterfaceState.stateAddrType.MIB_IPADDR_PRIMARY;
                        curif.InetAddr.Add(curip);
                    }
                }
            }
            if (curif != null)
            {
                mySysInfo.Interfaces.Add(curif);
            }
        }