Diffstat (limited to 'noncore/net/wellenreiter/daemon') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/daemon/.cvsignore | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/daemon.pro | 16 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/.cvsignore | 3 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/Makefile | 25 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/config.hh | 29 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/daemon.cc | 195 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/daemon.hh | 27 |
7 files changed, 0 insertions, 299 deletions
diff --git a/noncore/net/wellenreiter/daemon/.cvsignore b/noncore/net/wellenreiter/daemon/.cvsignore deleted file mode 100644 index 4299fd9..0000000 --- a/noncore/net/wellenreiter/daemon/.cvsignore +++ b/dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | *.o | ||
2 | *~ | ||
3 | moc_* | ||
4 | Makefile* | ||
diff --git a/noncore/net/wellenreiter/daemon/daemon.pro b/noncore/net/wellenreiter/daemon/daemon.pro deleted file mode 100644 index 33a6bb9..0000000 --- a/noncore/net/wellenreiter/daemon/daemon.pro +++ b/dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | DESTDIR = $(OPIEDIR)/bin | ||
2 | TEMPLATE = app | ||
3 | CONFIG = warn_on debug | ||
4 | #CONFIG = warn_on release | ||
5 | HEADERS = source/config.hh source/daemon.hh | ||
6 | SOURCES = source/daemon.cc | ||
7 | INCLUDEPATH += ../ | ||
8 | DEPENDPATH += $(OPIEDIR)/include | ||
9 | LIBS += -lpcap -lpthread -L$(OPIEDIR)/lib -lwellenreiter | ||
10 | INTERFACES = | ||
11 | TARGET = wellenreiterd | ||
12 | DEFINES += DEBUG | ||
13 | |||
14 | !contains( platform, x11 ) { | ||
15 | include ( $(OPIEDIR)/include.pro ) | ||
16 | } | ||
diff --git a/noncore/net/wellenreiter/daemon/source/.cvsignore b/noncore/net/wellenreiter/daemon/source/.cvsignore deleted file mode 100644 index ed65c71..0000000 --- a/noncore/net/wellenreiter/daemon/source/.cvsignore +++ b/dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | *.o | ||
2 | *~ | ||
3 | moc_* | ||
diff --git a/noncore/net/wellenreiter/daemon/source/Makefile b/noncore/net/wellenreiter/daemon/source/Makefile deleted file mode 100644 index 38d61f1..0000000 --- a/noncore/net/wellenreiter/daemon/source/Makefile +++ b/dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | # $Id$ | ||
2 | |||
3 | CPP = g++ | ||
4 | CPPFLAGS= -g -Wall -pedantic -DDEBUG -I ../../ | ||
5 | LIBS = -lpthread -lpcap ../../libwellenreiter/source/libwellenreiter.a | ||
6 | OBJ = daemon.o | ||
7 | |||
8 | .SUFFIXES: | ||
9 | .PHONY: all wellenreiterd clean distclean realclean | ||
10 | |||
11 | %.o : %.cc | ||
12 | $(CPP) $(CPPFLAGS) -c $< -o $@ | ||
13 | |||
14 | all:wellenreiterd | ||
15 | |||
16 | wellenreiterd:$(OBJ) | ||
17 | $(CPP) $(CPPFLAGS) $(OBJ) $(LIBS) -o $@ | ||
18 | @echo Build wellenreiterd | ||
19 | |||
20 | clean distclean realclean: | ||
21 | @rm -f wellenreiterd *~ *.o | ||
22 | @echo All dependent files have been removed. | ||
23 | |||
24 | daemon.o:config.hh | ||
25 | |||
diff --git a/noncore/net/wellenreiter/daemon/source/config.hh b/noncore/net/wellenreiter/daemon/source/config.hh deleted file mode 100644 index 0ac7eb9..0000000 --- a/noncore/net/wellenreiter/daemon/source/config.hh +++ b/dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Global configuration for wellenreiter | ||
4 | * | ||
5 | * $Id$ | ||
6 | * | ||
7 | * Written by Martin J. Muench <mjm@codito.de> | ||
8 | * | ||
9 | */ | ||
10 | |||
11 | #ifndef CONFIG_HH | ||
12 | #define CONFIG_HH | ||
13 | |||
14 | #define PROGNAME "wellenreiter" /* Name of program (for syslog et.al.) */ | ||
15 | #define VERSION "0.2" /* Version of wellenreiter */ | ||
16 | |||
17 | #define DAEMONADDR "127.0.0.1" | ||
18 | #define DAEMONPORT 37772 /* Port of Daemon */ | ||
19 | |||
20 | #define GUIADDR "127.0.0.1" /* Adress of GUI, later specified in configfile */ | ||
21 | #define GUIPORT 37773 /* Port of GUI, " " */ | ||
22 | |||
23 | /* Temporary cardmode stuff, will hopefully removed soon */ | ||
24 | #define CARD_TYPE_CISCO 1 | ||
25 | #define CARD_TYPE_NG 2 | ||
26 | #define CARD_TYPE_HOSTAP 3 | ||
27 | #define CARD_TYPE_ORINOCCO 4 | ||
28 | |||
29 | #endif /* CONFIG_HH */ | ||
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.cc b/noncore/net/wellenreiter/daemon/source/daemon.cc deleted file mode 100644 index b840f17..0000000 --- a/noncore/net/wellenreiter/daemon/source/daemon.cc +++ b/dev/null | |||
@@ -1,195 +0,0 @@ | |||
1 | /* | ||
2 | * Startup functions of wellenreiter | ||
3 | * | ||
4 | * $Id$ | ||
5 | */ | ||
6 | |||
7 | #include "config.hh" | ||
8 | #include "daemon.hh" | ||
9 | |||
10 | /* should be parsed from cfg-file */ | ||
11 | #define MAXCHANNEL 13 | ||
12 | #define CHANINTERVAL 500000 | ||
13 | |||
14 | |||
15 | /* Main function of wellenreiterd */ | ||
16 | int main(int argc, char **argv) | ||
17 | { | ||
18 | int sock, maxfd, retval; | ||
19 | char buffer[WL_SOCKBUF]; | ||
20 | struct pcap_pkthdr header; | ||
21 | struct sockaddr_in saddr; | ||
22 | // pcap_t *handletopcap; | ||
23 | wl_cardtype_t cardtype; | ||
24 | pthread_t sub; | ||
25 | const unsigned char *packet; | ||
26 | |||
27 | fd_set rset; | ||
28 | |||
29 | fprintf(stderr, "wellenreiterd %s\n\n", VERSION); | ||
30 | fprintf(stderr, "(c) 2002 by M-M-M\n\n"); | ||
31 | |||
32 | if(argc < 3) | ||
33 | usage(); | ||
34 | |||
35 | /* Set sniffer device */ | ||
36 | memset(cardtype.iface, 0, sizeof(cardtype.iface)); | ||
37 | strncpy(cardtype.iface, (char *)argv[1], sizeof(cardtype.iface) - 1); | ||
38 | |||
39 | /* Set card type */ | ||
40 | cardtype.type = atoi(argv[2]); | ||
41 | if(cardtype.type < 1 || cardtype.type > 4) | ||
42 | usage(); | ||
43 | |||
44 | /* Until we do not act as a read daemon, it starts the sniffer | ||
45 | right after startup */ | ||
46 | if (!start_sniffer(cardtype.iface,cardtype.type)) | ||
47 | { | ||
48 | wl_logerr("daemon, start_sniff did not return proper, aborting"); | ||
49 | exit(EXIT_FAILURE); | ||
50 | } | ||
51 | wl_loginfo ("daemon, wireless card prepared for sniffing"); | ||
52 | |||
53 | /* Setup socket for incoming commands */ | ||
54 | if((sock=wl_setupsock(DAEMONADDR, DAEMONPORT, saddr)) < 0) | ||
55 | { | ||
56 | wl_logerr("Cannot setup socket"); | ||
57 | exit(EXIT_FAILURE); | ||
58 | } | ||
59 | wl_loginfo("Set up socket '%d' for GUI communication", sock); | ||
60 | |||
61 | /* Create channelswitching thread */ | ||
62 | if(pthread_create(&sub, NULL, channel_switcher, | ||
63 | (void *)&cardtype) != 0) | ||
64 | { | ||
65 | wl_logerr("Cannot create thread: %s", strerror(errno)); | ||
66 | close(sock); | ||
67 | exit(EXIT_FAILURE); | ||
68 | } | ||
69 | if(pthread_detach(sub)) | ||
70 | { | ||
71 | wl_logerr("Error detaching thread"); | ||
72 | close(sock); | ||
73 | pthread_exit((pthread_t *)sub); | ||
74 | exit(EXIT_FAILURE); | ||
75 | } | ||
76 | wl_loginfo("Created and detached channel switching thread"); | ||
77 | |||
78 | FD_ZERO(&rset); | ||
79 | |||
80 | /* Start main loop */ | ||
81 | wl_loginfo("Starting main loop"); | ||
82 | while(1) | ||
83 | { | ||
84 | |||
85 | FD_SET(sock, &rset); | ||
86 | FD_SET(pcap_fileno(handletopcap), &rset); | ||
87 | |||
88 | /* maxfd = biggest filefd */ | ||
89 | maxfd = (sock > pcap_fileno(handletopcap) ? | ||
90 | sock + 1 : pcap_fileno(handletopcap)) + 1; | ||
91 | |||
92 | if(select(maxfd, &rset, NULL, NULL, NULL) < 0) | ||
93 | { | ||
94 | wl_logerr("Error calling select: %s", strerror(errno)); | ||
95 | break; | ||
96 | } | ||
97 | |||
98 | /* Got data on local socket from GUI */ | ||
99 | if(FD_ISSET(sock, &rset)) | ||
100 | { | ||
101 | /* Receive data from socket */ | ||
102 | if((retval=wl_recv(&sock, saddr, buffer, sizeof(buffer))) < 0) | ||
103 | { | ||
104 | wl_logerr("Error trying to read: %s", strerror(errno)); | ||
105 | break; | ||
106 | } | ||
107 | else | ||
108 | { | ||
109 | /* check type of packet and start function according to it */ | ||
110 | switch(retval) | ||
111 | { | ||
112 | case STARTSNIFF: | ||
113 | wl_loginfo("Received STARTSNIFF command"); | ||
114 | if(!send_ok(GUIADDR, GUIPORT, STARTSNIFF)) | ||
115 | wl_logerr("Cannot set OK_CMD to GUI"); | ||
116 | break; | ||
117 | case STOPSNIFF: | ||
118 | wl_loginfo("Received STOPSNIFF command"); | ||
119 | if(!send_ok(GUIADDR, GUIPORT, STOPSNIFF)) | ||
120 | wl_logerr("Cannot set FAIL_CMD to GUI"); | ||
121 | break; | ||
122 | default: | ||
123 | wl_logerr("Received unknown command: %d", retval); | ||
124 | break; | ||
125 | } | ||
126 | } | ||
127 | } /* FD_ISSET */ | ||
128 | |||
129 | /* Check pcap lib for packets */ | ||
130 | if(FD_ISSET(pcap_fileno(handletopcap), &rset)) | ||
131 | { | ||
132 | |||
133 | /* Grab one single packet */ | ||
134 | packet = pcap_next(handletopcap, &header); | ||
135 | |||
136 | /* process the packet */ | ||
137 | process_packets(&header,*&packet, GUIADDR, GUIPORT); | ||
138 | } | ||
139 | |||
140 | } /* while(1) */ | ||
141 | |||
142 | close(sock); | ||
143 | exit(EXIT_SUCCESS); | ||
144 | } | ||
145 | |||
146 | void | ||
147 | usage(void) | ||
148 | { | ||
149 | fprintf(stderr, "Usage: wellenreiter <device> <cardtype>\n" \ | ||
150 | "\t<device> = Wirelessdevice (e.g. wlan0)\n" \ | ||
151 | "\t<cardtype> = Cardtype:\tCisco\t= 1\n" \ | ||
152 | "\t\t\t\tNG\t= 2\n" \ | ||
153 | "\t\t\t\tHOSTAP\t= 3\n" \ | ||
154 | "\t\t\t\tLUCENT\t= 4\n"); | ||
155 | exit(EXIT_FAILURE); | ||
156 | } | ||
157 | |||
158 | void * | ||
159 | channel_switcher(void *cardtypeptr) | ||
160 | { | ||
161 | wl_cardtype_t *cardtype; | ||
162 | int maxchan=0; | ||
163 | int channel=1; | ||
164 | /* Get card info struct */ | ||
165 | cardtype = (wl_cardtype_t *)cardtypeptr; | ||
166 | /* Get from the wireless extension the amount of available channels | ||
167 | this prevents a fail in switching on us cards */ | ||
168 | maxchan = card_detect_channels(cardtype->iface); | ||
169 | |||
170 | if (maxchan < MAXCHANNEL) | ||
171 | { | ||
172 | #undef MAXCHANNEL | ||
173 | #define MAXCHANNEL maxchan | ||
174 | } | ||
175 | |||
176 | while(1) | ||
177 | { | ||
178 | |||
179 | /* If channel bigger than maxchannel, set to 1 */ | ||
180 | if(channel > MAXCHANNEL) | ||
181 | channel=1; | ||
182 | |||
183 | /* Set channel */ | ||
184 | if(!card_set_channel(cardtype->iface, channel, cardtype->type)) | ||
185 | { | ||
186 | wl_logerr("Cannot set channel, thread exiting"); | ||
187 | pthread_exit(NULL); | ||
188 | } | ||
189 | |||
190 | /* sleep */ | ||
191 | usleep(CHANINTERVAL); | ||
192 | |||
193 | channel++; | ||
194 | } /* while */ | ||
195 | } | ||
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.hh b/noncore/net/wellenreiter/daemon/source/daemon.hh deleted file mode 100644 index f9ac45e..0000000 --- a/noncore/net/wellenreiter/daemon/source/daemon.hh +++ b/dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | /* $Id$ */ | ||
2 | |||
3 | #ifndef DAEMON_HH | ||
4 | #define DAEMON_HH | ||
5 | |||
6 | #include <stdio.h> | ||
7 | #include <string.h> | ||
8 | #include <sys/types.h> | ||
9 | #include <sys/time.h> | ||
10 | #include <sys/socket.h> | ||
11 | #include <netinet/in.h> | ||
12 | #include <arpa/inet.h> | ||
13 | #include <pthread.h> | ||
14 | #include <unistd.h> | ||
15 | #include <errno.h> | ||
16 | |||
17 | #include <libwellenreiter/source/wl_sock.hh> | ||
18 | #include <libwellenreiter/source/wl_log.hh> | ||
19 | #include <libwellenreiter/source/wl_types.hh> | ||
20 | #include <libwellenreiter/source/wl_proto.hh> | ||
21 | #include <libwellenreiter/source/cardmode.hh> | ||
22 | #include <libwellenreiter/source/sniff.hh> | ||
23 | |||
24 | void usage(void); | ||
25 | void *channel_switcher(void *); | ||
26 | |||
27 | #endif /* DAEMON_HH */ | ||