Ethereal-dev: Re: [Ethereal-dev] ip defragment, virtual packets

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

From: Guy Harris <guy@xxxxxxxxxx>
Date: Tue, 10 Apr 2001 12:14:08 -0700 (PDT)
> I'd be inclined to wait.  I'll look at fixing those problems, although I
> might not be able to do it until this evening.

Well, I checked in a change that seems to work - I checked with a
capture with an NFS READDIRPLUS response in a fragmented IP datagram,
and also gave a quick check of the Wellfleet-compressed Frame Relay
capture you sent out.

If you restart work on building the release, you might want to check
David Frascone's DIAMETER changes in too (I'm about to take off for
lunch, and may not be able to do it until later this afternoon or this
evening).

Here's the change I checked in - you might want to look it over to see
if I've done anything wrong (one of the changes gets the "no-tvbuff"
data source name from "pi.compat_top_tvb", rather than using
"null_tvb_ds_name" - "pi.compat_top_tvb" starts out referring to the
frame top-level tvbuff, which has the name "Frame", and using
"pi.compat_top_tvb" means we don't have to set the name as well as
"pi.compat_top_tvb" in dissectors that create alternate data sources):

Index: packet-gtp.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/packet-gtp.c,v
retrieving revision 1.2
diff -c -r1.2 packet-gtp.c
*** packet-gtp.c	2001/04/04 03:29:49	1.2
--- packet-gtp.c	2001/04/10 19:08:02
***************
*** 1592,1597 ****
--- 1592,1598 ----
  	guint8		*target;
  	proto_tree	*ext_tree;
  	proto_item	*te;
+ 	packet_info	save_pi;
  
  	te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_PROTO_CONF, gtp_ext_val, "Unknown message"));
  	ext_tree = proto_item_add_subtree(te, ett_gtp_ext);
***************
*** 1626,1632 ****
--- 1627,1644 ----
  			tvb_set_free_cb(temp, free_tvb_data);
  			tvb_set_child_real_data_tvbuff(tvb, temp);
  			next_tvb = tvb_new_subset(temp, offset+5+raw_offset, proto_len+2, proto_len+2);
+ 
+ 			/* Save the current value of "pi", and adjust
+ 			   certain fields to reflect the new top-level
+ 			   tvbuff. */
+ 			save_pi = pi;
+ 			pi.compat_top_tvb = temp;
+ 			pi.len = tvb_reported_length(temp);
+ 			pi.captured_len = tvb_length(temp);
+ 
  			call_dissector(ppp_handle, next_tvb, pinfo, ext_tree); 
+ 
+ 			pi = save_pi;
  		}
  	}
  	
Index: packet-wcp.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/packet-wcp.c,v
retrieving revision 1.8
diff -c -r1.8 packet-wcp.c
*** packet-wcp.c	2001/03/30 10:51:50	1.8
--- packet-wcp.c	2001/04/10 19:08:02
***************
*** 309,314 ****
--- 309,316 ----
  	int		wcp_header_len;
  	guint16		temp, cmd, ext_cmd, seq;
  	tvbuff_t	*next_tvb;
+ 	packet_info	save_pi;
+ 	gboolean	must_restore_pi = FALSE;
  
  	pinfo->current_proto = "WCP";
  
***************
*** 394,399 ****
--- 396,409 ----
                               		"[Malformed Frame: Bad WCP compressed data]" );
  			return;
  		}
+ 
+ 		/* Save the current value of "pi", and adjust certain fields to
+ 		   reflect the new tvbuff. */
+ 		save_pi = pi;
+ 		pi.compat_top_tvb = next_tvb;
+ 		pi.len = tvb_reported_length(next_tvb);
+ 		pi.captured_len = tvb_length(next_tvb);
+ 		must_restore_pi = TRUE;
  	}
  
  	if ( tree)	 		/* add the check byte */
***************
*** 402,407 ****
--- 412,420 ----
  		 	tvb_get_guint8( tvb, tvb_reported_length(tvb)-1));
  
  	dissect_fr_uncompressed(next_tvb, pinfo, tree);
+ 
+ 	if (must_restore_pi)
+ 		pi = save_pi;
  
  	return;
  }
Index: epan/proto.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/epan/proto.c,v
retrieving revision 1.20
diff -c -r1.20 proto.c
*** proto.c	2001/04/05 19:25:16	1.20
--- proto.c	2001/04/10 19:08:03
***************
*** 1462,1470 ****
  	return pi;
  }
  
- /* The default name for a NullTVB. This removed when all dissectors use tvbuffs */
- static gchar* null_tvb_ds_name = "Frame";
- 
  static field_info *
  alloc_field_info(int hfindex, tvbuff_t *tvb, gint start, gint length)
  {
--- 1462,1467 ----
***************
*** 1492,1498 ****
  	if ( tvb)
  		fi->ds_name = tvb_get_name(tvb);
  	else
! 		fi->ds_name = null_tvb_ds_name;
  
  	return fi;
  }
--- 1489,1495 ----
  	if ( tvb)
  		fi->ds_name = tvb_get_name(tvb);
  	else
! 		fi->ds_name = tvb_get_name(pi.compat_top_tvb);
  
  	return fi;
  }