-rw-r--r-- | noncore/net/wellenreiter/daemon/source/daemon.cc | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.cc b/noncore/net/wellenreiter/daemon/source/daemon.cc index 4407436..5cf4e97 100644 --- a/noncore/net/wellenreiter/daemon/source/daemon.cc +++ b/noncore/net/wellenreiter/daemon/source/daemon.cc | |||
@@ -40,16 +40,18 @@ int main(int argc, char **argv) | |||
40 | if(cardtype.type < 1 || cardtype.type > 4) | 40 | if(cardtype.type < 1 || cardtype.type > 4) |
41 | usage(); | 41 | usage(); |
42 | 42 | ||
43 | if(!card_into_monitormode(&handletopcap, cardtype.iface, cardtype.type)) | 43 | /* set card into monitor mode */ |
44 | if(!card_into_monitormode(&handletopcap, cardtype.iface, | ||
45 | cardtype.type)) | ||
44 | { | 46 | { |
45 | wl_logerr("Cannot initialize the wireless-card, aborting"); | 47 | wl_logerr("Cannot initialize the wireless-card, aborting"); |
46 | exit(EXIT_FAILURE); | 48 | exit(EXIT_FAILURE); |
47 | } | 49 | } |
48 | wl_loginfo("Set card into monitor mode"); | 50 | wl_loginfo("Set card into monitor mode"); |
49 | 51 | ||
50 | 52 | /* setup pcap */ | |
51 | /////// following line will be moved to lib as soon as possible //////////// | 53 | if((handletopcap = pcap_open_live(cardtype.iface, |
52 | if((handletopcap = pcap_open_live(cardtype.iface, BUFSIZ, 1, 0, NULL)) == NULL) | 54 | BUFSIZ, 1, 0, NULL)) == NULL) |
53 | { | 55 | { |
54 | wl_logerr("pcap_open_live() failed: %s", strerror(errno)); | 56 | wl_logerr("pcap_open_live() failed: %s", strerror(errno)); |
55 | exit(EXIT_FAILURE); | 57 | exit(EXIT_FAILURE); |
@@ -58,8 +60,6 @@ int main(int argc, char **argv) | |||
58 | #ifdef HAVE_PCAP_NONBLOCK | 60 | #ifdef HAVE_PCAP_NONBLOCK |
59 | pcap_setnonblock(handletopcap, 1, NULL); | 61 | pcap_setnonblock(handletopcap, 1, NULL); |
60 | #endif | 62 | #endif |
61 | //////////////////////////////////////// | ||
62 | |||
63 | 63 | ||
64 | /* Setup socket for incoming commands */ | 64 | /* Setup socket for incoming commands */ |
65 | if((sock=wl_setupsock(DAEMONADDR, DAEMONPORT, saddr)) < 0) | 65 | if((sock=wl_setupsock(DAEMONADDR, DAEMONPORT, saddr)) < 0) |
@@ -70,7 +70,8 @@ int main(int argc, char **argv) | |||
70 | wl_loginfo("Set up socket '%d' for GUI communication", sock); | 70 | wl_loginfo("Set up socket '%d' for GUI communication", sock); |
71 | 71 | ||
72 | /* Create channelswitching thread */ | 72 | /* Create channelswitching thread */ |
73 | if(pthread_create(&sub, NULL, channel_switcher, (void *)&cardtype) != 0) | 73 | if(pthread_create(&sub, NULL, channel_switcher, |
74 | (void *)&cardtype) != 0) | ||
74 | { | 75 | { |
75 | wl_logerr("Cannot create thread: %s", strerror(errno)); | 76 | wl_logerr("Cannot create thread: %s", strerror(errno)); |
76 | close(sock); | 77 | close(sock); |
@@ -95,8 +96,9 @@ int main(int argc, char **argv) | |||
95 | FD_SET(sock, &rset); | 96 | FD_SET(sock, &rset); |
96 | FD_SET(pcap_fileno(handletopcap), &rset); | 97 | FD_SET(pcap_fileno(handletopcap), &rset); |
97 | 98 | ||
98 | /* socket or pcap handle bigger? Will be cleaned up, have to check pcap */ | 99 | /* maxfd = biggest filefd */ |
99 | maxfd = (sock > pcap_fileno(handletopcap) ? sock + 1: pcap_fileno(handletopcap)) + 1; | 100 | maxfd = (sock > pcap_fileno(handletopcap) ? |
101 | sock + 1 : pcap_fileno(handletopcap)) + 1; | ||
100 | 102 | ||
101 | if(select(maxfd, &rset, NULL, NULL, NULL) < 0) | 103 | if(select(maxfd, &rset, NULL, NULL, NULL) < 0) |
102 | { | 104 | { |
@@ -148,7 +150,8 @@ int main(int argc, char **argv) | |||
148 | exit(EXIT_SUCCESS); | 150 | exit(EXIT_SUCCESS); |
149 | } | 151 | } |
150 | 152 | ||
151 | void usage(void) | 153 | void |
154 | usage(void) | ||
152 | { | 155 | { |
153 | fprintf(stderr, "Usage: wellenreiter <device> <cardtype>\n" \ | 156 | fprintf(stderr, "Usage: wellenreiter <device> <cardtype>\n" \ |
154 | "\t<device> = Wirelessdevice (e.g. wlan0)\n" \ | 157 | "\t<device> = Wirelessdevice (e.g. wlan0)\n" \ |