summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packet-ieee80211.c28
-rw-r--r--wiretap/airopeek9.c47
-rw-r--r--wiretap/etherpeek.c24
-rw-r--r--wiretap/libpcap.c11
-rw-r--r--wiretap/netxray.c28
-rw-r--r--wiretap/wtap.h6
6 files changed, 89 insertions, 55 deletions
diff --git a/packet-ieee80211.c b/packet-ieee80211.c
index 18af2b7646..ac5bb75827 100644
--- a/packet-ieee80211.c
+++ b/packet-ieee80211.c
@@ -3,7 +3,7 @@
* Copyright 2000, Axis Communications AB
* Inquiries/bugreports should be sent to Johan.Jorgensen@axis.com
*
- * $Id: packet-ieee80211.c,v 1.103 2003/12/29 04:02:39 gerald Exp $
+ * $Id: packet-ieee80211.c,v 1.104 2004/01/27 08:06:11 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1243,7 +1243,7 @@ set_dst_addr_cols(packet_info *pinfo, const guint8 *addr, char *type)
static void
dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
proto_tree * tree, gboolean fixed_length_header,
- gboolean has_radio_information, gboolean has_no_fcs,
+ gboolean has_radio_information, gint fcs_len,
gboolean wlan_broken_fc)
{
guint16 fcf, flags, frame_type_subtype;
@@ -1258,6 +1258,7 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
proto_tree *flag_tree;
proto_tree *fc_tree;
guint16 hdr_len;
+ gboolean has_fcs;
gint len, reported_len;
gboolean save_fragmented;
tvbuff_t *volatile next_tvb = NULL;
@@ -1642,7 +1643,21 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
len = tvb_length_remaining(tvb, hdr_len);
reported_len = tvb_reported_length_remaining(tvb, hdr_len);
- if (!has_no_fcs && (wlan_check_fcs))
+ switch (fcs_len)
+ {
+ case 0: /* Definitely has no FCS */
+ has_fcs = FALSE;
+ break;
+
+ case 4: /* Definitely has an FCS */
+ has_fcs = TRUE;
+ break;
+
+ default: /* Don't know - use "wlan_check_fcs" */
+ has_fcs = wlan_check_fcs;
+ break;
+ }
+ if (has_fcs)
{
/*
* Well, this packet should, in theory, have an FCS.
@@ -1973,7 +1988,8 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
static void
dissect_ieee80211 (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
{
- dissect_ieee80211_common (tvb, pinfo, tree, FALSE, FALSE, FALSE, FALSE);
+ dissect_ieee80211_common (tvb, pinfo, tree, FALSE, FALSE,
+ pinfo->pseudo_header->ieee_802_11.fcs_len, FALSE);
}
/*
@@ -1983,8 +1999,8 @@ dissect_ieee80211 (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
static void
dissect_ieee80211_radio (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
{
- /* These packets do NOT have a FCS present */
- dissect_ieee80211_common (tvb, pinfo, tree, FALSE, TRUE, TRUE, FALSE);
+ dissect_ieee80211_common (tvb, pinfo, tree, FALSE, TRUE,
+ pinfo->pseudo_header->ieee_802_11.fcs_len, FALSE);
}
/*
diff --git a/wiretap/airopeek9.c b/wiretap/airopeek9.c
index 777628934a..4598d55ebd 100644
--- a/wiretap/airopeek9.c
+++ b/wiretap/airopeek9.c
@@ -1,7 +1,7 @@
/* airopeek9.c
* Routines for opening AiroPeek V9 files
*
- * $Id: airopeek9.c,v 1.4 2004/01/25 21:55:12 guy Exp $
+ * $Id: airopeek9.c,v 1.5 2004/01/27 08:06:11 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -74,6 +74,8 @@ static gboolean airopeek_read_v9(wtap *wth, int *err, gchar **err_info,
static gboolean airopeek_seek_read_v9(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info);
+static void airopeek_fill_pseudo_header(union wtap_pseudo_header *pseudo_header,
+ guchar *ap_pkt);
static int wtap_file_read_pattern (wtap *wth, char *pattern, int *err)
{
@@ -297,20 +299,7 @@ static gboolean airopeek_read_v9(wtap *wth, int *err, gchar **err_info _U_,
wth->phdr.len = length;
wth->phdr.caplen = sliceLength;
- /*
- * Fill the pseudo header with radio information.
- * XXX - we should supply the additional information;
- * the pseudo-header should probably be supplied in a fashion
- * similar to the new BSD radio header, so that the 802.11
- * dissector can determine which, if any, information items
- * are present.
- */
- wth->pseudo_header.ieee_802_11.channel =
- pletohl(&ap_pkt[AIROPEEK_V9_CHANNEL_OFFSET]);
- wth->pseudo_header.ieee_802_11.data_rate =
- pletohl(&ap_pkt[AIROPEEK_V9_RATE_OFFSET]);
- wth->pseudo_header.ieee_802_11.signal_level =
- pletohl(&ap_pkt[AIROPEEK_V9_SIGNAL_PERC_OFFSET]);
+ airopeek_fill_pseudo_header(&wth->pseudo_header, ap_pkt);
/* read the frame data */
buffer_assure_space(wth->frame_buffer, sliceLength);
@@ -356,12 +345,7 @@ airopeek_seek_read_v9(wtap *wth, long seek_off,
/* Read the packet header. */
wtap_file_read_expected_bytes(ap_pkt, sizeof(ap_pkt), wth->random_fh, err);
- pseudo_header->ieee_802_11.channel =
- pletohl(&ap_pkt[AIROPEEK_V9_CHANNEL_OFFSET]);
- pseudo_header->ieee_802_11.data_rate =
- pletohl(&ap_pkt[AIROPEEK_V9_RATE_OFFSET]);
- pseudo_header->ieee_802_11.signal_level =
- pletohl(&ap_pkt[AIROPEEK_V9_SIGNAL_PERC_OFFSET]);
+ airopeek_fill_pseudo_header(pseudo_header, ap_pkt);
/*
* XXX - should "errno" be set in "wtap_file_read_expected_bytes()"?
@@ -370,3 +354,24 @@ airopeek_seek_read_v9(wtap *wth, long seek_off,
wtap_file_read_expected_bytes(pd, length, wth->random_fh, err);
return TRUE;
}
+
+/*
+ * Fill the pseudo header with radio information.
+ * XXX - we should supply the additional information;
+ * the pseudo-header should probably be supplied in a fashion
+ * similar to the new BSD radio header, so that the 802.11
+ * dissector can determine which, if any, information items
+ * are present.
+ */
+static void
+airopeek_fill_pseudo_header(union wtap_pseudo_header *pseudo_header,
+ guchar *ap_pkt)
+{
+ pseudo_header->ieee_802_11.fcs_len = 0; /* no FCS */
+ pseudo_header->ieee_802_11.channel =
+ pletohl(&ap_pkt[AIROPEEK_V9_CHANNEL_OFFSET]);
+ pseudo_header->ieee_802_11.data_rate =
+ pletohl(&ap_pkt[AIROPEEK_V9_RATE_OFFSET]);
+ pseudo_header->ieee_802_11.signal_level =
+ pletohl(&ap_pkt[AIROPEEK_V9_SIGNAL_PERC_OFFSET]);
+}
diff --git a/wiretap/etherpeek.c b/wiretap/etherpeek.c
index 9da771ae03..ab37b00051 100644
--- a/wiretap/etherpeek.c
+++ b/wiretap/etherpeek.c
@@ -2,7 +2,7 @@
* Routines for opening EtherPeek (and TokenPeek?) files
* Copyright (c) 2001, Daniel Thompson <d.thompson@gmx.net>
*
- * $Id: etherpeek.c,v 1.26 2004/01/25 21:55:13 guy Exp $
+ * $Id: etherpeek.c,v 1.27 2004/01/27 08:06:11 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -141,6 +141,8 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info,
static gboolean etherpeek_seek_read_v7(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info);
+static void etherpeek_fill_pseudo_header_v7(
+ union wtap_pseudo_header *pseudo_header, airopeek_radio_hdr_t *radio_hdr);
static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info,
long *data_offset);
static gboolean etherpeek_seek_read_v56(wtap *wth, long seek_off,
@@ -418,9 +420,8 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info,
wth->phdr.caplen -= 4;
wth->data_offset += 4;
- wth->pseudo_header.ieee_802_11.channel = radio_hdr.channel;
- wth->pseudo_header.ieee_802_11.data_rate = radio_hdr.data_rate;
- wth->pseudo_header.ieee_802_11.signal_level = radio_hdr.signal_level;
+ etherpeek_fill_pseudo_header_v7(&wth->pseudo_header,
+ &radio_hdr);
break;
case WTAP_ENCAP_ETHERNET:
@@ -497,9 +498,8 @@ etherpeek_seek_read_v7(wtap *wth, long seek_off,
wtap_file_read_expected_bytes(&radio_hdr, 4, wth->random_fh,
err);
- pseudo_header->ieee_802_11.channel = radio_hdr.channel;
- pseudo_header->ieee_802_11.data_rate = radio_hdr.data_rate;
- pseudo_header->ieee_802_11.signal_level = radio_hdr.signal_level;
+ etherpeek_fill_pseudo_header_v7(pseudo_header,
+ &radio_hdr);
break;
case WTAP_ENCAP_ETHERNET:
@@ -518,6 +518,16 @@ etherpeek_seek_read_v7(wtap *wth, long seek_off,
return TRUE;
}
+static void
+etherpeek_fill_pseudo_header_v7(union wtap_pseudo_header *pseudo_header,
+ airopeek_radio_hdr_t *radio_hdr)
+{
+ pseudo_header->ieee_802_11.fcs_len = 0; /* no FCS */
+ pseudo_header->ieee_802_11.channel = radio_hdr->channel;
+ pseudo_header->ieee_802_11.data_rate = radio_hdr->data_rate;
+ pseudo_header->ieee_802_11.signal_level = radio_hdr->signal_level;
+}
+
static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_,
long *data_offset)
{
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index 5dc5b02e97..2ae197c5a0 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -1,6 +1,6 @@
/* libpcap.c
*
- * $Id: libpcap.c,v 1.108 2004/01/25 21:55:15 guy Exp $
+ * $Id: libpcap.c,v 1.109 2004/01/27 08:06:12 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -1045,6 +1045,15 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
wth->pseudo_header.eth.fcs_len = -1;
break;
+ case WTAP_ENCAP_IEEE_802_11:
+ /*
+ * We don't know whether there's an FCS in this frame or not.
+ * XXX - are there any OSes where the capture mechanism
+ * supplies an FCS?
+ */
+ wth->pseudo_header.ieee_802_11.fcs_len = -1;
+ break;
+
case WTAP_ENCAP_IRDA:
if (packet_size < sizeof (struct irda_sll_hdr)) {
/*
diff --git a/wiretap/netxray.c b/wiretap/netxray.c
index 9d000a28fa..fe8068aa9e 100644
--- a/wiretap/netxray.c
+++ b/wiretap/netxray.c
@@ -1,6 +1,6 @@
/* netxray.c
*
- * $Id: netxray.c,v 1.88 2004/01/25 23:50:48 guy Exp $
+ * $Id: netxray.c,v 1.89 2004/01/27 08:06:12 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -800,13 +800,6 @@ netxray_set_pseudo_header(wtap *wth, const guint8 *pd, int len,
break;
case WTAP_ENCAP_IEEE_802_11_WITH_RADIO:
- pseudo_header->ieee_802_11.channel =
- hdr->hdr_2_x.xxx[12];
- pseudo_header->ieee_802_11.data_rate =
- hdr->hdr_2_x.xxx[13];
- pseudo_header->ieee_802_11.signal_level =
- hdr->hdr_2_x.xxx[14];
-
/*
* It appears, in one 802.11 capture, that
* we have 4 bytes of junk at the ends of
@@ -824,23 +817,22 @@ netxray_set_pseudo_header(wtap *wth, const guint8 *pd, int len,
/*
* FCS.
*/
-#if 0
- pseudo_header->eth.fcs_len = 4;
-#else
- padding = 4;
-#endif
+ pseudo_header->ieee_802_11.fcs_len = 4;
} else {
/*
* Junk.
*/
padding = 4;
}
-#if 0
} else
- pseudo_header->eth.fcs_len = 0;
-#else
- }
-#endif
+ pseudo_header->ieee_802_11.fcs_len = 0;
+
+ pseudo_header->ieee_802_11.channel =
+ hdr->hdr_2_x.xxx[12];
+ pseudo_header->ieee_802_11.data_rate =
+ hdr->hdr_2_x.xxx[13];
+ pseudo_header->ieee_802_11.signal_level =
+ hdr->hdr_2_x.xxx[14];
break;
case WTAP_ENCAP_ISDN:
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 9dfed9bf96..3ed84ae566 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1,6 +1,6 @@
/* wtap.h
*
- * $Id: wtap.h,v 1.148 2004/01/25 21:55:17 guy Exp $
+ * $Id: wtap.h,v 1.149 2004/01/27 08:06:12 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -330,8 +330,10 @@ struct p2p_phdr {
gboolean sent; /* TRUE=sent, FALSE=received */
};
-/* Packet "pseudo-header" information for 802.11 with radio information. */
+/* Packet "pseudo-header" information for 802.11
+ Radio information is only present for WTAP_ENCAP_IEEE_802_11_WITH_RADIO. */
struct ieee_802_11_phdr {
+ gint fcs_len; /* Number of bytes of FCS - -1 means "unknown" */
guint8 channel; /* Channel number */
guint8 data_rate; /* in .5 Mb/s units */
guint8 signal_level; /* percentage */