]> git.tdb.fi Git - netvis.git/blobdiff - source/netvis.h
Initial revision
[netvis.git] / source / netvis.h
diff --git a/source/netvis.h b/source/netvis.h
new file mode 100644 (file)
index 0000000..daec1cf
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef NETVIS_H_
+#define NETVIS_H_
+
+#include <list>
+#include <map>
+#include <pcap.h>
+#include <msp/core/application.h>
+#include <msp/gbase/display.h>
+#include <msp/gbase/glcontext.h>
+#include <msp/gbase/window.h>
+#include <msp/gl/color.h>
+#include <msp/gl/font.h>
+#include <msp/time/timestamp.h>
+
+class Packet;
+class Host;
+
+class NetVis: public Msp::Application
+{
+private:
+       std::string iface;
+       pcap_t *pcap;
+       std::list<Packet *> packets;
+       std::map<unsigned, Host *> hosts;
+       Msp::Graphics::Display *dpy;
+       Msp::Graphics::Window *wnd;
+       Msp::Graphics::GLContext *glc;
+       Msp::Time::TimeStamp last_tick;
+       std::map<unsigned, Msp::GL::Color> port_colors;
+       Msp::GL::Font *font;
+       Msp::GL::Texture2D *font_tex;
+
+public:
+       NetVis(int, char **);
+       int main();
+       const Msp::GL::Font &get_font() const { return *font; }
+       const std::map<unsigned, Host *> &get_hosts() const { return hosts; }
+private:
+       virtual void tick();
+       Host &get_host(unsigned);
+       Msp::GL::Color &get_port_color(unsigned);
+
+       static void capture_handler(unsigned char *, const pcap_pkthdr *, const unsigned char *);
+
+       static Application::RegApp<NetVis> reg;
+};
+
+#endif