mirror of
https://github.com/genodelabs/genode.git
synced 2025-05-09 12:02:57 +00:00
nic_dump: support ICMP
Print out common header information of the Internet Control Message Protocol. Issue #2732
This commit is contained in:
parent
365bd347a6
commit
009330ab4c
@ -220,6 +220,11 @@ void Packet_log<Ipv4_packet>::print(Output &output) const
|
|||||||
print(output, " ", packet_log(*_pkt.data<Udp_packet const>(~0UL), _cfg));
|
print(output, " ", packet_log(*_pkt.data<Udp_packet const>(~0UL), _cfg));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Ipv4_packet::Protocol::ICMP:
|
||||||
|
|
||||||
|
print(output, " ", packet_log(*_pkt.data<Icmp_packet const>(~0UL), _cfg));
|
||||||
|
break;
|
||||||
|
|
||||||
default: ; }
|
default: ; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,3 +300,35 @@ void Packet_log<Udp_packet>::print(Output &output) const
|
|||||||
print(output, " ", packet_log(*_pkt.data<Dhcp_packet const>(~0UL), _cfg));
|
print(output, " ", packet_log(*_pkt.data<Dhcp_packet const>(~0UL), _cfg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
void Packet_log<Icmp_packet>::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: ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <net/dhcp.h>
|
#include <net/dhcp.h>
|
||||||
#include <net/ethernet.h>
|
#include <net/ethernet.h>
|
||||||
#include <net/tcp.h>
|
#include <net/tcp.h>
|
||||||
|
#include <net/icmp.h>
|
||||||
#include <net/ipv4.h>
|
#include <net/ipv4.h>
|
||||||
|
|
||||||
namespace Net {
|
namespace Net {
|
||||||
@ -45,18 +46,19 @@ struct Net::Packet_log_config
|
|||||||
{
|
{
|
||||||
using Style = Packet_log_style;
|
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)
|
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,
|
Packet_log_config(Style eth,
|
||||||
Style arp,
|
Style arp,
|
||||||
Style ipv4,
|
Style ipv4,
|
||||||
Style dhcp,
|
Style dhcp,
|
||||||
Style udp,
|
Style udp,
|
||||||
|
Style icmp,
|
||||||
Style tcp)
|
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 <>
|
template <>
|
||||||
void Packet_log<Udp_packet>::print(Genode::Output &output) const;
|
void Packet_log<Udp_packet>::print(Genode::Output &output) const;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
void Packet_log<Icmp_packet>::print(Genode::Output &output) const;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _PACKET_LOG_H_ */
|
#endif /* _PACKET_LOG_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user