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 | |||
@@ -7,31 +7,44 @@ | |||
7 | #include "config.hh" | 7 | #include "config.hh" |
8 | #include "daemon.hh" | 8 | #include "daemon.hh" |
9 | 9 | ||
10 | /* Main function of wellenreiterd */ | 10 | /* Main function of wellenreiterd */ |
11 | int main(int argc, char **argv) | 11 | int main(int argc, char **argv) |
12 | { | 12 | { |
13 | int sock, maxfd, retval; | 13 | int sock, maxfd, retval, card_type; |
14 | char buffer[128]; | 14 | char buffer[128], sniffer_device[5]; |
15 | struct pcap_pkthdr header; | 15 | struct pcap_pkthdr header; |
16 | pcap_t *handletopcap; | 16 | pcap_t *handletopcap; |
17 | const unsigned char *packet; | 17 | const unsigned char *packet; |
18 | 18 | ||
19 | fd_set rset; | 19 | fd_set rset; |
20 | 20 | ||
21 | fprintf(stderr, "wellenreiterd %s\n\n", VERSION); | 21 | fprintf(stderr, "wellenreiterd %s\n\n", VERSION); |
22 | fprintf(stderr, "(c) 2002 by M-M-M\n\n"); | ||
22 | 23 | ||
23 | if(!card_into_monitormode(&handletopcap, SNIFFER_DEVICE, CARD_TYPE)) | 24 | if(argc < 3) |
25 | usage(); | ||
26 | |||
27 | /* Set sniffer device */ | ||
28 | memset(sniffer_device, 0, sizeof(sniffer_device)); | ||
29 | strncpy(sniffer_device, (char *)argv[1], sizeof(sniffer_device) - 1); | ||
30 | |||
31 | /* Set card type */ | ||
32 | card_type = atoi(argv[2]); | ||
33 | if(card_type < 1 || card_type > 3) | ||
34 | usage(); | ||
35 | |||
36 | if(!card_into_monitormode(&handletopcap, sniffer_device, card_type)) | ||
24 | { | 37 | { |
25 | wl_logerr("Cannot set card into mon mode, aborting"); | 38 | wl_logerr("Cannot set card into mon mode, aborting"); |
26 | exit(-1); | 39 | exit(-1); |
27 | } | 40 | } |
28 | wl_loginfo("Set card into monitor mode"); | 41 | wl_loginfo("Set card into monitor mode"); |
29 | 42 | ||
30 | /////// following line will be moved to lib as soon as possible //////////// | 43 | /////// following line will be moved to lib as soon as possible //////////// |
31 | if((handletopcap = pcap_open_live(SNIFFER_DEVICE, BUFSIZ, 1, 0, NULL)) == NULL) | 44 | if((handletopcap = pcap_open_live(sniffer_device, BUFSIZ, 1, 0, NULL)) == NULL) |
32 | { | 45 | { |
33 | wl_logerr("pcap_open_live() failed: %s", strerror(errno)); | 46 | wl_logerr("pcap_open_live() failed: %s", strerror(errno)); |
34 | exit(-1); | 47 | exit(-1); |
35 | } | 48 | } |
36 | 49 | ||
37 | #ifdef HAVE_PCAP_NONBLOCK | 50 | #ifdef HAVE_PCAP_NONBLOCK |
@@ -39,17 +52,17 @@ int main(int argc, char **argv) | |||
39 | #endif | 52 | #endif |
40 | 53 | ||
41 | /* getting the datalink type */ | 54 | /* getting the datalink type */ |
42 | retval = pcap_datalink(handletopcap); | 55 | retval = pcap_datalink(handletopcap); |
43 | if (retval != DLT_IEEE802_11) /* Rawmode is IEEE802_11 */ | 56 | if (retval != DLT_IEEE802_11) /* Rawmode is IEEE802_11 */ |
44 | { | 57 | { |
45 | wl_loginfo("Interface %s does not work in the correct 802.11 raw mode", SNIFFER_DEVICE); | 58 | wl_loginfo("Interface %s does not work in the correct 802.11 raw mode", sniffer_device); |
46 | pcap_close(handletopcap); | 59 | pcap_close(handletopcap); |
47 | return 0; | 60 | return 0; |
48 | } | 61 | } |
49 | wl_loginfo("Your successfully listen on %s in 802.11 raw mode", SNIFFER_DEVICE); | 62 | wl_loginfo("Your successfully listen on %s in 802.11 raw mode", sniffer_device); |
50 | //////////////////////////////////////// | 63 | //////////////////////////////////////// |
51 | 64 | ||
52 | /* Setup socket for incoming commands */ | 65 | /* Setup socket for incoming commands */ |
53 | if((sock=commsock(DAEMONADDR, DAEMONPORT)) < 0) | 66 | if((sock=commsock(DAEMONADDR, DAEMONPORT)) < 0) |
54 | { | 67 | { |
55 | wl_logerr("Cannot setup socket"); | 68 | wl_logerr("Cannot setup socket"); |
@@ -114,6 +127,16 @@ int main(int argc, char **argv) | |||
114 | 127 | ||
115 | } /* while(1) */ | 128 | } /* while(1) */ |
116 | 129 | ||
117 | close(sock); | 130 | close(sock); |
118 | exit(0); | 131 | exit(0); |
119 | } | 132 | } |
133 | |||
134 | void usage(void) | ||
135 | { | ||
136 | fprintf(stderr, "Usage: wellenreiter <device> <cardtype>\n" \ | ||
137 | "\t<device> = Wirelessdevice (e.g. wlan0)\n" \ | ||
138 | "\t<cardtype> = Cardtype:\t Cisco\t= 1\n" \ | ||
139 | "\t\t\t\tNG\t= 2\n" \ | ||
140 | "\t\t\t\tHOSTAP\t= 3\n"); | ||
141 | exit(-1); | ||
142 | } | ||