1 --- a/protocol_parser.c
2 +++ b/protocol_parser.c
4 #include <net/if_arp.h>
5 #include <netinet/ip.h>
6 #include <netinet/udp.h>
7 +#include <asm/byteorder.h>
9 #include "prism_header.h"
10 #include "ieee80211_radiotap.h"
11 @@ -166,6 +167,7 @@ parse_radiotap_header(unsigned char** bu
12 __le32 present; /* the present bitmap */
13 unsigned char* b; /* current byte */
17 DEBUG("RADIOTAP HEADER\n");
19 @@ -176,21 +178,22 @@ parse_radiotap_header(unsigned char** bu
21 rh = (struct ieee80211_radiotap_header*)*buf;
22 b = *buf + sizeof(struct ieee80211_radiotap_header);
23 - present = rh->it_present;
24 + present = __le32_to_cpu(rh->it_present);
26 DEBUG("%08x\n", present);
28 + rt_len = __le16_to_cpu(rh->it_len);
29 /* check for header extension - ignore for now, just advance current position */
30 - while (present & 0x80000000 && b - *buf < rh->it_len) {
31 + while (present & 0x80000000 && b - *buf < rt_len) {
34 - present = *(__le32*)b;
35 + present = __le32_to_cpu(*(__le32*)b);
37 - present = rh->it_present; // in case it moved
38 + present = __le32_to_cpu(rh->it_present); // in case it moved
40 /* radiotap bitmap has 32 bit, but we are only interrested until
41 * bit 12 (IEEE80211_RADIOTAP_DB_ANTSIGNAL) => i<13 */
42 - for (i = 0; i < 13 && b - *buf < rh->it_len; i++) {
43 + for (i = 0; i < 13 && b - *buf < rt_len; i++) {
44 if ((present >> i) & 1) {
47 @@ -252,7 +255,7 @@ parse_radiotap_header(unsigned char** bu
49 case IEEE80211_RADIOTAP_CHANNEL:
50 /* channel & channel type */
51 - current_packet.phy_freq = *(u_int16_t*)b;
52 + current_packet.phy_freq = __le16_to_cpu(*(u_int16_t*)b);
53 DEBUG("[chan %d ", current_packet.phy_freq);
55 if (*(u_int16_t*)b & IEEE80211_CHAN_A) {
56 @@ -298,8 +301,8 @@ parse_radiotap_header(unsigned char** bu
57 DEBUG("noise: %d\n", current_packet.noise);
58 DEBUG("snr: %d\n", current_packet.snr);
60 - *buf = *buf + rh->it_len;
61 - return len - rh->it_len;
62 + *buf = *buf + rt_len;
63 + return len - rt_len;
67 @@ -312,22 +315,25 @@ parse_80211_header(unsigned char** buf,
73 if (len < 2) /* not even enough space for fc */
76 wh = (struct ieee80211_hdr*)*buf;
77 - hdrlen = ieee80211_get_hdrlen(wh->frame_control);
78 + fc = __le16_to_cpu(wh->frame_control);
79 + hdrlen = ieee80211_get_hdrlen(fc);
84 current_packet.len = len;
85 - current_packet.wlan_type = (wh->frame_control & (IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE));
86 + current_packet.wlan_type = (fc & (IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE));
88 - DEBUG("wlan_type %x - type %x - stype %x\n", wh->frame_control, wh->frame_control & IEEE80211_FCTL_FTYPE, wh->frame_control & IEEE80211_FCTL_STYPE );
89 + DEBUG("wlan_type %x - type %x - stype %x\n", fc,
90 + fc & IEEE80211_FCTL_FTYPE, fc & IEEE80211_FCTL_STYPE );
92 - DEBUG("%s\n", get_packet_type_name(wh->frame_control));
93 + DEBUG("%s\n", get_packet_type_name(fc));
95 bssid = ieee80211_get_bssid(wh, len);