Commit 0fc310ee authored by Bruno Randolf's avatar Bruno Randolf

add own wlan frame definitions

parent 2b2334e4
......@@ -53,40 +53,40 @@ channel.o: channel.c main.h ccan/list/list.h average.h util.h \
ieee80211_util.h ieee80211.h wext.h channel.h
control.o: control.c main.h ccan/list/list.h average.h control.h
display.o: display.c display.h main.h ccan/list/list.h average.h \
ieee80211.h
wlan80211.h
display-channel.o: display-channel.c display.h main.h ccan/list/list.h \
average.h network.h
display-essid.o: display-essid.c display.h main.h ccan/list/list.h \
average.h util.h
display-filter.o: display-filter.c display.h main.h ccan/list/list.h \
average.h util.h ieee80211.h network.h
average.h util.h wlan80211.h network.h
display-help.o: display-help.c display.h main.h ccan/list/list.h \
average.h util.h
display-history.o: display-history.c display.h main.h ccan/list/list.h \
average.h util.h
display-main.o: display-main.c display.h main.h ccan/list/list.h \
average.h util.h ieee80211.h olsr_header.h batman_adv_header-14.h \
average.h util.h wlan80211.h olsr_header.h batman_adv_header-14.h \
listsort.h
display-spectrum.o: display-spectrum.c display.h main.h ccan/list/list.h \
average.h util.h
display-statistics.o: display-statistics.c display.h main.h \
ccan/list/list.h average.h util.h ieee80211_util.h ieee80211.h
essid.o: essid.c main.h ccan/list/list.h average.h util.h ieee80211.h \
ccan/list/list.h average.h util.h
essid.o: essid.c main.h ccan/list/list.h average.h util.h wlan80211.h \
essid.h
ieee80211_util.o: ieee80211_util.c ieee80211.h ieee80211_util.h main.h \
ccan/list/list.h average.h util.h
listsort.o: listsort.c ccan/list/list.h listsort.h
main.o: main.c main.h ccan/list/list.h average.h util.h capture.h \
protocol_parser.h network.h display.h ieee80211.h ieee80211_util.h \
protocol_parser.h network.h display.h ieee80211_util.h ieee80211.h \
wext.h control.h channel.h node.h essid.h
network.o: network.c main.h ccan/list/list.h average.h util.h network.h
node.o: node.c main.h ccan/list/list.h average.h util.h ieee80211.h \
essid.h
protocol_parser.o: protocol_parser.c prism_header.h ieee80211.h \
ieee80211_util.h olsr_header.h batman_header.h batman_adv_header-14.h \
protocol_parser.h main.h ccan/list/list.h average.h util.h \
radiotap/radiotap.h radiotap/radiotap_iter.h radiotap/radiotap.h
util.o: util.c util.h ieee80211.h
node.o: node.c main.h ccan/list/list.h average.h util.h wlan80211.h essid.h
protocol_parser.o: protocol_parser.c prism_header.h ieee80211_util.h \
ieee80211.h wlan80211.h olsr_header.h batman_header.h \
batman_adv_header-14.h protocol_parser.h main.h ccan/list/list.h \
average.h util.h radiotap/radiotap.h radiotap/radiotap_iter.h \
radiotap/radiotap.h
util.o: util.c util.h wlan80211.h
wext.o: wext.c wext.h main.h ccan/list/list.h average.h util.h
$(NAME): $(OBJS)
......
......@@ -24,7 +24,7 @@
#include "display.h"
#include "main.h"
#include "util.h"
#include "ieee80211.h"
#include "wlan80211.h"
#include "network.h"
#define CHECKED(_x) (conf.filter_pkt & (_x)) ? '*' : ' '
......@@ -43,7 +43,7 @@ update_filter_win(WINDOW *win)
print_centered(win, 0, 57, " Edit Filters ");
l = 2;
wattron(win, get_packet_type_color(IEEE80211_FTYPE_MGMT));
wattron(win, get_packet_type_color(WLAN_FRAME_TYPE_MGMT));
wattron(win, A_BOLD);
mvwprintw(win, l++, 2, "m: [%c] MANAGEMENT Frames", CHECKED(PKT_TYPE_MGMT));
wattroff(win, A_BOLD);
......@@ -52,14 +52,14 @@ update_filter_win(WINDOW *win)
mvwprintw(win, l++, 2, "a: [%c] Association", CHECKED(PKT_TYPE_ASSOC));
mvwprintw(win, l++, 2, "u: [%c] Authentication", CHECKED(PKT_TYPE_AUTH));
l++;
wattron(win, get_packet_type_color(IEEE80211_FTYPE_CTL));
wattron(win, get_packet_type_color(WLAN_FRAME_TYPE_CTRL));
wattron(win, A_BOLD);
mvwprintw(win, l++, 2, "c: [%c] CONTROL Frames", CHECKED(PKT_TYPE_CTRL));
wattroff(win, A_BOLD);
mvwprintw(win, l++, 2, "r: [%c] CTS/RTS", CHECKED(PKT_TYPE_RTSCTS));
mvwprintw(win, l++, 2, "k: [%c] ACK", CHECKED(PKT_TYPE_ACK));
l++;
wattron(win, get_packet_type_color(IEEE80211_FTYPE_DATA));
wattron(win, get_packet_type_color(WLAN_FRAME_TYPE_DATA));
wattron(win, A_BOLD);
mvwprintw(win, l++, 2, "d: [%c] DATA Frames", CHECKED(PKT_TYPE_DATA));
wattroff(win, A_BOLD);
......
......@@ -25,7 +25,7 @@
#include "display.h"
#include "main.h"
#include "util.h"
#include "ieee80211.h"
#include "wlan80211.h"
#include "olsr_header.h"
#include "batman_adv_header-14.h"
#include "listsort.h"
......@@ -489,31 +489,31 @@ update_dump_win(struct packet_info* p)
else {
wprintw(dump_win, "%-7s", get_packet_type_name(p->wlan_type));
switch (p->wlan_type & IEEE80211_FCTL_FTYPE) {
case IEEE80211_FTYPE_DATA:
switch (p->wlan_type) {
case WLAN_FRAME_DATA:
case WLAN_FRAME_DATA_CF_ACK:
case WLAN_FRAME_DATA_CF_POLL:
case WLAN_FRAME_DATA_CF_ACKPOLL:
case WLAN_FRAME_QDATA:
case WLAN_FRAME_QDATA_CF_ACK:
case WLAN_FRAME_QDATA_CF_POLL:
case WLAN_FRAME_QDATA_CF_ACKPOLL:
if ( p->wlan_wep == 1)
wprintw(dump_win, "ENCRYPTED");
break;
case IEEE80211_FTYPE_CTL:
switch (p->wlan_type & IEEE80211_FCTL_STYPE) {
case IEEE80211_STYPE_CTS:
case IEEE80211_STYPE_RTS:
case IEEE80211_STYPE_ACK:
wprintw(dump_win, "%s", ether_sprintf(p->wlan_dst));
break;
}
case WLAN_FRAME_CTS:
case WLAN_FRAME_RTS:
case WLAN_FRAME_ACK:
wprintw(dump_win, "%s", ether_sprintf(p->wlan_dst));
break;
case WLAN_FRAME_BEACON:
case WLAN_FRAME_PROBE_RESP:
wprintw(dump_win, "'%s' %llx", p->wlan_essid,
p->wlan_tsf);
break;
case WLAN_FRAME_PROBE_REQ:
wprintw(dump_win, "'%s'", p->wlan_essid);
break;
case IEEE80211_FTYPE_MGMT:
switch (p->wlan_type & IEEE80211_FCTL_STYPE) {
case IEEE80211_STYPE_BEACON:
case IEEE80211_STYPE_PROBE_RESP:
wprintw(dump_win, "'%s' %llx", p->wlan_essid,
p->wlan_tsf);
break;
case IEEE80211_STYPE_PROBE_REQ:
wprintw(dump_win, "'%s'", p->wlan_essid);
break;
}
}
}
......
......@@ -24,7 +24,6 @@
#include "display.h"
#include "main.h"
#include "util.h"
#include "ieee80211_util.h"
#define STAT_PACK_POS 9
#define STAT_BYTE_POS (STAT_PACK_POS + 9)
......
......@@ -28,7 +28,7 @@
#include "display.h"
#include "main.h"
#include "ieee80211.h"
#include "wlan80211.h"
static WINDOW *conf_win = NULL;
......@@ -120,10 +120,10 @@ get_packet_type_color(int type)
{
if (type == 1) /* special case for bad FCS */
return RED;
switch (type & IEEE80211_FCTL_FTYPE) {
case IEEE80211_FTYPE_DATA: return BLUE;
case IEEE80211_FTYPE_CTL: return WHITE;
case IEEE80211_FTYPE_MGMT: return CYAN;
switch (type & WLAN_FRAME_FC_TYPE_MASK) {
case WLAN_FRAME_TYPE_DATA: return BLUE;
case WLAN_FRAME_TYPE_CTRL: return WHITE;
case WLAN_FRAME_TYPE_MGMT: return CYAN;
}
return YELLOW;
}
......
......@@ -22,7 +22,7 @@
#include "main.h"
#include "util.h"
#include "ieee80211.h"
#include "wlan80211.h"
#include "essid.h"
......@@ -99,8 +99,8 @@ update_essids(struct packet_info* p, struct node_info* n)
return; /* ignore */
/* only check beacons and probe response frames */
if (!IEEE80211_IS_MGMT_STYPE(p->wlan_type, IEEE80211_STYPE_BEACON) &&
!IEEE80211_IS_MGMT_STYPE(p->wlan_type, IEEE80211_STYPE_PROBE_RESP))
if ((p->wlan_type != WLAN_FRAME_BEACON) &&
(p->wlan_type != WLAN_FRAME_PROBE_RESP))
return;
DEBUG("SPLIT check ibss '%s' node %s ", p->wlan_essid,
......
......@@ -24,44 +24,8 @@
#include "util.h"
u8*
ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len)
{
__le16 fc;
if (len < 24)
return NULL;
fc = le16_to_cpu(hdr->frame_control);
switch (fc & IEEE80211_FCTL_FTYPE) {
case IEEE80211_FTYPE_DATA:
switch (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) {
case IEEE80211_FCTL_TODS:
return hdr->addr1;
case (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS):
return NULL;
case IEEE80211_FCTL_FROMDS:
return hdr->addr2;
case 0:
return hdr->addr3;
}
break;
case IEEE80211_FTYPE_MGMT:
return hdr->addr3;
case IEEE80211_FTYPE_CTL:
if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)
return hdr->addr1;
else
return NULL;
}
return NULL;
}
int
ieee80211_get_hdrlen(u16 fc)
ieee80211_get_hdrlen(u_int16_t fc)
{
int hdrlen = 24;
......
......@@ -17,16 +17,11 @@
#ifndef _IEEE80211_UTIL_H_
#define _IEEE80211_UTIL_H_
#include "ieee80211.h"
struct packet_info;
int
ieee80211_get_hdrlen(u16 fc);
u8*
ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len);
ieee80211_get_hdrlen(u_int16_t fc);
void
ieee802_11_parse_elems(unsigned char *start, size_t len, struct packet_info *pkt);
......@@ -38,5 +33,4 @@ ieee80211_frame_duration(int phymode, size_t len, int rate, int short_preamble,
int
ieee80211_frequency_to_channel(int freq);
#endif
......@@ -34,7 +34,6 @@
#include "protocol_parser.h"
#include "network.h"
#include "display.h"
#include "ieee80211.h"
#include "ieee80211_util.h"
#include "wext.h"
#include "control.h"
......
......@@ -23,7 +23,7 @@
#include "main.h"
#include "util.h"
#include "ieee80211.h"
#include "wlan80211.h"
#include "essid.h"
......@@ -73,8 +73,8 @@ copy_nodeinfo(struct node_info* n, struct packet_info* p)
n->wlan_wpa = ap->wlan_wpa;
}
}
if (IEEE80211_IS_MGMT_STYPE(p->wlan_type, IEEE80211_STYPE_BEACON) ||
IEEE80211_IS_MGMT_STYPE(p->wlan_type, IEEE80211_STYPE_PROBE_RESP)) {
if ((p->wlan_type == WLAN_FRAME_BEACON) ||
(p->wlan_type == WLAN_FRAME_PROBE_RESP)) {
n->wlan_tsf = p->wlan_tsf;
n->wlan_bintval = p->wlan_bintval;
n->wlan_wpa = p->wlan_wpa;
......@@ -96,17 +96,17 @@ copy_nodeinfo(struct node_info* n, struct packet_info* p)
else if (p->pkt_chan_idx >= 0)
n->wlan_channel = channels[p->pkt_chan_idx].chan;
if (IEEE80211_IS_DATA_STYPE(p->wlan_type, IEEE80211_STYPE_DATA) ||
IEEE80211_IS_DATA_STYPE(p->wlan_type, IEEE80211_STYPE_QOS_DATA) ||
IEEE80211_IS_MGMT_STYPE(p->wlan_type, IEEE80211_STYPE_AUTH) ||
IEEE80211_IS_MGMT_STYPE(p->wlan_type, IEEE80211_STYPE_BEACON) ||
IEEE80211_IS_MGMT_STYPE(p->wlan_type, IEEE80211_STYPE_PROBE_RESP) ||
IEEE80211_IS_DATA_STYPE(p->wlan_type, IEEE80211_STYPE_DATA_CFACK) ||
IEEE80211_IS_DATA_STYPE(p->wlan_type, IEEE80211_STYPE_DATA_CFPOLL) ||
IEEE80211_IS_DATA_STYPE(p->wlan_type, IEEE80211_STYPE_DATA_CFACKPOLL) ||
IEEE80211_IS_DATA_STYPE(p->wlan_type, IEEE80211_STYPE_QOS_DATA_CFACK) ||
IEEE80211_IS_DATA_STYPE(p->wlan_type, IEEE80211_STYPE_QOS_DATA_CFPOLL) ||
IEEE80211_IS_DATA_STYPE(p->wlan_type, IEEE80211_STYPE_QOS_DATA_CFACKPOLL))
if ((p->wlan_type == WLAN_FRAME_DATA) ||
(p->wlan_type == WLAN_FRAME_QDATA) ||
(p->wlan_type == WLAN_FRAME_AUTH) ||
(p->wlan_type == WLAN_FRAME_BEACON) ||
(p->wlan_type == WLAN_FRAME_PROBE_RESP) ||
(p->wlan_type == WLAN_FRAME_DATA_CF_ACK) ||
(p->wlan_type == WLAN_FRAME_DATA_CF_POLL) ||
(p->wlan_type == WLAN_FRAME_DATA_CF_ACKPOLL) ||
(p->wlan_type == WLAN_FRAME_QDATA_CF_ACK) ||
(p->wlan_type == WLAN_FRAME_QDATA_CF_POLL) ||
(p->wlan_type == WLAN_FRAME_QDATA_CF_ACKPOLL))
n->wlan_wep = p->wlan_wep;
if (p->wlan_seqno != 0) {
......
......@@ -26,8 +26,8 @@
#include <netinet/udp.h>
#include "prism_header.h"
#include "ieee80211.h"
#include "ieee80211_util.h"
#include "wlan80211.h"
#include "olsr_header.h"
#include "batman_header.h"
#include "batman_adv_header-14.h"
......@@ -359,19 +359,18 @@ parse_radiotap_header(unsigned char** buf, int len, struct packet_info* p)
static int
parse_80211_header(unsigned char** buf, int len, struct packet_info* p)
{
struct ieee80211_hdr* wh;
struct ieee80211_mgmt* whm;
struct wlan_frame* wh;
int hdrlen;
u8* ra = NULL;
u8* ta = NULL;
u8* bssid = NULL;
u16 fc, cap_i;
u_int8_t* ra = NULL;
u_int8_t* ta = NULL;
u_int8_t* bssid = NULL;
u_int16_t fc, cap_i;
if (len < 2) /* not even enough space for fc */
return -1;
wh = (struct ieee80211_hdr*)*buf;
fc = le16toh(wh->frame_control);
wh = (struct wlan_frame*)*buf;
fc = le16toh(wh->fc);
hdrlen = ieee80211_get_hdrlen(fc);
DEBUG("len %d hdrlen %d\n", len, hdrlen);
......@@ -380,186 +379,177 @@ parse_80211_header(unsigned char** buf, int len, struct packet_info* p)
return -1;
p->wlan_len = len;
p->wlan_type = (fc & (IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE));
p->wlan_type = (fc & WLAN_FRAME_FC_MASK);
DEBUG("wlan_type %x - type %x - stype %x\n", fc, fc & IEEE80211_FCTL_FTYPE, fc & IEEE80211_FCTL_STYPE );
DEBUG("wlan_type %x - type %x - stype %x\n", fc, fc & WLAN_FRAME_FC_TYPE_MASK, fc & WLAN_FRAME_FC_STYPE_MASK);
DEBUG("%s\n", get_packet_type_name(fc));
bssid = ieee80211_get_bssid(wh, len);
switch (p->wlan_type & WLAN_FRAME_FC_TYPE_MASK) {
case WLAN_FRAME_TYPE_DATA:
p->pkt_types |= PKT_TYPE_DATA;
p->wlan_nav = le16toh(wh->duration);
DEBUG("DATA NAV %d\n", p->wlan_nav);
p->wlan_seqno = le16toh(wh->seq);
DEBUG("DATA SEQ %d\n", p->wlan_seqno);
switch (p->wlan_type & IEEE80211_FCTL_FTYPE) {
case IEEE80211_FTYPE_DATA:
p->pkt_types |= PKT_TYPE_DATA;
switch (p->wlan_type & IEEE80211_FCTL_STYPE) {
case IEEE80211_STYPE_NULLFUNC:
DEBUG("A1 %s\n", ether_sprintf(wh->addr1));
DEBUG("A2 %s\n", ether_sprintf(wh->addr2));
DEBUG("A3 %s\n", ether_sprintf(wh->addr3));
DEBUG("A4 %s\n", ether_sprintf(wh->addr4));
DEBUG("ToDS %d FromDS %d\n", (fc & WLAN_FRAME_FC_FROM_DS) != 0, (fc & WLAN_FRAME_FC_TO_DS) != 0);
ra = wh->addr1;
ta = wh->addr2;
/* AP, STA or IBSS */
if ((fc & WLAN_FRAME_FC_FROM_DS) == 0 &&
(fc & WLAN_FRAME_FC_TO_DS) == 0) {
p->wlan_mode = WLAN_MODE_IBSS;
bssid = wh->addr3;
} else if ((fc & WLAN_FRAME_FC_FROM_DS) &&
(fc & WLAN_FRAME_FC_TO_DS)) {
p->wlan_mode = WLAN_MODE_4ADDR;
//TODO bssid = either addr3 or add4;
} else if (fc & WLAN_FRAME_FC_FROM_DS) {
p->wlan_mode = WLAN_MODE_AP;
bssid = wh->addr2;
} else if (fc & WLAN_FRAME_FC_TO_DS) {
p->wlan_mode = WLAN_MODE_STA;
bssid = wh->addr1;
}
/* WEP */
if (fc & WLAN_FRAME_FC_PROTECTED)
p->wlan_wep = 1;
if (fc & WLAN_FRAME_FC_RETRY)
p->wlan_retry = 1;
break;
case WLAN_FRAME_TYPE_CTRL:
p->pkt_types |= PKT_TYPE_CTRL;
break;
case WLAN_FRAME_TYPE_MGMT:
p->pkt_types |= PKT_TYPE_MGMT;
ra = wh->addr1;
ta = wh->addr2;
bssid = wh->addr3;
p->wlan_seqno = le16toh(wh->seq);
DEBUG("MGMT SEQ %d\n", p->wlan_seqno);
if (fc & WLAN_FRAME_FC_RETRY)
p->wlan_retry = 1;
break;
}
switch (p->wlan_type) {
case WLAN_FRAME_NULL:
p->pkt_types |= PKT_TYPE_NULL;
break;
case IEEE80211_STYPE_QOS_DATA:
case WLAN_FRAME_QDATA:
/* TODO: ouch, should properly define a qos header */
p->pkt_types |= PKT_TYPE_QDATA;
p->wlan_qos_class = wh->addr4[0] & 0x7;
DEBUG("***QDATA %x\n", p->wlan_qos_class);
break;
}
p->wlan_nav = le16toh(wh->duration_id);
DEBUG("DATA NAV %d\n", p->wlan_nav);
p->wlan_seqno = le16toh(wh->seq_ctrl);
DEBUG("DATA SEQ %d\n", p->wlan_seqno);
DEBUG("A1 %s\n", ether_sprintf(wh->addr1));
DEBUG("A2 %s\n", ether_sprintf(wh->addr2));
DEBUG("A3 %s\n", ether_sprintf(wh->addr3));
DEBUG("A4 %s\n", ether_sprintf(wh->addr4));
DEBUG("ToDS %d FromDS %d\n", (fc & IEEE80211_FCTL_FROMDS) != 0, (fc & IEEE80211_FCTL_TODS) != 0);
ra = wh->addr1;
ta = wh->addr2;
//sa = ieee80211_get_SA(wh);
//da = ieee80211_get_DA(wh);
/* AP, STA or IBSS */
if ((fc & IEEE80211_FCTL_FROMDS) == 0 &&
(fc & IEEE80211_FCTL_TODS) == 0)
p->wlan_mode = WLAN_MODE_IBSS;
else if ((fc & IEEE80211_FCTL_FROMDS) &&
(fc & IEEE80211_FCTL_TODS))
p->wlan_mode = WLAN_MODE_4ADDR;
else if (fc & IEEE80211_FCTL_FROMDS)
p->wlan_mode = WLAN_MODE_AP;
else if (fc & IEEE80211_FCTL_TODS)
p->wlan_mode = WLAN_MODE_STA;
/* WEP */
if (fc & IEEE80211_FCTL_PROTECTED)
p->wlan_wep = 1;
if (fc & IEEE80211_FCTL_RETRY)
p->wlan_retry = 1;
break;
case IEEE80211_FTYPE_CTL:
p->pkt_types |= PKT_TYPE_CTRL;
switch (p->wlan_type & IEEE80211_FCTL_STYPE) {
case IEEE80211_STYPE_RTS:
case WLAN_FRAME_RTS:
p->pkt_types |= PKT_TYPE_RTSCTS;
p->wlan_nav = le16toh(wh->duration_id);
p->wlan_nav = le16toh(wh->duration);
DEBUG("RTS NAV %d\n", p->wlan_nav);
ra = wh->addr1;
ta = wh->addr2;
break;
case IEEE80211_STYPE_CTS:
case WLAN_FRAME_CTS:
p->pkt_types |= PKT_TYPE_RTSCTS;
p->wlan_nav = le16toh(wh->duration_id);
p->wlan_nav = le16toh(wh->duration);
DEBUG("CTS NAV %d\n", p->wlan_nav);
ra = wh->addr1;
break;
case IEEE80211_STYPE_ACK:
case WLAN_FRAME_ACK:
p->pkt_types |= PKT_TYPE_ACK;
p->wlan_nav = le16toh(wh->duration_id);
p->wlan_nav = le16toh(wh->duration);
DEBUG("ACK NAV %d\n", p->wlan_nav);
ra = wh->addr1;
break;
case IEEE80211_STYPE_PSPOLL:
case WLAN_FRAME_PSPOLL:
ra = wh->addr1;
bssid = wh->addr1;
ta = wh->addr2;
break;
case IEEE80211_STYPE_CFEND:
case IEEE80211_STYPE_CFENDACK:
case WLAN_FRAME_CF_END:
case WLAN_FRAME_CF_END_ACK:
ra = wh->addr1;
ta = wh->addr2;
bssid = wh->addr2;
break;
case IEEE80211_STYPE_BACK_REQ:
case IEEE80211_STYPE_BACK:
case WLAN_FRAME_BLKACK:
case WLAN_FRAME_BLKACK_REQ:
p->pkt_types |= PKT_TYPE_ACK;
p->wlan_nav = le16toh(wh->duration_id);
p->wlan_nav = le16toh(wh->duration);
ra = wh->addr1;
ta = wh->addr2;
}
break;
case IEEE80211_FTYPE_MGMT:
p->pkt_types |= PKT_TYPE_MGMT;
whm = (struct ieee80211_mgmt*)*buf;
ta = whm->sa;
ra = whm->da;
bssid = whm->bssid;
p->wlan_seqno = le16toh(wh->seq_ctrl);
DEBUG("MGMT SEQ %d\n", p->wlan_seqno);
if (fc & IEEE80211_FCTL_RETRY)
p->wlan_retry = 1;
switch (p->wlan_type & IEEE80211_FCTL_STYPE) {
case IEEE80211_STYPE_BEACON:
p->pkt_types |= PKT_TYPE_BEACON;
p->wlan_tsf = le64toh(whm->u.beacon.timestamp);
p->wlan_bintval = le16toh(whm->u.beacon.beacon_int);
ieee802_11_parse_elems(whm->u.beacon.variable,
len - sizeof(struct ieee80211_mgmt) - 4 /* FCS */, p);
DEBUG("ESSID %s \n", p->wlan_essid );
DEBUG("CHAN %d \n", p->wlan_channel );
cap_i = le16toh(whm->u.beacon.capab_info);
if (cap_i & WLAN_CAPABILITY_IBSS)
p->wlan_mode = WLAN_MODE_IBSS;
else if (cap_i & WLAN_CAPABILITY_ESS)
p->wlan_mode = WLAN_MODE_AP;
if (cap_i & WLAN_CAPABILITY_PRIVACY)
p->wlan_wep = 1;
break;
case IEEE80211_STYPE_PROBE_RESP:
p->pkt_types |= PKT_TYPE_PROBE;
p->wlan_tsf = le64toh(whm->u.beacon.timestamp);
ieee802_11_parse_elems(whm->u.beacon.variable,
len - sizeof(struct ieee80211_mgmt) - 4 /* FCS */, p);
case WLAN_FRAME_BEACON:
case WLAN_FRAME_PROBE_RESP:
if (p->wlan_type == WLAN_FRAME_BEACON)
p->pkt_types |= PKT_TYPE_BEACON;
else
p->pkt_types |= PKT_TYPE_PROBE;
struct wlan_frame_beacon* bc = (struct wlan_frame_beacon*)(*buf + WLAN_FRAME_LEN_MGMT);
p->wlan_tsf = le64toh(bc->tsf);
p->wlan_bintval = le16toh(bc->bintval);
DEBUG("TSF %u\n BINTVAL %u", p->wlan_tsf, p->wlan_bintval);
ieee802_11_parse_elems(bc->ie,
len - WLAN_FRAME_LEN_MGMT - 4 /* FCS */, p);
DEBUG("ESSID %s \n", p->wlan_essid );
DEBUG("CHAN %d \n", p->wlan_channel );
cap_i = le16toh(whm->u.beacon.capab_info);
if (cap_i & WLAN_CAPABILITY_IBSS)
cap_i = le16toh(bc->capab);
if (cap_i & WLAN_CAPAB_IBSS)
p->wlan_mode = WLAN_MODE_IBSS;
else if (cap_i & WLAN_CAPABILITY_ESS)
else if (cap_i & WLAN_CAPAB_ESS)
p->wlan_mode = WLAN_MODE_AP;
if (cap_i & WLAN_CAPABILITY_PRIVACY)
if (cap_i & WLAN_CAPAB_PRIVACY)
p->wlan_wep = 1;
break;
case IEEE80211_STYPE_PROBE_REQ:
case WLAN_FRAME_PROBE_REQ:
p->pkt_types |= PKT_TYPE_PROBE;
ieee802_11_parse_elems(whm->u.probe_req.variable,
len - 24 - 4 /* FCS */,
p);
ieee802_11_parse_elems((*buf + WLAN_FRAME_LEN_MGMT),
len - WLAN_FRAME_LEN_MGMT - 4 /* FCS */, p);
p->wlan_mode = WLAN_MODE_PROBE;
break;
case IEEE80211_STYPE_ASSOC_REQ:
case IEEE80211_STYPE_ASSOC_RESP:
case IEEE80211_STYPE_REASSOC_REQ:
case IEEE80211_STYPE_REASSOC_RESP:
case IEEE80211_STYPE_DISASSOC:
case WLAN_FRAME_ASSOC_REQ:
case WLAN_FRAME_ASSOC_RESP:
case WLAN_FRAME_REASSOC_REQ:
case WLAN_FRAME_REASSOC_RESP:
case WLAN_FRAME_DISASSOC:
p->pkt_types |= PKT_TYPE_ASSOC;
break;
case IEEE80211_STYPE_AUTH:
if (fc & IEEE80211_FCTL_PROTECTED)
case WLAN_FRAME_AUTH:
if (fc & WLAN_FRAME_FC_PROTECTED)
p->wlan_wep = 1;
/* no break */
case IEEE80211_STYPE_DEAUTH:
case WLAN_FRAME_DEAUTH:
p->pkt_types |= PKT_TYPE_AUTH;
break;
case IEEE80211_STYPE_ACTION:
case WLAN_FRAME_ACTION:
break;
}
break;
}
if (ta != NULL) {
......@@ -576,7 +566,7 @@ parse_80211_header(unsigned char** buf, int len, struct packet_info* p)
}
/* only data frames contain more info, otherwise stop parsing */
if (IEEE80211_IS_DATA(p->wlan_type) && p->wlan_wep != 1) {
if (WLAN_FRAME_IS_DATA(p->wlan_type) && p->wlan_wep != 1) {
*buf = *buf + hdrlen;
return len - hdrlen;
}
......
......@@ -21,7 +21,7 @@
#include <string.h>
#include "util.h"
#include "ieee80211.h"
#include "wlan80211.h"
struct pkt_names {
......@@ -31,57 +31,57 @@ struct pkt_names {
/* a list of packet type names for easier indexing with padding */
static struct pkt_names mgmt_names[] = {
{ 'a', "ASOCRQ" }, /* IEEE80211_STYPE_ASSOC_REQ 0x0000 */
{ 'A', "ASOCRP" }, /* IEEE80211_STYPE_ASSOC_RESP 0x0010 */
{ 'a', "REASRQ" }, /* IEEE80211_STYPE_REASSOC_REQ 0x0020 */
{ 'A', "REASRP" }, /* IEEE80211_STYPE_REASSOC_RESP 0x0030 */
{ 'p', "PROBRQ" }, /* IEEE80211_STYPE_PROBE_REQ 0x0040 */
{ 'P', "PROBRP" }, /* IEEE80211_STYPE_PROBE_RESP 0x0050 */
{ 'T', "TIMING" }, /* Timing Advertisement 0x0060 */
{ 'a', "ASOCRQ" }, /* WLAN_FRAME_ASSOC_REQ, "Association request" */
{ 'A', "ASOCRP" }, /* WLAN_FRAME_ASSOC_RESP, "Association response" */
{ 'a', "REASRQ" }, /* WLAN_FRAME_REASSOC_REQ, "Reassociation request" */
{ 'A', "REASRP" }, /* WLAN_FRAME_REASSOC_RESP, "Reassociation response" */
{ 'p', "PROBRQ" }, /* WLAN_FRAME_PROBE_REQ, "Probe request" */
{ 'P', "PROBRP" }, /* WLAN_FRAME_PROBE_RESP, "Probe response" */
{ 'T', "TIMING" }, /* WLAN_FRAME_TIME, "Timing Advertisement" */
{ '-', "-RESV-" }, /* RESERVED */
{ 'B', "BEACON" }, /* IEEE80211_STYPE_BEACON 0x0080 */
{ 't', "ATIM" }, /* IEEE80211_STYPE_ATIM 0x0090 */
{ 'D', "DISASC" }, /* IEEE80211_STYPE_DISASSOC 0x00A0 */
{ 'u', "AUTH" }, /* IEEE80211_STYPE_AUTH 0x00B0 */
{ 'U', "DEAUTH" }, /* IEEE80211_STYPE_DEAUTH 0x00C0 */
{ 'C', "ACTION" }, /* IEEE80211_STYPE_ACTION 0x00D0 */
{ 'c', "ACTNOA" }, /* Action No Ack 0x00E0 */
{ 'B', "BEACON" }, /* WLAN_FRAME_BEACON, "Beacon" */
{ 't', "ATIM" }, /* WLAN_FRAME_ATIM, "ATIM" */
{ 'D', "DISASC" }, /* WLAN_FRAME_DISASSOC, "Disassociation" */
{ 'u', "AUTH" }, /* WLAN_FRAME_AUTH, "Authentication" */
{ 'U', "DEAUTH" }, /* WLAN_FRAME_DEAUTH, "Deauthentication" */
{ 'C', "ACTION" }, /* WLAN_FRAME_ACTION, "Action" */
{ 'c', "ACTNOA" }, /* WLAN_FRAME_ACTION_NOACK, "Action No Ack" */
};
static struct pkt_names ctrl_names[] = {
{ 'w', "CTWRAP" }, /* Control Wrapper 0x0070 */
{ 'b', "BACKRQ" }, /* IEEE80211_STYPE_BACK_REQ 0x0080 */
{ 'B', "BACK" }, /* IEEE80211_STYPE_BACK 0x0090 */
{ 's', "PSPOLL" }, /* IEEE80211_STYPE_PSPOLL 0x00A0 */
{ 'R', "RTS" }, /* IEEE80211_STYPE_RTS 0x00B0 */
{ 'C', "CTS" }, /* IEEE80211_STYPE_CTS 0x00C0 */
{ 'K', "ACK" }, /* IEEE80211_STYPE_ACK 0x00D0 */
{ 'f', "CFEND" }, /* IEEE80211_STYPE_CFEND 0x00E0 */
{ 'f', "CFENDK" }, /* IEEE80211_STYPE_CFENDACK 0x00F0 */
{ 'w', "CTWRAP" }, /* WLAN_FRAME_CTRL_WRAP, "Control Wrapper" */
{ 'b', "BACKRQ" }, /* WLAN_FRAME_BLKACK_REQ, "Block Ack Request" */
{ 'B', "BACK" }, /* WLAN_FRAME_BLKACK, "Block Ack" */
{ 's', "PSPOLL" }, /* WLAN_FRAME_PSPOLL, "PS-Poll" */
{ 'R', "RTS" }, /* WLAN_FRAME_RTS, "RTS" */
{ 'C', "CTS" }, /* WLAN_FRAME_CTS, "CTS" */
{ 'K', "ACK" }, /* WLAN_FRAME_ACK, "ACK" */
{ 'f', "CFEND" }, /* WLAN_FRAME_CF_END, "CF-End" */
{ 'f', "CFENDK" }, /* WLAN_FRAME_CF_END_ACK, "CF-End + CF-Ack" */
};