forked from osmocom/wireshark
editcap: if -T was specified, change the linktype of all interfaces.
Don't just change the linktype of the file (if it has one) and the linktypes of all the packets, change the linktype of all interfaces as well. Fixes #17520.
This commit is contained in:
parent
6e12643f19
commit
158810c713
64
editcap.c
64
editcap.c
|
@ -1020,18 +1020,43 @@ editcap_dump_open(const char *filename, const wtap_dump_params *params,
|
|||
WTAP_BLOCK_IF_ID_AND_INFO) != BLOCK_NOT_SUPPORTED) {
|
||||
for (guint i = 0; i < idbs_seen->len; i++) {
|
||||
wtap_block_t if_data = g_array_index(idbs_seen, wtap_block_t, i);
|
||||
wtap_block_t if_data_copy;
|
||||
|
||||
/*
|
||||
* Add this IDB to the file to which we're currently writing.
|
||||
* Make a copy of this IDB, so that we can change the
|
||||
* encapsulation type without trashing the original.
|
||||
*/
|
||||
if (!wtap_dump_add_idb(pdh, if_data, err, err_info)) {
|
||||
if_data_copy = wtap_block_make_copy(if_data);
|
||||
|
||||
/*
|
||||
* If an encapsulation type was specified, override the
|
||||
* encapsulation type of the interface.
|
||||
*/
|
||||
if (out_frame_type != -2) {
|
||||
wtapng_if_descr_mandatory_t *if_mand;
|
||||
|
||||
if_mand = (wtapng_if_descr_mandatory_t *)wtap_block_get_mandatory_data(if_data_copy);
|
||||
if_mand->wtap_encap = out_frame_type;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add this possibly-modified IDB to the file to which
|
||||
* we're currently writing.
|
||||
*/
|
||||
if (!wtap_dump_add_idb(pdh, if_data_copy, err, err_info)) {
|
||||
int close_err;
|
||||
gchar *close_err_info;
|
||||
|
||||
wtap_dump_close(pdh, &close_err, &close_err_info);
|
||||
g_free(close_err_info);
|
||||
wtap_block_unref(if_data_copy);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Release the copy - wtap_dump_add_idb() makes its own copy.
|
||||
*/
|
||||
wtap_block_unref(if_data_copy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1057,16 +1082,39 @@ process_new_idbs(wtap *wth, wtap_dumper *pdh, GArray *idbs_seen,
|
|||
wtap_block_t if_data_copy;
|
||||
|
||||
/*
|
||||
* Add this IDB to the file to which we're currently writing.
|
||||
* Make a copy of this IDB, so that we can change the
|
||||
* encapsulation type without trashing the original.
|
||||
*/
|
||||
if (!wtap_dump_add_idb(pdh, if_data, err, err_info))
|
||||
if_data_copy = wtap_block_make_copy(if_data);
|
||||
|
||||
/*
|
||||
* If an encapsulation type was specified, override the
|
||||
* encapsulation type of the interface.
|
||||
*/
|
||||
if (out_frame_type != -2) {
|
||||
wtapng_if_descr_mandatory_t *if_mand;
|
||||
|
||||
if_mand = (wtapng_if_descr_mandatory_t *)wtap_block_get_mandatory_data(if_data_copy);
|
||||
if_mand->wtap_encap = out_frame_type;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add this possibly-modified IDB to the file to which
|
||||
* we're currently writing.
|
||||
*/
|
||||
if (!wtap_dump_add_idb(pdh, if_data_copy, err, err_info))
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
* Also add it to the set of IDBs we've seen, in case we
|
||||
* start writing to another file (which would be of the
|
||||
* same type as the current file, and thus will also require
|
||||
* interface IDs).
|
||||
* Release the copy - wtap_dump_add_idb() makes its own copy.
|
||||
*/
|
||||
wtap_block_unref(if_data_copy);
|
||||
|
||||
/*
|
||||
* Also add an unmodified copy to the set of IDBs we've seen,
|
||||
* in case we start writing to another file (which would be
|
||||
* of the same type as the current file, and thus will also
|
||||
* require interface IDs).
|
||||
*/
|
||||
if_data_copy = wtap_block_make_copy(if_data);
|
||||
g_array_append_val(idbs_seen, if_data_copy);
|
||||
|
|
Loading…
Reference in New Issue