public void ToString_Test()
        {
            var macAddress = new MACAddress
            {
                Bytes = new Byte[]
                {
                    0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC
                }
            };

            macAddress.ToString().Should().Be("12:34:56:78:9A:BC");

            macAddress.SetByte(0, 0xFF);
            macAddress.ToString().Should().Be("FF:34:56:78:9A:BC");
        }
Exemplo n.º 2
0
 public static HostName ToHostName(this MACAddress address)
 {
     return(new HostName(address.ToString()));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Converts a MAC address to a name value item with the given name
 /// </summary>
 /// <param name="strName">The name of the name value item</param>
 /// <param name="maAddress">The MAC address which should be converted to the value of the name value item</param>
 /// <returns>An array of name value items which represents the given parameters</returns>
 public static NameValueItem[] ConvertToNameValueItems(string strName, MACAddress maAddress)
 {
     return(new NameValueItem[] { new NameValueItem(strName, maAddress.ToString()) });
 }
Exemplo n.º 4
0
        public RTL8168(PCIDevice device) : base()
        {
            if (device == null)
            {
                throw new ArgumentException("PCI Device is null. Unable to get Realtek 8168 card");
            }
            pciCard = device;

            // We are handling this device
            pciCard.Claimed = true;
            BaseAddress     = pciCard.BAR0 & (~0xFU);

            Console.WriteLine("Amount of bars: " + device.BaseAddressBar.Length);
            Console.WriteLine("BAR0: " + BaseAddress);

            // Enable the card
            pciCard.EnableDevice();

            SetIrqHandler(device.InterruptLine, HandleNetworkInterrupt);

            //Ports.OutB((ushort)(BaseAddress + 0xE0), 0x08);
            Console.WriteLine("Reset");
            Reset();

            // Get the MAC Address
            byte[] eeprom_mac = new byte[6];
            for (uint b = 0; b < 6; b++)
            {
                eeprom_mac[b] = Ports.InB((ushort)(BaseAddress + b));
            }

            mac = new MACAddress(eeprom_mac);
            Console.WriteLine("MAC: " + mac.ToString());
            Console.WriteLine("Init buffers");
            InitBuffers();

            Ports.OutD((ushort)(BaseAddress + 0x44), 0x0000E70F); // Enable RX

            Ports.OutD((ushort)(BaseAddress + 0x37), 0x04);

            Ports.OutD((ushort)(BaseAddress + 0x40), 0x03000700); // Enable TX

            Ports.OutD((ushort)(BaseAddress + 0xDA), 2048);       // Max rx packet size

            Ports.OutB((ushort)(BaseAddress + 0xEC), 0x3F);       // No early transmit

            Ports.OutD((ushort)(BaseAddress + 0x20), (uint)mTxDescriptor.Offset);
            Console.WriteLine("addresstx desc: " + mTxDescriptor.Offset);

            Ports.OutD((ushort)(BaseAddress + 0xE4), (uint)mRxDescriptor.Offset);
            Console.WriteLine("addressrx desc: " + mRxDescriptor.Offset);

            if (((GetMacVersion() & 0x7cf00000) == 0x54100000) || ((GetMacVersion() & 0x7cf00000) == 0x54000000))
            {
                Console.WriteLine("8168H Detected!");

                Ports.OutD((ushort)(BaseAddress + 0x40), Ports.InD((ushort)(BaseAddress + 0x40)) | (1 << 7)); // AUTO TX FIFO
            }

            Ports.OutW((ushort)(BaseAddress + 0x3C), 0xC3FF); //Activating all Interrupts

            Ports.OutB((ushort)(BaseAddress + 0x37), 0x0C);   // Enabling receive and transmit

            //Console.WriteLine("Netcard version: 0x" + System.Utils.Conversion.DecToHex((int)GetMacVersion() & 0x7cf00000));
            //Console.WriteLine("Netcard version: 0x" + System.Utils.Conversion.DecToHex((int)GetMacVersion() & 0x7c800000));
        }