diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-12-19 23:53:46 +0100 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2014-12-19 23:53:46 +0100 |
commit | ddcdbb03d7073958add33192db1d775cbdad3ded (patch) | |
tree | ae8dfa6e277dd9e744e7c9f646b32c4b71381714 /ui/tap_export_pdu.h | |
parent | 0bb9e1bc17f95f002590f8395b056706dac7ce82 (diff) | |
download | wireshark-ddcdbb03d7073958add33192db1d775cbdad3ded.tar.gz |
[RFC] Implement Export PDU for tsharkbug/3444
This patch introduces the "-U tap_name[,filter]" tshark option and
is similar to the "Export PDUs as file" option in Wireshark.
Wireshark implements this feature by reopening a capture file, applying
a tap and finally opening the temporary file. Since tshark knows
in advance that a PDU export is needed, it can optimize by not creating
the temporary file and perform the export at the first opportunity.
This patch splits the opening/tapping functionality from error reporting
since tshark does not need a temp file and has no dialogs.
The capture file comment is now specified explicitly as there is no
"current file" anymore if the tap is running without active file.
TODO:
- Do not '#ifdef 0' the GTK/Qt functionality, split the file
to avoid a linking error with tshark.
- Why is pkt_encap modifiable? Both Wireshark Qt and GTK set
WTAP_ENCAP_WIRESHARK_UPPER_PDU, what is the idea behind this?
- Review whether it is acceptable to overwrite save_file in tshark.
- Add documentation (tshark manpage).
Bug: 3444
Change-Id: Ie159495d42c32c2ba7400f2991b7b8185b3fda09
Diffstat (limited to 'ui/tap_export_pdu.h')
-rw-r--r-- | ui/tap_export_pdu.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ui/tap_export_pdu.h b/ui/tap_export_pdu.h index df6b5bad45..5c2de947d2 100644 --- a/ui/tap_export_pdu.h +++ b/ui/tap_export_pdu.h @@ -32,8 +32,36 @@ typedef struct _exp_pdu_t { wtap_dumper* wdh; } exp_pdu_t; +/** + * Filters the current opened capture file into a temporary file. On success, + * TRUE is returned and the filtered file is opened into the UI. + */ gboolean do_export_pdu(const char *filter, gchar *tap_name, exp_pdu_t *data); +/** + * Registers the tap listener which will add matching packets to the exported + * file. Must be called before exp_pdu_open. + * + * @param tap_name One of the names registered with register_export_pdu_tap(). + * @param filter An tap filter, may be NULL to disable filtering which + * improves performance if you do not need a filter. + * @return NULL on success or an error string on failure which must be freed + * with g_free(). Failure could occur when the filter or tap_name are invalid. + */ +char *exp_pdu_pre_open(const char *tap_name, const char *filter, + exp_pdu_t *exp_pdu_tap_data); + +/** + * Use the given file descriptor for writing an output file. Can only be called + * once and exp_pdu_pre_open() must be called before. + * + * @return 0 on success or a wtap error code. + */ +int exp_pdu_open(exp_pdu_t *data, int fd, char *comment); + +/* Stops the PDUs export. */ +int exp_pdu_close(exp_pdu_t *exp_pdu_tap_data); + #ifdef __cplusplus } #endif /* __cplusplus */ |