diff options
Diffstat (limited to 'epan')
-rw-r--r-- | epan/tap.c | 44 | ||||
-rw-r--r-- | epan/tap.h | 1 |
2 files changed, 45 insertions, 0 deletions
diff --git a/epan/tap.c b/epan/tap.c index 2b8dd1da20..b692fcd58d 100644 --- a/epan/tap.c +++ b/epan/tap.c @@ -245,6 +245,50 @@ tap_push_tapped_queue(epan_dissect_t *edt) } } + +/* This function can be used by a dissector to fetch any tapped data before + * returning. + * This can be useful if one wants to extract the data inside dissector BEFORE + * it exists as an alternative to the callbacks that are all called AFTER the + * dissection has completed. + * + * Example: SMB2 uses this mechanism to extract the data tapped from NTLMSSP + * containing the account and domain names before exiting. + * Note that the SMB2 tap listener specifies all three callbacks as NULL. + * + * Beware: when using this mechanism to extract the tapped data you can not + * use "filters" and should specify the "filter" as NULL when registering + * the tap listener. + */ +void * +fetch_tapped_data(int tap_id, int idx) +{ + tap_packet_t *tp; + guint i; + + /* nothing to do, just return */ + if(!tapping_is_active){ + return NULL; + } + + /* nothing to do, just return */ + if(!tap_packet_index){ + return NULL; + } + + /* loop over all tapped packets and return the one with index idx */ + for(i=0;i<tap_packet_index;i++){ + tp=&tap_packet_array[i]; + if(tp->tap_id==tap_id){ + if(!idx--){ + return tp->tap_specific_data; + } + } + } + + return NULL; +} + /* This function is called when we need to reset all tap listeners, for example when we open/start a new capture or if we need to rescan the packet list. */ diff --git a/epan/tap.h b/epan/tap.h index 9fc8233b46..2a8fa4cbc3 100644 --- a/epan/tap.h +++ b/epan/tap.h @@ -50,5 +50,6 @@ extern GString *register_tap_listener(const char *tapname, void *tapdata, tap_draw_cb tap_draw); extern void remove_tap_listener(void *tapdata); extern gboolean have_tap_listeners(void); +extern void *fetch_tapped_data(int tap_id, int idx); #endif |