summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -162,41 +162,56 @@ int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo)
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;