aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-06-03 12:58:36 -0700
committerGuy Harris <guy@alum.mit.edu>2017-06-03 19:59:08 +0000
commit30c86f8b34233b1cf262c14660d32388bc7362d9 (patch)
tree1930ddcdc75ef79a170bf474b1a4550a88a7a6de
parent69ed5d5841605c63cbe017a2a0006f4085b8bb23 (diff)
Don't keep the pcap/pcapng link-layer header type as interface data.
Either 1) it can be determined from the libwiretap encapsulation type, in which case it's redundant information or 2) there *is* no pcap/pcapng link-layer header type for that encapsulation type, in which case you need to check for the attempt to determine it failing and handle that failure appropriately. Change-Id: Ie9557b513365c1fc8c6df74b9c8239e29aad46bc Reviewed-on: https://code.wireshark.org/review/21924 Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--ui/gtk/file_import_dlg.c1
-rw-r--r--ui/tap_export_pdu.c1
-rw-r--r--wiretap/erf.c2
-rw-r--r--wiretap/file_access.c3
-rw-r--r--wiretap/merge.c8
-rw-r--r--wiretap/nettrace_3gpp_32_423.c1
-rw-r--r--wiretap/pcapng.c19
-rw-r--r--wiretap/wtap.c3
-rw-r--r--wiretap/wtap.h1
9 files changed, 12 insertions, 27 deletions
diff --git a/ui/gtk/file_import_dlg.c b/ui/gtk/file_import_dlg.c
index 0e71ca9b34..0076fe9bde 100644
--- a/ui/gtk/file_import_dlg.c
+++ b/ui/gtk/file_import_dlg.c
@@ -501,7 +501,6 @@ file_import_open(text_import_info_t *info)
int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data);
int_data_mand->wtap_encap = info->encapsulation;
int_data_mand->time_units_per_second = 1000000; /* default microsecond resolution */
- int_data_mand->link_type = wtap_wtap_encap_to_pcap_encap(info->encapsulation);
int_data_mand->snap_len = WTAP_MAX_PACKET_SIZE;
wtap_block_add_string_option(int_data, OPT_IDB_NAME, "Fake IF File->Import", strlen("Fake IF File->Import"));
diff --git a/ui/tap_export_pdu.c b/ui/tap_export_pdu.c
index fec86cff1d..76e4326ab3 100644
--- a/ui/tap_export_pdu.c
+++ b/ui/tap_export_pdu.c
@@ -146,7 +146,6 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data);
int_data_mand->wtap_encap = WTAP_ENCAP_WIRESHARK_UPPER_PDU;
int_data_mand->time_units_per_second = 1000000000; /* default nanosecond resolution */
- int_data_mand->link_type = wtap_wtap_encap_to_pcap_encap(WTAP_ENCAP_WIRESHARK_UPPER_PDU);
int_data_mand->snap_len = WTAP_MAX_PACKET_SIZE;
wtap_block_add_string_option(int_data, OPT_IDB_NAME, "Fake IF, PDU->Export", strlen("Fake IF, PDU->Export"));
diff --git a/wiretap/erf.c b/wiretap/erf.c
index 21951d596b..7b1fe9d5ff 100644
--- a/wiretap/erf.c
+++ b/wiretap/erf.c
@@ -953,7 +953,6 @@ int erf_populate_interfaces(wtap *wth)
int_data_mand->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_mand->time_units_per_second = 1000000000; /* XXX Since Wireshark only supports down to nanosecond resolution we have to dilute to this */
- int_data_mand->link_type = wtap_wtap_encap_to_pcap_encap(WTAP_ENCAP_ERF);
int_data_mand->snap_len = 65535; /* ERF max length */
/* XXX: if_IPv4addr opt 4 Interface network address and netmask.*/
@@ -1242,7 +1241,6 @@ int erf_populate_interface(erf_t *erf_priv, wtap *wth, union wtap_pseudo_header
int_data_mand->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_mand->time_units_per_second = 1000000000; /* XXX Since Wireshark only supports down to nanosecond resolution we have to dilute to this */
- int_data_mand->link_type = wtap_wtap_encap_to_pcap_encap(WTAP_ENCAP_ERF);
int_data_mand->snap_len = 65535; /* ERF max length */
/* XXX: if_IPv4addr opt 4 Interface network address and netmask.*/
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 159f214023..91fcf718b0 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -1125,7 +1125,6 @@ success:
/* No need to add an option, this is the default */
descr_mand->tsprecision = WTAP_TSPREC_USEC;
}
- descr_mand->link_type = wtap_wtap_encap_to_pcap_encap(wth->file_encap);
descr_mand->snap_len = wth->snapshot_length;
descr_mand->num_stat_entries = 0; /* Number of ISB:s */
@@ -2221,7 +2220,6 @@ wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean co
if ((encap != WTAP_ENCAP_PER_PACKET) && (encap != file_int_data_mand->wtap_encap)) {
descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(descr);
descr_mand->wtap_encap = encap;
- descr_mand->link_type = wtap_wtap_encap_to_pcap_encap(encap);
}
g_array_append_val(wdh->interface_data, descr);
}
@@ -2230,7 +2228,6 @@ wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean co
descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(descr);
descr_mand->wtap_encap = encap;
descr_mand->time_units_per_second = 1000000; /* default microsecond resolution */
- descr_mand->link_type = wtap_wtap_encap_to_pcap_encap(encap);
descr_mand->snap_len = snaplen;
descr_mand->num_stat_entries = 0; /* Number of ISB:s */
descr_mand->interface_statistics = NULL;
diff --git a/wiretap/merge.c b/wiretap/merge.c
index 8605b7fbeb..0ba1b81a66 100644
--- a/wiretap/merge.c
+++ b/wiretap/merge.c
@@ -460,14 +460,6 @@ is_duplicate_idb(const wtap_block_t idb1, const wtap_block_t idb2)
return FALSE;
}
- merge_debug("idb1_mand->link_type == idb2_mand->link_type: %s",
- (idb1_mand->link_type == idb2_mand->link_type) ? "TRUE":"FALSE");
- if (idb1_mand->link_type != idb2_mand->link_type) {
- /* Clearly not the same interface. */
- merge_debug("merge::is_duplicate_idb() returning FALSE");
- return FALSE;
- }
-
merge_debug("idb1_mand->time_units_per_second == idb2_mand->time_units_per_second: %s",
(idb1_mand->time_units_per_second == idb2_mand->time_units_per_second) ? "TRUE":"FALSE");
if (idb1_mand->time_units_per_second != idb2_mand->time_units_per_second) {
diff --git a/wiretap/nettrace_3gpp_32_423.c b/wiretap/nettrace_3gpp_32_423.c
index 5495476af7..08c8a3c258 100644
--- a/wiretap/nettrace_3gpp_32_423.c
+++ b/wiretap/nettrace_3gpp_32_423.c
@@ -788,7 +788,6 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_
int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data);
int_data_mand->wtap_encap = WTAP_ENCAP_WIRESHARK_UPPER_PDU;
int_data_mand->time_units_per_second = 1000000; /* default microsecond resolution */
- int_data_mand->link_type = wtap_wtap_encap_to_pcap_encap(WTAP_ENCAP_WIRESHARK_UPPER_PDU);
int_data_mand->snap_len = WTAP_MAX_PACKET_SIZE;
wtap_block_add_string_option(int_data, OPT_IDB_NAME, "Fake IF", strlen("Fake IF"));
int_data_mand->num_stat_entries = 0; /* Number of ISB:s */
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c
index 8d30d957af..f21e028c94 100644
--- a/wiretap/pcapng.c
+++ b/wiretap/pcapng.c
@@ -677,6 +677,7 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh,
guint to_read, opt_cont_buf_len;
pcapng_interface_description_block_t idb;
wtapng_if_descr_mandatory_t* if_descr_mand;
+ guint link_type;
pcapng_option_header_t oh;
guint8 *option_content = NULL; /* Allocate as large as the options block */
gchar* tmp_content;
@@ -720,19 +721,19 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh,
wblock->block = wtap_block_create(WTAP_BLOCK_IF_DESCR);
if_descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(wblock->block);
if (pn->byte_swapped) {
- if_descr_mand->link_type = GUINT16_SWAP_LE_BE(idb.linktype);
+ link_type = GUINT16_SWAP_LE_BE(idb.linktype);
if_descr_mand->snap_len = GUINT32_SWAP_LE_BE(idb.snaplen);
} else {
- if_descr_mand->link_type = idb.linktype;
+ link_type = idb.linktype;
if_descr_mand->snap_len = idb.snaplen;
}
- if_descr_mand->wtap_encap = wtap_pcap_encap_to_wtap_encap(if_descr_mand->link_type);
+ if_descr_mand->wtap_encap = wtap_pcap_encap_to_wtap_encap(link_type);
if_descr_mand->time_units_per_second = time_units_per_second;
if_descr_mand->tsprecision = tsprecision;
pcapng_debug("pcapng_read_if_descr_block: IDB link_type %u (%s), snap %u",
- if_descr_mand->link_type,
+ link_type,
wtap_encap_string(if_descr_mand->wtap_encap),
if_descr_mand->snap_len);
@@ -3970,13 +3971,15 @@ pcapng_write_if_descr_block(wtap_dumper *wdh, wtap_block_t int_data, int *err)
pcapng_write_block_t block_data;
struct pcapng_option_header option_hdr;
wtapng_if_descr_mandatory_t* mand_data = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data);
+ int link_type;
pcapng_debug("pcapng_write_if_descr_block: encap = %d (%s), snaplen = %d",
- mand_data->link_type,
- wtap_encap_string(wtap_pcap_encap_to_wtap_encap(mand_data->link_type)),
+ mand_data->wtap_encap,
+ wtap_encap_string(mand_data->wtap_encap),
mand_data->snap_len);
- if (mand_data->link_type == (guint16)-1) {
+ link_type = wtap_wtap_encap_to_pcap_encap(mand_data->wtap_encap);
+ if (link_type == -1) {
*err = WTAP_ERR_UNWRITABLE_ENCAP;
return FALSE;
}
@@ -4000,7 +4003,7 @@ pcapng_write_if_descr_block(wtap_dumper *wdh, wtap_block_t int_data, int *err)
wdh->bytes_dumped += sizeof bh;
/* write block fixed content */
- idb.linktype = mand_data->link_type;
+ idb.linktype = link_type;
idb.reserved = 0;
idb.snaplen = mand_data->snap_len;
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 58a22e9298..2ee507f749 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -254,10 +254,9 @@ wtap_get_debug_if_descr(const wtap_block_t if_descr,
}
g_string_append_printf(info,
- "%*cEncapsulation = %s (%d/%u - %s)%s", indent, ' ',
+ "%*cEncapsulation = %s (%d - %s)%s", indent, ' ',
wtap_encap_string(if_descr_mand->wtap_encap),
if_descr_mand->wtap_encap,
- if_descr_mand->link_type,
wtap_encap_short_string(if_descr_mand->wtap_encap),
line_end);
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 957dc76c6b..ee68a8eabe 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1286,7 +1286,6 @@ typedef struct wtapng_if_descr_mandatory_s {
guint64 time_units_per_second;
int tsprecision; /**< WTAP_TSPREC_ value for this interface */
- guint16 link_type;
guint32 snap_len;
guint8 num_stat_entries;