diff options
author | Guy Harris <guy@alum.mit.edu> | 2004-01-27 08:06:12 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2004-01-27 08:06:12 +0000 |
commit | 2528c053cecdf0acd82a225027df52dcf44439ef (patch) | |
tree | 89a2f17b206f3ebfb142436d83e8a435262dde06 /wiretap | |
parent | 70e3d8a0974b5aceb1b0175f437ad570b633677e (diff) | |
download | wireshark-2528c053cecdf0acd82a225027df52dcf44439ef.tar.gz wireshark-2528c053cecdf0acd82a225027df52dcf44439ef.tar.bz2 wireshark-2528c053cecdf0acd82a225027df52dcf44439ef.zip |
Supply a pseudo-header for all 802.11 packets; add an "fcs_len" field to
it, similar to the Ethernet pseudo-header's "fcs_len" field, and use it
in the 802.11 dissector.
svn path=/trunk/; revision=9884
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/airopeek9.c | 47 | ||||
-rw-r--r-- | wiretap/etherpeek.c | 24 | ||||
-rw-r--r-- | wiretap/libpcap.c | 11 | ||||
-rw-r--r-- | wiretap/netxray.c | 28 | ||||
-rw-r--r-- | wiretap/wtap.h | 6 |
5 files changed, 67 insertions, 49 deletions
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 */ |