]> git.tdb.fi Git - netvis.git/blobdiff - source/netvis.h
Restructure packet handling
[netvis.git] / source / netvis.h
index a205d0564af72b89e340173b212614cc54a5c404..68eed052f3649255d4d9ee74655e624a89327968 100644 (file)
@@ -11,11 +11,15 @@ Distributed unter the GPL
 #include <list>
 #include <map>
 #include <pcap.h>
+#include <netinet/ether.h>
+#include <netinet/ip.h>
+#include <netinet/tcp.h>
+#include <netinet/udp.h>
 #include <msp/core/application.h>
 #include <msp/debug/profiler.h>
-#include <msp/gbase/display.h>
-#include <msp/gbase/glcontext.h>
-#include <msp/gbase/simplewindow.h>
+#include <msp/graphics/display.h>
+#include <msp/graphics/glcontext.h>
+#include <msp/graphics/simplewindow.h>
 #include <msp/gl/color.h>
 #include <msp/gl/font.h>
 #include <msp/time/timestamp.h>
@@ -26,9 +30,21 @@ class Packet;
 class Port;
 class Resolver;
 
-class NetVis: public Msp::Application
+class NetVis: public Msp::RegisteredApplication<NetVis>
 {
 private:
+       struct CaptureContext
+       {
+               const pcap_pkthdr *cap_hdr;
+               Host *src_host;
+               Port *src_port;
+               Host *dst_host;
+               Port *dst_port;
+               unsigned size;
+
+               CaptureContext();
+       };
+
        std::string iface;
        pcap_t *pcap;
        Resolver *resolver;
@@ -67,10 +83,13 @@ private:
        void create_history_texture();
 
        static void capture_handler(unsigned char *, const pcap_pkthdr *, const unsigned char *);
+       void handle_ethernet(CaptureContext &, const ethhdr *, unsigned);
+       void handle_ipv4(CaptureContext &, const iphdr *, unsigned);
+       void handle_tcp(CaptureContext &, const tcphdr *, unsigned);
+       void handle_udp(CaptureContext &, const udphdr *, unsigned);
+       void handle_packet(CaptureContext &);
 
        void sighandler(int);
-
-       static Application::RegApp<NetVis> reg;
 };
 
 #endif