X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fnetvis.cpp;h=ff05507a2fc04364d31d1814037b9c247b1bdbbe;hb=398c5e3e6e03080b6b057fd56858ab04694969ed;hp=bcdba3f28c6314ff1ebf72a9891181e797dba08d;hpb=42bd2e83d66a98584540dd8cc5b47ee2349fe844;p=netvis.git diff --git a/source/netvis.cpp b/source/netvis.cpp index bcdba3f..ff05507 100644 --- a/source/netvis.cpp +++ b/source/netvis.cpp @@ -9,10 +9,10 @@ Distributed unter the GPL #include #include #include +#include #include #include #include -#include #include #include #include @@ -26,6 +26,7 @@ Distributed unter the GPL #include #include #include +#include "history.h" #include "host.h" #include "netvis.h" #include "packet.h" @@ -42,8 +43,6 @@ NetVis::NetVis(int argc, char **argv): font(0), max_hosts(1000), max_visible_hosts(30), - draw_labels(true), - blend(true), frames(0) { if(argc<2) @@ -67,7 +66,6 @@ NetVis::NetVis(int argc, char **argv): wnd = new Graphics::SimpleGLWindow(1024, 768); wnd->set_title("NetVis"); wnd->signal_close.connect(sigc::bind(sigc::mem_fun(this, &NetVis::exit), 0)); - wnd->signal_key_press.connect(sigc::mem_fun(this, &NetVis::key_press)); wnd->show(); GL::enable(GL::BLEND); @@ -76,6 +74,8 @@ NetVis::NetVis(int argc, char **argv): font = new GL::Font; DataFile::load(*font, "dejavu-10.font"); + history = new History(*this, 301, 100); + catch_signal(SIGINT); } @@ -117,6 +117,8 @@ void NetVis::tick() while(pcap_dispatch(pcap, -1, &capture_handler, reinterpret_cast(this))>0) ; resolver->tick(); + history->tick(tick_t); + float min_activity = numeric_limits::max(); for(map::iterator i=hosts.begin(); i!=hosts.end(); ++i) @@ -224,6 +226,11 @@ void NetVis::render() font->draw_string(format("%.2f fps", fps)); GL::Texture::unbind(); GL::pop_matrix(); + + GL::push_matrix(); + GL::translate(170, -370, 0); + history->render(); + GL::pop_matrix(); } Host &NetVis::get_host(unsigned a) @@ -255,17 +262,6 @@ const Port &NetVis::get_port(unsigned number) return *port; } -void NetVis::key_press(unsigned key, unsigned, wchar_t) -{ - if(key==46) - draw_labels = !draw_labels; - else if(key==56) - { - blend = !blend; - GL::set(GL_BLEND, blend); - } -} - void NetVis::capture_handler(unsigned char *user, const pcap_pkthdr *, const unsigned char *data) { NetVis *self = reinterpret_cast(user); @@ -302,6 +298,11 @@ void NetVis::capture_handler(unsigned char *user, const pcap_pkthdr *, const uns shost.add_activity(size); if(dhost) dhost->add_activity(size); + + if((ntohl(ip->saddr)&self->localnet_mask)==self->localnet) + self->history->activity(0, size); + else if((ntohl(ip->daddr)&self->localnet_mask)==self->localnet) + self->history->activity(size, 0); } }