diff options
author | Moshe Kaplan <me@moshekaplan.com> | 2016-11-24 09:37:01 -0500 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-12-02 16:07:35 +0000 |
commit | 20c57cb298e4f3b7ac66a22fb7477e4cf424a11b (patch) | |
tree | 3929a45a2f0df5182af007af697edfa9a55a4634 /epan/dissectors/packet-dcm.c | |
parent | 9ca313cfbe4993a0a36520d216a3e4282b0b7b99 (diff) |
Enable exporting objects with tshark
A new "--export-object <protocol>,<destdir>" option is added to tshark.
This required refactoring Export Object behavior in all GUIs to give the
export object handling to the dissector, rather than the ui layer.
Included in the refactoring was fixing some serious memory leaks in Qt
Export Object dialog, crash due to memory scope issues in GTK Export
Object dialog, and addition sorting column feature in Qt dialog (set
up by creating a widget to manage the items that were previously
leaking memory)
Bug: 9319
Ping-Bug: 13174
Change-Id: I515d7662fa1f150f672b1476716f347ec27deb9b
Reviewed-on: https://code.wireshark.org/review/18927
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-dcm.c')
-rw-r--r-- | epan/dissectors/packet-dcm.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/epan/dissectors/packet-dcm.c b/epan/dissectors/packet-dcm.c index ac501bf40f..fc7ee38fbd 100644 --- a/epan/dissectors/packet-dcm.c +++ b/epan/dissectors/packet-dcm.c @@ -221,6 +221,7 @@ #include <epan/expert.h> #include <epan/tap.h> #include <epan/reassemble.h> +#include <epan/export_object.h> #include "packet-tcp.h" @@ -369,6 +370,38 @@ static const value_string dcm_assoc_item_type[] = { { 0, NULL } }; +static gboolean +dcm_eo_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, + const void *data) +{ + export_object_list_t *object_list = (export_object_list_t *)tapdata; + const dicom_eo_t *eo_info = (const dicom_eo_t *)data; + export_object_entry_t *entry; + + if (eo_info) { /* We have data waiting for us */ + /* + Don't copy any data. dcm_export_create_object() is already g_malloc() the items + Still, the values will be freed when the export Object window is closed. + Therefore, strings and buffers must be copied + */ + entry = g_new(export_object_entry_t, 1); + + entry->pkt_num = pinfo->num; + entry->hostname = eo_info->hostname; + entry->content_type = eo_info->content_type; + entry->filename = g_path_get_basename(eo_info->filename); + entry->payload_len = eo_info->payload_len; + entry->payload_data = eo_info->payload_data; + + object_list->add_entry(object_list->gui_data, entry); + + return TRUE; /* State changed - window should be redrawn */ + } else { + return FALSE; /* State unchanged - no window updates needed */ + } +} + + /* ************************************************************************* */ /* Fragment items */ /* ************************************************************************* */ @@ -7175,7 +7208,7 @@ proto_register_dcm(void) "When not set, the decoding may fail and the exports may become corrupt.", &global_dcm_reassemble); - dicom_eo_tap = register_tap("dicom_eo"); /* DICOM Export Object tap */ + dicom_eo_tap = register_export_object(proto_dcm, dcm_eo_packet, NULL); register_init_routine(&dcm_init); register_cleanup_routine(&dcm_cleanup); |