From d1108ea9e4b0de6bf5f66670a200bcd46d4b5e0b Mon Sep 17 00:00:00 2001 From: Jan Bronicki Date: Tue, 25 May 2021 03:02:40 +0200 Subject: [PATCH] [#5] Fixed basic issues in ICMP, now works, but bad checksum --- .../NetworkServer/Modules/IcmpServerModule.cs | 50 +++++++++++++------ 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/src/Renode/Network/NetworkServer/Modules/IcmpServerModule.cs b/src/Renode/Network/NetworkServer/Modules/IcmpServerModule.cs index f032e4720..59928b587 100644 --- a/src/Renode/Network/NetworkServer/Modules/IcmpServerModule.cs +++ b/src/Renode/Network/NetworkServer/Modules/IcmpServerModule.cs @@ -52,9 +52,9 @@ public void HandleIcmpPacket(Action FrameReady, IPv4Packet ipv4Pa ParentServer.Log(LogLevel.Warning, "Failed to create an ICMPv4 response for this packet: {0}", (ICMPv4Packet)ipv4Packet.PayloadPacket); return; } - + ParentServer.Log(LogLevel.Noisy, "Dupa 1"); var ipv4ResponsePacket = CreateIPv4Packet(ipv4Packet); - + ParentServer.Log(LogLevel.Noisy, "Dupa 2"); if (!CreateEthernetFramePacket(ipv4ResponsePacket, icmpv4PacketResponse, icmpDestinationAddress, out var response)) { ParentServer.Log(LogLevel.Warning, "Failed to create an EthernetFramePacket response for this packet: {0}", (ICMPv4Packet)ipv4Packet.PayloadPacket); @@ -85,7 +85,7 @@ private bool CreateIcmpResponse(IPv4Packet ipv4Packet, out ICMPv4Packet icmpPack } icmpPacketResponse = CreateIcmpv4Packet(ipv4Packet, byteReply); - ParentServer.Log(LogLevel.Noisy, "Created an ICMPv4 response: {0}", icmpPacketResponse.PayloadPacket); + ParentServer.Log(LogLevel.Noisy, "Created an ICMPv4 response: {0}", icmpPacketResponse); return true; } @@ -101,10 +101,9 @@ private bool GetReplyIfRequestSupported(IPv4Packet ipv4Packet, out byte[] byteRe { // byteReply = null; byteReply = new byte[8]; - for (var i=0; i - /// Creates an IPv4 response packet + /// Creates an IPv4 response packet from a given IPv4 packet /// /// /// private IPv4Packet CreateIPv4Packet(IPv4Packet ipv4Packet) { - var ipv4PacketResponse = new IPv4Packet(IP, - ((IPv4Packet)ipv4Packet.ParentPacket).SourceAddress); - + ParentServer.Log(LogLevel.Noisy, "Creating IPv4 packet response"); + // var ipv4PacketResponse = new IPv4Packet(IP, + // ((IPv4Packet)ipv4Packet.ParentPacket).SourceAddress); + var ipv4PacketResponse = new IPv4Packet(IP, ipv4Packet.SourceAddress); ParentServer.Log(LogLevel.Noisy, "Created IPv4 packet response"); return ipv4PacketResponse; }