Diffstat (limited to 'noncore/net/wellenreiter/daemon/source/daemon.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/daemon.cc | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.cc b/noncore/net/wellenreiter/daemon/source/daemon.cc index cc72377..54f308a 100644 --- a/noncore/net/wellenreiter/daemon/source/daemon.cc +++ b/noncore/net/wellenreiter/daemon/source/daemon.cc @@ -11,6 +11,6 @@ int main(int argc, char **argv) { - int sock, maxfd, retval; - char buffer[128]; + int sock, maxfd, retval, card_type; + char buffer[128], sniffer_device[5]; struct pcap_pkthdr header; pcap_t *handletopcap; @@ -20,6 +20,19 @@ int main(int argc, char **argv) fprintf(stderr, "wellenreiterd %s\n\n", VERSION); + fprintf(stderr, "(c) 2002 by M-M-M\n\n"); - if(!card_into_monitormode(&handletopcap, SNIFFER_DEVICE, CARD_TYPE)) + if(argc < 3) + usage(); + + /* Set sniffer device */ + memset(sniffer_device, 0, sizeof(sniffer_device)); + strncpy(sniffer_device, (char *)argv[1], sizeof(sniffer_device) - 1); + + /* Set card type */ + card_type = atoi(argv[2]); + if(card_type < 1 || card_type > 3) + usage(); + + if(!card_into_monitormode(&handletopcap, sniffer_device, card_type)) { wl_logerr("Cannot set card into mon mode, aborting"); @@ -29,5 +42,5 @@ int main(int argc, char **argv) /////// following line will be moved to lib as soon as possible //////////// - if((handletopcap = pcap_open_live(SNIFFER_DEVICE, BUFSIZ, 1, 0, NULL)) == NULL) + if((handletopcap = pcap_open_live(sniffer_device, BUFSIZ, 1, 0, NULL)) == NULL) { wl_logerr("pcap_open_live() failed: %s", strerror(errno)); @@ -43,9 +56,9 @@ int main(int argc, char **argv) if (retval != DLT_IEEE802_11) /* Rawmode is IEEE802_11 */ { - wl_loginfo("Interface %s does not work in the correct 802.11 raw mode", SNIFFER_DEVICE); + wl_loginfo("Interface %s does not work in the correct 802.11 raw mode", sniffer_device); pcap_close(handletopcap); return 0; } - wl_loginfo("Your successfully listen on %s in 802.11 raw mode", SNIFFER_DEVICE); + wl_loginfo("Your successfully listen on %s in 802.11 raw mode", sniffer_device); //////////////////////////////////////// @@ -118,2 +131,12 @@ int main(int argc, char **argv) exit(0); } + +void usage(void) +{ + fprintf(stderr, "Usage: wellenreiter <device> <cardtype>\n" \ + "\t<device> = Wirelessdevice (e.g. wlan0)\n" \ + "\t<cardtype> = Cardtype:\t Cisco\t= 1\n" \ + "\t\t\t\tNG\t= 2\n" \ + "\t\t\t\tHOSTAP\t= 3\n"); + exit(-1); +} |