Add support for Sniffer 4.6 wireless captures.

svn path=/trunk/; revision=5106
This commit is contained in:
Gerald Combs 2002-04-07 19:10:10 +00:00
parent 815093d2ac
commit f0e2b1a83c
1 changed files with 23 additions and 8 deletions

View File

@ -1,6 +1,6 @@
/* netxray.c
*
* $Id: netxray.c,v 1.47 2002/03/04 00:25:35 guy Exp $
* $Id: netxray.c,v 1.48 2002/04/07 19:10:10 gerald Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -66,6 +66,9 @@ struct netxray_hdr {
static double TpS[] = { 1e6, 1193000.0, 1193180.0 };
#define NUM_NETXRAY_TIMEUNITS (sizeof TpS / sizeof TpS[0])
/* End-of-packet padding. (802.11 captures appear to have four bytes of it.) */
guint padding;
/* Version number strings. */
static const char vers_1_0[] = {
'0', '0', '1', '.', '0', '0', '0', '\0'
@ -99,6 +102,8 @@ struct netxrayrec_2_x_hdr {
guint16 orig_len; /* packet length */
guint16 incl_len; /* capture length */
guint32 xxx[7]; /* unknown */
/* For 802.11 captures, the "unkown" data appears to include
signal level, channel, and data rate information */
};
static gboolean netxray_read(wtap *wth, int *err, long *data_offset);
@ -126,7 +131,7 @@ int netxray_open(wtap *wth, int *err)
WTAP_ENCAP_UNKNOWN, /* ARCNET raw */
WTAP_ENCAP_UNKNOWN, /* ARCNET 878.2 */
WTAP_ENCAP_ATM_RFC1483, /* ATM */
WTAP_ENCAP_UNKNOWN, /* Wireless WAN */
WTAP_ENCAP_IEEE_802_11, /* Wireless WAN */
WTAP_ENCAP_UNKNOWN /* IrDA */
};
#define NUM_NETXRAY_ENCAPS (sizeof netxray_encap / sizeof netxray_encap[0])
@ -198,6 +203,10 @@ int netxray_open(wtap *wth, int *err)
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
return -1;
}
padding = 0;
if (netxray_encap[hdr.network] == WTAP_ENCAP_IEEE_802_11) {
padding = 4;
}
/* This is a netxray file */
wth->file_type = file_type;
@ -237,7 +246,7 @@ int netxray_open(wtap *wth, int *err)
/* Read the next packet */
static gboolean netxray_read(wtap *wth, int *err, long *data_offset)
{
guint32 packet_size;
guint32 packet_size, buffer_size;
int bytes_read;
union {
struct netxrayrec_1_x_hdr hdr_1_x;
@ -294,18 +303,24 @@ reread:
wth->data_offset += hdr_size;
packet_size = pletohs(&hdr.hdr_1_x.incl_len);
buffer_assure_space(wth->frame_buffer, packet_size);
buffer_size = packet_size - padding;
buffer_assure_space(wth->frame_buffer, buffer_size);
*data_offset = wth->data_offset;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(buffer_start_ptr(wth->frame_buffer), 1,
packet_size, wth->fh);
buffer_size, wth->fh);
if ((guint32)bytes_read != packet_size) {
if ((guint32)bytes_read != buffer_size) {
*err = file_error(wth->fh);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
}
if (file_seek(wth->fh, padding, SEEK_CUR) == -1) {
*err = file_error(wth->fh);
return FALSE;
}
wth->data_offset += packet_size;
t = (double)pletohl(&hdr.hdr_1_x.timelo)
@ -315,8 +330,8 @@ reread:
wth->phdr.ts.tv_sec = wth->capture.netxray->start_time + (long)t;
wth->phdr.ts.tv_usec = (unsigned long)((t-(double)(unsigned long)(t))
*1.0e6);
wth->phdr.caplen = packet_size;
wth->phdr.len = pletohs(&hdr.hdr_1_x.orig_len);
wth->phdr.caplen = buffer_size;
wth->phdr.len = pletohs(&hdr.hdr_1_x.orig_len) - padding;
wth->phdr.pkt_encap = wth->file_encap;
return TRUE;