예제 #1
0
        public static void Init()
        {
            int NetworkDeviceID = 0;

            Console.WriteLine("Searching for Ethernet Controllers...");

            foreach (PCIDevice device in PCI.Devices)
            {
                if ((device.ClassCode == 0x02) && (device.Subclass == 0x00) && // is Ethernet Controller
                    device == PCI.GetDevice(device.bus, device.slot, device.function))
                {
                    Console.WriteLine("Found " + PCIDevice.DeviceClass.GetDeviceString(device) + " on PCI " + device.bus + ":" + device.slot + ":" + device.function);

                    #region PCNETII

                    if (device.VendorID == (ushort)VendorID.AMD && device.DeviceID == (ushort)DeviceID.PCNETII)
                    {
                        Console.WriteLine("NIC IRQ: " + device.InterruptLine);

                        var AMDPCNetIIDevice = new AMDPCNetII(device);

                        AMDPCNetIIDevice.NameID = ("eth" + NetworkDeviceID);

                        Console.WriteLine("Registered at " + AMDPCNetIIDevice.NameID + " (" + AMDPCNetIIDevice.MACAddress.ToString() + ")");

                        AMDPCNetIIDevice.Enable();

                        NetworkDeviceID++;
                    }

                    #endregion
                    #region RTL8139

                    if (device.VendorID == 0x10EC && device.DeviceID == 0x8139)
                    {
                        var RTL8139Device = new RTL8139(device);

                        RTL8139Device.NameID = ("eth" + NetworkDeviceID);

                        RTL8139Device.Enable();

                        NetworkDeviceID++;
                    }

                    #endregion
                }
            }

            if (NetworkDevice.Devices.Count == 0)
            {
                Console.WriteLine("No supported network card found!!");
            }
            else
            {
                Console.WriteLine("Network initialization done!");
            }
        }
예제 #2
0
        public static void Init(bool debug = true)
        {
            if (debug)
            {
                CustomConsole.WriteLineInfo("Finding nic...");
            }

            PCIDevice RTL8168 = PCI.GetDevice((VendorID)0x10EC, (DeviceID)0x8168);

            if (RTL8168 != null)
            {
                if (debug)
                {
                    CustomConsole.WriteLineOK("Found RTL8168 NIC on PCI " + RTL8168.bus + ":" + RTL8168.slot + ":" + RTL8168.function);
                    CustomConsole.WriteLineInfo("NIC IRQ: " + RTL8168.InterruptLine);
                }
                RTL8168NIC = new HAL.Drivers.Network.RTL8168(RTL8168);
                if (debug)
                {
                    CustomConsole.WriteLineInfo("NIC MAC Address: " + RTL8168NIC.MACAddress.ToString());
                }
                Network.NetworkStack.Init();
                RTL8168NIC.Enable();
            }
            PCIDevice AMDPCNETII = PCI.GetDevice(VendorID.AMD, DeviceID.PCNETII);

            if (AMDPCNETII != null)
            {
                if (debug)
                {
                    CustomConsole.WriteLineOK("Found AMDPCNETII NIC on PCI " + AMDPCNETII.bus + ":" + AMDPCNETII.slot + ":" + AMDPCNETII.function);
                    CustomConsole.WriteLineInfo("NIC IRQ: " + AMDPCNETII.InterruptLine);
                }
                AMDPCNetIINIC = new HAL.Drivers.Network.AMDPCNetII(AMDPCNETII);
                if (debug)
                {
                    CustomConsole.WriteLineInfo("NIC MAC Address: " + AMDPCNetIINIC.MACAddress.ToString());
                }
                Network.NetworkStack.Init();
                AMDPCNetIINIC.Enable();
            }
            if (RTL8168 == null && AMDPCNETII == null)
            {
                CustomConsole.WriteLineError("No supported network card found!!");
                return;
            }
            if (debug)
            {
                CustomConsole.WriteLineOK("Network initialization done!");
            }
        }
