Ethereal-cvs: [ethereal-cvs] cvs commit: ethereal/wiretap wtap.c wtap.h

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

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Tue, 27 Jun 2000 02:14:06 -0500 (CDT)
guy         2000/06/27 02:13:59 CDT

  Modified files:
    wiretap              wtap.c wtap.h 
  Log:
  Add routines to Wiretap to allow a client of Wiretap to get:
  
  	a pointer to the "wtap_pkthdr" structure for an open capture
  	file;
  
  	a pointer to the "wtap_pseudo_header" union for an open capture
  	file;
  
  	a pointer to the packet buffer for an open capture file;
  
  so that a program using "wtap_read()" in a loop can get at those items.
  
  Keep, in a "capture_file" structure, an indicator of whether:
  
  	no file is open;
  
  	a file is open, and being read;
  
  	a file is open, and is being read, but the user tried to quit
  	out of reading the file (e.g., by doing "File/Quit");
  
  	a file is open, and has been completely read.
  
  Abort if we try to close a capture that's being read if the user hasn't
  tried to quit out of the read.
  
  Have "File/Quit" check if a file is being read; if so, just set the
  state indicator to "user tried to quit out of it", so that the code
  reading the file can do what's appropriate to clean up, rather than
  closing the file out from under that code and causing crashes.
  
  Have "read_cap_file()" read the capture file with a loop using
  "wtap_read()", rather than by using "wtap_loop()"; have it check after
  reading each packet whether the user tried to abort the read and, if so,
  close the capture and return an indication that the read was aborted by
  the user.  Otherwise, return an indication of whether the read
  completely succeeded or failed in the middle (and, if it failed, return
  the error code through a pointer).
  
  Have "continue_tail_cap_file()" read the capture file with a loop using
  "wtap_read()", rather than by using "wtap_loop()"; have it check after
  reading each packet whether the user tried to abort the read and, if so,
  quit the loop, and after the loop finishes (even if it read no packets),
  return an indication that the read was aborted by the user if that
  happened.  Otherwise, return an indication of whether the read
  completely succeeded or failed in the middle (and, if it failed, return
  the error code through a pointer).
  
  Have "finish_tail_cap_file()" read the capture file with a loop using
  "wtap_read()", rather than by using "wtap_loop()"; have it check after
  reading each packet whether the user tried to abort the read and, if so,
  quit the loop, and after the loop finishes (even if it read no packets),
  close the capture and return an indication that the read was aborted by
  the user if that happened.  Otherwise, return an indication of whether
  the read completely succeeded or failed in the middle (and, if it
  failed, return the error code through a pointer).
  
  Have their callers check whether the read was aborted or not and, if it
  was, bail out in the appropriate fashion (exit if it's reading a file
  specified by "-r" on the command line; exit the main loop if it's
  reading a file specified with File->Open; kill the capture child if it's
  "continue_tail_cap_file()"; exit the main loop if it's
  "finish_tail_cap_file()".
  
  Revision  Changes    Path
  1.45      +18 -3     ethereal/wiretap/wtap.c
  1.74      +4 -1      ethereal/wiretap/wtap.h