aboutsummaryrefslogtreecommitdiffstats
path: root/sharkd_session.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-12-31 19:36:12 -0800
committerGuy Harris <guy@alum.mit.edu>2019-01-01 05:03:42 +0000
commit2d41b15495e245d9292ba42dd3954bdebc9f3290 (patch)
tree40282b7aab9f1347489126dd98974a681dca888f /sharkd_session.c
parentba589a4e445a8ad8054073eff846087fc61c9ef8 (diff)
Add a "failed" return for tap packet routines.
This allows taps that can fail to report an error and fail; a failed tap's packet routine won't be called again, so they don't have to keep track of whether they've failed themselves. We make the return value from the packet routine an enum. Don't have a separate type for the per-packet routine for "follow" taps; they're expected to act like tap packet routines, so just use the type for tap packet routines. One tap packet routine returned -1; that's not a valid return value, and wasn't one before this change (the return value was a boolean), so presume the intent was "don't redraw". Another tap routine's early return, without doing any work, returned TRUE; this is presumably an error (no work done, no need to redraw), so presumably it should be "don't redraw". Clean up some white space while we're at it. Change-Id: Ia7d2b717b2cace4b13c2b886e699aa4d79cc82c8 Reviewed-on: https://code.wireshark.org/review/31283 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'sharkd_session.c')
-rw-r--r--sharkd_session.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/sharkd_session.c b/sharkd_session.c
index b1aff99a89..af4f9bdd52 100644
--- a/sharkd_session.c
+++ b/sharkd_session.c
@@ -1207,7 +1207,7 @@ sharkd_session_process_tap_expert_cb(void *tapdata)
putchar(',');
}
-static gboolean
+static tap_packet_status
sharkd_session_packet_tap_expert_cb(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *pointer)
{
struct sharkd_expert_tap *etd = (struct sharkd_expert_tap *) tapdata;
@@ -1215,7 +1215,7 @@ sharkd_session_packet_tap_expert_cb(void *tapdata, packet_info *pinfo _U_, epan_
expert_info_t *ei_copy;
if (ei == NULL)
- return FALSE;
+ return TAP_PACKET_DONT_REDRAW;
ei_copy = g_new(expert_info_t, 1);
/* Note: this is a shallow copy */
@@ -1227,7 +1227,7 @@ sharkd_session_packet_tap_expert_cb(void *tapdata, packet_info *pinfo _U_, epan_
etd->details = g_slist_prepend(etd->details, ei_copy);
- return TRUE;
+ return TAP_PACKET_REDRAW;
}
static void
@@ -1437,7 +1437,7 @@ sharkd_session_process_tap_rtp_free_cb(void *tapdata)
g_free(rtp_req);
}
-static gboolean
+static tap_packet_status
sharkd_session_packet_tap_rtp_analyse_cb(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const void *pointer)
{
struct sharkd_analyse_rtp *rtp_req = (struct sharkd_analyse_rtp *) tapdata;
@@ -1471,7 +1471,7 @@ sharkd_session_packet_tap_rtp_analyse_cb(void *tapdata, packet_info *pinfo, epan
rtp_req->packets = g_slist_append(rtp_req->packets, item);
}
- return TRUE;
+ return TAP_PACKET_REDRAW;
}
/**
@@ -3072,15 +3072,16 @@ struct sharkd_iograph
GString *error;
};
-static gboolean
+static tap_packet_status
sharkd_iograph_packet(void *g, packet_info *pinfo, epan_dissect_t *edt, const void *dummy _U_)
{
struct sharkd_iograph *graph = (struct sharkd_iograph *) g;
int idx;
+ gboolean update_succeeded;
idx = get_io_graph_index(pinfo, graph->interval);
if (idx < 0 || idx >= SHARKD_IOGRAPH_MAX_ITEMS)
- return FALSE;
+ return TAP_PACKET_DONT_REDRAW;
if (idx + 1 > graph->num_items)
{
@@ -3102,7 +3103,9 @@ sharkd_iograph_packet(void *g, packet_info *pinfo, epan_dissect_t *edt, const vo
graph->num_items = idx + 1;
}
- return update_io_graph_item(graph->items, idx, pinfo, edt, graph->hf_index, graph->calc_type, graph->interval);
+ update_succeeded = update_io_graph_item(graph->items, idx, pinfo, edt, graph->hf_index, graph->calc_type, graph->interval);
+ /* XXX - TAP_PACKET_FAILED if the item couldn't be updated, with an error message? */
+ return update_succeeded ? TAP_PACKET_REDRAW : TAP_PACKET_DONT_REDRAW;
}
/**
@@ -4147,7 +4150,7 @@ sharkd_rtp_download_decode(struct sharkd_download_rtp *req)
g_hash_table_destroy(decoders_hash_);
}
-static gboolean
+static tap_packet_status
sharkd_session_packet_download_tap_rtp_cb(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const void *data)
{
const struct _rtp_info *rtp_info = (const struct _rtp_info *) data;
@@ -4155,7 +4158,7 @@ sharkd_session_packet_download_tap_rtp_cb(void *tapdata, packet_info *pinfo, epa
/* do not consider RTP packets without a setup frame */
if (rtp_info->info_setup_frame_num == 0)
- return FALSE;
+ return TAP_PACKET_DONT_REDRAW;
if (rtpstream_id_equal_pinfo_rtp_info(&req_rtp->id, pinfo, rtp_info))
{
@@ -4177,7 +4180,7 @@ sharkd_session_packet_download_tap_rtp_cb(void *tapdata, packet_info *pinfo, epa
req_rtp->packets = g_slist_append(req_rtp->packets, rtp_packet);
}
- return FALSE;
+ return TAP_PACKET_DONT_REDRAW;
}
/**