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/ip.h>
16 #include <netinet/ip6.h>
17 #include <netinet/tcp.h>
18 #include <netinet/udp.h>
19 #include <msp/core/application.h>
20 #include <msp/debug/profiler.h>
21 #include <msp/graphics/display.h>
22 #include <msp/graphics/glcontext.h>
23 #include <msp/graphics/simplewindow.h>
24 #include <msp/gl/color.h>
25 #include <msp/gl/font.h>
26 #include <msp/time/timestamp.h>
35 class NetVis: public Msp::RegisteredApplication<NetVis>
40 const pcap_pkthdr *cap_hdr;
53 std::list<Address> localnets;
55 Msp::Graphics::SimpleGLWindow *wnd;
59 unsigned max_visible_hosts;
60 std::map<Address, Host *> hosts;
61 std::map<Address, Host *> disabled_hosts;
62 std::list<Packet *> packets;
63 std::map<unsigned, Port *> ports;
66 Msp::Time::TimeStamp tick_t;
67 Msp::Time::TimeStamp fps_t;
75 const Msp::GL::Font &get_font() const { return *font; }
76 const std::map<Address, Host *> &get_hosts() const { return hosts; }
77 const std::map<unsigned, Port *> &get_ports() const { return ports; }
81 Host &get_host(const Address &);
82 Msp::GL::Color generate_color(bool) const;
83 Port &get_port(unsigned);
84 void create_history_texture();
86 static void capture_handler(unsigned char *, const pcap_pkthdr *, const unsigned char *);
87 void handle_ethernet(CaptureContext &, const ethhdr *, unsigned);
88 void handle_ipv4(CaptureContext &, const iphdr *, unsigned);
89 void handle_ipv6(CaptureContext &, const ip6_hdr *, unsigned);
90 void handle_tcp(CaptureContext &, const tcphdr *, unsigned);
91 void handle_udp(CaptureContext &, const udphdr *, unsigned);
92 void handle_packet(CaptureContext &);