]> git.tdb.fi Git - netvis.git/blob - source/netvis.h
47f5de5bd31e7b05ea80248fe1ae32f32ffa5669
[netvis.git] / source / netvis.h
1 /* $Id$
2
3 This file is part of NetVis
4 Copyright @ 2008 Mikko Rasa, Mikkosoft Productions
5 Distributed unter the GPL
6 */
7
8 #ifndef NETVIS_H_
9 #define NETVIS_H_
10
11 #include <list>
12 #include <map>
13 #include <pcap.h>
14 #include <msp/core/application.h>
15 #include <msp/debug/profiler.h>
16 #include <msp/gbase/display.h>
17 #include <msp/gbase/glcontext.h>
18 #include <msp/gbase/simplewindow.h>
19 #include <msp/gl/color.h>
20 #include <msp/gl/font.h>
21 #include <msp/time/timestamp.h>
22
23 class Host;
24 class Packet;
25 class Resolver;
26
27 class NetVis: public Msp::Application
28 {
29 private:
30         std::string iface;
31         pcap_t *pcap;
32         Resolver *resolver;
33         unsigned localnet;
34         unsigned localnet_mask;
35
36         Msp::Graphics::SimpleGLWindow *wnd;
37         Msp::GL::Font *font;
38
39         unsigned max_hosts;
40         unsigned max_visible_hosts;
41         std::map<unsigned, Host *> hosts;
42         std::map<unsigned, Host *> disabled_hosts;
43         std::list<Packet *> packets;
44         std::map<unsigned, Msp::GL::Color> port_colors;
45         bool draw_labels;
46         bool blend;
47
48         Msp::Time::TimeStamp tick_t;
49         Msp::Time::TimeStamp fps_t;
50         unsigned frames;
51         float fps;
52
53         Msp::Debug::Profiler profiler;
54
55 public:
56         NetVis(int, char **);
57         ~NetVis();
58
59         const Msp::GL::Font &get_font() const { return *font; }
60         const std::map<unsigned, Host *> &get_hosts() const { return hosts; }
61 private:
62         virtual void tick();
63         Host &get_host(unsigned);
64         Msp::GL::Color &get_port_color(unsigned);
65         void key_press(unsigned, unsigned, wchar_t);
66
67         static void capture_handler(unsigned char *, const pcap_pkthdr *, const unsigned char *);
68
69         void sighandler(int);
70
71         static Application::RegApp<NetVis> reg;
72 };
73
74 #endif