summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/libwellenreiter
authormickeyl <mickeyl>2003-03-30 01:51:14 (UTC)
committer mickeyl <mickeyl>2003-03-30 01:51:14 (UTC)
commitd11a0154e2d9732854c9a3d598857bc20f359849 (patch) (unidiff)
treeaf0e0273d01f4f6c64c9f230f22bb91a7a8a21d8 /noncore/net/wellenreiter/libwellenreiter
parent99899abc80a8aa05044eeecd8a061b0a8efaa713 (diff)
downloadopie-d11a0154e2d9732854c9a3d598857bc20f359849.zip
opie-d11a0154e2d9732854c9a3d598857bc20f359849.tar.gz
opie-d11a0154e2d9732854c9a3d598857bc20f359849.tar.bz2
- the network work for libopie2 pays off...
- good bye to wellenreiterd, t'was fun but always too unstable and too hard to maintain - good bye to libwellenreiter
Diffstat (limited to 'noncore/net/wellenreiter/libwellenreiter') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/.cvsignore4
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/docs/quickintro88
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/docs/wl_conf.817
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/docs/wl_log.812
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/docs/wl_sniff.821
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/docs/wl_sock.826
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/docs/wl_types.825
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro16
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/.cvsignore3
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/Makefile20
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc451
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh107
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/extract.hh59
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/ieee802_11.hh250
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/sniff.cc419
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/sniff.hh73
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc81
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/wl_conf.hh12
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/wl_log.cc51
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/wl_log.hh14
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc221
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh27
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc92
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/wl_sock.hh21
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/wl_types.hh43
25 files changed, 0 insertions, 2153 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/.cvsignore b/noncore/net/wellenreiter/libwellenreiter/.cvsignore
deleted file mode 100644
index 4299fd9..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/.cvsignore
+++ b/dev/null
@@ -1,4 +0,0 @@
1*.o
2*~
3moc_*
4Makefile*
diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/quickintro b/noncore/net/wellenreiter/libwellenreiter/docs/quickintro
deleted file mode 100644
index 97458b7..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/docs/quickintro
+++ b/dev/null
@@ -1,88 +0,0 @@
1
2Name: libwellenreiter
3Author: Martin J. Muench
4
5NOTE: This is just a very short summary of the functions included
6in libwellenreiter, written because a lack of time. The whole
7library will be rewritten with extended documentation and
8test programs.
9
10--
11Wellenreiter types:
12In proto.hh the following type (wl_network_t) is declared:
13
14typedef struct {
15 int net_type; /* 1 = Accesspoint ; 2 = Ad-Hoc */
16 int ssid_len; /* Length of SSID */
17 int channel; /* Channel */
18 int wep; /* 1 = WEP enabled ; 0 = disabled */
19 char mac[64]; /* MAC address of Accesspoint */
20 char bssid[128]; /* BSSID of Accesspoint */
21} wl_network_t;
22
23When a network is found, the structure has to be set and
24sent to the send_network_found() function.
25
26When the GUI receives a found network string it calls the
27get_network_found() function to get its own structure set.
28
29--
30Included functions:
31
32--
33Protocol:
34
35Send a found network to GUI:
36int send_network_found (const char *, int, void *);
37
38The first two arguments are the guihost and the guiport.
39The third is the filled structure (wl_network_t), that will
40be send to the GUI.
41
42Setup structure for found network:
43int get_network_found (void *, const char *);
44
45When the GUI receives a new network found packet it calls
46this function and passes a wl_network_t structure and the
47received buffer. The function will strip the data from
48the buffer and set it to the structure.
49
50--
51Log to syslog/info:
52void wl_loginfo(const char *, ...);
53
54Log to syslog/err:
55void wl_logerr(const char *, ...);
56
57Use like printf() function with format strings and so on.
58
59--
60Setup udp socket for incoming commands:
61int commsock(const char *, int);
62
63Fist argument is the host where it should listen and second
64is the port. Socket is returned, on failure -1 is returned.
65
66
67Recvfrom socket:
68int recv_commsock(int *, char *, int);
69
70First argument is the address of the socket, second is a buffer
71that should be filled in and the third is the maxlength of the
72buffer. On error, -1 is returned, on success the number of
73packet type is returned. (return value should be used with switch
74command, for types see proto.hh)
75
76Send command to udp socket:
77int sendcomm(const char *, int, const char *, ...);
78
79First two arguments are the host and port where the command should
80be send to, followed by buffer that should be send. On error, -1
81is returned.
82
83
84---
85
86Thats it for the moment.
87
88mjm.
diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/wl_conf.8 b/noncore/net/wellenreiter/libwellenreiter/docs/wl_conf.8
deleted file mode 100644
index 8d2fe27..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/docs/wl_conf.8
+++ b/dev/null
@@ -1,17 +0,0 @@
1wl_conf
2
3#include <wellenreiter/wl_conf.hh>
4
5int wl_checkcfg(void);
6int wl_cfgvalue(const char *token, char *out, int maxlen);
7
8wl_checkcfg checks whether the wellenreiter configfile exists.
9wl_cfgvalue searches for the given token and copies maxlen
10characters of its value to out.
11
12wl_ckeckcfg returns 1 if the file exists and is readable and
130 on error.
14
15wl_cfgvalue returns -1 on error, 0 if nothing was found and
161 on success.
17
diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/wl_log.8 b/noncore/net/wellenreiter/libwellenreiter/docs/wl_log.8
deleted file mode 100644
index 00262bd..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/docs/wl_log.8
+++ b/dev/null
@@ -1,12 +0,0 @@
1wl_log
2
3#include <wellenreiter/wl_log.hh>
4
5void wl_loginfo(const char *string, ...)
6void wl_logerr(const char *string, ...)
7
8wl_loginfo() and wl_err() write string to syslog(),
9either to INFO or to ERR.
10
11no return values
12
diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/wl_sniff.8 b/noncore/net/wellenreiter/libwellenreiter/docs/wl_sniff.8
deleted file mode 100644
index 9a65223..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/docs/wl_sniff.8
+++ b/dev/null
@@ -1,21 +0,0 @@
1sniff.cc
2
3#include <wellenreiter/sniff.hh>
4
5void process_packets(const struct pcap_pkthdr *pkthdr,
6 const unsigned char *packet,
7 char *guihost,
8 int guiport)
9
10The function process_packets() will use libpcap to get the
11informations for a 802.11b packet. When it finds a valid
12network it calls the wl_send function and sends a found
13network packet to the guiport on the guihost.
14
15
16Return value
17
18none
19
20NOTE: process_packets() is void at the moment because there
21will be alot of non-critical and annoying errors.
diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/wl_sock.8 b/noncore/net/wellenreiter/libwellenreiter/docs/wl_sock.8
deleted file mode 100644
index 62e935b..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/docs/wl_sock.8
+++ b/dev/null
@@ -1,26 +0,0 @@
1wl_sock
2
3#include <wellenreiter/wl_sock.hh>
4
5int wl_setupsock(const char *host, int port, struct sockaddr_in *)
6int wl_send(const char *host, int port, const char *string, ...)
7int wl_recv(int *socket, struct sockaddr_in *, char *out, int len)
8
9
10wl_setupsock() returns the number of the activated udp socket.
11
12wl_send() sends string to the given host.
13
14wl_recv() checks for incoming data on a socket (created using
15wl_setupsock()). It writes the incoming data to out with a
16maxlen of len.
17
18
19wl_setupsock() returns -1 on error and the number of socket on
20success.
21wl_send() returns 0 on error and 1 on success.
22wl_recv() returns -1 on error and the type of the received packet
23on success.
24
25Note: To use this function you have to set a sockaddr_in structure
26and pass it to wl_setupsock and wl_receive.
diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/wl_types.8 b/noncore/net/wellenreiter/libwellenreiter/docs/wl_types.8
deleted file mode 100644
index d12f564..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/docs/wl_types.8
+++ b/dev/null
@@ -1,25 +0,0 @@
1wl_types.hh
2
3wl_types.hh contains the global buffers and type definitions.
4
5At the moment these are:
6
7/* Type definitions, to be continued */
8#define WL_NETFOUND 01
9#define WL_NETLOST 02
10#define WL_STARTSNIFF 98
11#define WL_STOPSNIFF 99
12
13#define WL_SOCKBUF 512 /* Buffer for wl_send and wl_recv calls */
14
15/* WL network structure */
16typedef struct {
17 int net_type; /* 1 = Accesspoint ; 2 = Ad-Hoc */
18 int ssid_len; /* Length of SSID */
19 int channel; /* Channel */
20 int wep; /* 1 = WEP enabled ; 0 = disabled */
21 char mac[64]; /* MAC address of Accesspoint */
22 char bssid[128]; /* BSSID of Net */
23} wl_network_t;
24
25Will be filled up with other structs and size definitions asap.
diff --git a/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro b/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro
deleted file mode 100644
index 5930c60..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro
+++ b/dev/null
@@ -1,16 +0,0 @@
1DESTDIR = $(OPIEDIR)/lib
2TEMPLATE = lib
3CONFIG = warn_on debug
4VERSION = 0.2
5HEADERS = source/cardmode.hh source/wl_log.hh source/wl_proto.hh source/sniff.hh source/wl_sock.hh source/wl_types.hh
6SOURCES = source/cardmode.cc source/wl_log.cc source/wl_proto.cc source/sniff.cc source/wl_sock.cc
7
8LIBS = -lpcap
9TMAKE_CFLAGS += -D__UNIX__
10DEFINES += DEBUG
11TARGET = wellenreiter
12
13!contains( platform, x11 ) {
14 include ( $(OPIEDIR)/include.pro )
15}
16
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/.cvsignore b/noncore/net/wellenreiter/libwellenreiter/source/.cvsignore
deleted file mode 100644
index ed65c71..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/.cvsignore
+++ b/dev/null
@@ -1,3 +0,0 @@
1*.o
2*~
3moc_*
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/Makefile b/noncore/net/wellenreiter/libwellenreiter/source/Makefile
deleted file mode 100644
index 0017f05..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/Makefile
+++ b/dev/null
@@ -1,20 +0,0 @@
1# $Id$
2
3OBJ = wl_proto.o wl_sock.o wl_log.o wl_conf.o cardmode.o sniff.o
4CPP = g++
5CPPFLAGS = -Wall -pedantic -g -DDEBUG
6
7%.o : %.cc
8 $(CPP) $(CPPFLAGS) -c $< -o $@
9
10 static:libwellenreiter.a
11libwellenreiter.a: $(OBJ)
12 ar -cr libwellenreiter.a $(OBJ)
13
14 shared:libwellenreiter.so
15libwellenreiter.so: $(OBJ)
16 $(CPP) $(CPPFLAGS) -shared -o libwellenreiter.so $(OBJ)
17
18clean:
19 rm -f *.o *.a *.so *~
20
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
deleted file mode 100644
index 4f187c0..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
+++ b/dev/null
@@ -1,451 +0,0 @@
1/*
2 * Set card modes for sniffing
3 *
4 * $Id$
5 */
6
7#include "cardmode.hh"
8#include "wl_log.hh"
9pcap_t *handletopcap;
10/* main card into monitor function */
11int card_into_monitormode (const char *device, int cardtype)
12{
13 char CiscoRFMON[35] = "/proc/driver/aironet/";
14 FILE *CISCO_CONFIG_FILE;
15
16 /* Checks if we have a device to sniff on */
17 if(device == NULL)
18 {
19 wl_logerr("No device given");
20 return 0;
21 }
22
23 /* Setting the promiscous and up flag to the interface */
24 if (!card_set_promisc_up(device))
25 {
26 wl_logerr("Cannot set interface to promisc mode");
27 return 0;
28 }
29 wl_loginfo("Interface set to promisc mode");
30
31 /* Check the cardtype and executes the commands to go into monitor mode */
32 if (cardtype == CARD_TYPE_CISCO)
33 {
34 /* bring the sniffer into rfmon mode */
35 snprintf(CiscoRFMON, sizeof(CiscoRFMON) - 1, DEFAULT_PATH, device);
36 if((CISCO_CONFIG_FILE = fopen(CiscoRFMON,"w")) == NULL)
37 {
38 wl_logerr("Cannot open config file: %s", strerror(errno));
39 return 0;
40 }
41 fputs ("Mode: r",CISCO_CONFIG_FILE);
42 fputs ("Mode: y",CISCO_CONFIG_FILE);
43 fputs ("XmitPower: 1",CISCO_CONFIG_FILE);
44 fclose(CISCO_CONFIG_FILE);
45 }
46 else if (cardtype == CARD_TYPE_NG)
47 {
48 char wlanngcmd[80];
49 snprintf(wlanngcmd, sizeof(wlanngcmd) - 1, "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=true", device, 1);
50 if (system(wlanngcmd) != 0)
51 {
52 wl_logerr("Could not set %s in raw mode, check cardtype", device);
53 return 0;
54 }
55 }
56 else if (cardtype == CARD_TYPE_HOSTAP)
57 {
58#if WIRELESS_EXT > 14
59 // IW_MODE_MONITOR was implemented in Wireless Extensions Version 15
60 int skfd;
61 skfd = socket(AF_INET, SOCK_STREAM, 0);
62 struct iwreq wrq;
63 wrq.u.mode = IW_MODE_MONITOR;
64
65 if(iw_set_ext(skfd,(char *) device,SIOCSIWMODE,&wrq)<0)
66 {
67 wl_logerr("Could not set hostap card %s to raw mode, check cardtype", device);
68 return 0;
69 }
70 else
71 {
72 wl_loginfo("Successfully set hostap card %s into raw mode",device);
73 return 1;
74 }
75 return 1;
76#else
77 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring
78 int fd;
79 //Wireless tools structure for the iocalls
80 struct iwreq ireq;
81 int *ptr;
82 /* Socket needed to use the iocall to */
83 fd = socket(AF_INET, SOCK_STREAM, 0);
84
85 if ( fd == -1 ) {
86 return -1;
87 }
88
89 ptr = (int *) ireq.u.name;
90 // This is the monitor mode for 802.11 non-prism header
91 ptr[0] = 2;
92 strcpy(ireq.ifr_ifrn.ifrn_name, device);
93 if (ioctl( fd, SIOCDEVPRIVATE, &ireq)==0)
94 {
95 /* All was fine... */
96 close(fd);
97 wl_loginfo("Set hostap card %s into monitormode",device);
98 return 1;
99 }
100 else
101 {
102 /* iocall does not work */
103 close(fd);
104 wl_logerr("Could not set hostap card %s into monitormode, check cardtype",device);
105 return 0;
106 }
107#endif
108 }
109 else if (cardtype == CARD_TYPE_ORINOCCO )
110 {
111 if (!card_set_channel (device, 1, CARD_TYPE_ORINOCCO))
112 {
113 wl_logerr("Could not set %s in raw mode, check cardtype", device);
114 return 0;
115 }
116 else
117 {
118 wl_loginfo("Successfully set %s into raw mode",device);
119 }
120 }
121
122 /* Setting the promiscous and up flag to the interface */
123 if (!card_check_rfmon_datalink(device))
124 {
125 wl_logerr("Cannot set interface to rfmon mode");
126 return 0;
127 }
128 else
129 {
130 wl_loginfo("Interface set to rfmon mode");
131 }
132 return 1;
133}
134
135/* Check card is in the rfmon mode */
136int card_check_rfmon_datalink (const char *device)
137{
138 int datalinktype=0;
139 pcap_t *phandle;
140 phandle = pcap_open_live((char *)device, 65,0,0,NULL);
141 datalinktype = pcap_datalink (phandle);
142 pcap_close(phandle);
143
144 if (datalinktype != DLT_IEEE802_11) /* Rawmode is IEEE802_11 */
145 {
146 return 0;
147 }
148 else
149 {
150 wl_loginfo("Your successfully listen on %s in 802.11 raw mode", device);
151 return 1;
152 }
153}
154
155/* Ipaq running familiar does not have a loopback device, we need one */
156int check_loopback()
157{
158 /* Checking for a loopback interface with 127.0.0.1, otherwise the other stuff seems to fail on
159 familiar linux on ipaq's */
160 int err;
161 /* First generate a socket to use with iocalls */
162 int fd = socket(AF_INET, SOCK_DGRAM, 0);
163 if (fd < 0)
164 {
165 /* In case of an error */
166 wl_logerr("check_loopback, generation of a socket failed, cannot continue");
167 return 0;
168 }
169 /* Fill an empty an interface structure with the right flags (UP and Promsic) */
170 struct ifreq ifr;
171 strncpy(ifr.ifr_name, "lo",3);
172
173 /* Get the interface flags, loopback interfaces can be detected that way */
174 err = ioctl(fd, SIOCGIFFLAGS, &ifr);
175 if (err < 0)
176 {
177 wl_logerr("check_loopback, could not get the flags of lo, check if you got a lo loopback interface, cannot continue");
178 close(fd);
179 return 0;
180 }
181 /* Checking the flags for IFF_LOOPBACK flags */
182 if(ifr.ifr_flags && IFF_LOOPBACK)
183 {
184 /* Yes, we do have a loopback interface....sup! */
185 close(fd);
186 wl_loginfo ("check_loopback, check for loopback interface lo successful");
187 return 1;
188 }
189 else
190 {
191 wl_logerr("check_loopback, did not found an interface lo with the IFF_LOOPBACK flag set, cannot continue");
192 close(fd);
193 return 0;
194 }
195 /* Should never be reached */
196 return 0;
197} /*check_loopback */
198
199
200/* Set card into promisc mode */
201int card_set_promisc_up (const char *device)
202{
203 int err;
204 /* First generate a socket to use with iocalls */
205 int fd = socket(AF_INET, SOCK_DGRAM, 0);
206 if (fd < 0)
207 {
208 /* In case of an error */
209 perror("socket");
210 return 0;
211 }
212
213 /* Fill an empty an interface structure with the right flags (UP and Promsic) */
214 struct ifreq ifr;
215 strncpy(ifr.ifr_name, device,10);
216 ifr.ifr_flags = IFF_UP + IFF_PROMISC;
217 err = ioctl(fd, SIOCSIFFLAGS, &ifr);
218 if (err < 0)
219 {
220 perror("Could not access the interface, ");
221 close(fd);
222 return 0;
223 }
224
225 /* Get the informations back from the interface to check if the flags are correct */
226 strncpy(ifr.ifr_name, device,10);
227 err = ioctl(fd, SIOCGIFFLAGS, &ifr);
228 if (err < 0)
229 {
230 perror("Could not access the interface, ");
231 close(fd);
232 return 0;
233 }
234
235 if(ifr.ifr_flags && IFF_UP)
236 {
237 close(fd);
238 return 1;
239 }
240 else
241 {
242 wl_logerr("Could not set promisc flag on %d", device);
243 close(fd);
244 return 0;
245 }
246}
247
248/* Remove card from promisc mode */
249int card_remove_promisc (const char *device)
250{
251 int err;
252 /* First generate a socket to use with iocalls */
253 int fd = socket(AF_INET, SOCK_DGRAM, 0);
254 if (fd < 0)
255 {
256 /* In case of an error */
257 perror("socket");
258 return 0;
259 }
260
261 /* Fill an empty an interface structure with the right flags (UP and Promsic) */
262 struct ifreq ifr;
263 /* Get the flags from the interface*/
264 strncpy(ifr.ifr_name, device,10);
265 err = ioctl(fd, SIOCGIFFLAGS, &ifr);
266 if (err < 0)
267 {
268 perror("Could not access the interface, ");
269 close(fd);
270 return 0;
271 }
272 /* Remove the IFF_PROMISC flag */
273 ifr.ifr_flags = ifr.ifr_flags - IFF_PROMISC;
274 /*Set the new flags to the interface*/
275 err = ioctl(fd, SIOCSIFFLAGS, &ifr);
276 if (err < 0)
277 {
278 perror("Could not access the interface, ");
279 close(fd);
280 return 0;
281 }
282
283 /* Get the flags again to check if IFF_PROMISC is removed */
284 err = ioctl(fd, SIOCGIFFLAGS, &ifr);
285 if (err < 0)
286 {
287 perror("Could not access the interface, ");
288 close(fd);
289 return 0;
290 }
291 if(ifr.ifr_flags && IFF_PROMISC)
292 {
293 wl_logerr("Could not remove the promisc flag on %d", device);
294 close(fd);
295 return 0;
296 }
297 else
298 {
299 /* Successfully removed the promisc flags */
300 close(fd);
301 return 1;
302 }
303}
304
305
306
307
308/* Set channel (Wireless frequency) of the device */
309int card_set_channel (const char *device, int channel, int cardtype)
310{
311 if (cardtype == CARD_TYPE_CISCO || cardtype == CARD_TYPE_NG)
312 {
313 /* Cisco and wlan-ng drivers don't need channelswitching */
314 return 1;
315 }
316 /* If it is a lucent orinocco card */
317 else if (cardtype == CARD_TYPE_ORINOCCO)
318 {
319 int fd;
320 //Wireless tools structure for the iocalls
321 struct iwreq ireq;
322 int *ptr;
323 /* Socket needed to use the iocall to */
324 fd = socket(AF_INET, SOCK_STREAM, 0);
325
326 if ( fd == -1 ) {
327 return -1;
328 }
329
330 ptr = (int *) ireq.u.name;
331 // This is the monitor mode for 802.11 non-prism header
332 ptr[0] = 2;
333 ptr[1] = channel;
334 strcpy(ireq.ifr_ifrn.ifrn_name, device);
335 if (ioctl( fd, SIOCIWFIRSTPRIV + 0x8, &ireq)==0)
336 {
337 /* All was fine... */
338 close(fd);
339 wl_loginfo("Set channel %d on interface %s",channel, device);
340 return 1;
341 }
342 else
343 {
344 /* iocall does not work */
345 close(fd);
346 wl_logerr("Could not set channel %d on %s, check cardtype",channel, device);
347 return 0;
348 }
349 }
350 /* when it is an hostap card you need another iocall for channel switching */
351 else if (cardtype == CARD_TYPE_HOSTAP)
352 {
353 int skfd;
354 skfd = socket(AF_INET, SOCK_STREAM, 0);
355 struct iwreq wrq;
356 iw_float2freq((double) channel, &wrq.u.freq);
357
358 if(iw_set_ext(skfd,(char *) device,SIOCSIWFREQ,&wrq)<0)
359 {
360 wl_logerr("Could not set hostap card %s to channel %d", device, channel);
361 return 0;
362 }
363 else
364 {
365 wl_loginfo("Successfully set hostap card %s to channel %d", device, channel);
366 return 1;
367 }
368 }
369 /* For undefined situations */
370 return 0;
371}
372
373
374int card_detect_channels (char * device)
375{
376 int skfd;
377 skfd = socket(AF_INET, SOCK_STREAM, 0);
378 struct iw_rangerange;
379 /* Get list of frequencies / channels */
380 printf ("\n hostap card get the frequencies");
381 /* Get list of frequencies / channels */
382 if(iw_get_range_info(skfd, device, &range) < 0)
383 { /* We are failsave if something went wrong, asume only 11 channels */
384 return 11;
385 }
386 else
387 {
388 if(range.num_frequency > 0)
389 {
390 return range.num_frequency;
391 }
392 else
393 { /* We are failsave asume only 11 channels */
394 return 11;
395 }
396 }
397
398} /* End of card_detect_channels */
399
400int iw_get_range_info(int skfd, const char * ifname, iw_range * range)
401{
402 struct iwreq wrq2;
403 char buffer[sizeof(iw_range) * 2];/* Large enough */
404
405 /* Cleanup */
406 memset(buffer, 0, sizeof(buffer));
407 wrq2.u.data.pointer = (caddr_t) buffer;
408 wrq2.u.data.length = sizeof(buffer);
409 wrq2.u.data.flags = 0;
410
411 if(iw_get_ext(skfd, (char *)ifname, SIOCGIWRANGE, &wrq2) < 0)
412 {
413 wl_logerr("Could not get the range from the interface");
414 return(-1);
415 }
416 else
417 {
418 /* Copy stuff at the right place, ignore extra */
419 memcpy((char *) range, buffer, sizeof(iw_range));
420 return 0;
421 }
422}
423
424/*------------------------------------------------------------------*/
425/*
426 * Convert our internal representation of frequencies to a floating point.
427 */
428double iw_freq2float(iw_freq * in)
429{
430 int i;
431 double res = (double) in->m;
432 for(i = 0; i < in->e; i++)
433 res *= 10;
434 return(res);
435}
436
437
438 void iw_float2freq(double in, iw_freq *out)
439{
440 /* Version without libm : slower */
441 out->e = 0;
442 while(in > 1e9)
443 {
444 in /= 10;
445 out->e++;
446 }
447 out->m = (long) in;
448}
449
450
451
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh
deleted file mode 100644
index 73e0ae1..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh
+++ b/dev/null
@@ -1,107 +0,0 @@
1/* $Id$ */
2
3#ifndef CARDMODE_HH
4#define CARDMODE_HH
5
6#include <string.h>
7#include <stdlib.h>
8#include <errno.h>
9#include <sys/types.h>
10#include <sys/time.h>
11#include <sys/socket.h>
12#include <netinet/in.h>
13#include <arpa/inet.h>
14#include <sys/ioctl.h>
15#include <unistd.h>
16#include <linux/if.h>
17
18/* Following typedefs are needed here, because linux/wireless.h
19 includes linux/ethertool.h which is using them */
20typedef signed char s8;
21typedef unsigned char u8;
22typedef signed short s16;
23typedef unsigned short u16;
24typedef signed int s32;
25typedef unsigned int u32;
26typedef signed long long s64;
27typedef unsigned long long u64;
28
29#include <linux/wireless.h>
30
31#ifndef SIOCIWFIRSTPRIV
32#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
33#endif
34
35extern "C"
36{
37#include <net/bpf.h>
38#include <pcap.h>
39}
40
41extern pcap_t *handletopcap;
42
43/* Defines, used for the card setup */
44#define DEFAULT_PATH "/proc/driver/aironet/%s/Config"
45#define CISCO_STATUS "/proc/driver/aironet/%s/Status"
46#define CARD_TYPE_CISCO 1
47#define CARD_TYPE_NG 2
48#define CARD_TYPE_HOSTAP 3
49#define CARD_TYPE_ORINOCCO 4
50
51/* Some usefull constants for frequencies */
52#define KILO 1e3
53#define MEGA 1e6
54#define GIGA 1e9
55
56
57/* only for now, until we have the daemon running */
58/*the config file should provide these information */
59#define CARD_TYPE CARD_TYPE_HOSTAP
60
61/* Prototypes */
62int card_check_rfmon_datalink (const char *device);
63int card_into_monitormode (const char *, int);
64int check_loopback();
65int card_set_promisc_up (const char *device);
66int card_remove_promisc (const char *device);
67int card_set_channel (const char *device, int channel,int cardtype);
68int iw_get_range_info(int skfd, const char * ifname, struct iw_range * range);
69double iw_freq2float(iw_freq * in);
70 void iw_float2freq(double in, iw_freq *out);
71int card_detect_channels (char * device);
72
73/*------------------------------------------------------------------*/
74/*
75 * Wrapper to push some Wireless Parameter in the driver
76 */
77static inline int
78 iw_set_ext(int skfd, /* Socket to the kernel */
79 char * ifname, /* Device name */
80 int request,/* WE ID */
81 struct iwreq * pwrq) /* Fixed part of the request */
82{
83 /* Set device name */
84 strncpy(pwrq->ifr_name, ifname, IFNAMSIZ);
85 /* Do the request */
86 return(ioctl(skfd, request, pwrq));
87}
88
89/*------------------------------------------------------------------*/
90/*
91 * Wrapper to extract some Wireless Parameter out of the driver
92 */
93static inline int
94 iw_get_ext(int skfd, /* Socket to the kernel */
95 char * ifname, /* Device name */
96 int request,/* WE ID */
97 struct iwreq * pwrq) /* Fixed part of the request */
98{
99 /* Set device name */
100 strncpy(pwrq->ifr_name, ifname, IFNAMSIZ);
101 /* Do the request */
102 return(ioctl(skfd, request, pwrq));
103}
104
105
106
107#endif /* CARDMODE_HH */
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/extract.hh b/noncore/net/wellenreiter/libwellenreiter/source/extract.hh
deleted file mode 100644
index f948bcb..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/extract.hh
+++ b/dev/null
@@ -1,59 +0,0 @@
1/* $Id$ */
2/*
3 * Copyright (c) 1992, 1993, 1994, 1995, 1996
4 *The Regents of the University of California. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that: (1) source code distributions
8 * retain the above copyright notice and this paragraph in its entirety, (2)
9 * distributions including binary code include the above copyright notice and
10 * this paragraph in its entirety in the documentation or other materials
11 * provided with the distribution, and (3) all advertising materials mentioning
12 * features or use of this software display the following acknowledgement:
13 * ``This product includes software developed by the University of California,
14 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
15 * the University nor the names of its contributors may be used to endorse
16 * or promote products derived from this software without specific prior
17 * written permission.
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 */
22/* Network to host order macros */
23
24#ifndef EXTRACT_HH
25#define EXTRACT_HH
26
27#ifdef LBL_ALIGN
28#define EXTRACT_16BITS(p) \
29 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
30 (u_int16_t)*((const u_int8_t *)(p) + 1)))
31#define EXTRACT_32BITS(p) \
32 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
33 (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
34 (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
35 (u_int32_t)*((const u_int8_t *)(p) + 3)))
36#else
37#define EXTRACT_16BITS(p) \
38 ((u_int16_t)ntohs(*(const u_int16_t *)(p)))
39#define EXTRACT_32BITS(p) \
40 ((u_int32_t)ntohl(*(const u_int32_t *)(p)))
41#endif
42
43#define EXTRACT_24BITS(p) \
44 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
45 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
46 (u_int32_t)*((const u_int8_t *)(p) + 2)))
47
48/* Little endian protocol host order macros */
49#define EXTRACT_LE_8BITS(p) (*(p))
50#define EXTRACT_LE_16BITS(p) \
51 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \
52 (u_int16_t)*((const u_int8_t *)(p) + 0)))
53#define EXTRACT_LE_32BITS(p) \
54 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \
55 (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
56 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
57 (u_int32_t)*((const u_int8_t *)(p) + 0)))
58
59#endif /* EXTRACT_HH */
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/ieee802_11.hh b/noncore/net/wellenreiter/libwellenreiter/source/ieee802_11.hh
deleted file mode 100644
index 872fd40..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/ieee802_11.hh
+++ b/dev/null
@@ -1,250 +0,0 @@
1/* $Id$ */
2/*
3 * Copyright (c) 2001
4 *Fortress Technologies
5 * Charlie Lenahan ( clenahan@fortresstech.com )
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)
10 * distributions including binary code include the above copyright notice and
11 * this paragraph in its entirety in the documentation or other materials
12 * provided with the distribution, and (3) all advertising materials mentioning
13 * features or use of this software display the following acknowledgement:
14 * ``This product includes software developed by the University of California,
15 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 * the University nor the names of its contributors may be used to endorse
17 * or promote products derived from this software without specific prior
18 * written permission.
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 */
23
24#ifndef IEEE802_11_HH
25#define IEEE802_11_HH
26
27 #define IEEE802_11_FC_LEN2
28
29#define T_MGMT 0x0 /* management */
30#define T_CTRL 0x1 /* control */
31#define T_DATA 0x2 /* data */
32#define T_RESV 0x3 /* reserved */
33
34 #define ST_ASSOC_REQUEST 0x0
35 #define ST_ASSOC_RESPONSE 0x1
36 #define ST_REASSOC_REQUEST 0x2
37 #define ST_REASSOC_RESPONSE 0x3
38 #define ST_PROBE_REQUEST 0x4
39 #define ST_PROBE_RESPONSE 0x5
40 /* RESERVED 0x6 */
41 /* RESERVED 0x7 */
42 #define ST_BEACON 0x8
43 #define ST_ATIM 0x9
44 #define ST_DISASSOC 0xA
45 #define ST_AUTH 0xB
46 #define ST_DEAUTH 0xC
47 /* RESERVED 0xD */
48 /* RESERVED 0xE */
49 /* RESERVED 0xF */
50
51
52 #define CTRL_PS_POLL0xA
53 #define CTRL_RTS0xB
54 #define CTRL_CTS0xC
55 #define CTRL_ACK0xD
56 #define CTRL_CF_END0xE
57 #define CTRL_END_ACK0xF
58
59/*
60 * Bits in the frame control field.
61 */
62 #define FC_VERSION(fc) ((fc) & 0x3)
63 #define FC_TYPE(fc) (((fc) >> 2) & 0x3)
64 #define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF)
65 #define FC_TO_DS(fc) ((fc) & 0x0100)
66 #define FC_FROM_DS(fc) ((fc) & 0x0200)
67 #define FC_MORE_FLAG(fc)((fc) & 0x0400)
68 #define FC_RETRY(fc) ((fc) & 0x0800)
69 #define FC_POWER_MGMT(fc)((fc) & 0x1000)
70 #define FC_MORE_DATA(fc)((fc) & 0x2000)
71 #define FC_WEP(fc) ((fc) & 0x4000)
72 #define FC_ORDER(fc) ((fc) & 0x8000)
73
74struct mgmt_header_t {
75 u_int16_tfc;
76 u_int16_t duration;
77 u_int8_tda[6];
78 u_int8_tsa[6];
79 u_int8_tbssid[6];
80 u_int16_tseq_ctrl;
81};
82
83 #define MGMT_HEADER_LEN(2+2+6+6+6+2)
84
85 #define CAPABILITY_ESS(cap)((cap) & 0x0001)
86 #define CAPABILITY_IBSS(cap)((cap) & 0x0002)
87 #define CAPABILITY_CFP(cap)((cap) & 0x0004)
88 #define CAPABILITY_CFP_REQ(cap)((cap) & 0x0008)
89 #define CAPABILITY_PRIVACY(cap)((cap) & 0x0010)
90
91struct ssid_t {
92 u_int8_telement_id;
93 u_int8_tlength;
94 u_char ssid[33]; /* 32 + 1 for null */
95} ;
96
97struct rates_t {
98 u_int8_telement_id;
99 u_int8_tlength;
100 u_int8_trate[8];
101};
102
103struct challenge_t {
104 u_int8_telement_id;
105 u_int8_tlength;
106 u_int8_ttext[254]; /* 1-253 + 1 for null */
107};
108struct fh_t {
109 u_int8_telement_id;
110 u_int8_tlength;
111 u_int16_tdwell_time;
112 u_int8_thop_set;
113 u_int8_t hop_pattern;
114 u_int8_thop_index;
115};
116
117struct ds_t {
118 u_int8_telement_id;
119 u_int8_tlength;
120 u_int8_tchannel;
121};
122
123struct cf_t {
124 u_int8_telement_id;
125 u_int8_tlength;
126 u_int8_tcount;
127 u_int8_tperiod;
128 u_int16_tmax_duration;
129 u_int16_tdur_remaing;
130};
131
132struct tim_t {
133 u_int8_telement_id;
134 u_int8_tlength;
135 u_int8_tcount;
136 u_int8_tperiod;
137 u_int8_tbitmap_control;
138 u_int8_tbitmap[251];
139};
140
141 #define E_SSID 0
142 #define E_RATES 1
143 #define E_FH 2
144 #define E_DS 3
145 #define E_CF 4
146 #define E_TIM 5
147 #define E_IBSS 6
148 #define E_CISCO 133
149 /* reserved 7 */
150 /* reserved 8 */
151 /* reserved 9 */
152 /* reserved 10 */
153 /* reserved 11 */
154 /* reserved 12 */
155 /* reserved 13 */
156 /* reserved 14 */
157 /* reserved 15 */
158 /* reserved 16 */
159
160 #define E_CHALLENGE 16
161 /* reserved 17 */
162 /* reserved 18 */
163 /* reserved 19 */
164 /* reserved 16 */
165 /* reserved 16 */
166
167
168struct mgmt_body_t {
169 u_int8_t timestamp[8];
170 u_int16_t beacon_interval;
171 u_int16_t listen_interval;
172 u_int16_t status_code;
173 u_int16_t aid;
174 u_char ap[6];
175 u_int16_treason_code;
176 u_int16_tauth_alg;
177 u_int16_tauth_trans_seq_num;
178 struct challenge_t challenge;
179 u_int16_tcapability_info;
180 struct ssid_tssid;
181 struct rates_t rates;
182 struct ds_tds;
183 struct cf_tcf;
184 struct fh_tfh;
185 struct tim_ttim;
186};
187
188struct ctrl_rts_t {
189 u_int16_tfc;
190 u_int16_tduration;
191 u_int8_tra[6];
192 u_int8_tta[6];
193 u_int8_tfcs[4];
194};
195
196 #define CTRL_RTS_LEN(2+2+6+6+4)
197
198struct ctrl_cts_t {
199 u_int16_tfc;
200 u_int16_tduration;
201 u_int8_tra[6];
202 u_int8_tfcs[4];
203};
204
205 #define CTRL_CTS_LEN(2+2+6+4)
206
207struct ctrl_ack_t {
208 u_int16_tfc;
209 u_int16_tduration;
210 u_int8_tra[6];
211 u_int8_tfcs[4];
212};
213
214 #define CTRL_ACK_LEN(2+2+6+4)
215
216struct ctrl_ps_poll_t {
217 u_int16_tfc;
218 u_int16_taid;
219 u_int8_tbssid[6];
220 u_int8_tta[6];
221 u_int8_tfcs[4];
222};
223
224 #define CTRL_PS_POLL_LEN(2+2+6+6+4)
225
226struct ctrl_end_t {
227 u_int16_tfc;
228 u_int16_tduration;
229 u_int8_tra[6];
230 u_int8_tbssid[6];
231 u_int8_tfcs[4];
232};
233
234 #define CTRL_END_LEN(2+2+6+6+4)
235
236struct ctrl_end_ack_t {
237 u_int16_tfc;
238 u_int16_tduration;
239 u_int8_tra[6];
240 u_int8_tbssid[6];
241 u_int8_tfcs[4];
242};
243
244 #define CTRL_END_ACK_LEN(2+2+6+6+4)
245
246 #define IV_IV(iv)((iv) & 0xFFFFFF)
247 #define IV_PAD(iv)(((iv) >> 24) & 0x3F)
248 #define IV_KEYID(iv)(((iv) >> 30) & 0x03)
249
250#endif /* IEEE802_11_HH */
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
deleted file mode 100644
index 0616a7e..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
+++ b/dev/null
@@ -1,419 +0,0 @@
1/*
2 * rfmon mode sniffer
3 *
4 * $Id$
5 */
6
7#include "sniff.hh"
8#include "ieee802_11.hh"
9#include "extract.hh"
10#include "wl_log.hh"
11#include "wl_types.hh"
12#include "wl_proto.hh"
13#include "cardmode.hh"
14
15int start_sniffer(const char *device, int cardtype )
16{
17
18 /* This function initialize the sniffing
19 1. Check for lo interface
20 2. bring it into promsicous mode and UP
21 3. bring device into rfmon mode
22 start the pcap sniffing process.
23 */
24
25 /* Do we have the device name ? */
26 if(device == NULL)
27 {
28 wl_logerr("start_sniffer, parameter \"device\" is empty, please check your config");
29 return 0;
30 }
31
32 /* Some Linux System does not have a loopback device lo with 127.0.0.1 so sockets could
33 not made correctly, let the proggie check that and proceed only if it exists. */
34 if (!check_loopback())
35 {
36 wl_logerr("start_sniffer, check_loopback failed, cannot continue without a loopback");
37 return 0;
38 }
39
40 /* Set the card into regulary promiscous mode first and set the UP flag, in case no ip
41 was given. It would work without the promisc flags but i dont like this */
42 if (!card_set_promisc_up(device))
43 {
44 wl_logerr("start_sniffer, card_set_promisc_up failed, cannot continue");
45 return 0;
46 }
47
48 /* Set card into the rfmon/monitoring mode */
49 if (!card_into_monitormode(device,cardtype))
50 {
51 wl_logerr("start_sniffer, cannot put wireless card into monitoring mode, aborting");
52 return 0;
53 }
54
55 /* setup pcap handle, used for the packet decoding etc. */
56 if((handletopcap = pcap_open_live((char *) device, BUFSIZ, 1, 0, NULL)) == NULL)
57 {
58 wl_logerr("pcap_open_live() failed: %s", strerror(errno));
59 return 0;
60 }
61
62#ifdef HAVE_PCAP_NONBLOCK
63 pcap_setnonblock(handletopcap, 1, NULL);
64#endif
65 return 1;
66}
67
68
69int stop_sniffer(const char *device, int cardtype)
70{
71 /* This function terminates the sniffing
72 1. get the device state
73 2. remove the rfmon state
74 3. Remove the promisc state
75 start the pcap sniffing process.
76
77 */
78
79 /* Do we really have at least a lo interface with the 127.0.0.1 ? */
80 return 0;
81
82}
83
84
85/* Main function, checks packets */
86void process_packets(const struct pcap_pkthdr *pkthdr,
87 const unsigned char *packet,
88 char *guihost,
89 int guiport)
90{
91 unsigned int caplen = pkthdr->caplen;
92 unsigned int length = pkthdr->len;
93 u_int16_t fc;
94 unsigned int HEADER_LENGTH;
95
96 /* pinfo holds all interresting information for us */
97 struct packetinfo pinfo;
98 struct packetinfo *pinfoptr;
99
100 /* wl_network_t will finally be set and send to the ui */
101 wl_network_t wl_net;
102
103 pinfoptr=&pinfo;
104
105 pinfoptr->isvalid = 0;
106 pinfoptr->pktlen = pkthdr->len;
107
108 if (caplen < IEEE802_11_FC_LEN)
109 {
110 /* This is a garbage packet, because is does not long enough
111 to hold a 802.11b header */
112 pinfoptr->isvalid = 0;
113 return;
114 }
115
116 /* Gets the framecontrol bits (2bytes long) */
117 fc = EXTRACT_LE_16BITS(packet);
118
119 HEADER_LENGTH = GetHeaderLength(fc);
120
121 if (caplen < HEADER_LENGTH)
122 {
123 /* This is a garbage packet, because it is not long enough
124 to hold a correct header of its type */
125 pinfoptr->isvalid = 0;
126 return;
127 }
128
129 /* Decode 802.11b header out of the packet */
130 if (decode_80211b_hdr(packet,pinfoptr) == 0)
131 {
132 /* Justification of the ofset to further process the packet */
133 length -= HEADER_LENGTH;
134 caplen -= HEADER_LENGTH;
135 packet += HEADER_LENGTH;
136 }
137 else /* Something is wrong,could not be a correct packet */
138 return;
139
140 switch (FC_TYPE(fc))
141 {
142 /* Is it a managemnet frame? */
143 case T_MGMT:
144 switch (FC_SUBTYPE(fc))
145 {
146 case ST_BEACON:
147 if (handle_beacon(fc, packet,pinfoptr) ==0)
148 {
149 if (!strcmp(pinfoptr->desthwaddr,"ff:ff:ff:ff:ff:ff") == 0)
150 {
151 /* Every beacon must have the broadcast as destination
152 so it must be a shitti packet */
153 pinfoptr->isvalid = 0;
154 return;
155 }
156
157 if (pinfoptr->cap_ESS == pinfoptr->cap_IBSS)
158 {
159 /* Only one of both are possible, so must be
160 a noise packet, if this comes up */
161 pinfoptr->isvalid = 0;
162 return;
163 }
164 if (pinfoptr->channel < 1 || pinfoptr->channel > 14)
165 {
166 /* Only channels between 1 and 14 are possible
167 others must be noise packets */
168 pinfoptr->isvalid = 0;
169 return;
170 }
171
172 /* Here should be the infos to the gui issued */
173 if (pinfoptr->cap_ESS == 1 && pinfoptr->cap_IBSS ==0)
174 {
175 wl_loginfo("Found an access point");
176 wl_net.net_type=1;
177 }
178 else if(pinfoptr->cap_ESS == 0 && pinfoptr->cap_IBSS == 2)
179 {
180 wl_loginfo("Found an ad-hoc network");
181 wl_net.net_type=2;
182 }
183
184 if (strcmp (pinfoptr->ssid,NONBROADCASTING) ==0)
185 wl_loginfo("Net is a non-broadcasting network");
186 else
187 wl_loginfo("SSID is: %s", pinfoptr->ssid);
188
189 wl_loginfo("SSID is: %s", pinfoptr->ssid);
190 memset(wl_net.bssid, 0, sizeof(wl_net.bssid));
191 memcpy(wl_net.bssid, pinfoptr->ssid, sizeof(wl_net.bssid)-1);
192
193 wl_loginfo("SSID length is: %d", pinfoptr->ssid_len);
194 wl_net.ssid_len=pinfoptr->ssid_len;
195
196 wl_loginfo("Channel is: %d", pinfoptr->channel);
197 wl_net.channel=pinfoptr->channel;
198 wl_net.wep=pinfoptr->cap_WEP;
199
200 wl_loginfo("Mac is: %s", pinfoptr->sndhwaddr);
201 memset(wl_net.mac, 0, sizeof(wl_net.mac));
202 memcpy(wl_net.mac, pinfoptr->sndhwaddr, sizeof(wl_net.mac)-1);
203
204 if(!send_network_found((char *)guihost, guiport, &wl_net))
205 {
206 wl_logerr("Error sending data to UI: %s", strerror(errno));
207 break;
208 }
209 wl_loginfo("Sent network to GUI '%s:%d'", guihost, guiport);
210 }
211 break;
212
213 default:
214 wl_logerr("Unknown IEEE802.11 frame subtype (%d)", FC_SUBTYPE(fc));
215 break;
216 } /* End of switch over different mgt frame types */
217
218 break;
219
220 case T_CTRL:
221 wl_loginfo("Received control frame, not implemented yet");
222 break;
223
224 case T_DATA:
225 wl_loginfo("Received date frame, not implemented yet");
226 break;
227
228 default:
229 wl_logerr("Unknown IEEE802.11 frame type (%d)", FC_TYPE(fc));
230 break;
231 }
232}
233
234/* This decodes the 802.11b frame header out of the 802.11b packet
235 all the infos is placed into the packetinfo structure */
236int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo)
237{
238 const struct mgmt_header_t *mgthdr = (const struct mgmt_header_t *) p;
239 ppinfo->fcsubtype = FC_SUBTYPE(mgthdr->fc);
240
241 /* Get the sender, bssid and dest mac address */
242 etheraddr_string(mgthdr->bssid,ppinfo->bssid);
243 etheraddr_string(mgthdr->da,ppinfo->desthwaddr);
244 etheraddr_string(mgthdr->sa,ppinfo->sndhwaddr);
245 ppinfo->fc_wep = FC_WEP(mgthdr->fc);
246 return 0;
247}
248
249
250void etheraddr_string(register const u_char *ep, char *text)
251{
252 static char hex[] = "0123456789abcdef";
253 register unsigned int i, j;
254 register char *cp;
255 char buf[sizeof("00:00:00:00:00:00\0")];
256 cp = buf;
257 if ((j = *ep >> 4) != 0)
258 {
259 *cp++ = hex[j];
260 }
261 else
262 {
263 *cp++ = '0';
264 }
265 *cp++ = hex[*ep++ & 0xf];
266
267 for (i = 5; (int)--i >= 0;)
268 {
269 *cp++ = ':';
270 if ((j = *ep >> 4) != 0)
271 {
272 *cp++ = hex[j];
273 }
274 else
275 {
276 *cp++ = '0';
277 }
278
279 *cp++ = hex[*ep++ & 0xf];
280 }
281 *cp = '\0';
282 strcpy(text,buf);
283}
284
285/* beacon handler */
286int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo)
287{
288 struct mgmt_body_t pbody;
289 int offset = 0;
290
291 /* Get the static informations out of the packet */
292 memset(&pbody, 0, sizeof(pbody));
293 memcpy(&pbody.timestamp, p, 8);
294 offset += 8;
295 pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset);
296 offset += 2;
297 pbody.capability_info = EXTRACT_LE_16BITS(p+offset);
298 offset += 2;
299
300 /* Gets the different flags out of the capabilities */
301 ppinfo->cap_ESS = CAPABILITY_ESS(pbody.capability_info);
302 ppinfo->cap_IBSS = CAPABILITY_IBSS(pbody.capability_info);
303 ppinfo->cap_WEP = CAPABILITY_PRIVACY(pbody.capability_info);
304
305 /* Gets the tagged elements out of the packets */
306 while (offset + 1 < ppinfo->pktlen)
307 {
308 switch (*(p + offset))
309 {
310 case E_SSID:
311 memcpy(&(pbody.ssid),p+offset,2); offset += 2;
312 if (pbody.ssid.length > 0)
313 {
314 memcpy(&(pbody.ssid.ssid),p+offset,pbody.ssid.length);
315 offset += pbody.ssid.length;
316 pbody.ssid.ssid[pbody.ssid.length]='\0';
317 if (strcmp((char *)pbody.ssid.ssid,"")==0)
318 memcpy(ppinfo->ssid, NONBROADCASTING, sizeof(ppinfo->ssid));
319 else
320 memcpy(ppinfo->ssid, pbody.ssid.ssid, sizeof(ppinfo->ssid));
321 ppinfo->ssid_len = pbody.ssid.length;
322 }
323 break;
324
325 case E_CHALLENGE:
326 memcpy(&(pbody.challenge),p+offset,2); offset += 2;
327 if (pbody.challenge.length > 0)
328 {
329 memcpy(&(pbody.challenge.text),p+offset,pbody.challenge.length);
330 offset += pbody.challenge.length;
331 pbody.challenge.text[pbody.challenge.length]='\0';
332 }
333 break;
334 case E_RATES:
335 memcpy(&(pbody.rates),p+offset,2); offset += 2;
336 if (pbody.rates.length > 0)
337 {
338 memcpy(&(pbody.rates.rate),p+offset,pbody.rates.length);
339 offset += pbody.rates.length;
340 }
341 break;
342 case E_DS:
343 memcpy(&(pbody.ds),p+offset,3);
344 offset +=3;
345 ppinfo->channel = pbody.ds.channel;
346 break;
347 case E_CF:
348 memcpy(&(pbody.cf),p+offset,8);
349 offset +=8;
350 break;
351 case E_TIM:
352 memcpy(&(pbody.tim),p+offset,2);
353 offset +=2;
354 memcpy(&(pbody.tim.count),p+offset,3);
355 offset +=3;
356 if ((pbody.tim.length -3) > 0)
357 {
358 memcpy((pbody.tim.bitmap),p+(pbody.tim.length -3),(pbody.tim.length -3));
359 offset += pbody.tim.length -3;
360 }
361 break;
362 default:
363
364 offset+= *(p+offset+1) + 2;
365 break;
366 } /* end of switch*/
367 } /* end of for loop */
368 return 0;
369
370} /* End of handle_beacon */
371
372
373int GetHeaderLength(u_int16_t fc)
374{
375 int iLength=0;
376
377 switch (FC_TYPE(fc))
378 {
379 case T_MGMT:
380 iLength = MGMT_HEADER_LEN;
381 break;
382 case T_CTRL:
383 switch (FC_SUBTYPE(fc))
384 {
385 case CTRL_PS_POLL:
386 iLength = CTRL_PS_POLL_LEN;
387 break;
388 case CTRL_RTS:
389 iLength = CTRL_RTS_LEN;
390 break;
391 case CTRL_CTS:
392 iLength = CTRL_CTS_LEN;
393 break;
394 case CTRL_ACK:
395 iLength = CTRL_ACK_LEN;
396 break;
397 case CTRL_CF_END:
398 iLength = CTRL_END_LEN;
399 break;
400 case CTRL_END_ACK:
401 iLength = CTRL_END_ACK_LEN;
402 break;
403 default:
404 iLength = 0;
405 break;
406 }
407 break;
408 case T_DATA:
409 if (FC_TO_DS(fc) && FC_FROM_DS(fc))
410 iLength = 30;
411 else
412 iLength = 24;
413 break;
414 default:
415 wl_logerr("unknown IEEE802.11 frame type (%d)", FC_TYPE(fc));
416 break;
417 }
418 return iLength;
419}
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh b/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh
deleted file mode 100644
index a4cf4b7..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh
+++ b/dev/null
@@ -1,73 +0,0 @@
1/* $Id$ */
2
3#ifndef SNIFF_HH
4#define SNIFF_HH
5
6#include <string.h>
7#include <stdio.h>
8#include <stdlib.h>
9#include <errno.h>
10#include <sys/types.h>
11#include <sys/time.h>
12#include <sys/socket.h>
13#include <netinet/in.h>
14#include <arpa/inet.h>
15
16extern "C"
17{
18#include <net/bpf.h>
19#include <pcap.h>
20}
21
22#define NONBROADCASTING "non-broadcasting"
23
24/* holds all the interresting data */
25struct packetinfo
26{
27 int isvalid;
28 int pktlen;
29 int fctype;
30 int fcsubtype;
31 int fc_wep;
32 int cap_WEP;
33 int cap_IBSS;
34 int cap_ESS;
35 int channel;
36 char bssid[sizeof("00:00:00:00:00:00") + 1];
37 char desthwaddr[sizeof("00:00:00:00:00:00") + 1];
38 char sndhwaddr[sizeof("00:00:00:00:00:00") + 1];
39 char ssid[128];
40 int ssid_len;
41};
42
43/* Function definitions */
44/* Used for stoping and starting the sniffer process */
45int start_sniffer(const char *device, int cardtype);
46int stop_sniffer(const char *device, int cardtype);
47void process_packets(const struct pcap_pkthdr* pkthdr,const u_char* packet, char *, int);
48int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo);
49void etheraddr_string(register const u_char *ep,char * text);
50int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo);
51int GetHeaderLength(u_int16_t fc);
52
53/*
54 * True if "l" bytes of "var" were captured.
55 *
56 * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large
57 * that "snapend - (l)" underflows.
58 *
59 * The check is for <= rather than < because "l" might be 0.
60 */
61#define TTEST2(var, l) (snapend - (l) <= snapend && \
62 (const u_char *)&(var) <= snapend - (l))
63
64/* True if "var" was captured */
65#define TTEST(var) TTEST2(var, sizeof(var))
66
67/* Bail if "l" bytes of "var" were not captured */
68#define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc
69
70/* Bail if "var" was not captured */
71#define TCHECK(var) TCHECK2(var, sizeof(var))
72
73#endif /* SNIFF_HH */
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc
deleted file mode 100644
index ba56754..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc
+++ b/dev/null
@@ -1,81 +0,0 @@
1/*
2 * Configfile operations for wellenreiter
3 *
4 * $Id$
5 */
6
7#include "wl_conf.hh"
8#include "wl_log.hh"
9#include "wl_types.hh"
10
11/* Check whether configfile exists and is readable */
12int wl_checkcfg(void)
13{
14 FILE *wl_config;
15
16 if((wl_config = fopen(WL_CONFFILE, "r")) == NULL)
17 {
18 wl_logerr("Cannot open configfile: %s", strerror(errno));
19 return 0;
20 }
21 else
22 {
23 fclose(wl_config);
24 return 1;
25 }
26
27}
28
29/* Get value for given token from config file */
30int wl_cfgvalue(const char *token, char *out, int maxlen)
31{
32 FILE *wl_config;
33 char *ptr, *ptr2;
34 char confbuf[WL_CONFBUFF];
35
36 if(token == NULL)
37 return -1;
38
39 if((wl_config = fopen(WL_CONFFILE, "r")) == NULL)
40 {
41 wl_logerr("Cannot open configfile: %s", strerror(errno));
42 return -1;
43 }
44
45 /* Clear buffers */
46 memset(out, 0, maxlen);
47 memset(confbuf, 0, sizeof(confbuf));
48
49 while((fgets(confbuf, sizeof(confbuf) - 1, wl_config)) != NULL)
50 {
51
52 /* Ignore comments */
53 if(confbuf[0] == '#') continue;
54
55 /* Search for token, if found check whether next character
56 * is a '=' or a ' '
57 */
58 if(strstr(confbuf, token) != NULL &&
59 (confbuf[strlen(token)] == '=' || confbuf[strlen(token)] == ' '))
60 {
61
62 /* Get value between quotes */
63 if((ptr = strstr(confbuf, "\"")) == NULL)
64 break;
65 ++ptr;
66 if((ptr2 = strstr(ptr, "\"")) == NULL)
67 break;
68 ptr2[0] = '\0';
69
70 memcpy(out, ptr, maxlen - 1);
71 break;
72
73 }
74 memset(confbuf, 0, sizeof(confbuf));
75 }
76
77 fclose(wl_config);
78
79 return (out[0] == '\0' ? 0 : 1);
80}
81
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.hh
deleted file mode 100644
index 4061440..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.hh
+++ b/dev/null
@@ -1,12 +0,0 @@
1/* $Id$ */
2
3#ifndef WLCONF_HH
4#define WLCONF_HH
5
6#include <string.h>
7#include <errno.h>
8
9int wl_checkcfg(void);
10int wl_cfgvalue(const char *, char *, int);
11
12#endif /* WLCONF_HH */
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_log.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_log.cc
deleted file mode 100644
index 7adaba8..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/wl_log.cc
+++ b/dev/null
@@ -1,51 +0,0 @@
1/*
2 * Small functions to log to syslog
3 *
4 * $Id$
5 */
6
7#include "wl_log.hh"
8
9/* Log to syslog INFO */
10void wl_loginfo(const char *fmt,...)
11{
12
13 char buffer[4096];
14 va_list ap;
15
16 memset(buffer, 0, sizeof(buffer));
17 va_start(ap, fmt);
18 vsnprintf(buffer, sizeof(buffer)-1, fmt, ap);
19 va_end(ap);
20
21 openlog("libwellenreiter", LOG_PID, LOG_SYSLOG);
22 syslog(LOG_INFO, "(info) %s", buffer);
23 closelog();
24
25#ifdef DEBUG
26 fprintf(stderr, "(info) %s\n", buffer);
27#endif
28
29}
30
31/* Log to syslog ERR */
32void wl_logerr(const char *fmt,...)
33{
34
35 char buffer[4096];
36 va_list ap;
37
38 memset(buffer, 0, sizeof(buffer));
39 va_start(ap, fmt);
40 vsnprintf(buffer, sizeof(buffer)-1, fmt, ap);
41 va_end(ap);
42
43 openlog("libwellenreiter", LOG_PID, LOG_SYSLOG);
44 syslog(LOG_INFO, "(err) %s", buffer);
45 closelog();
46
47#ifdef DEBUG
48 fprintf(stderr, "(err) %s\n", buffer);
49#endif
50
51}
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_log.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_log.hh
deleted file mode 100644
index 8f6e543..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/wl_log.hh
+++ b/dev/null
@@ -1,14 +0,0 @@
1/* $Id$ */
2
3#ifndef WLLOG_HH
4#define WLLOG_HH
5
6#include <stdio.h>
7#include <syslog.h>
8#include <stdarg.h>
9#include <string.h>
10
11void wl_loginfo(const char *, ...);
12void wl_logerr(const char *, ...);
13
14#endif /* WLLOG_HH */
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc
deleted file mode 100644
index 6c3846f..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc
+++ b/dev/null
@@ -1,221 +0,0 @@
1/*
2 * Communication protocol
3 *
4 * $Id$
5 */
6
7#include "wl_types.hh"
8#include "wl_proto.hh"
9#include "wl_log.hh"
10#include "wl_sock.hh"
11
12/* Adds a field to the buffer */
13unsigned int add_field(char *buffer, const char *string, int len)
14{
15 char newlen[5];
16
17 /* 3 Byte = Length */
18 memset(newlen, 0, sizeof(newlen));
19 snprintf(newlen, sizeof(newlen) - 1, "%.3d", len);
20 memcpy(buffer, newlen, 3);
21
22 /* Length bytes = Value */
23 memcpy(buffer + 3, string, atoi(newlen));
24
25 /* Return length of attached field */
26 return (atoi(newlen) + 3);
27}
28
29unsigned int get_field(const char *buffer, char *out, int maxlen)
30{
31 char len[5];
32
33 /* Get length of value */
34 memset(len, 0, sizeof(len));
35 memcpy(len, buffer, 3);
36
37 /* Copy buffer to out pointer */
38 memset(out, 0, maxlen);
39 if(atoi(len) > maxlen -1)
40 memcpy(out, buffer + 3, maxlen - 1);
41 else
42 memcpy(out, buffer + 3, atoi(len));
43
44 /* Return length of whole field (including 3 byte length) */
45 return (atoi(len) + 3);
46}
47
48/* Send ok message */
49int send_ok(const char *guihost, int guiport, int code)
50{
51 unsigned int len = 0;
52 char buffer[128], temp[5];
53
54 memset(buffer, 0, sizeof(buffer));
55
56 memset(temp, 0, sizeof(temp));
57 snprintf(temp, sizeof(temp) - 1, "%.2d", CMD_OK);
58 memcpy(buffer, temp, 2);
59 len += 2;
60
61 memset(temp, 0, sizeof(temp));
62 snprintf(temp, sizeof(temp) - 1, "%.2d", code);
63 len += add_field(buffer + len, temp, 2);
64
65 /* Send prepared buffer to UI */
66#ifdef DEBUG
67 wl_loginfo("Sent ok to UI: '%s'", buffer);
68#endif
69
70 return ((!wl_send(guihost, guiport, buffer)) ? 0 : 1);
71}
72
73/* Send fail message */
74int send_fail(const char *guihost, int guiport,
75 int code, const char *errstr)
76{
77 unsigned int len = 0;
78 char buffer[128], temp[5];
79
80 memset(buffer, 0, sizeof(buffer));
81
82 memset(temp, 0, sizeof(temp));
83 snprintf(temp, sizeof(temp) - 1, "%.2d", CMD_FAIL);
84 memcpy(buffer, temp, 2);
85 len += 2;
86
87 memset(temp, 0, sizeof(temp));
88 snprintf(temp, sizeof(temp) - 1, "%.2d", code);
89 len += add_field(buffer + len, temp, 2);
90
91 len += add_field(buffer + len, errstr, strlen(errstr));
92
93 /* Send prepared buffer to UI */
94#ifdef DEBUG
95 wl_loginfo("Send CMD_FAIL to UI: '%s'", buffer);
96#endif
97
98 return ((!wl_send(guihost, guiport, buffer)) ? 0 : 1);
99}
100
101int get_ok(const char *buffer)
102{
103 char temp[5];
104 unsigned int len = 0;
105
106 /* packet type already determined, skip check */
107 len += 2;
108
109 /* what is ok for? */
110 memset(temp, 0, sizeof(temp));
111 len += get_field(buffer + len, temp, sizeof(temp));
112
113 return atoi(temp);
114}
115
116/* put failmessage into buffer */
117int get_fail(char *out, const char *buffer, size_t bufflen)
118{
119 char temp[5];
120 int error=0;
121 unsigned int len = 0;
122
123 /* packet type already determined, skip check */
124 len += 2;
125
126 /* what is fail for? */
127 memset(temp, 0, sizeof(temp));
128 len += get_field(buffer + len, temp, sizeof(temp));
129 error=atoi(temp);
130
131 /* get errorstring and fill into buffer */
132 memset(out, 0, bufflen);
133 len += get_field(buffer + len, out, bufflen - 1);
134
135 return error;
136}
137
138
139/* Send found network to UI */
140int send_network_found (const char *guihost, int guiport, void *structure)
141{
142 wl_network_t *ptr;
143 char buffer[2048], temp[5];
144 unsigned int len = 0;
145
146 ptr = (wl_network_t *)structure;
147
148 memset(buffer,0,sizeof(buffer));
149 /* Type = Found new net (without length field) */
150 memset(temp, 0, sizeof(temp));
151 snprintf(temp, sizeof(temp) - 1, "%.2d", WL_NETFOUND);
152 memcpy(buffer, temp, 2);
153 len += 2;
154
155 /* Set Net-type */
156 memset(temp, 0, sizeof(temp));
157 snprintf(temp, sizeof(temp) - 1, "%d", ptr->net_type);
158 len += add_field(buffer + len, temp, 1);
159
160 /* Set channel */
161 memset(temp, 0, sizeof(temp));
162 snprintf(temp, sizeof(temp) - 1, "%.2d", ptr->channel);
163 len += add_field(buffer + len, temp, 2);
164
165 /* Set WEP y/n */
166 memset(temp, 0, sizeof(temp));
167 snprintf(temp, sizeof(temp) - 1, "%d", ptr->wep);
168 len += add_field(buffer + len, temp, 1);
169
170 /* Set Mac */
171 len += add_field(buffer + len, ptr->mac, 17);
172
173 /* Set ssid */
174 if(len + ptr->ssid_len < sizeof(buffer) - 1)
175 len += add_field(buffer + len, ptr->bssid, ptr->ssid_len);
176 else
177 len += add_field(buffer + len, ptr->bssid, sizeof(buffer) - len - 1);
178
179 /* Send prepared buffer to UI */
180#ifdef DEBUG
181 wl_loginfo("Sending network to UI: '%s'", buffer);
182#endif
183
184 return ((!wl_send(guihost, guiport, buffer)) ? 0 : 1);
185}
186
187/* Fill buffer into structur */
188int get_network_found (void *structure, const char *buffer)
189{
190 wl_network_t *ptr;
191 char temp[5];
192 unsigned int len = 0;
193
194 ptr = (wl_network_t *)structure;
195
196 /* packet type already determined, skip check */
197 len += 2;
198
199 /* Get net type (accesspoint || ad-hoc || ...) */
200 memset(temp, 0, sizeof(temp));
201 len += get_field(buffer + len, temp, sizeof(temp));
202 ptr->net_type = atoi(temp);
203
204 /* Get channel */
205 memset(temp, 0, sizeof(temp));
206 len += get_field(buffer + len, temp, sizeof(temp));
207 ptr->channel = atoi(temp);
208
209 /* Set WEP y/n */
210 memset(temp, 0, sizeof(temp));
211 len += get_field(buffer + len, temp, sizeof(temp));
212 ptr->wep = atoi(temp);
213
214 /* Set MAC address */
215 len += get_field(buffer + len, ptr->mac, sizeof(ptr->mac));
216
217 /* Set BSSID */
218 len += get_field(buffer + len, ptr->bssid, sizeof(ptr->bssid));
219
220 return 1;
221}
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh
deleted file mode 100644
index 63ac53b..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh
+++ b/dev/null
@@ -1,27 +0,0 @@
1/* $Id$ */
2
3#ifndef WLPROTO_HH
4#define WLPROTO_HH
5
6#include <stdio.h>
7#include <string.h>
8#include <stdlib.h>
9
10/* Type definitions, to be continued */
11#define NETFOUND 01
12#define NETLOST 02
13#define CMD_FAIL 50
14#define CMD_OK 51
15#define STARTSNIFF 98
16#define STOPSNIFF 99
17
18unsigned int add_field(char *, const char *, int);
19unsigned int get_field(const char *, char *, int);
20int send_ok(const char *, int, int);
21int get_ok(const char *);
22int send_fail(const char *, int, int, const char *);
23int get_fail(char *, const char *, size_t);
24int send_network_found (const char *, int, void *);
25int get_network_found (void *, const char *);
26
27#endif /* WLPROTO_HH */
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc
deleted file mode 100644
index 6e26cb8..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc
+++ b/dev/null
@@ -1,92 +0,0 @@
1/*
2 * Socket operations for wellenreiter
3 *
4 * $Id$
5 */
6
7#include "wl_sock.hh"
8#include "wl_log.hh"
9
10/* Setup UDP Socket for incoming commands */
11int wl_setupsock(const char *host, int port, struct sockaddr_in saddr)
12{
13 int sock;
14
15 if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
16 {
17 wl_logerr("Cannot set up socket: %s", strerror(errno));
18 return -1;
19 }
20
21 memset(&saddr, 0, sizeof(saddr));
22 saddr.sin_family = PF_INET;
23 saddr.sin_port = htons(port);
24 saddr.sin_addr.s_addr = inet_addr(host);
25
26 if(bind(sock,(struct sockaddr *)&saddr, sizeof(saddr)) < 0)
27 {
28 wl_logerr("Cannot bind socket: %s", strerror(errno));
29 close(sock);
30 return -1;
31 }
32
33 return sock;
34}
35
36/* Send a string to commsock */
37int wl_send(const char *host, int port, const char *string, ...)
38{
39 int sock;
40 char buffer[4096];
41 struct sockaddr_in saddr;
42 va_list ap;
43
44 /* Generate string */
45 memset(buffer, 0, sizeof(buffer));
46 va_start(ap, string);
47 vsnprintf(buffer, sizeof(buffer)-1, string, ap);
48 va_end(ap);
49
50 saddr.sin_family = AF_INET;
51 saddr.sin_port = htons(port);
52 saddr.sin_addr.s_addr = inet_addr(host);
53
54 /* Setup socket */
55 if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
56 {
57 wl_logerr("Cannot set up socket: %s", strerror(errno));
58 return 0;
59 }
60
61 if(sendto(sock, buffer, sizeof(buffer), 0, (struct sockaddr *)&saddr, sizeof(saddr)) < 0)
62 {
63 wl_logerr("Cannot write to socket: %s", strerror(errno));
64 close(sock);
65 return 0;
66 }
67
68 if(close(sock) < 0)
69 wl_logerr("Cannot close socket: %s", strerror(errno));
70
71 return 1;
72}
73
74/* Check for new messages on commsock */
75int wl_recv(int *sock, struct sockaddr_in cliaddr, char *out, int maxlen)
76{
77 socklen_t len = sizeof(struct sockaddr);
78 char retval[3];
79
80 memset(out, 0, maxlen);
81 if(recvfrom(*sock, out, maxlen - 1, 0, (struct sockaddr *)&cliaddr, &len) < 0)
82 {
83 wl_logerr("Cannot receive from socket: %s", strerror(errno));
84 return -1;
85 }
86
87 /* Get packet type and return it */
88 memset(retval, 0, sizeof(retval));
89 memcpy(retval, out, 2);
90
91 return atoi(retval);
92}
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.hh
deleted file mode 100644
index e7d9747..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.hh
+++ b/dev/null
@@ -1,21 +0,0 @@
1/* $Id */
2
3#ifndef WLSOCK_HH
4#define WLSOCK_HH
5
6#include <stdarg.h>
7#include <sys/types.h>
8#include <sys/socket.h>
9#include <netinet/in.h>
10#include <arpa/inet.h>
11#include <signal.h>
12#include <string.h>
13#include <unistd.h>
14#include <stdlib.h>
15#include <errno.h>
16
17int wl_setupsock(const char *, int, struct sockaddr_in);
18int wl_send(const char *, int, const char *, ...);
19int wl_recv(int *, struct sockaddr_in, char *, int);
20
21#endif /* WLSOCK_HH */
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_types.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_types.hh
deleted file mode 100644
index afc105c..0000000
--- a/noncore/net/wellenreiter/libwellenreiter/source/wl_types.hh
+++ b/dev/null
@@ -1,43 +0,0 @@
1/*
2 * Global bufffer size and type definitions
3 *
4 * $Id$
5 *
6 */
7
8#ifndef WL_TYPES_HH
9#define WL_TYPES_HH
10
11/* Type definitions, to be continued */
12#define WL_NETFOUND 01
13#define WL_NETLOST 02
14#define WL_STARTSNIFF 98
15#define WL_STOPSNIFF 99
16
17/* Socket specific */
18#define WL_SOCKBUF 512 /* Buffer for wl_send and wl_recv calls */
19
20/* Channelswitching */
21typedef struct {
22 int type; /* Type of card (chip) */
23 char iface[6]; /* Interface of card */
24} wl_cardtype_t;
25
26
27/* WL network structure */
28typedef struct {
29 int net_type; /* 1 = Accesspoint ; 2 = Ad-Hoc */
30 int ssid_len; /* Length of SSID */
31 int channel; /* Channel */
32 int wep; /* 1 = WEP enabled ; 0 = disabled */
33 char mac[64]; /* MAC address of Accesspoint */
34 char bssid[128]; /* BSSID of Net */
35} wl_network_t;
36
37/* Config specific */
38#define WL_CONFFILE "sample.conf"
39#define WL_CONFBUFF 128
40
41
42#endif /* WL_TYPES_HH */
43