From 5730f31306231e7aaa4e98cf5058fef7798ee4e9 Mon Sep 17 00:00:00 2001 From: darkjames Date: Thu, 12 May 2011 19:47:49 +0000 Subject: Packet editor: support for saving changed frames. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@37099 f5534014-38df-0310-8fa8-9805f1628bb7 --- file.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'file.c') diff --git a/file.c b/file.c index e9d9b23be8..b114844a6c 100644 --- a/file.c +++ b/file.c @@ -396,6 +396,12 @@ cf_reset_state(capture_file *cf) free_frame_data_sequence(cf->frames); cf->frames = NULL; } +#ifdef WANT_PACKET_EDITOR + if (cf->edited_frames) { + g_tree_destroy(cf->edited_frames); + cf->edited_frames = NULL; + } +#endif cf_unselect_packet(cf); /* nothing to select */ cf->first_displayed = 0; cf->last_displayed = 0; @@ -1517,6 +1523,22 @@ cf_read_frame_r(capture_file *cf, frame_data *fdata, gchar *err_info; char errmsg_errno[1024+1]; +#ifdef WANT_PACKET_EDITOR + /* if fdata->file_off == -1 it means packet was edited, and we must find data inside edited_frames tree */ + if (G_UNLIKELY(fdata->file_off == -1)) { + const modified_frame_data *frame = (const modified_frame_data *) g_tree_lookup(cf->edited_frames, GINT_TO_POINTER(fdata->num)); + + if (!frame) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "fdata->file_off == -1, but can't find modified frame!"); + return FALSE; + } + + *pseudo_header = frame->ph; + memcpy(pd, frame->pd, fdata->cap_len); + return TRUE; + } +#endif + if (!wtap_seek_read(cf->wth, fdata->file_off, pseudo_header, pd, fdata->cap_len, &err, &err_info)) { switch (err) { -- cgit v1.2.3