Ethereal-dev: Re: [Ethereal-dev] VJ compressed PPP packets ??

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

From: Guy Harris <gharris@xxxxxxxxxxxx>
Date: Thu, 15 Mar 2001 23:31:09 -0800
On Thu, Mar 15, 2001 at 11:05:11PM -0800, Guy Harris wrote:
> > Currently this code doesn't add named data support to
> > tethereal. That shouldn't be a problem until we actually
> > have a dissector that uses named data. Then tethereal 
> > will only display the received frame and not the extra
> > data sources created by dissectors.
> 
> We probably want to do what's done for the hex view notebook - if
> there's only one data source, print it the way we do now, and, if
> there's more than one data source, print each one, with the name as a
> tag.
> 
> Note that the code that prints the hex data for "tethereal -x" is the
> same as the code that prints the hex data if you select "Print hex data"
> in the "Print" dialog box in Ethereal, so there's also currently no
> named data support when printing a packet to a printer or a file in
> Ethereal.

Here's a patch, to be applied on top of either

	1) the result of applying your patch plus my first patch

or

	2) the result of applying my merged version of those two patches

to the current CVS tree; it changes the hex printing code to handle all
the data sources.  It works OK with one data source, which is all
Ethereal currently creates.
*** file.c.noprint	Thu Mar 15 21:56:51 2001
--- file.c	Thu Mar 15 23:24:03 2001
***************
*** 1231,1238 ****
  
  	if (print_args->print_hex) {
  	  /* Print the full packet data as hex. */
! 	  print_hex_data(cf->print_fh, print_args->format, cf->pd,
! 			fdata->cap_len, fdata->flags.encoding);
  	}
  
          /* Print a blank line if we print anything after this. */
--- 1231,1237 ----
  
  	if (print_args->print_hex) {
  	  /* Print the full packet data as hex. */
! 	  print_hex_data(cf->print_fh, print_args->format, fdata);
  	}
  
          /* Print a blank line if we print anything after this. */
*** print.c.dist	Thu Mar 15 23:18:57 2001
--- print.c	Thu Mar 15 23:23:45 2001
***************
*** 177,189 ****
  	}
  }
  
! void print_hex_data(FILE *fh, gint format, register const u_char *cp,
! 		register u_int length, char_enc encoding)
  {
! 	if (format == PR_FMT_PS)
! 		print_hex_data_ps(fh, cp, length, encoding);
! 	else
! 		print_hex_data_text(fh, cp, length, encoding);
  }
  
  /* This routine was created by Dan Lasley <DLASLEY@xxxxxxxxxx>, and
--- 177,218 ----
  	}
  }
  
! void print_hex_data(FILE *fh, gint format, frame_data *fd)
  {
! 	gboolean multiple_sources;
! 	GSList *src;
! 	tvbuff_t *tvb;
! 	char *name;
! 	char *line;
! 	const u_char *cp;
! 	guint length;
! 
! 	/*
! 	 * Set "multiple_sources" iff this frame has more than one
! 	 * data source; if it does, we need to print the name of
! 	 * the data source before printing the data from the
! 	 * data source.
! 	 */
! 	multiple_sources = (fd->data_src->next != NULL);
! 
! 	for (src = fd->data_src; src != NULL; src = src->next) {
! 		tvb = src->data;
! 		if (multiple_sources) {
! 			name = tvb_get_name(tvb);
! 			line = g_malloc(strlen(name) + 3);	/* <name>:\n\0 */
! 			strcpy(line, name);
! 			strcat(line, ":\n");
! 			print_line(fh, format, line);
! 			g_free(line);
! 			print_line(fh, format, "\n");
! 		}
! 		length = tvb_length(tvb);
! 		cp = tvb_get_ptr(tvb, 0, length);
! 		if (format == PR_FMT_PS)
! 			print_hex_data_ps(fh, cp, length, fd->flags.encoding);
! 		else
! 			print_hex_data_text(fh, cp, length, fd->flags.encoding);
! 	}
  }
  
  /* This routine was created by Dan Lasley <DLASLEY@xxxxxxxxxx>, and
*** print.h.dist	Fri Aug 11 20:18:52 2000
--- print.h	Thu Mar 15 23:24:18 2001
***************
*** 54,61 ****
  void print_finale(FILE *fh, gint format);
  void proto_tree_print(gboolean print_one_packet, print_args_t *print_args,
      GNode *protocol_tree, const u_char *pd, frame_data *fd, FILE *fh);
! void print_hex_data(FILE *fh, gint format, register const u_char *cp,
!     register u_int length, char_enc encoding);
  void print_line(FILE *fh, gint format, char *line);
  
  #endif /* print.h */
--- 54,60 ----
  void print_finale(FILE *fh, gint format);
  void proto_tree_print(gboolean print_one_packet, print_args_t *print_args,
      GNode *protocol_tree, const u_char *pd, frame_data *fd, FILE *fh);
! void print_hex_data(FILE *fh, gint format, frame_data *fd);
  void print_line(FILE *fh, gint format, char *line);
  
  #endif /* print.h */
*** tethereal.c.dist	Thu Mar 15 21:47:28 2001
--- tethereal.c	Thu Mar 15 23:23:51 2001
***************
*** 1257,1264 ****
        putchar('\n');
      }
      if (print_hex) {
!       print_hex_data(stdout, print_args.format, buf,
! 			fdata.cap_len, fdata.flags.encoding);
        putchar('\n');
      }
      fdata.cinfo = NULL;
--- 1257,1263 ----
        putchar('\n');
      }
      if (print_hex) {
!       print_hex_data(stdout, print_args.format, &fdata);
        putchar('\n');
      }
      fdata.cinfo = NULL;