summaryrefslogtreecommitdiff
authormjm <mjm>2002-12-16 17:59:21 (UTC)
committer mjm <mjm>2002-12-16 17:59:21 (UTC)
commit1a981d3a1d8ef7860d673bce009b7253d7e279d7 (patch) (unidiff)
tree0a9e31d9cee51110dfe67b8c0ef1f2c8d0a27241
parente6255e52c1ec8988f3a1490827b92874459d6ede (diff)
downloadopie-1a981d3a1d8ef7860d673bce009b7253d7e279d7.zip
opie-1a981d3a1d8ef7860d673bce009b7253d7e279d7.tar.gz
opie-1a981d3a1d8ef7860d673bce009b7253d7e279d7.tar.bz2
foobar
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/daemon/source/config.hh2
-rw-r--r--noncore/net/wellenreiter/daemon/source/daemon.cc35
-rw-r--r--noncore/net/wellenreiter/daemon/source/daemon.hh2
3 files changed, 31 insertions, 8 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/config.hh b/noncore/net/wellenreiter/daemon/source/config.hh
index 42c56da..cac9565 100644
--- a/noncore/net/wellenreiter/daemon/source/config.hh
+++ b/noncore/net/wellenreiter/daemon/source/config.hh
@@ -17,14 +17,12 @@
17#define DAEMONADDR "127.0.0.1" 17#define DAEMONADDR "127.0.0.1"
18#define DAEMONPORT 37772 /* Port of Daemon */ 18#define DAEMONPORT 37772 /* Port of Daemon */
19 19
20#define GUIADDR "127.0.0.1" /* Adress of GUI, later specified in configfile */ 20#define GUIADDR "127.0.0.1" /* Adress of GUI, later specified in configfile */
21#define GUIPORT 37773 /* Port of GUI, " " */ 21#define GUIPORT 37773 /* Port of GUI, " " */
22 22
23
24/* Temporary cardmode stuff, will hopefully removed soon */ 23/* Temporary cardmode stuff, will hopefully removed soon */
25#define CARD_TYPE_CISCO 1 24#define CARD_TYPE_CISCO 1
26#define CARD_TYPE_NG 2 25#define CARD_TYPE_NG 2
27#define CARD_TYPE_HOSTAP 3 26#define CARD_TYPE_HOSTAP 3
28#define SNIFFER_DEVICE "wlan0"
29 27
30#endif /* CONFIG_HH */ 28#endif /* CONFIG_HH */
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 */
11int main(int argc, char **argv) 11int 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
134void 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}
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.hh b/noncore/net/wellenreiter/daemon/source/daemon.hh
index 09acf11..8d03b97 100644
--- a/noncore/net/wellenreiter/daemon/source/daemon.hh
+++ b/noncore/net/wellenreiter/daemon/source/daemon.hh
@@ -16,7 +16,9 @@
16#include "../../libwellenreiter/source/sock.hh" 16#include "../../libwellenreiter/source/sock.hh"
17#include "../../libwellenreiter/source/log.hh" 17#include "../../libwellenreiter/source/log.hh"
18#include "../../libwellenreiter/source/proto.hh" 18#include "../../libwellenreiter/source/proto.hh"
19#include "../../libwellenreiter/source/cardmode.hh" 19#include "../../libwellenreiter/source/cardmode.hh"
20#include "../../libwellenreiter/source/sniff.hh" 20#include "../../libwellenreiter/source/sniff.hh"
21 21
22void usage(void);
23
22#endif /* DAEMON_HH */ 24#endif /* DAEMON_HH */