summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
Side-by-side diff
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.cc48
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
@@ -5,16 +5,20 @@
*/
#include "sniff.hh"
#include "ieee802_11.hh"
#include "extract.hh"
#include "wl_log.hh"
+#include "wl_types.hh"
#include "wl_proto.hh"
/* Main function, checks packets */
-void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *packet, char *guihost, int guiport)
+void process_packets(const struct pcap_pkthdr *pkthdr,
+ const unsigned char *packet,
+ char *guihost,
+ int guiport)
{
unsigned int caplen = pkthdr->caplen;
unsigned int length = pkthdr->len;
u_int16_t fc;
unsigned int HEADER_LENGTH;
@@ -92,31 +96,30 @@ void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *pack
others must be noise packets */
pinfoptr->isvalid = 0;
return;
}
/* Here should be the infos to the gui issued */
- if (pinfoptr->cap_ESS == 1 &&pinfoptr->cap_IBSS ==0)
- {
- wl_loginfo("Found an access point");
- wl_net.net_type=1;
- }
+ if (pinfoptr->cap_ESS == 1 && pinfoptr->cap_IBSS ==0)
+ {
+ wl_loginfo("Found an access point");
+ wl_net.net_type=1;
+ }
else if(pinfoptr->cap_ESS == 0 && pinfoptr->cap_IBSS == 2)
- {
- wl_loginfo("Found an ad-hoc network");
- wl_net.net_type=2;
- }
-
- memset(wl_net.bssid, 0, sizeof(wl_net.bssid));
+ {
+ wl_loginfo("Found an ad-hoc network");
+ wl_net.net_type=2;
+ }
if (strcmp (pinfoptr->ssid,NONBROADCASTING) ==0)
wl_loginfo("Net is a non-broadcasting network");
else
wl_loginfo("SSID is: %s", pinfoptr->ssid);
wl_loginfo("SSID is: %s", pinfoptr->ssid);
+ memset(wl_net.bssid, 0, sizeof(wl_net.bssid));
memcpy(wl_net.bssid, pinfoptr->ssid, sizeof(wl_net.bssid)-1);
wl_loginfo("SSID length is: %d", pinfoptr->ssid_len);
wl_net.ssid_len=pinfoptr->ssid_len;
wl_loginfo("Channel is: %d", pinfoptr->channel);
@@ -234,13 +237,14 @@ int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo)
switch (*(p + offset))
{
case E_SSID:
memcpy(&(pbody.ssid),p+offset,2); offset += 2;
if (pbody.ssid.length > 0)
{
- memcpy(&(pbody.ssid.ssid),p+offset,pbody.ssid.length); offset += pbody.ssid.length;
+ memcpy(&(pbody.ssid.ssid),p+offset,pbody.ssid.length);
+ offset += pbody.ssid.length;
pbody.ssid.ssid[pbody.ssid.length]='\0';
if (strcmp((char *)pbody.ssid.ssid,"")==0)
memcpy(ppinfo->ssid, NONBROADCASTING, sizeof(ppinfo->ssid));
else
memcpy(ppinfo->ssid, pbody.ssid.ssid, sizeof(ppinfo->ssid));
ppinfo->ssid_len = pbody.ssid.length;
@@ -248,33 +252,39 @@ int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo)
break;
case E_CHALLENGE:
memcpy(&(pbody.challenge),p+offset,2); offset += 2;
if (pbody.challenge.length > 0)
{
- memcpy(&(pbody.challenge.text),p+offset,pbody.challenge.length); offset += pbody.challenge.length;
+ memcpy(&(pbody.challenge.text),p+offset,pbody.challenge.length);
+ offset += pbody.challenge.length;
pbody.challenge.text[pbody.challenge.length]='\0';
}
break;
case E_RATES:
memcpy(&(pbody.rates),p+offset,2); offset += 2;
if (pbody.rates.length > 0)
{
- memcpy(&(pbody.rates.rate),p+offset,pbody.rates.length); offset += pbody.rates.length;
+ memcpy(&(pbody.rates.rate),p+offset,pbody.rates.length);
+ offset += pbody.rates.length;
}
break;
case E_DS:
- memcpy(&(pbody.ds),p+offset,3); offset +=3;
+ memcpy(&(pbody.ds),p+offset,3);
+ offset +=3;
ppinfo->channel = pbody.ds.channel;
break;
case E_CF:
- memcpy(&(pbody.cf),p+offset,8); offset +=8;
+ memcpy(&(pbody.cf),p+offset,8);
+ offset +=8;
break;
case E_TIM:
- memcpy(&(pbody.tim),p+offset,2); offset +=2;
- memcpy(&(pbody.tim.count),p+offset,3); offset +=3;
+ memcpy(&(pbody.tim),p+offset,2);
+ offset +=2;
+ memcpy(&(pbody.tim.count),p+offset,3);
+ offset +=3;
if ((pbody.tim.length -3) > 0)
{
memcpy((pbody.tim.bitmap),p+(pbody.tim.length -3),(pbody.tim.length -3));
offset += pbody.tim.length -3;
}
break;