find devices
This commit is contained in:
parent
cc32b4bdcd
commit
2a5788d69b
1 changed files with 26 additions and 2 deletions
28
Riddle.cpp
28
Riddle.cpp
|
@ -49,6 +49,7 @@ int main ( int argc, char **argv ) {
|
|||
( "help,h", "prints this" )
|
||||
( "dump,d", "enable dump mode" )
|
||||
( "iface,i", value< string >(), "interface to sniff from. [auto]" )
|
||||
( "iface-list,y", "prints all available devices." )
|
||||
( "input,I", value< string >(), "reads packets from a pcap file (disable iface input)" )
|
||||
( "filter,f", value< vector< string > >()->multitoken(), "use to filter packet with bpf" )
|
||||
( "limit,l", value< int >(), "set max number of packet" )
|
||||
|
@ -66,17 +67,40 @@ int main ( int argc, char **argv ) {
|
|||
} catch ( boost::program_options::unknown_option ex1 ) {
|
||||
cerr << "ERROR >> " << ex1.what() << "" << endl;
|
||||
cerr << ">> Try '" << argv[0] << " --help' for more information." << endl;
|
||||
return EXIT_SUCCESS;
|
||||
return EXIT_FAILURE;
|
||||
} catch ( boost::program_options::invalid_command_line_syntax ex2 ) {
|
||||
cerr << "ERROR >> " << ex2.what() << "" << endl;
|
||||
cerr << ">> Try '" << argv[0] << " --help' for more information." << endl;
|
||||
return EXIT_SUCCESS;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if ( vm.count ( "help" ) ) {
|
||||
cout << desc << endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if ( vm.count ( "iface-list" ) ) {
|
||||
|
||||
pcap_if_t *alldevsp, *device;
|
||||
char error_buffer[100];
|
||||
|
||||
cerr << ">> Finding available devices ... " << endl;
|
||||
if( pcap_findalldevs( &alldevsp , error_buffer) ) {
|
||||
cerr << "ERROR >> pcap_findalldevs: " << error_buffer << endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
cerr << ">> I found these devices: ";
|
||||
|
||||
for(device = alldevsp ; device != NULL ; device = device->next)
|
||||
{
|
||||
cerr << device->name << " ";
|
||||
}
|
||||
|
||||
cerr << endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
int realuid, realgid, effectiveuid, effectivegid;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue