mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-01 13:51:02 +00:00
Update Global to call driver initialization routines for different drivers. Devices are enumerated during startup regardless of what hardware you are using. Update FrodeTest workspace to run via new NetworkDevice interface Update Builder.cs so that QEMU gets called with only either "-net tap" or "-net user", as these two options conflict Internalized most of the TCP/IP stack leaving only the User needed classes available to use. Commented most of TCP/IP stack public methods, and cleaned out code a little bit.
46 lines
2 KiB
C#
46 lines
2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Cosmos.Hardware;
|
|
using Cosmos.Sys.Network;
|
|
|
|
namespace Cosmos.Playground.Kudzu {
|
|
public class RTL8139 {
|
|
|
|
public static void Test() {
|
|
Console.WriteLine("Start server application an another host,");
|
|
Console.WriteLine("then press enter to send test packet.");
|
|
Console.ReadLine();
|
|
Console.WriteLine("Sending test packet.");
|
|
|
|
var xUDP = new Cosmos.Sys.Network.UDPPacket(
|
|
// Use a different port so it does not conflict wtih listener since we
|
|
// are using the same IP on host for testing
|
|
0x0A00020F, 32001 // 10.0.2.15
|
|
, 0xFFFFFFFF, 32000 // 255.255.255.255, Broadcast
|
|
, new byte[] { 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16 });
|
|
var xEthernet = new EthernetPacket(xUDP.GetData()
|
|
, 0x525400123457, 0xFFFFFFFFFFFF
|
|
, EthernetPacket.PacketType.IP);
|
|
|
|
Cosmos.Hardware.Network.Devices.RTL8139.RTL8139_Old.DebugOutput = false;
|
|
var xNICs = Cosmos.Hardware.Network.Devices.RTL8139.RTL8139_Old.FindAll();
|
|
var xNIC = xNICs[0];
|
|
|
|
Console.WriteLine(xNIC.Name);
|
|
Console.WriteLine("Revision: " + xNIC.HardwareRevision);
|
|
Console.WriteLine("MAC: " + xNIC.MACAddress);
|
|
|
|
Console.WriteLine("Enabling network card.");
|
|
xNIC.Enable();
|
|
xNIC.InitializeDriver();
|
|
|
|
Console.WriteLine("Sending bytes.");
|
|
var xBytes = xEthernet.GetData();
|
|
DebugUtil.WriteBinary("RTLTest", "Prepare to send packet", xBytes);
|
|
System.Diagnostics.Debugger.Break();
|
|
xNIC.TransmitBytes(xBytes);
|
|
}
|
|
|
|
}
|
|
}
|