From Stephen Donnelly:
Add frame.interface_id support for pcap DLT_ERF file format https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7281 svn path=/trunk/; revision=42824
This commit is contained in:
parent
d40cb34ba9
commit
8a62ebc28d
|
@ -105,7 +105,6 @@ 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));
|
||||
|
||||
|
@ -277,40 +276,7 @@ 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++;
|
||||
}
|
||||
erf_populate_interfaces(wth);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -746,3 +712,51 @@ int erf_dump_open(wtap_dumper *wdh, int *err)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int erf_populate_interfaces(wtap *wth)
|
||||
{
|
||||
wtapng_if_descr_t int_data;
|
||||
int i;
|
||||
|
||||
if (!wth)
|
||||
return -1;
|
||||
|
||||
if (!wth->interface_data) {
|
||||
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;
|
||||
|
||||
/* Preemptively create interface entries for 4 interfaces, since this is the max number in ERF */
|
||||
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 0;
|
||||
}
|
||||
|
|
|
@ -108,4 +108,6 @@ int erf_open(wtap *wth, int *err, gchar **err_info);
|
|||
int erf_dump_can_write_encap(int encap);
|
||||
int erf_dump_open(wtap_dumper *wdh, int *err);
|
||||
|
||||
int erf_populate_interfaces(wtap *wth);
|
||||
|
||||
#endif /* __W_ERF_H__ */
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "pcap-common.h"
|
||||
#include "pcap-encap.h"
|
||||
#include "libpcap.h"
|
||||
#include "erf.h"
|
||||
|
||||
/* See source to the "libpcap" library for information on the "libpcap"
|
||||
file format. */
|
||||
|
@ -668,6 +669,14 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
|
|||
} else {
|
||||
wth->phdr.ts.nsecs = hdr.hdr.ts_usec * 1000;
|
||||
}
|
||||
} else {
|
||||
/* update frame.interface_id for ERF format */
|
||||
wth->phdr.presence_flags |= WTAP_HAS_INTERFACE_ID;
|
||||
wth->phdr.interface_id = wth->pseudo_header.erf.phdr.flags & 0x03;
|
||||
|
||||
if(!wth->interface_data) {
|
||||
erf_populate_interfaces(wth);
|
||||
}
|
||||
}
|
||||
wth->phdr.caplen = packet_size;
|
||||
wth->phdr.len = orig_size;
|
||||
|
|
Loading…
Reference in New Issue