ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] Using tcp_dissect pdus and fragment, segment reassembly

From: Graham Bloice <graham.bloice@xxxxxxxxxxxxx>
Date: Fri, 26 Jan 2007 17:04:13 +0000
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Graham Bloice wrote:
> I've been attempting to add tcp fragment reassembly using
> tcp_dissect_pdus() to an existing dissector that already used the epan
> reassembly code for an internal part of the protocol.
> 
> However it seems that when I add the tcp_dissect_pdus() call then the
> other reassembly stops working.  The call to fragment_add_seq_check()
> never returns a non-null fragment_data pointer.
> 
> I grep'd all the other dissectors and didn't find any using a
> combination of both methods.
> 
> Is there a problem with using both, or have I just gone wrong somewhere?
> 

I've now resolved my issues with the combination of the two reassembly
options, and the problem was down to errors in my dissector.

In doing so, I ran across a couple of documentation issues:

In the Developers Guide, Section 9.3, Example 9.17. Decompressing data
packets for dissection

The code calls tvb_set_free_cb() for the newly created next_tvb.  This
is unnecessary as the call to tvb_set_child_real_data() adds next_tvb to
the chained list of tvb, thus ensuring that next_tvb is correctly
deleted.  In fact when I had the call in, Visual Studio kept breaking
deep down in ntdll.dll, probably because of a double free every time the
main tvb was deleted.

In README.developer, para 2..2.7 The example conversation code doesn't
assign the result of conversation_new() back into the conversation variable.

I've attached patches for these two items.

- --
Regards,

Graham Bloice
Software Developer
Trihedral UK Limited
Tel: +44 (0)7002 874433
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFujSNcs4xxHO/MtURAhePAKCpo8vEg5zQq7wJ+t6u/qonrO8mHgCfSe85
eSti+m46GPuNkkT7jqSaM8o=
=MiNy
-----END PGP SIGNATURE-----

Attachment: README.developer.patch.sig
Description: Binary data

Attachment: WSDG_chapter_dissection.xml.patch.sig
Description: Binary data

Index: doc/README.developer
===================================================================
--- doc/README.developer	(revision 20501)
+++ doc/README.developer	(working copy)
@@ -2809,7 +2809,7 @@
 
     /* create the conversation with your data pointer  */
 
-    conversation_new(pinfo->fd->num,  &pinfo->src, &pinfo->dst, pinfo->ptype,
+    conversation = conversation_new(pinfo->fd->num,  &pinfo->src, &pinfo->dst, pinfo->ptype,
 	    pinfo->srcport, pinfo->destport, 0);
     conversation_add_proto_data(conversation, my_proto, (void *)data_ptr);
 }
Index: docbook/wsdg_src/WSDG_chapter_dissection.xml
===================================================================
--- docbook/wsdg_src/WSDG_chapter_dissection.xml	(revision 20501)
+++ docbook/wsdg_src/WSDG_chapter_dissection.xml	(working copy)
@@ -682,7 +682,6 @@
 		next_tvb = tvb_new_real_data(decompressed_buffer, orig_size, orig_size);
 		tvb_set_child_real_data_tvbuff(tvb, next_tvb);
 		add_new_data_source(pinfo, next_tvb, "Decompressed Data");
-		tvb_set_free_cb(next_tvb, g_free);
 	} else {
 		next_tvb = tvb_new_subset(tvb, offset, -1, -1);
 	}