new function fetch_tapped_data()
authorsahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 7 Dec 2005 13:12:39 +0000 (13:12 +0000)
committersahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 7 Dec 2005 13:12:39 +0000 (13:12 +0000)
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)

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@16722 f5534014-38df-0310-8fa8-9805f1628bb7

epan/tap.c
epan/tap.h

index 2b8dd1da2079e7f09f689a671ba076ffd8f21106..b692fcd58d65e3ffa7999994a8ab7ee02786755c 100644 (file)
@@ -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.
 */
index 9fc8233b46ac772250ccb814d67dd4ac252c39c3..2a8fa4cbc301522439790398dd6c68fa86407eef 100644 (file)
@@ -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