aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/erf.c
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2012-05-24 09:24:05 +0000
committerAnders Broman <anders.broman@ericsson.com>2012-05-24 09:24:05 +0000
commit8a62ebc28de1fcd8b4f01065d224acbe904ae805 (patch)
treedcfa8b344d580131b387f8ee25f735da4c90ee72 /wiretap/erf.c
parentd40cb34ba95e207eb6bb9a6697af795970fc9dea (diff)
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
Diffstat (limited to 'wiretap/erf.c')
-rw-r--r--wiretap/erf.c84
1 files changed, 49 insertions, 35 deletions
diff --git a/wiretap/erf.c b/wiretap/erf.c
index b3769643c5..d4064c2389 100644
--- a/wiretap/erf.c
+++ b/wiretap/erf.c
@@ -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;
+}