Ethereal-dev: [Ethereal-dev] TALI dissector patch to enable "Follow TCP stream"

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Viorel Suman <vsuman@xxxxxxxx>
Date: Thu, 4 Nov 2004 18:51:31 +0200 (EET)
Hello,

Attached is a packet-tali.c dissector patch which fix a problem
related to "Follow TCP stream" functionality : pinfo->net_src and pinfo->net_dst fields saved before TALI payload dissecting and
restored after.

WBR,

Viorel Suman
Software Developer

Avalanche Mobile NV (http://www.avmob.com)
Busitel 1, Orlyplein 85
1043 DS Amsterdam
The Netherlands

Phone: +31 (0) 20 403 74 70
Fax:   +31 (0) 20 403 73 10
diff -ur ethereal-0.10.7/epan/dissectors/packet-tali.c ethereal-0.10.7-fixed/epan/dissectors/packet-tali.c
--- ethereal-0.10.7/epan/dissectors/packet-tali.c	2004-10-21 01:34:37.000000000 +0300
+++ ethereal-0.10.7-fixed/epan/dissectors/packet-tali.c	2004-11-04 14:09:56.000000000 +0200
@@ -95,6 +95,7 @@
   char opcode[TALI_OPCODE_LENGTH+1]; /* TALI opcode */
   guint16 length; /* TALI length */
   tvbuff_t *payload_tvb = NULL;
+  address save_src, save_dst;
   
   /* Set up structures needed to add the protocol subtree and manage it */
   proto_item *tali_item = NULL;
@@ -124,8 +125,17 @@
 
   if (length > 0) {
     payload_tvb = tvb_new_subset(tvb, TALI_HEADER_LENGTH, -1, -1);
-    if (payload_tvb != NULL && !dissector_try_string(tali_dissector_table, opcode, payload_tvb, pinfo, tree)) {
-      call_dissector(data_handle, payload_tvb, pinfo, tree);
+    if (payload_tvb != NULL) {
+      /* Save original addresses */
+      SET_ADDRESS(&save_src, pinfo->net_src.type, pinfo->net_src.len, pinfo->net_src.data);
+      SET_ADDRESS(&save_dst, pinfo->net_dst.type, pinfo->net_dst.len, pinfo->net_dst.data);
+      if (dissector_try_string(tali_dissector_table, opcode, payload_tvb, pinfo, tree)) {
+        /* Restore original addresses */
+        SET_ADDRESS(&(pinfo->net_src), save_src.type, save_src.len, save_src.data);
+        SET_ADDRESS(&(pinfo->net_dst), save_dst.type, save_dst.len, save_dst.data);
+      } else {
+        call_dissector(data_handle, payload_tvb, pinfo, tree);
+      }
     }
   }
 }