Add a plain "radiotap.channel" field to the radiotap dissector.

Check for an invalid channel frequency.  Pass the channel, data rate,
and quality to the 802.11 dissector, so that they show up there
as well.  Clean up whitespace.

svn path=/trunk/; revision=19878
This commit is contained in:
Gerald Combs 2006-11-12 00:52:05 +00:00
parent 14810dd30c
commit d20f77d3ec
3 changed files with 36 additions and 17 deletions

View File

@ -1107,7 +1107,7 @@ add_fixed_field (proto_tree * tree, tvbuff_t * tvb, int offset, int lfcode)
proto_item *tsinfo_item;
proto_tree *tsinfo_tree;
guint32 tsi;
tsinfo_item = proto_tree_add_item(tree, hf_ts_info, tvb,
offset, 3, TRUE);
tsinfo_tree = proto_item_add_subtree(tsinfo_item, ett_tsinfo_tree);
@ -2037,7 +2037,7 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of
proto_tree_add_item(tree, hf_tsinfo_up, tvb, offset + 2, 1, TRUE);
proto_tree_add_item(tree, hf_class_type, tvb, offset + 3, 1, TRUE);
proto_tree_add_item(tree, hf_class_mask, tvb, offset + 4, 1, TRUE);
switch (type)
switch (type)
{
case 0:
proto_tree_add_item(tree, ff_src_mac_addr, tvb, offset + 5,
@ -3647,7 +3647,7 @@ dissect_ieee80211 (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
static void
dissect_ieee80211_datapad (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
{
dissect_ieee80211_common (tvb, pinfo, tree, FALSE, FALSE,
dissect_ieee80211_common (tvb, pinfo, tree, FALSE, TRUE,
pinfo->pseudo_header->ieee_802_11.fcs_len, FALSE, TRUE);
}
@ -4788,6 +4788,7 @@ proto_register_ieee80211 (void)
register_dissector("wlan_fixed", dissect_ieee80211_fixed, proto_wlan);
register_dissector("wlan_bsfc", dissect_ieee80211_bsfc, proto_wlan);
register_dissector("wlan_datapad", dissect_ieee80211_datapad, proto_wlan);
register_dissector("wlan_radio", dissect_ieee80211_radio, proto_wlan);
register_init_routine(wlan_defragment_init);
wlan_tap = register_tap("wlan");

View File

@ -141,6 +141,7 @@ static int hf_radiotap_pad = -1;
static int hf_radiotap_length = -1;
static int hf_radiotap_present = -1;
static int hf_radiotap_mactime = -1;
static int hf_radiotap_channel = -1;
static int hf_radiotap_channel_frequency = -1;
static int hf_radiotap_channel_flags = -1;
static int hf_radiotap_datarate = -1;
@ -186,7 +187,7 @@ static gint ett_radiotap = -1;
static gint ett_radiotap_present = -1;
static gint ett_radiotap_flags = -1;
static dissector_handle_t ieee80211_handle;
static dissector_handle_t ieee80211_radio_handle;
static dissector_handle_t ieee80211_datapad_handle;
static void
@ -425,6 +426,9 @@ proto_register_radiotap(void)
{ &hf_radiotap_fcs,
{ "802.11 FCS", "radiotap.fcs",
FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL } },
{ &hf_radiotap_channel,
{ "Channel", "radiotap.channel",
FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } },
{ &hf_radiotap_channel_frequency,
{ "Channel frequency", "radiotap.channel.freq",
FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } },
@ -530,7 +534,7 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
gint8 dbm;
guint8 db, rflags;
guint32 present, next_present;
int bit;
int bit, channel;
if(check_col(pinfo->cinfo, COL_PROTOCOL))
col_set_str(pinfo->cinfo, COL_PROTOCOL, "WLAN");
@ -659,8 +663,9 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
rate / 2, rate & 1 ? 5 : 0);
}
if (tree) {
pinfo->pseudo_header->ieee_802_11.data_rate = rate;
proto_tree_add_uint_format(radiotap_tree, hf_radiotap_datarate,
tvb, offset, 1, tvb_get_guint8(tvb, offset),
tvb, offset, 1, rate,
"Data Rate: %d.%d Mb/s", rate / 2, rate & 1 ? 5 : 0);
}
offset++;
@ -750,10 +755,19 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (tree) {
freq = tvb_get_letohs(tvb, offset);
flags = tvb_get_letohs(tvb, offset+2);
proto_tree_add_uint_format(radiotap_tree, hf_radiotap_channel_frequency,
tvb, offset, 2, freq,
"Channel: %u (chan %u)", freq, ieee80211_mhz2ieee(freq, flags));
proto_tree_add_uint(radiotap_tree, hf_radiotap_channel_flags,
channel = ieee80211_mhz2ieee(freq, flags);
if (channel < 1) {
proto_tree_add_uint_format(radiotap_tree, hf_radiotap_channel_frequency,
tvb, offset, 2, freq,
"Channel frequency: %u (invalid)", freq);
} else {
pinfo->pseudo_header->ieee_802_11.channel = (guint8) channel;
proto_tree_add_uint(radiotap_tree, hf_radiotap_channel,
tvb, offset, 2, (guint32) channel);
proto_tree_add_uint(radiotap_tree, hf_radiotap_channel_frequency,
tvb, offset, 2, freq);
}
proto_tree_add_uint(radiotap_tree, hf_radiotap_channel_flags,
tvb, offset+2, 2, flags);
}
offset+=4;
@ -784,8 +798,9 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (length_remaining < 2)
break;
if (tree) {
pinfo->pseudo_header->ieee_802_11.signal_level = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(radiotap_tree, hf_radiotap_quality,
tvb, offset, 2, tvb_get_letohs(tvb, offset));
tvb, offset, 2, pinfo->pseudo_header->ieee_802_11.signal_level);
}
offset+=2;
length_remaining-=2;
@ -854,7 +869,7 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* dissect the 802.11 header next */
call_dissector((rflags & IEEE80211_RADIOTAP_F_DATAPAD) ?
ieee80211_datapad_handle : ieee80211_handle,
ieee80211_datapad_handle : ieee80211_radio_handle,
next_tvb, pinfo, tree);
}
@ -864,7 +879,7 @@ proto_reg_handoff_radiotap(void)
dissector_handle_t radiotap_handle;
/* handle for 802.11 dissector */
ieee80211_handle = find_dissector("wlan");
ieee80211_radio_handle = find_dissector("wlan_radio");
ieee80211_datapad_handle = find_dissector("wlan_datapad");
radiotap_handle = create_dissector_handle(dissect_radiotap, proto_radiotap);

View File

@ -86,7 +86,7 @@ struct mtp2_hdr {
#endif
/*
* The fake link-layer header of LAPD packets
* The fake link-layer header of LAPD packets
*/
struct lapd_sll_hdr {
guint16 sll_pkttype; /* packet type */
@ -639,7 +639,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
gboolean aix;
int file_encap;
/* Read in the number that should be at the start of a "libpcap" file */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&magic, 1, sizeof magic, wth->fh);
@ -697,7 +697,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
case PCAP_SWAPPED_NSEC_MAGIC:
/* Host that wrote it out has a byte order opposite to
ours, and was running a program using either ss990915
ours, and was running a program using either ss990915
or ss991029 libpcap. */
byte_swapped = TRUE;
modified = FALSE;
@ -1277,6 +1277,9 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
* supplies an FCS?
*/
wth->pseudo_header.ieee_802_11.fcs_len = -1;
wth->pseudo_header.ieee_802_11.channel = 0;
wth->pseudo_header.ieee_802_11.data_rate = 0;
wth->pseudo_header.ieee_802_11.signal_level = 0;
break;
case WTAP_ENCAP_IRDA:
@ -1814,7 +1817,7 @@ libpcap_read_mtp2_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_heade
}
return libpcap_get_mtp2_pseudoheader(&mtp2_hdr, pseudo_header);
}
static gboolean