]> git.tdb.fi Git - netvis.git/blob - source/netvis.h
Resolve port names
[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 Port;
26 class Resolver;
27
28 class NetVis: public Msp::Application
29 {
30 private:
31         std::string iface;
32         pcap_t *pcap;
33         Resolver *resolver;
34         unsigned localnet;
35         unsigned localnet_mask;
36
37         Msp::Graphics::SimpleGLWindow *wnd;
38         Msp::GL::Font *font;
39
40         unsigned max_hosts;
41         unsigned max_visible_hosts;
42         std::map<unsigned, Host *> hosts;
43         std::map<unsigned, Host *> disabled_hosts;
44         std::list<Packet *> packets;
45         std::map<unsigned, Port> ports;
46         bool draw_labels;
47         bool blend;
48
49         Msp::Time::TimeStamp tick_t;
50         Msp::Time::TimeStamp fps_t;
51         unsigned frames;
52         float fps;
53
54         Msp::Debug::Profiler profiler;
55
56 public:
57         NetVis(int, char **);
58         ~NetVis();
59
60         const Msp::GL::Font &get_font() const { return *font; }
61         const std::map<unsigned, Host *> &get_hosts() const { return hosts; }
62 private:
63         virtual void tick();
64         Host &get_host(unsigned);
65         Msp::GL::Color generate_color(bool) const;
66         const Port &get_port(unsigned);
67         void key_press(unsigned, unsigned, wchar_t);
68
69         static void capture_handler(unsigned char *, const pcap_pkthdr *, const unsigned char *);
70
71         void sighandler(int);
72
73         static Application::RegApp<NetVis> reg;
74 };
75
76 #endif