예제 #3
0
        public static bool NetworkCardAvailable()
        {
            PCIDevice device;

            device = PCI.GetDevice(VendorID.AMD, DeviceID.PCNETII);
            if (device != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// Get MAC Address String
        /// </summary>
        public static string PhysicalAddress()
        {
            PCIDevice device;

            device = PCI.GetDevice(VendorID.AMD, DeviceID.PCNETII);
            if (NetworkCardAvailable())
            {
                AMDPCNetII nic = new AMDPCNetII(device);
                return(nic.MACAddress.ToString());
            }
            else
            {
                return("");
            }
        }
예제 #5
0
        public static void DetectHyperVisor()
        {
            AreaInfo.HALDevInfo.WriteDevicePrefix("VIRT", "Detecting host platform...");
            PCIDevice Virtualizor = PCI.GetDevice((VendorID)PCIDevicesExtended.VendorID.Virtualbox, (DeviceID)PCIDevicesExtended.DeviceID.VirtualBox);

            Kernel.VM   = Kernel.Hypervisor.VirtualBox;
            Kernel.Host = PCIDevicesExtended.DeviceIDStr(PCIDevicesExtended.DeviceID.VirtualBox);
            if (Virtualizor == null)
            {
                Virtualizor = PCI.GetDevice(VendorID.VMWare, DeviceID.SVGAIIAdapter);
                Kernel.VM   = Kernel.Hypervisor.VMWare;
                Kernel.Host = PCIDevicesExtended.VendorIDStr(PCIDevicesExtended.VendorID.VMWare);
                if (Virtualizor == null)
                {
                    Kernel.IsVirtualised = false;
                    Kernel.VM            = Kernel.Hypervisor.RealShit;
                    Kernel.Host          = "Non-virtualised hardware or unrecognised host";
                }
            }
        }
예제 #6
0
        protected override void BeforeRun()
        {
            Console.Clear();
            #region Register additional network cards
            int i = 1;
            foreach (PCIDevice device in PCI.Devices)
            {
                if ((device.ClassCode == 0x02) && (device.Subclass == 0x00) && // is Ethernet Controller
                    device == PCI.GetDevice(device.bus, device.slot, device.function))
                {
                    Console.WriteLine("Found " + PCIDevice.DeviceClass.GetDeviceString(device) + " on PCI " + device.bus + ":" + device.slot + ":" + device.function);


                    if (device.VendorID == 0x10EC && device.DeviceID == 0x8168)
                    {
                        Console.WriteLine("RTL8168 NIC IRQ: " + device.InterruptLine);

                        var RTL8168Device = new RTL8168(device);

                        RTL8168Device.NameID = "eth" + i;

                        Console.WriteLine("Registered at " + RTL8168Device.NameID + " (" + RTL8168Device.MACAddress.ToString() + ")");

                        RTL8168Device.Enable();
                        i++;
                    }
                }
            }
            foreach (var item in Intel8254X.FindAll())
            {
                item.NameID = "eth" + i;
                item.Enable();
                Console.WriteLine("Registered at " + item.NameID + " (" + item.MACAddress.ToString() + ")");
                i++;
            }
            #endregion
            try
            {
                using (var xClient = new DHCPClient())
                {
                    /** Send a DHCP Discover packet **/
                    //This will automatically set the IP config after DHCP response
                    NetworkStack.Update();
                    int r = xClient.SendDiscoverPacket();
                    if (r == -1)
                    {
                        Console.WriteLine("Failure while configuring DHCP: timeout");
                        xClient.Close();
                        return;
                    }
                    else
                    {
                        Console.WriteLine("DHCP Configure: result: " + r);
                    }
                    xClient.Close();  //don't forget to close!
                }
                ipconfig();
            }
            catch (Exception x)
            {
                Console.WriteLine("err: " + x.Message);
            }

            NTPClient client = new NTPClient();
            var       t      = client.GetNetworkTime();
            Console.WriteLine("Curent time: " + t);

            HTTPClient http     = new HTTPClient("github.com");
            var        responce = http.GET("/test.html");
            Console.WriteLine("====");
            Console.WriteLine(responce);
        }