5 files changed, 45 insertions, 41 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc index e516177..6e512c4 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc +++ b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc | |||
@@ -9,8 +9,12 @@ | |||
9 | #include "extract.hh" | 9 | #include "extract.hh" |
10 | #include "wl_log.hh" | 10 | #include "wl_log.hh" |
11 | #include "wl_types.hh" | ||
11 | #include "wl_proto.hh" | 12 | #include "wl_proto.hh" |
12 | 13 | ||
13 | /* Main function, checks packets */ | 14 | /* Main function, checks packets */ |
14 | void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *packet, char *guihost, int guiport) | 15 | void process_packets(const struct pcap_pkthdr *pkthdr, |
16 | const unsigned char *packet, | ||
17 | char *guihost, | ||
18 | int guiport) | ||
15 | { | 19 | { |
16 | unsigned int caplen = pkthdr->caplen; | 20 | unsigned int caplen = pkthdr->caplen; |
@@ -96,16 +100,14 @@ void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *pack | |||
96 | 100 | ||
97 | /* Here should be the infos to the gui issued */ | 101 | /* Here should be the infos to the gui issued */ |
98 | if (pinfoptr->cap_ESS == 1 &&pinfoptr->cap_IBSS ==0) | 102 | if (pinfoptr->cap_ESS == 1 && pinfoptr->cap_IBSS ==0) |
99 | { | 103 | { |
100 | wl_loginfo("Found an access point"); | 104 | wl_loginfo("Found an access point"); |
101 | wl_net.net_type=1; | 105 | wl_net.net_type=1; |
102 | } | 106 | } |
103 | else if(pinfoptr->cap_ESS == 0 && pinfoptr->cap_IBSS == 2) | 107 | else if(pinfoptr->cap_ESS == 0 && pinfoptr->cap_IBSS == 2) |
104 | { | 108 | { |
105 | wl_loginfo("Found an ad-hoc network"); | 109 | wl_loginfo("Found an ad-hoc network"); |
106 | wl_net.net_type=2; | 110 | wl_net.net_type=2; |
107 | } | 111 | } |
108 | |||
109 | memset(wl_net.bssid, 0, sizeof(wl_net.bssid)); | ||
110 | 112 | ||
111 | if (strcmp (pinfoptr->ssid,NONBROADCASTING) ==0) | 113 | if (strcmp (pinfoptr->ssid,NONBROADCASTING) ==0) |
@@ -115,4 +117,5 @@ void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *pack | |||
115 | 117 | ||
116 | wl_loginfo("SSID is: %s", pinfoptr->ssid); | 118 | wl_loginfo("SSID is: %s", pinfoptr->ssid); |
119 | memset(wl_net.bssid, 0, sizeof(wl_net.bssid)); | ||
117 | memcpy(wl_net.bssid, pinfoptr->ssid, sizeof(wl_net.bssid)-1); | 120 | memcpy(wl_net.bssid, pinfoptr->ssid, sizeof(wl_net.bssid)-1); |
118 | 121 | ||
@@ -238,5 +241,6 @@ int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) | |||
238 | if (pbody.ssid.length > 0) | 241 | if (pbody.ssid.length > 0) |
239 | { | 242 | { |
240 | memcpy(&(pbody.ssid.ssid),p+offset,pbody.ssid.length); offset += pbody.ssid.length; | 243 | memcpy(&(pbody.ssid.ssid),p+offset,pbody.ssid.length); |
244 | offset += pbody.ssid.length; | ||
241 | pbody.ssid.ssid[pbody.ssid.length]='\0'; | 245 | pbody.ssid.ssid[pbody.ssid.length]='\0'; |
242 | if (strcmp((char *)pbody.ssid.ssid,"")==0) | 246 | if (strcmp((char *)pbody.ssid.ssid,"")==0) |
@@ -252,5 +256,6 @@ int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) | |||
252 | if (pbody.challenge.length > 0) | 256 | if (pbody.challenge.length > 0) |
253 | { | 257 | { |
254 | memcpy(&(pbody.challenge.text),p+offset,pbody.challenge.length); offset += pbody.challenge.length; | 258 | memcpy(&(pbody.challenge.text),p+offset,pbody.challenge.length); |
259 | offset += pbody.challenge.length; | ||
255 | pbody.challenge.text[pbody.challenge.length]='\0'; | 260 | pbody.challenge.text[pbody.challenge.length]='\0'; |
256 | } | 261 | } |
@@ -260,17 +265,22 @@ int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) | |||
260 | if (pbody.rates.length > 0) | 265 | if (pbody.rates.length > 0) |
261 | { | 266 | { |
262 | memcpy(&(pbody.rates.rate),p+offset,pbody.rates.length); offset += pbody.rates.length; | 267 | memcpy(&(pbody.rates.rate),p+offset,pbody.rates.length); |
268 | offset += pbody.rates.length; | ||
263 | } | 269 | } |
264 | break; | 270 | break; |
265 | case E_DS: | 271 | case E_DS: |
266 | memcpy(&(pbody.ds),p+offset,3); offset +=3; | 272 | memcpy(&(pbody.ds),p+offset,3); |
273 | offset +=3; | ||
267 | ppinfo->channel = pbody.ds.channel; | 274 | ppinfo->channel = pbody.ds.channel; |
268 | break; | 275 | break; |
269 | case E_CF: | 276 | case E_CF: |
270 | memcpy(&(pbody.cf),p+offset,8); offset +=8; | 277 | memcpy(&(pbody.cf),p+offset,8); |
278 | offset +=8; | ||
271 | break; | 279 | break; |
272 | case E_TIM: | 280 | case E_TIM: |
273 | memcpy(&(pbody.tim),p+offset,2); offset +=2; | 281 | memcpy(&(pbody.tim),p+offset,2); |
274 | memcpy(&(pbody.tim.count),p+offset,3); offset +=3; | 282 | offset +=2; |
283 | memcpy(&(pbody.tim.count),p+offset,3); | ||
284 | offset +=3; | ||
275 | if ((pbody.tim.length -3) > 0) | 285 | if ((pbody.tim.length -3) > 0) |
276 | { | 286 | { |
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc index 0630d04..664ba92 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc +++ b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc | |||
@@ -5,4 +5,5 @@ | |||
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include "wl_types.hh" | ||
7 | #include "wl_proto.hh" | 8 | #include "wl_proto.hh" |
8 | #include "wl_log.hh" | 9 | #include "wl_log.hh" |
@@ -35,5 +36,5 @@ int get_field(const char *buffer, char *out, int maxlen) | |||
35 | memset(out, 0, maxlen); | 36 | memset(out, 0, maxlen); |
36 | 37 | ||
37 | if(atoi(len)-3 > maxlen -1) | 38 | if(atoi(len) > maxlen -1) |
38 | memcpy(out, buffer + 3, maxlen - 1); | 39 | memcpy(out, buffer + 3, maxlen - 1); |
39 | else | 40 | else |
@@ -55,5 +56,5 @@ int send_network_found (const char *guihost, int guiport, void *structure) | |||
55 | /* Type = Found new net (without length field) */ | 56 | /* Type = Found new net (without length field) */ |
56 | memset(temp, 0, sizeof(temp)); | 57 | memset(temp, 0, sizeof(temp)); |
57 | snprintf(temp, sizeof(temp), "%.2d", NETFOUND); | 58 | snprintf(temp, sizeof(temp), "%.2d", WL_NETFOUND); |
58 | memcpy(buffer, temp, 2); | 59 | memcpy(buffer, temp, 2); |
59 | len += 2; | 60 | len += 2; |
@@ -99,5 +100,5 @@ int get_network_found (void *structure, const char *buffer) | |||
99 | 100 | ||
100 | ptr = (wl_network_t *)structure; | 101 | ptr = (wl_network_t *)structure; |
101 | 102 | ||
102 | /* packet type already determined, skip check */ | 103 | /* packet type already determined, skip check */ |
103 | len += 2; | 104 | len += 2; |
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh index f645f58..46ef8e5 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh +++ b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh | |||
@@ -19,12 +19,3 @@ int send_network_found (const char *, int, void *); | |||
19 | int get_network_found (void *, const char *); | 19 | int get_network_found (void *, const char *); |
20 | 20 | ||
21 | typedef struct { | ||
22 | int net_type; /* 1 = Accesspoint ; 2 = Ad-Hoc */ | ||
23 | int ssid_len; /* Length of SSID */ | ||
24 | int channel; /* Channel */ | ||
25 | int wep; /* 1 = WEP enabled ; 0 = disabled */ | ||
26 | char mac[64]; /* MAC address of Accesspoint */ | ||
27 | char bssid[128]; /* BSSID of Net */ | ||
28 | } wl_network_t; | ||
29 | |||
30 | #endif /* WLPROTO_HH */ | 21 | #endif /* WLPROTO_HH */ |
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc index db6b7b8..6e26cb8 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc +++ b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc | |||
@@ -9,7 +9,6 @@ | |||
9 | 9 | ||
10 | /* Setup UDP Socket for incoming commands */ | 10 | /* Setup UDP Socket for incoming commands */ |
11 | int wl_setupsock(const char *host, int port) | 11 | int wl_setupsock(const char *host, int port, struct sockaddr_in saddr) |
12 | { | 12 | { |
13 | struct sockaddr_in saddr; | ||
14 | int sock; | 13 | int sock; |
15 | 14 | ||
@@ -24,5 +23,5 @@ int wl_setupsock(const char *host, int port) | |||
24 | saddr.sin_port = htons(port); | 23 | saddr.sin_port = htons(port); |
25 | saddr.sin_addr.s_addr = inet_addr(host); | 24 | saddr.sin_addr.s_addr = inet_addr(host); |
26 | 25 | ||
27 | if(bind(sock,(struct sockaddr *)&saddr, sizeof(saddr)) < 0) | 26 | if(bind(sock,(struct sockaddr *)&saddr, sizeof(saddr)) < 0) |
28 | { | 27 | { |
@@ -74,13 +73,15 @@ int wl_send(const char *host, int port, const char *string, ...) | |||
74 | 73 | ||
75 | /* Check for new messages on commsock */ | 74 | /* Check for new messages on commsock */ |
76 | int wl_recv(int *sock, char *out, int maxlen) | 75 | int wl_recv(int *sock, struct sockaddr_in cliaddr, char *out, int maxlen) |
77 | { | 76 | { |
78 | struct sockaddr_in *cliaddr; | ||
79 | socklen_t len = sizeof(struct sockaddr); | 77 | socklen_t len = sizeof(struct sockaddr); |
80 | char retval[3]; | 78 | char retval[3]; |
81 | 79 | ||
82 | memset(out, 0, maxlen); | 80 | memset(out, 0, maxlen); |
83 | if(recvfrom(*sock, out, maxlen - 1, 0, (struct sockaddr *)cliaddr, &len) < 0) | 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; | 84 | return -1; |
85 | } | ||
85 | 86 | ||
86 | /* Get packet type and return it */ | 87 | /* Get packet type and return it */ |
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.hh index 6ddbaef..e7d9747 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.hh +++ b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.hh | |||
@@ -1,7 +1,8 @@ | |||
1 | /* $id */ | 1 | /* $Id */ |
2 | 2 | ||
3 | #ifndef WLSOCK_HH | 3 | #ifndef WLSOCK_HH |
4 | #define WLSOCK_HH | 4 | #define WLSOCK_HH |
5 | 5 | ||
6 | #include <stdarg.h> | ||
6 | #include <sys/types.h> | 7 | #include <sys/types.h> |
7 | #include <sys/socket.h> | 8 | #include <sys/socket.h> |
@@ -14,7 +15,7 @@ | |||
14 | #include <errno.h> | 15 | #include <errno.h> |
15 | 16 | ||
16 | int wl_setupsock(const char *, int); | 17 | int wl_setupsock(const char *, int, struct sockaddr_in); |
17 | int wl_send(const char *, int, const char *, ...); | 18 | int wl_send(const char *, int, const char *, ...); |
18 | int wl_recv(int *, char *, int); | 19 | int wl_recv(int *, struct sockaddr_in, char *, int); |
19 | 20 | ||
20 | #endif /* WLSOCK_HH */ | 21 | #endif /* WLSOCK_HH */ |