aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/wtap-int.h
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2020-10-22 01:10:57 -0700
committerGuy Harris <gharris@sonic.net>2020-10-22 02:58:07 -0700
commitd0270415a9d198eae0b8c739b17780e6c347ebcd (patch)
treecf745f012fc0e4197558c6acac267704988dd95d /wiretap/wtap-int.h
parente16ef82d7c4ae292c9a46530124aef268c35011f (diff)
editcap, tshark: process IDBs in the middle of input files.
Instead of grabbing the set of IDBs found at open time, have a loop using wtap_get_next_interface_description() to read all unread IDBs run after opening the input file, after reading a packet from the input file, and after getting an EOF on the input file. Add a routine wtap_uses_interface_ids() to check whether the file type and subtype for a dump file uses interface IDs and requires IDBs. If so, in the aforementioned loop, add the IDBs to the dump stream. Add a routine wtap_dump_add_idb() to add IDBs to a dump stream. Have it call a file-format-specific routine to add the IDBs; the only file type that supports it is pcapng, and it 1) writes out the IDB and 2) adds it to the set of IDBs for the stream. Add a wtap_dump_params_init_no_idbs() routine that prevents the IDBs from the input file from being used to initialize the output file; use it in cases where we're using the aforementioned loop to copy over IDBs. Don't require any IDBs to be present when opening a pcapng file for writing; 1) the simplest pcapng file has just an SHB in it, 2) that requirement causes dumps that don't provide IDBs at open time to fail, and 3) the real issue is that we don't want packets with an interface ID not corresponding to a known IDB, and we already have a check for that. (There are some hacks here; eventually, when everything processes the IDBs in such a loop, we may be able to get rid of the "two favors of dump parameter initialization" hack.) Fixes #15844. Addresses the same issue in #15502, but there are other issues there that also need to be addressed. In addition, the merge code also needs to be changed to handle this.
Diffstat (limited to 'wiretap/wtap-int.h')
-rw-r--r--wiretap/wtap-int.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h
index 14ab66d584..7c7efb428d 100644
--- a/wiretap/wtap-int.h
+++ b/wiretap/wtap-int.h
@@ -80,6 +80,9 @@ struct wtap_dumper;
*/
typedef void *WFILE_T;
+typedef gboolean (*subtype_add_idb_func)(struct wtap_dumper*, wtap_block_t,
+ int *, gchar **);
+
typedef gboolean (*subtype_write_func)(struct wtap_dumper*,
const wtap_rec *rec,
const guint8*, int*, gchar**);
@@ -91,18 +94,19 @@ struct wtap_dumper {
int snaplen;
int encap;
wtap_compression_type compression_type;
- gboolean needs_reload; /* TRUE if the file requires re-loading after saving with wtap */
+ gboolean needs_reload; /* TRUE if the file requires re-loading after saving with wtap */
gint64 bytes_dumped;
- void *priv; /* this one holds per-file state and is free'd automatically by wtap_dump_close() */
- void *wslua_data; /* this one holds wslua state info and is not free'd */
+ void *priv; /* this one holds per-file state and is free'd automatically by wtap_dump_close() */
+ void *wslua_data; /* this one holds wslua state info and is not free'd */
- subtype_write_func subtype_write; /* write out a record */
- subtype_finish_func subtype_finish; /* write out information to finish writing file */
+ subtype_add_idb_func subtype_add_idb; /* add an IDB, writing it as necessary */
+ subtype_write_func subtype_write; /* write out a record */
+ subtype_finish_func subtype_finish; /* write out information to finish writing file */
addrinfo_lists_t *addrinfo_lists; /**< Struct containing lists of resolved addresses */
GArray *shb_hdrs;
- GArray *nrb_hdrs; /**< name resolution comment/custom_opt, or NULL */
+ GArray *nrb_hdrs; /**< name resolution comment/custom_opt, or NULL */
GArray *interface_data; /**< An array holding the interface data from pcapng IDB:s or equivalent(?) NULL if not present.*/
GArray *dsbs_initial; /**< An array of initial DSBs (of type wtap_block_t) */