Distributed unter the GPL
*/
-#include <iostream>
#include <limits>
#include <cstdlib>
#include <cmath>
using namespace Msp;
NetVis::NetVis(int argc, char **argv):
+ pcap(0),
+ resolver(0),
+ wnd(0),
+ font(0),
max_hosts(1000),
max_visible_hosts(30),
draw_labels(true),
if(argc<2)
throw UsageError("No interface given");
iface = argv[1];
-}
-int NetVis::main()
-{
char err[1024];
pcap = pcap_open_live(iface.c_str(), 128, true, 0, err);
if(!pcap)
localnet = ntohl(localnet);
localnet_mask = ntohl(localnet_mask);
- dpy = new Graphics::Display;
- wnd = new Graphics::Window(*dpy, 1024, 768);
- glc = new Graphics::GLContext(*wnd);
+ resolver = new Resolver;
+
+ 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));
DataFile::load(*font, "dejavu-10.font");
catch_signal(SIGINT);
+}
- resolver = new Resolver;
-
- //set_loop_mode(TICK_BUSY);
-
- Application::main();
-
+NetVis::~NetVis()
+{
delete resolver;
delete font;
- delete glc;
delete wnd;
- delete dpy;
-
- cout<<hosts.size()+disabled_hosts.size()<<" different hosts seen\n";
- cout<<"capture: "<<profiler.scope("capture").total_time<<'\n';
- cout<<"tick: "<<profiler.scope("tick").total_time<<'\n';
- cout<<"render: "<<profiler.scope("render").total_time<<'\n';
pcap_close(pcap);
for(map<unsigned, Host *>::iterator i=hosts.begin(); i!=hosts.end(); ++i)
delete i->second;
for(list<Packet *>::iterator i=packets.begin(); i!=packets.end(); ++i)
delete *i;
-
- return exit_code;
}
void NetVis::tick()
frames = 0;
}
- dpy->tick();
+ wnd->get_display().tick();
{
Debug::ProfilingScope s(profiler, "capture");
GL::pop_matrix();
GL::Texture::unbind();
- glc->swap_buffers();
+ wnd->swap_buffers();
}
++frames;