aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2007-04-30 06:19:35 +0000
committerGuy Harris <guy@alum.mit.edu>2007-04-30 06:19:35 +0000
commit3a0381579e284f8f5b34747a42c385bc91a9b234 (patch)
treee84d8cd6c2d98b54eabacfb4bb466fe2db2e534a /epan
parentc38acbae0e0228394c2435262c181a98cb9d8589 (diff)
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
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-radiotap.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/epan/dissectors/packet-radiotap.c b/epan/dissectors/packet-radiotap.c
index c1c02049f2..673d12eee6 100644
--- a/epan/dissectors/packet-radiotap.c
+++ b/epan/dissectors/packet-radiotap.c
@@ -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 {
IEEE80211_RADIOTAP_TSFT = 0,
IEEE80211_RADIOTAP_FLAGS = 1,
@@ -230,17 +235,15 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
void
capture_radiotap(const guchar *pd, int offset, int len, packet_counts *ld)
{
- const struct ieee80211_radiotap_header *hdr;
guint16 it_len;
guint32 present;
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 ++;
return;
}
- hdr = (const struct ieee80211_radiotap_header *)&pd[offset];
- it_len = pletohs(&hdr->it_len);
+ it_len = pletohs(&pd[RADIOTAP_LENGTH_OFFSET]);
if(!BYTES_ARE_IN_FRAME(offset, len, it_len)) {
ld->other ++;
return;
@@ -252,15 +255,15 @@ capture_radiotap(const guchar *pd, int offset, int len, packet_counts *ld)
return;
}
- if(it_len < sizeof(*hdr)) {
+ if(it_len < RADIOTAP_MIN_HEADER_LEN) {
/* Header length is shorter than fixed-length portion of header */
ld->other ++;
return;
}
- present = pletohl(&hdr->it_present);
- offset += sizeof(*hdr);
- it_len -= sizeof(*hdr);
+ present = pletohl(&pd[RADIOTAP_PRESENT_OFFSET]);
+ offset += RADIOTAP_MIN_HEADER_LEN;
+ it_len -= RADIOTAP_MIN_HEADER_LEN;
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
* 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
* 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,
tvb, 4, 4, TRUE);
}
- offset += sizeof(struct ieee80211_radiotap_header);
- length_remaining -= sizeof(struct ieee80211_radiotap_header);
+ offset += RADIOTAP_MIN_HEADER_LEN;
+ length_remaining -= RADIOTAP_MIN_HEADER_LEN;
rflags = 0;
for (; present; present = next_present) {