wmpSniffer.cc
Go to the documentation of this file.
00001 /*------------------------------------------------------------------------
00002  *---------------------           WMPSNIFFER          --------------------
00003  *------------------------------------------------------------------------
00004  *                                                         V7.0B  11/05/10
00005  *
00006  *
00007  *  File: wmpSniffer.cc
00008  *  Authors: Danilo Tardioli
00009  *  ----------------------------------------------------------------------
00010  *  Copyright (C) 2000-2012, Universidad de Zaragoza, SPAIN
00011  *
00012  *  Contact Addresses: Danilo Tardioli                   dantard@unizar.es
00013  *
00014  *  RT-WMP is free software; you can  redistribute it and/or  modify it
00015  *  under the terms of the GNU General Public License  as published by the
00016  *  Free Software Foundation;  either  version 2, or (at  your option) any
00017  *  later version.
00018  *
00019  *  RT-WMP  is distributed  in the  hope  that  it will be   useful, but
00020  *  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
00021  *  MERCHANTABILITY  or  FITNESS FOR A  PARTICULAR PURPOSE.    See the GNU
00022  *  General Public License for more details.
00023  *
00024  *  You should have received  a  copy of  the  GNU General Public  License
00025  *  distributed with RT-WMP;  see file COPYING.   If not,  write to the
00026  *  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
00027  *  02111-1307, USA.
00028  *
00029  *  As a  special exception, if you  link this  unit  with other  files to
00030  *  produce an   executable,   this unit  does  not  by  itself cause  the
00031  *  resulting executable to be covered by the  GNU General Public License.
00032  *  This exception does  not however invalidate  any other reasons why the
00033  *  executable file might be covered by the GNU Public License.
00034  *
00035  *----------------------------------------------------------------------*/
00036 
00037 #include <sys/types.h>
00038 #include <unistd.h>
00039 using namespace std;
00040 
00041 //#include <config.h>
00042 #include <gtkmm/main.h>
00043 
00044 #include "main_window.hh"
00045 #include "bridge.hh"
00046 #include "misc.h"
00047 #include "BoundedHash.h"
00048 #include <glibmm/keyfile.h>
00049 #include <signal.h>
00050 #include <pcap_layer.h>
00051 
00052 char iface[16];
00053 char sniff_iface[16];
00054 
00055 void sig_hand(int n) {
00056         Gtk::Main::quit();
00057 }
00058 
00059 int main(int argc, char **argv) {
00060 
00061         char * param = NULL;
00062         if (argc > 2) {
00063                 fprintf(
00064                                 stderr,
00065                                 "wmpSniffer v0.1\nUsage: %s [sniff iface]\nSet recording parameters in %s.conf\n",
00066                                 argv[0], argv[0]);
00067                 exit(0);
00068         } else if (argc == 2) {
00069                 param = argv[1];
00070         }
00071 
00072         if (argc==1){
00073                 pcap_init(strdup("lo"), 3);
00074         }else{
00075             pcap_init(strdup(argv[1]), 3);
00076                         
00077         }
00078         pid_t pID = vfork(); //smarter fork, pauses parent process till done
00079         if (pID == 0) {
00080 
00081                 setresuid(getuid(), getuid(), getuid()); //set all UID's
00082                 setresgid(getgid(), getgid(), getgid()); //set all GID's
00083 
00084                 g_thread_init(NULL);
00085                 gdk_threads_init();
00086 
00087                 Gtk::Main m(&argc, &argv);
00088                 main_window *main_window = new class main_window(param);
00089                 Gtk::Main::signal_quit().connect(
00090                                 sigc::mem_fun(main_window, &main_window::on_exit));
00091                 signal(SIGINT, sig_hand);
00092 
00093                 gdk_threads_enter();
00094                 try {
00095                         m.run(*main_window);
00096                 } catch (...) {
00097 
00098                 }
00099                 gdk_threads_leave();
00100 
00101                 delete main_window;
00102                 _exit(0);
00103         } else{
00104                 return 0;
00105         }
00106 }


ros_rt_wmp_sniffer
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Mon Oct 6 2014 08:27:58