X-Git-Url: http://git.tdb.fi/?p=netvis.git;a=blobdiff_plain;f=source%2Fnetvis.cpp;h=ff05507a2fc04364d31d1814037b9c247b1bdbbe;hp=fb02c0dde99d13828a35d07c38e5b5ecf6c8bd9f;hb=398c5e3e6e03080b6b057fd56858ab04694969ed;hpb=d44d45bee2c3b6b5a8822ecdc23528dcf039ee2a diff --git a/source/netvis.cpp b/source/netvis.cpp index fb02c0d..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" @@ -73,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); } @@ -114,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) @@ -221,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) @@ -288,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); } }