X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fnetvis.h;h=cd451339880c4fc5d40ceaf0666df937f34461f2;hb=e4b57e21ec2bc7f99c182eea23ecec297e111799;hp=daec1cfade0116cbfa08b5632e253752b81ba8e1;hpb=229e1d6ab66a9e987ffe3cd4a8de7c7f874f6de1;p=netvis.git diff --git a/source/netvis.h b/source/netvis.h index daec1cf..cd45133 100644 --- a/source/netvis.h +++ b/source/netvis.h @@ -1,48 +1,97 @@ +/* $Id$ + +This file is part of NetVis +Copyright @ 2008 Mikko Rasa, Mikkosoft Productions +Distributed unter the GPL +*/ + #ifndef NETVIS_H_ #define NETVIS_H_ #include #include #include +#include +#include +#include +#include +#include #include -#include -#include -#include +#include +#include +#include +#include #include #include #include +#include "address.h" -class Packet; +class History; class Host; +class Packet; +class Port; +class Resolver; -class NetVis: public Msp::Application +class NetVis: public Msp::RegisteredApplication { 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; - std::list packets; - std::map hosts; - Msp::Graphics::Display *dpy; - Msp::Graphics::Window *wnd; - Msp::Graphics::GLContext *glc; - Msp::Time::TimeStamp last_tick; - std::map port_colors; + Resolver *resolver; + std::list
localnets; + + Msp::Graphics::SimpleGLWindow *wnd; Msp::GL::Font *font; - Msp::GL::Texture2D *font_tex; + + unsigned max_hosts; + unsigned max_visible_hosts; + std::map hosts; + std::map disabled_hosts; + std::list packets; + std::map ports; + History *history; + + Msp::Time::TimeStamp tick_t; + Msp::Time::TimeStamp fps_t; + unsigned frames; + float fps; public: NetVis(int, char **); - int main(); + ~NetVis(); + const Msp::GL::Font &get_font() const { return *font; } - const std::map &get_hosts() const { return hosts; } + const std::map &get_hosts() const { return hosts; } + const std::map &get_ports() const { return ports; } private: virtual void tick(); - Host &get_host(unsigned); - Msp::GL::Color &get_port_color(unsigned); + void render(); + Host &get_host(const Address &); + Msp::GL::Color generate_color(bool) const; + Port &get_port(unsigned); + 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_ipv6(CaptureContext &, const ip6_hdr *, unsigned); + void handle_tcp(CaptureContext &, const tcphdr *, unsigned); + void handle_udp(CaptureContext &, const udphdr *, unsigned); + void handle_packet(CaptureContext &); - static Application::RegApp reg; + void sighandler(int); }; #endif