Diffstat (limited to 'noncore/net/wellenreiter/libwellenreiter/source/sniff.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/sniff.cc | 48 |
1 files changed, 29 insertions, 19 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 | |||
@@ -8,10 +8,14 @@ | |||
8 | #include "ieee802_11.hh" | 8 | #include "ieee802_11.hh" |
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; |
17 | unsigned int length = pkthdr->len; | 21 | unsigned int length = pkthdr->len; |
@@ -95,18 +99,16 @@ void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *pack | |||
95 | } | 99 | } |
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) |
112 | wl_loginfo("Net is a non-broadcasting network"); | 114 | wl_loginfo("Net is a non-broadcasting network"); |
@@ -114,6 +116,7 @@ void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *pack | |||
114 | wl_loginfo("SSID is: %s", pinfoptr->ssid); | 116 | wl_loginfo("SSID is: %s", pinfoptr->ssid); |
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 | ||
119 | wl_loginfo("SSID length is: %d", pinfoptr->ssid_len); | 122 | wl_loginfo("SSID length is: %d", pinfoptr->ssid_len); |
@@ -237,7 +240,8 @@ int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) | |||
237 | memcpy(&(pbody.ssid),p+offset,2); offset += 2; | 240 | memcpy(&(pbody.ssid),p+offset,2); offset += 2; |
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) |
243 | memcpy(ppinfo->ssid, NONBROADCASTING, sizeof(ppinfo->ssid)); | 247 | memcpy(ppinfo->ssid, NONBROADCASTING, sizeof(ppinfo->ssid)); |
@@ -251,7 +255,8 @@ int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) | |||
251 | memcpy(&(pbody.challenge),p+offset,2); offset += 2; | 255 | memcpy(&(pbody.challenge),p+offset,2); offset += 2; |
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 | } |
257 | break; | 262 | break; |
@@ -259,19 +264,24 @@ int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) | |||
259 | memcpy(&(pbody.rates),p+offset,2); offset += 2; | 264 | memcpy(&(pbody.rates),p+offset,2); offset += 2; |
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 | { |
277 | memcpy((pbody.tim.bitmap),p+(pbody.tim.length -3),(pbody.tim.length -3)); | 287 | memcpy((pbody.tim.bitmap),p+(pbody.tim.length -3),(pbody.tim.length -3)); |