summaryrefslogtreecommitdiff
authormax <max>2002-12-08 16:26:16 (UTC)
committer max <max>2002-12-08 16:26:16 (UTC)
commita2840f80792c7e40ee3b44be0ec48302d8816cc0 (patch) (side-by-side diff)
tree21318df2f9611818f4a0fe501381b19ae753e493
parent5fd10ba0772bb87598a3f4fd2e0fff8c3d4dbe43 (diff)
downloadopie-a2840f80792c7e40ee3b44be0ec48302d8816cc0.zip
opie-a2840f80792c7e40ee3b44be0ec48302d8816cc0.tar.gz
opie-a2840f80792c7e40ee3b44be0ec48302d8816cc0.tar.bz2
macaddress-fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/sniff.cc23
1 files changed, 19 insertions, 4 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
index 81eccab..3c227ab 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
@@ -114,137 +114,152 @@ void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *pack
{
wl_loginfo("SSID is: %s", pinfoptr->ssid);
// wl_net.bssid=pinfoptr->ssid;
}
wl_loginfo("SSID length is: %d", pinfoptr->ssid_len);
wl_net.ssid_len=pinfoptr->ssid_len;
wl_loginfo("Channel is: %d", pinfoptr->channel);
wl_net.channel=pinfoptr->channel;
wl_net.wep=pinfoptr->cap_WEP;
wl_loginfo("Mac is: %s", pinfoptr->sndhwaddr);
memcpy(wl_net.mac, pinfoptr->sndhwaddr, sizeof(wl_net.mac)-1);;
wl_loginfo("SSID is: %s", pinfoptr->ssid);
memcpy(wl_net.bssid, pinfoptr->ssid, sizeof(wl_net.bssid)-1);
// printf ("\n\tDest : %s\n",pinfoptr->desthwaddr);
send_network_found((char *)guihost, guiport, &wl_net);
wl_loginfo("Sent network to GUI '%s:%d'", guihost, guiport);
}
break;
default:
wl_logerr("Unknown IEEE802.11 frame subtype (%d)", FC_SUBTYPE(fc));
break;
} /* End of switch over different mgt frame types */
break;
case T_CTRL:
wl_loginfo("Received control frame, not implemented yet");
break;
case T_DATA:
wl_loginfo("Received date frame, not implemented yet");
break;
default:
wl_logerr("Unknown IEEE802.11 frame type (%d)", FC_TYPE(fc));
break;
}
}
/* This decodes the 802.11b frame header out of the 802.11b packet
all the infos is placed into the packetinfo structure */
int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo)
{
const struct mgmt_header_t *mgthdr = (const struct mgmt_header_t *) p;
ppinfo->fcsubtype = FC_SUBTYPE(mgthdr->fc);
/* Get the sender, bssid and dest mac address */
etheraddr_string(mgthdr->bssid,ppinfo->bssid);
etheraddr_string(mgthdr->da,ppinfo->desthwaddr);
etheraddr_string(mgthdr->sa,ppinfo->sndhwaddr);
ppinfo->fc_wep = FC_WEP(mgthdr->fc);
return 0;
}
void etheraddr_string(register const u_char *ep, char *text)
{
static char hex[] = "0123456789abcdef";
register unsigned int i, j;
register char *cp;
- char buf[sizeof("00:00:00:00:00:00")];
+ char buf[sizeof("00:00:00:00:00:00\0")];
cp = buf;
if ((j = *ep >> 4) != 0)
- *cp++ = hex[j];
+ {
+ *cp++ = hex[j];
+ }
+ else
+ {
+ *cp++ = '0';
+ }
*cp++ = hex[*ep++ & 0xf];
- for (i = 5; (int)--i >= 0;) {
+
+ for (i = 5; (int)--i >= 0;)
+ {
*cp++ = ':';
if ((j = *ep >> 4) != 0)
- *cp++ = hex[j];
+ {
+ *cp++ = hex[j];
+ }
+ else
+ {
+ *cp++ = '0';
+ }
+
*cp++ = hex[*ep++ & 0xf];
}
*cp = '\0';
strcpy(text,buf);
}
/* beacon handler */
int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo)
{
struct mgmt_body_t pbody;
int offset = 0;
/* Get the static informations out of the packet */
memset(&pbody, 0, sizeof(pbody));
memcpy(&pbody.timestamp, p, 8);
offset += 8;
pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset);
offset += 2;
pbody.capability_info = EXTRACT_LE_16BITS(p+offset);
offset += 2;
/* Gets the different flags out of the capabilities */
ppinfo->cap_ESS = CAPABILITY_ESS(pbody.capability_info);
ppinfo->cap_IBSS = CAPABILITY_IBSS(pbody.capability_info);
ppinfo->cap_WEP = CAPABILITY_PRIVACY(pbody.capability_info);
/* Gets the tagged elements out of the packets */
while (offset + 1 < ppinfo->pktlen)
{
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;
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;
}
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;
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;
}
break;
case E_DS:
memcpy(&(pbody.ds),p+offset,3); offset +=3;
ppinfo->channel = pbody.ds.channel;
break;