]> git.tdb.fi Git - netvis.git/blob - source/netvis.h
daec1cfade0116cbfa08b5632e253752b81ba8e1
[netvis.git] / source / netvis.h
1 #ifndef NETVIS_H_
2 #define NETVIS_H_
3
4 #include <list>
5 #include <map>
6 #include <pcap.h>
7 #include <msp/core/application.h>
8 #include <msp/gbase/display.h>
9 #include <msp/gbase/glcontext.h>
10 #include <msp/gbase/window.h>
11 #include <msp/gl/color.h>
12 #include <msp/gl/font.h>
13 #include <msp/time/timestamp.h>
14
15 class Packet;
16 class Host;
17
18 class NetVis: public Msp::Application
19 {
20 private:
21         std::string iface;
22         pcap_t *pcap;
23         std::list<Packet *> packets;
24         std::map<unsigned, Host *> hosts;
25         Msp::Graphics::Display *dpy;
26         Msp::Graphics::Window *wnd;
27         Msp::Graphics::GLContext *glc;
28         Msp::Time::TimeStamp last_tick;
29         std::map<unsigned, Msp::GL::Color> port_colors;
30         Msp::GL::Font *font;
31         Msp::GL::Texture2D *font_tex;
32
33 public:
34         NetVis(int, char **);
35         int main();
36         const Msp::GL::Font &get_font() const { return *font; }
37         const std::map<unsigned, Host *> &get_hosts() const { return hosts; }
38 private:
39         virtual void tick();
40         Host &get_host(unsigned);
41         Msp::GL::Color &get_port_color(unsigned);
42
43         static void capture_handler(unsigned char *, const pcap_pkthdr *, const unsigned char *);
44
45         static Application::RegApp<NetVis> reg;
46 };
47
48 #endif