Skip to content

Commit

Permalink
Udp sending works now.
Browse files Browse the repository at this point in the history
  • Loading branch information
mterwoord committed Dec 7, 2014
1 parent 1b4627a commit 145b2e7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Users/Matthijs/PlaygroundSystem/HALGlobal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void Execute()
NetworkStack.ConfigIP(xNic, new Config(new Address(192, 168, 17, 100), new Address(255, 255, 255, 0)));

var xClient = new UdpClient(15);
xClient.Connect(new Address(192, 168, 17, 101), 25);
xClient.Connect(new Address(192, 168, 17, 1), 25);
xClient.Send(new byte[]
{
1,
Expand Down
1 change: 0 additions & 1 deletion source/Cosmos.System/Network/ARP/ARPPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ internal ARPPacket(byte[] rawData)

protected override void initFields()
{
Sys.Console.WriteLine("ARPPacket.initFields called");
base.initFields();
aHardwareType = (UInt16)((mRawData[14] << 8) | mRawData[15]);
aProtocolType = (UInt16)((mRawData[16] << 8) | mRawData[17]);
Expand Down
1 change: 0 additions & 1 deletion source/Cosmos.System/Network/EthernetPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ protected EthernetPacket(byte[] rawData)

protected virtual void initFields()
{
global::System.Console.WriteLine("EthernetPacket.InitFields called");
destMAC = new MACAddress(mRawData, 0);
srcMAC = new MACAddress(mRawData, 6);
aEtherType = (UInt16)((mRawData[12] << 8) | mRawData[13]);
Expand Down
4 changes: 3 additions & 1 deletion source/Cosmos.System/Network/IPv4/OutgoingBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,13 @@ internal static void ARPCache_Update(ARPReply_Ethernet arp_reply)
BufferEntry entry = queue[e];
if (entry.Status == BufferEntry.EntryStatus.ARP_SENT)
{
var xDestIP = entry.Packet.DestinationIP.Hash;
var xSenderIP = arp_reply.SenderIP.Hash;
if (entry.Packet.DestinationIP.CompareTo(arp_reply.SenderIP) == 0)
{
entry.Packet.DestinationMAC = arp_reply.SenderMAC;

entry.Status = BufferEntry.EntryStatus.JUST_SEND;
entry.Status = BufferEntry.EntryStatus.DONE;
}
}
else if (entry.Status == BufferEntry.EntryStatus.ROUTE_ARP_SENT)
Expand Down
9 changes: 7 additions & 2 deletions source/Cosmos.System/Network/NetworkStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ public static void ConfigIP(NetworkDevice nic, IPv4.Config config)

internal static void HandlePacket(byte[] packetData)
{
//Sys.Console.Write("Received Packet Length=");
//Sys.Console.WriteLine(packetData.Length);
Sys.Console.Write("Received Packet Length=");
if (packetData == null)
{
Sys.Console.WriteLine("**NULL**");
return;
}
Sys.Console.WriteLine(packetData.Length);
//Sys.Console.WriteLine(BitConverter.ToString(packetData));

UInt16 etherType = (UInt16)((packetData[12] << 8) | packetData[13]);
Expand Down

0 comments on commit 145b2e7

Please sign in to comment.