diff --git a/repos/os/src/server/nic_dump/packet_log.cc b/repos/os/src/server/nic_dump/packet_log.cc index 41fd8febd7..bdadb11d4a 100644 --- a/repos/os/src/server/nic_dump/packet_log.cc +++ b/repos/os/src/server/nic_dump/packet_log.cc @@ -220,6 +220,11 @@ void Packet_log::print(Output &output) const print(output, " ", packet_log(*_pkt.data(~0UL), _cfg)); break; + case Ipv4_packet::Protocol::ICMP: + + print(output, " ", packet_log(*_pkt.data(~0UL), _cfg)); + break; + default: ; } } @@ -295,3 +300,35 @@ void Packet_log::print(Output &output) const print(output, " ", packet_log(*_pkt.data(~0UL), _cfg)); } } + + +template <> +void Packet_log::print(Output &output) const +{ + using Genode::print; + + /* print header attributes */ + switch (_cfg.icmp) { + case Packet_log_style::COMPREHENSIVE: + + print(output, "\033[32mICMP\033[0m"); + print(output, " typ ", (unsigned)_pkt.type()); + print(output, " cod ", (unsigned)_pkt.code()); + print(output, " crc ", _pkt.checksum()); + print(output, " roh ", _pkt.rest_of_header()); + break; + + case Packet_log_style::COMPACT: + + print(output, "\033[32mICMP\033[0m ", (unsigned)_pkt.type(), " ", + (unsigned)_pkt.code()); + break; + + case Packet_log_style::SHORT: + + print(output, "\033[32mICMP\033[0m"); + break; + + default: ; + } +} diff --git a/repos/os/src/server/nic_dump/packet_log.h b/repos/os/src/server/nic_dump/packet_log.h index eb5e8cfef3..5b2a66ecb0 100644 --- a/repos/os/src/server/nic_dump/packet_log.h +++ b/repos/os/src/server/nic_dump/packet_log.h @@ -22,6 +22,7 @@ #include #include #include +#include #include namespace Net { @@ -45,18 +46,19 @@ struct Net::Packet_log_config { using Style = Packet_log_style; - Style eth, arp, ipv4, dhcp, udp, tcp; + Style eth, arp, ipv4, dhcp, udp, icmp, tcp; Packet_log_config(Style def = Style::COMPACT) - : eth(def), arp(def), ipv4(def), dhcp(def), udp(def), tcp(def) { } + : eth(def), arp(def), ipv4(def), dhcp(def), udp(def), icmp(def), tcp(def) { } Packet_log_config(Style eth, Style arp, Style ipv4, Style dhcp, Style udp, + Style icmp, Style tcp) - : eth(eth), arp(arp), ipv4(ipv4), dhcp(dhcp), udp(udp), tcp(tcp) { } + : eth(eth), arp(arp), ipv4(ipv4), dhcp(dhcp), udp(udp), icmp(icmp), tcp(tcp) { } }; @@ -114,6 +116,9 @@ namespace Net { template <> void Packet_log::print(Genode::Output &output) const; + + template <> + void Packet_log::print(Genode::Output &output) const; } #endif /* _PACKET_LOG_H_ */