aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-radiotap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2010-04-30 08:26:12 +0000
committerGuy Harris <guy@alum.mit.edu>2010-04-30 08:26:12 +0000
commitd4010f20588c3050c5f74198430a021ffceb8d9a (patch)
tree3678171ec7e2d822d39a1779cef2db76978e55c1 /epan/dissectors/packet-radiotap.c
parent3c8db1cae53bc86f4f56585808ecb10b9c9af1b7 (diff)
Clean up some calls to use the same offset as the call to put the parent
into the protocol tree. Put the cases for various Radiotap data items into numerical order by the bit number. svn path=/trunk/; revision=32610
Diffstat (limited to 'epan/dissectors/packet-radiotap.c')
-rw-r--r--epan/dissectors/packet-radiotap.c367
1 files changed, 192 insertions, 175 deletions
diff --git a/epan/dissectors/packet-radiotap.c b/epan/dissectors/packet-radiotap.c
index 12805d7aa8..09e6d576cb 100644
--- a/epan/dissectors/packet-radiotap.c
+++ b/epan/dissectors/packet-radiotap.c
@@ -90,7 +90,7 @@ enum ieee80211_radiotap_type {
IEEE80211_RADIOTAP_ANTENNA = 11,
IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
- IEEE80211_RADIOTAP_RX_FLAGS = 14,
+ IEEE80211_RADIOTAP_RX_FLAGS = 14, /* could also be FCS */
IEEE80211_RADIOTAP_XCHANNEL = 18,
IEEE80211_RADIOTAP_EXT = 31
};
@@ -885,44 +885,44 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
present_tree = proto_item_add_subtree(pt, ett_radiotap_present);
proto_tree_add_item(present_tree, hf_radiotap_present_tsft,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
proto_tree_add_item(present_tree, hf_radiotap_present_flags,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
proto_tree_add_item(present_tree, hf_radiotap_present_rate,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
proto_tree_add_item(present_tree, hf_radiotap_present_channel,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
proto_tree_add_item(present_tree, hf_radiotap_present_fhss,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
proto_tree_add_item(present_tree, hf_radiotap_present_dbm_antsignal,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
proto_tree_add_item(present_tree, hf_radiotap_present_dbm_antnoise,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
proto_tree_add_item(present_tree, hf_radiotap_present_lock_quality,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
proto_tree_add_item(present_tree, hf_radiotap_present_tx_attenuation,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
proto_tree_add_item(present_tree, hf_radiotap_present_db_tx_attenuation,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
proto_tree_add_item(present_tree, hf_radiotap_present_dbm_tx_attenuation,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
proto_tree_add_item(present_tree, hf_radiotap_present_antenna,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
proto_tree_add_item(present_tree, hf_radiotap_present_db_antsignal,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
proto_tree_add_item(present_tree, hf_radiotap_present_db_antnoise,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
if (radiotap_bit14_fcs) {
proto_tree_add_item(present_tree, hf_radiotap_present_hdrfcs,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
} else {
proto_tree_add_item(present_tree, hf_radiotap_present_rxflags,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
}
proto_tree_add_item(present_tree, hf_radiotap_present_xchannel,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
proto_tree_add_item(present_tree, hf_radiotap_present_ext,
- tvb, 4, 4, TRUE);
+ tvb, offset + 4, 4, TRUE);
}
offset += RADIOTAP_MIN_HEADER_LEN;
length_remaining -= RADIOTAP_MIN_HEADER_LEN;
@@ -936,6 +936,22 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
bit = BITNO_32(present ^ next_present);
switch (bit) {
+
+ case IEEE80211_RADIOTAP_TSFT:
+ align_offset = ALIGN_OFFSET(offset, 8);
+ offset += align_offset;
+ length_remaining -= align_offset;
+ if (length_remaining < 8)
+ break;
+ radiotap_info->tsft=tvb_get_letoh64(tvb, offset);
+ if (tree) {
+ proto_tree_add_uint64(radiotap_tree, hf_radiotap_mactime,
+ tvb, offset, 8,radiotap_info->tsft );
+ }
+ offset+=8;
+ length_remaining-=8;
+ break;
+
case IEEE80211_RADIOTAP_FLAGS:
{
proto_tree *flags_tree;
@@ -968,6 +984,7 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
length_remaining--;
break;
}
+
case IEEE80211_RADIOTAP_RATE:
if (length_remaining < 1)
break;
@@ -987,82 +1004,7 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
length_remaining--;
radiotap_info->rate = rate;
break;
- case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
- if (length_remaining < 1)
- break;
- dbm = (gint8) tvb_get_guint8(tvb, offset);
- col_add_fstr(pinfo->cinfo, COL_RSSI, "%d dBm", dbm);
- if (tree) {
- proto_tree_add_int_format(radiotap_tree,
- hf_radiotap_dbm_antsignal,
- tvb, offset, 1, dbm,
- "SSI Signal: %d dBm", dbm);
- }
- offset++;
- length_remaining--;
- radiotap_info->dbm_antsignal=dbm;
- break;
- case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
- if (length_remaining < 1)
- break;
- db = tvb_get_guint8(tvb, offset);
- col_add_fstr(pinfo->cinfo, COL_RSSI, "%u dB", db);
- if (tree) {
- proto_tree_add_uint_format(radiotap_tree,
- hf_radiotap_db_antsignal,
- tvb, offset, 1, db,
- "SSI Signal: %u dB", db);
- }
- offset++;
- length_remaining--;
- break;
- case IEEE80211_RADIOTAP_DBM_ANTNOISE:
- if (length_remaining < 1)
- break;
- dbm = (gint8) tvb_get_guint8(tvb, offset);
- if (tree) {
- proto_tree_add_int_format(radiotap_tree,
- hf_radiotap_dbm_antnoise,
- tvb, offset, 1, dbm,
- "SSI Noise: %d dBm", dbm);
- }
- offset++;
- length_remaining--;
- radiotap_info->dbm_antnoise=dbm;
- break;
- case IEEE80211_RADIOTAP_DB_ANTNOISE:
- if (length_remaining < 1)
- break;
- db = tvb_get_guint8(tvb, offset);
- if (tree) {
- proto_tree_add_uint_format(radiotap_tree,
- hf_radiotap_db_antnoise,
- tvb, offset, 1, db,
- "SSI Noise: %u dB", db);
- }
- offset++;
- length_remaining--;
- break;
- case IEEE80211_RADIOTAP_ANTENNA:
- if (length_remaining < 1)
- break;
- if (tree) {
- proto_tree_add_uint(radiotap_tree, hf_radiotap_antenna,
- tvb, offset, 1, tvb_get_guint8(tvb, offset));
- }
- offset++;
- length_remaining--;
- break;
- case IEEE80211_RADIOTAP_DBM_TX_POWER:
- if (length_remaining < 1)
- break;
- if (tree) {
- proto_tree_add_int(radiotap_tree, hf_radiotap_txpower,
- tvb, offset, 1, tvb_get_guint8(tvb, offset));
- }
- offset++;
- length_remaining--;
- break;
+
case IEEE80211_RADIOTAP_CHANNEL:
{
proto_item *it;
@@ -1118,83 +1060,66 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
length_remaining-=4;
break;
}
- case IEEE80211_RADIOTAP_XCHANNEL:
- {
- proto_item *it;
- proto_tree *flags_tree;
- align_offset = ALIGN_OFFSET(offset, 4);
+ case IEEE80211_RADIOTAP_FHSS:
+ align_offset = ALIGN_OFFSET(offset, 2);
offset += align_offset;
length_remaining -= align_offset;
- if (length_remaining < 8)
+ if (length_remaining < 2)
break;
+ proto_tree_add_item(radiotap_tree, hf_radiotap_fhss_hopset,
+ tvb, offset, 1, FALSE);
+ proto_tree_add_item(radiotap_tree, hf_radiotap_fhss_pattern,
+ tvb, offset, 1, FALSE);
+ offset+=2;
+ length_remaining-=2;
+ break;
+
+ case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
+ if (length_remaining < 1)
+ break;
+ dbm = (gint8) tvb_get_guint8(tvb, offset);
+ col_add_fstr(pinfo->cinfo, COL_RSSI, "%d dBm", dbm);
if (tree) {
- int channel;
- guint8 maxpower;
+ proto_tree_add_int_format(radiotap_tree,
+ hf_radiotap_dbm_antsignal,
+ tvb, offset, 1, dbm,
+ "SSI Signal: %d dBm", dbm);
+ }
+ offset++;
+ length_remaining--;
+ radiotap_info->dbm_antsignal=dbm;
+ break;
- flags = tvb_get_letohl(tvb, offset);
- freq = tvb_get_letohs(tvb, offset+4);
- channel = tvb_get_guint8(tvb, offset+6);
- maxpower = tvb_get_guint8(tvb, offset+7);
- proto_tree_add_uint(radiotap_tree, hf_radiotap_xchannel,
- tvb, offset+6, 1, (guint32) channel);
- proto_tree_add_uint(radiotap_tree, hf_radiotap_xchannel_frequency,
- tvb, offset+4, 2, freq);
- it = proto_tree_add_uint(radiotap_tree, hf_radiotap_xchannel_flags,
- tvb, offset+0, 4, flags);
- flags_tree = proto_item_add_subtree(it, ett_radiotap_xchannel_flags);
- proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_turbo,
- tvb, offset+0, 1, flags);
- proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_cck,
- tvb, offset+0, 1, flags);
- proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_ofdm,
- tvb, offset+0, 1, flags);
- proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_2ghz,
- tvb, offset+0, 1, flags);
- proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_5ghz,
- tvb, offset+1, 1, flags);
- proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_passive,
- tvb, offset+1, 1, flags);
- proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_dynamic,
- tvb, offset+1, 1, flags);
- proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_gfsk,
- tvb, offset+1, 1, flags);
- proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_gsm,
- tvb, offset+1, 1, flags);
- proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_sturbo,
- tvb, offset+1, 1, flags);
- proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_half,
- tvb, offset+1, 1, flags);
- proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_quarter,
- tvb, offset+1, 1, flags);
- proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_ht20,
- tvb, offset+2, 1, flags);
- proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_ht40u,
- tvb, offset+2, 1, flags);
- proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_ht40d,
- tvb, offset+2, 1, flags);
-#if 0
- proto_tree_add_uint(radiotap_tree, hf_radiotap_xchannel_maxpower,
- tvb, offset+7, 1, maxpower);
-#endif
+ case IEEE80211_RADIOTAP_DBM_ANTNOISE:
+ if (length_remaining < 1)
+ break;
+ dbm = (gint8) tvb_get_guint8(tvb, offset);
+ if (tree) {
+ proto_tree_add_int_format(radiotap_tree,
+ hf_radiotap_dbm_antnoise,
+ tvb, offset, 1, dbm,
+ "SSI Noise: %d dBm", dbm);
}
- offset+=8 /* flags + freq + ieee + maxregpower */;
- length_remaining-=8;
+ offset++;
+ length_remaining--;
+ radiotap_info->dbm_antnoise=dbm;
break;
- }
- case IEEE80211_RADIOTAP_FHSS:
+
+ case IEEE80211_RADIOTAP_LOCK_QUALITY:
align_offset = ALIGN_OFFSET(offset, 2);
offset += align_offset;
length_remaining -= align_offset;
if (length_remaining < 2)
break;
- proto_tree_add_item(radiotap_tree, hf_radiotap_fhss_hopset,
- tvb, offset, 1, FALSE);
- proto_tree_add_item(radiotap_tree, hf_radiotap_fhss_pattern,
- tvb, offset, 1, FALSE);
+ if (tree) {
+ proto_tree_add_uint(radiotap_tree, hf_radiotap_quality,
+ tvb, offset, 2, tvb_get_letohs(tvb, offset));
+ }
offset+=2;
length_remaining-=2;
break;
+
case IEEE80211_RADIOTAP_TX_ATTENUATION:
align_offset = ALIGN_OFFSET(offset, 2);
offset += align_offset;
@@ -1206,6 +1131,7 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
offset+=2;
length_remaining-=2;
break;
+
case IEEE80211_RADIOTAP_DB_TX_ATTENUATION:
align_offset = ALIGN_OFFSET(offset, 2);
offset += align_offset;
@@ -1217,33 +1143,58 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
offset+=2;
length_remaining-=2;
break;
- case IEEE80211_RADIOTAP_TSFT:
- align_offset = ALIGN_OFFSET(offset, 8);
- offset += align_offset;
- length_remaining -= align_offset;
- if (length_remaining < 8)
+
+ case IEEE80211_RADIOTAP_DBM_TX_POWER:
+ if (length_remaining < 1)
break;
- radiotap_info->tsft=tvb_get_letoh64(tvb, offset);
if (tree) {
- proto_tree_add_uint64(radiotap_tree, hf_radiotap_mactime,
- tvb, offset, 8,radiotap_info->tsft );
+ proto_tree_add_int(radiotap_tree, hf_radiotap_txpower,
+ tvb, offset, 1, tvb_get_guint8(tvb, offset));
}
- offset+=8;
- length_remaining-=8;
+ offset++;
+ length_remaining--;
break;
- case IEEE80211_RADIOTAP_LOCK_QUALITY:
- align_offset = ALIGN_OFFSET(offset, 2);
- offset += align_offset;
- length_remaining -= align_offset;
- if (length_remaining < 2)
+
+ case IEEE80211_RADIOTAP_ANTENNA:
+ if (length_remaining < 1)
break;
if (tree) {
- proto_tree_add_uint(radiotap_tree, hf_radiotap_quality,
- tvb, offset, 2, tvb_get_letohs(tvb, offset));
+ proto_tree_add_uint(radiotap_tree, hf_radiotap_antenna,
+ tvb, offset, 1, tvb_get_guint8(tvb, offset));
}
- offset+=2;
- length_remaining-=2;
+ offset++;
+ length_remaining--;
+ break;
+
+ case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
+ if (length_remaining < 1)
+ break;
+ db = tvb_get_guint8(tvb, offset);
+ col_add_fstr(pinfo->cinfo, COL_RSSI, "%u dB", db);
+ if (tree) {
+ proto_tree_add_uint_format(radiotap_tree,
+ hf_radiotap_db_antsignal,
+ tvb, offset, 1, db,
+ "SSI Signal: %u dB", db);
+ }
+ offset++;
+ length_remaining--;
break;
+
+ case IEEE80211_RADIOTAP_DB_ANTNOISE:
+ if (length_remaining < 1)
+ break;
+ db = tvb_get_guint8(tvb, offset);
+ if (tree) {
+ proto_tree_add_uint_format(radiotap_tree,
+ hf_radiotap_db_antnoise,
+ tvb, offset, 1, db,
+ "SSI Noise: %u dB", db);
+ }
+ offset++;
+ length_remaining--;
+ break;
+
case IEEE80211_RADIOTAP_RX_FLAGS:
{
proto_tree *flags_tree;
@@ -1282,6 +1233,72 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
break;
}
+
+ case IEEE80211_RADIOTAP_XCHANNEL:
+ {
+ proto_item *it;
+ proto_tree *flags_tree;
+
+ align_offset = ALIGN_OFFSET(offset, 4);
+ offset += align_offset;
+ length_remaining -= align_offset;
+ if (length_remaining < 8)
+ break;
+ if (tree) {
+ int channel;
+ guint8 maxpower;
+
+ flags = tvb_get_letohl(tvb, offset);
+ freq = tvb_get_letohs(tvb, offset+4);
+ channel = tvb_get_guint8(tvb, offset+6);
+ maxpower = tvb_get_guint8(tvb, offset+7);
+ proto_tree_add_uint(radiotap_tree, hf_radiotap_xchannel,
+ tvb, offset+6, 1, (guint32) channel);
+ proto_tree_add_uint(radiotap_tree, hf_radiotap_xchannel_frequency,
+ tvb, offset+4, 2, freq);
+ it = proto_tree_add_uint(radiotap_tree, hf_radiotap_xchannel_flags,
+ tvb, offset+0, 4, flags);
+ flags_tree = proto_item_add_subtree(it, ett_radiotap_xchannel_flags);
+ proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_turbo,
+ tvb, offset+0, 1, flags);
+ proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_cck,
+ tvb, offset+0, 1, flags);
+ proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_ofdm,
+ tvb, offset+0, 1, flags);
+ proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_2ghz,
+ tvb, offset+0, 1, flags);
+ proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_5ghz,
+ tvb, offset+1, 1, flags);
+ proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_passive,
+ tvb, offset+1, 1, flags);
+ proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_dynamic,
+ tvb, offset+1, 1, flags);
+ proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_gfsk,
+ tvb, offset+1, 1, flags);
+ proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_gsm,
+ tvb, offset+1, 1, flags);
+ proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_sturbo,
+ tvb, offset+1, 1, flags);
+ proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_half,
+ tvb, offset+1, 1, flags);
+ proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_quarter,
+ tvb, offset+1, 1, flags);
+ proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_ht20,
+ tvb, offset+2, 1, flags);
+ proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_ht40u,
+ tvb, offset+2, 1, flags);
+ proto_tree_add_boolean(flags_tree, hf_radiotap_xchannel_flags_ht40d,
+ tvb, offset+2, 1, flags);
+#if 0
+ proto_tree_add_uint(radiotap_tree, hf_radiotap_xchannel_maxpower,
+ tvb, offset+7, 1, maxpower);
+#endif
+ }
+ offset+=8 /* flags + freq + ieee + maxregpower */;
+ length_remaining-=8;
+ break;
+ }
+
default:
/*
* This indicates a field whose size we do not