if(i!=ports.end())
return *i->second;
Port *port = new Port(*this, number);
+ if(number>=0x10000)
+ {
+ if((number&0xFF)==IPPROTO_ICMP)
+ port->set_name("icmp");
+ else if((number&0xFF)==IPPROTO_ICMPV6)
+ port->set_name("icmp6");
+ }
ports[number] = port;
return *port;
}
const udphdr *udp = reinterpret_cast<const udphdr *>(ip+1);
handle_udp(ctx, udp, len-sizeof(iphdr));
}
+ else if(ip->protocol==IPPROTO_ICMP)
+ {
+ const icmphdr *icmp = reinterpret_cast<const icmphdr *>(ip+1);
+ handle_icmp(ctx, icmp, len-sizeof(iphdr));
+ }
else
IO::print("Unknown protocol in ip: %d\n", ip->protocol);
}
const udphdr *udp = reinterpret_cast<const udphdr *>(ip6+1);
handle_udp(ctx, udp, len-sizeof(ip6_hdr));
}
+ else if(ip6->ip6_nxt==IPPROTO_ICMPV6)
+ {
+ const icmp6_hdr *icmp6 = reinterpret_cast<const icmp6_hdr *>(ip6+1);
+ handle_icmp6(ctx, icmp6, len-sizeof(ip6_hdr));
+ }
else
IO::print("Unknown next header in ip6: %d\n", ip6->ip6_nxt);
}
handle_packet(ctx);
}
+void NetVis::handle_icmp(CaptureContext &ctx, const icmphdr *, unsigned)
+{
+ ctx.src_port = &get_port(0x10000|IPPROTO_ICMP);
+ ctx.dst_port = ctx.src_port;
+ handle_packet(ctx);
+}
+
+void NetVis::handle_icmp6(CaptureContext &ctx, const icmp6_hdr *, unsigned)
+{
+ ctx.src_port = &get_port(0x10000|IPPROTO_ICMPV6);
+ ctx.dst_port = ctx.src_port;
+ handle_packet(ctx);
+}
+
void NetVis::handle_packet(CaptureContext &ctx)
{
Port *port = 0;
#include <map>
#include <pcap.h>
#include <netinet/ether.h>
+#include <netinet/icmp6.h>
#include <netinet/ip.h>
+#include <netinet/ip_icmp.h>
#include <netinet/ip6.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
void handle_ipv6(CaptureContext &, const ip6_hdr *, unsigned);
void handle_tcp(CaptureContext &, const tcphdr *, unsigned);
void handle_udp(CaptureContext &, const udphdr *, unsigned);
+ void handle_icmp(CaptureContext &, const icmphdr *, unsigned);
+ void handle_icmp6(CaptureContext &, const icmp6_hdr *, unsigned);
void handle_packet(CaptureContext &);
void sighandler(int);
unsigned get_number() const { return number; }
bool is_registered() const { return registered; }
+ void set_name(const std::string &);
const std::string &get_name() const { return name; }
const Msp::GL::Color &get_color() const { return color; }