- unsigned size=ntohs(ip->tot_len);
- unsigned port=0;
- if(ip->protocol==IPPROTO_TCP)
- {
- const tcphdr *tcp=reinterpret_cast<const tcphdr *>(ip+1);
- port=min(ntohs(tcp->source), ntohs(tcp->dest));
- }
- else if(ip->protocol==IPPROTO_UDP)
- {
- const udphdr *udp=reinterpret_cast<const udphdr *>(ip+1);
- port=min(ntohs(udp->source), ntohs(udp->dest));
- }
- Host &shost=self->get_host(ntohl(ip->saddr));
- Host *dhost=0;
- if((ntohl(ip->daddr)&0xFF)!=0xFF)
- dhost=&self->get_host(ntohl(ip->daddr));
+void NetVis::handle_tcp(CaptureContext &ctx, const tcphdr *tcp, unsigned)
+{
+ ctx.src_port = &get_port(ntohs(tcp->source));
+ ctx.dst_port = &get_port(ntohs(tcp->dest));
+ handle_packet(ctx);
+}
+
+void NetVis::handle_udp(CaptureContext &ctx, const udphdr *udp, unsigned)
+{
+ ctx.src_port = &get_port(ntohs(udp->source));
+ ctx.dst_port = &get_port(ntohs(udp->dest));
+ 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);
+}