aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tap.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 /epan/tap.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 'epan/tap.c')
-rw-r--r--epan/tap.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/epan/tap.c b/epan/tap.c
index 9355c86315..e0e3a22beb 100644
--- a/epan/tap.c
+++ b/epan/tap.c
@@ -80,6 +80,7 @@ typedef struct _tap_listener_t {
struct _tap_listener_t *next;
int tap_id;
gboolean needs_redraw;
+ gboolean failed;
guint flags;
gchar *fstring;
dfilter_t *code;
@@ -310,12 +311,49 @@ tap_push_tapped_queue(epan_dissect_t *edt)
if (!(tp->flags & TAP_PACKET_IS_ERROR_PACKET) || (tl->flags & TL_REQUIRES_ERROR_PACKETS))
{
if(tp->tap_id==tl->tap_id){
- gboolean passed=TRUE;
+ if(!tl->packet){
+ /* There isn't a per-packet
+ * routine for this tap.
+ */
+ continue;
+ }
+ if(tl->failed){
+ /* A previous call failed,
+ * meaning "stop running this
+ * tap", so don't call the
+ * packet routine.
+ */
+ continue;
+ }
+
+ /* If we have a filter, see if the
+ * packet passes.
+ */
if(tl->code){
- passed=dfilter_apply_edt(tl->code, edt);
+ if (!dfilter_apply_edt(tl->code, edt)){
+ /* The packet didn't
+ * pass the filter. */
+ continue;
+ }
}
- if(passed && tl->packet){
- tl->needs_redraw|=tl->packet(tl->tapdata, tp->pinfo, edt, tp->tap_specific_data);
+
+ /* So call the per-packet routine. */
+ tap_packet_status status;
+
+ status = tl->packet(tl->tapdata, tp->pinfo, edt, tp->tap_specific_data);
+
+ switch (status) {
+
+ case TAP_PACKET_DONT_REDRAW:
+ break;
+
+ case TAP_PACKET_REDRAW:
+ tl->needs_redraw=TRUE;
+ break;
+
+ case TAP_PACKET_FAILED:
+ tl->failed=TRUE;
+ break;
}
}
}
@@ -380,6 +418,7 @@ reset_tap_listeners(void)
tl->reset(tl->tapdata);
}
tl->needs_redraw=TRUE;
+ tl->failed=FALSE;
}
}
@@ -490,6 +529,7 @@ register_tap_listener(const char *tapname, void *tapdata, const char *fstring,
tl=(tap_listener_t *)g_malloc0(sizeof(tap_listener_t));
tl->needs_redraw=TRUE;
+ tl->failed=FALSE;
tl->flags=flags;
if(fstring){
if(!dfilter_compile(fstring, &code, &err_msg)){