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;