From Stephen Donnelly:

Add frame.interface_id support for ERF file format

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7266

svn path=/trunk/; revision=42807
This commit is contained in:
Anders Broman 2012-05-23 06:41:37 +00:00
parent 0832853fa8
commit 00ba6b0dc5
1 changed files with 39 additions and 1 deletions

View File

@ -56,6 +56,7 @@
#include "wtap-int.h"
#include "file_wrappers.h"
#include "buffer.h"
#include "pcap-encap.h"
#include "atm.h"
#include "erf.h"
@ -104,6 +105,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
guint8 type;
size_t r;
gchar * buffer;
wtapng_if_descr_t int_data;
memset(&prevts, 0, sizeof(prevts));
@ -275,6 +277,41 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = erf_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
/* Preemptively create interface entries for 4 interfaces, since this is the max number in ERF */
wth->interface_data = g_array_new(FALSE, FALSE, sizeof(wtapng_if_descr_t));
memset(&int_data, 0, sizeof(int_data)); /* Zero all fields */
int_data.wtap_encap = WTAP_ENCAP_ERF;
int_data.time_units_per_second = (1LL<<32); /* ERF format resolution is 2^-32, capture resolution is unknown */
int_data.link_type = wtap_wtap_encap_to_pcap_encap(WTAP_ENCAP_ERF);
int_data.snap_len = 65535; /* ERF max length */
int_data.opt_comment = NULL;
/* XXX: if_IPv4addr opt 4 Interface network address and netmask.*/
/* XXX: if_IPv6addr opt 5 Interface network address and prefix length (stored in the last byte).*/
/* XXX: if_MACaddr opt 6 Interface Hardware MAC address (48 bits).*/
/* XXX: if_EUIaddr opt 7 Interface Hardware EUI address (64 bits)*/
int_data.if_speed = 0; /* Unknown */
int_data.if_tsresol = 0xa0; /* ERF format resolution is 2^-32 = 0xa0, capture resolution is unknown */
/* XXX: if_tzone 10 Time zone for GMT support (TODO: specify better). */
int_data.if_filter_str = NULL;
int_data.bpf_filter_len = 0;
int_data.if_filter_bpf_bytes = NULL;
int_data.if_os = NULL;
int_data.if_fcslen = 0; /* unknown! */
/* XXX if_tsoffset; opt 14 A 64 bits integer value that specifies an offset (in seconds)...*/
/* Interface statistics */
int_data.num_stat_entries = 0;
int_data.interface_statistics = NULL;
for (i=0; i<4; i++) {
int_data.if_name = g_strdup_printf("Port %c", 'A'+i);
int_data.if_description = g_strdup_printf("ERF Interface Id %d (Port %c)", i, 'A'+i);
g_array_append_val(wth->interface_data, int_data);
wth->number_of_interfaces++;
}
return 1;
}
@ -376,7 +413,7 @@ static int erf_read_header(FILE_T fh,
if (phdr != NULL) {
guint64 ts = pletohll(&erf_header->ts);
phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID;
phdr->ts.secs = (long) (ts >> 32);
ts = ((ts & 0xffffffff) * 1000 * 1000 * 1000);
ts += (ts & 0x80000000) << 1; /* rounding */
@ -385,6 +422,7 @@ static int erf_read_header(FILE_T fh,
phdr->ts.nsecs -= 1000000000;
phdr->ts.secs += 1;
}
phdr->interface_id = (erf_header->flags & 0x03);
}
/* Copy the ERF pseudo header */