Kernel: Print to debug log ICMP unreachable messages

These messages should be forwarded to underlying sockets
This commit is contained in:
Bananymous 2024-02-25 21:32:37 +02:00
parent 6ebfe05fce
commit efdc4817bb
2 changed files with 8 additions and 0 deletions

View File

@ -18,6 +18,7 @@ namespace Kernel
enum ICMPType : uint8_t
{
EchoReply = 0x00,
DestinationUnreachable = 0x03,
EchoRequest = 0x08,
};

View File

@ -212,6 +212,13 @@ namespace Kernel
TRY(interface.send_bytes(dst_mac, EtherType::IPv4, packet));
break;
}
case ICMPType::DestinationUnreachable:
{
auto& ipv4_header = ipv4_data.slice(sizeof(ICMPHeader)).as<const IPv4Header>();
dprintln("Destination '{}' unreachable, code {2H}", ipv4_header.dst_address, icmp_header.code);
// FIXME: inform the socket
break;
}
default:
dprintln("Unhandleded ICMP packet (type {2H})", icmp_header.type);
break;