Don't cast a "guint8 *" to a pointer to a structure; just use the
pointer to the guint8, plus explicitly defined structure offsets (the structure had better be the same on all platforms, forever, otherwise binary compatibility breaks, which would be an error, given that the structure appears in capture files). svn path=/trunk/; revision=21619
This commit is contained in:
parent
c38acbae0e
commit
3a0381579e
|
@ -65,6 +65,11 @@ struct ieee80211_radiotap_header {
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define RADIOTAP_MIN_HEADER_LEN 8 /* minimum header length */
|
||||||
|
#define RADIOTAP_VERSION_OFFSET 0 /* offset of version field */
|
||||||
|
#define RADIOTAP_LENGTH_OFFSET 2 /* offset of length field */
|
||||||
|
#define RADIOTAP_PRESENT_OFFSET 4 /* offset of "present" field */
|
||||||
|
|
||||||
enum ieee80211_radiotap_type {
|
enum ieee80211_radiotap_type {
|
||||||
IEEE80211_RADIOTAP_TSFT = 0,
|
IEEE80211_RADIOTAP_TSFT = 0,
|
||||||
IEEE80211_RADIOTAP_FLAGS = 1,
|
IEEE80211_RADIOTAP_FLAGS = 1,
|
||||||
|
@ -230,17 +235,15 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
|
||||||
void
|
void
|
||||||
capture_radiotap(const guchar *pd, int offset, int len, packet_counts *ld)
|
capture_radiotap(const guchar *pd, int offset, int len, packet_counts *ld)
|
||||||
{
|
{
|
||||||
const struct ieee80211_radiotap_header *hdr;
|
|
||||||
guint16 it_len;
|
guint16 it_len;
|
||||||
guint32 present;
|
guint32 present;
|
||||||
guint8 rflags;
|
guint8 rflags;
|
||||||
|
|
||||||
if(!BYTES_ARE_IN_FRAME(offset, len, (int)sizeof(*hdr))) {
|
if(!BYTES_ARE_IN_FRAME(offset, len, RADIOTAP_MIN_HEADER_LEN)) {
|
||||||
ld->other ++;
|
ld->other ++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
hdr = (const struct ieee80211_radiotap_header *)&pd[offset];
|
it_len = pletohs(&pd[RADIOTAP_LENGTH_OFFSET]);
|
||||||
it_len = pletohs(&hdr->it_len);
|
|
||||||
if(!BYTES_ARE_IN_FRAME(offset, len, it_len)) {
|
if(!BYTES_ARE_IN_FRAME(offset, len, it_len)) {
|
||||||
ld->other ++;
|
ld->other ++;
|
||||||
return;
|
return;
|
||||||
|
@ -252,15 +255,15 @@ capture_radiotap(const guchar *pd, int offset, int len, packet_counts *ld)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(it_len < sizeof(*hdr)) {
|
if(it_len < RADIOTAP_MIN_HEADER_LEN) {
|
||||||
/* Header length is shorter than fixed-length portion of header */
|
/* Header length is shorter than fixed-length portion of header */
|
||||||
ld->other ++;
|
ld->other ++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
present = pletohl(&hdr->it_present);
|
present = pletohl(&pd[RADIOTAP_PRESENT_OFFSET]);
|
||||||
offset += sizeof(*hdr);
|
offset += RADIOTAP_MIN_HEADER_LEN;
|
||||||
it_len -= sizeof(*hdr);
|
it_len -= RADIOTAP_MIN_HEADER_LEN;
|
||||||
|
|
||||||
rflags = 0;
|
rflags = 0;
|
||||||
|
|
||||||
|
@ -671,7 +674,7 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||||
* FIXME: This only works if there is exactly 1 it_present
|
* FIXME: This only works if there is exactly 1 it_present
|
||||||
* field in the header
|
* field in the header
|
||||||
*/
|
*/
|
||||||
if (length_remaining < sizeof(struct ieee80211_radiotap_header)) {
|
if (length_remaining < RADIOTAP_MIN_HEADER_LEN) {
|
||||||
/*
|
/*
|
||||||
* Radiotap header is shorter than the fixed-length portion
|
* Radiotap header is shorter than the fixed-length portion
|
||||||
* plus one "present" bitset.
|
* plus one "present" bitset.
|
||||||
|
@ -719,8 +722,8 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||||
proto_tree_add_item(present_tree, hf_radiotap_present_ext,
|
proto_tree_add_item(present_tree, hf_radiotap_present_ext,
|
||||||
tvb, 4, 4, TRUE);
|
tvb, 4, 4, TRUE);
|
||||||
}
|
}
|
||||||
offset += sizeof(struct ieee80211_radiotap_header);
|
offset += RADIOTAP_MIN_HEADER_LEN;
|
||||||
length_remaining -= sizeof(struct ieee80211_radiotap_header);
|
length_remaining -= RADIOTAP_MIN_HEADER_LEN;
|
||||||
|
|
||||||
rflags = 0;
|
rflags = 0;
|
||||||
for (; present; present = next_present) {
|
for (; present; present = next_present) {
|
||||||
|
|
Loading…
Reference in New Issue