3 This file is part of NetVis
4 Copyright @ 2008 Mikko Rasa, Mikkosoft Productions
5 Distributed unter the GPL
14 #include <netinet/ether.h>
15 #include <netinet/icmp6.h>
16 #include <netinet/ip.h>
17 #include <netinet/ip_icmp.h>
18 #include <netinet/ip6.h>
19 #include <netinet/tcp.h>
20 #include <netinet/udp.h>
21 #include <msp/core/application.h>
22 #include <msp/debug/profiler.h>
23 #include <msp/graphics/display.h>
24 #include <msp/graphics/glcontext.h>
25 #include <msp/graphics/simplewindow.h>
26 #include <msp/gl/color.h>
27 #include <msp/gl/font.h>
28 #include <msp/time/timestamp.h>
37 class NetVis: public Msp::RegisteredApplication<NetVis>
42 const pcap_pkthdr *cap_hdr;
55 std::list<Address> localnets;
57 Msp::Graphics::SimpleGLWindow *wnd;
61 unsigned max_visible_hosts;
62 std::map<Address, Host *> hosts;
63 std::map<Address, Host *> disabled_hosts;
64 std::list<Packet *> packets;
65 std::map<unsigned, Port *> ports;
68 Msp::Time::TimeStamp tick_t;
69 Msp::Time::TimeStamp fps_t;
77 const Msp::GL::Font &get_font() const { return *font; }
78 const std::map<Address, Host *> &get_hosts() const { return hosts; }
79 const std::map<unsigned, Port *> &get_ports() const { return ports; }
83 Host &get_host(const Address &);
84 Msp::GL::Color generate_color(bool) const;
85 Port &get_port(unsigned);
86 void create_history_texture();
88 static void capture_handler(unsigned char *, const pcap_pkthdr *, const unsigned char *);
89 void handle_ethernet(CaptureContext &, const ethhdr *, unsigned);
90 void handle_ipv4(CaptureContext &, const iphdr *, unsigned);
91 void handle_ipv6(CaptureContext &, const ip6_hdr *, unsigned);
92 void handle_tcp(CaptureContext &, const tcphdr *, unsigned);
93 void handle_udp(CaptureContext &, const udphdr *, unsigned);
94 void handle_icmp(CaptureContext &, const icmphdr *, unsigned);
95 void handle_icmp6(CaptureContext &, const icmp6_hdr *, unsigned);
96 void handle_packet(CaptureContext &);