From d12b09b8868be0cf6b8af72c9e6c34921481b08b Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Wed, 7 Dec 2005 13:12:39 +0000 Subject: new function fetch_tapped_data() This function can be called from a dissector to fetch (if any) tapped data from a tap. This can offer an alternative method of passing data between different dissectors much cleaner than the pinfo pollition and private_data design mistake. The SMB2 dissector uses this method to extract vital data such as Account_Name from the ntlmssp dissector (that is 3 leveld down from smb2) svn path=/trunk/; revision=16722 --- epan/tap.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'epan/tap.c') 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;itap_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. */ -- cgit v1.2.1