wireshark/file.h

111 lines
3.7 KiB
C
Raw Normal View History

/* file.h
* Definitions for file structures and routines
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __FILE_H__
#define __FILE_H__
#include <epan/packet-range.h>
#include "wiretap/wtap.h"
#include <epan/dfilter/dfilter.h>
#include "print.h"
#include <errno.h>
#include <epan/epan.h>
#include "cfile.h"
/* Return values from "cf_read()", "cf_continue_tail()", and
"cf_finish_tail()". */
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()". svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
typedef enum {
READ_SUCCESS, /* read succeeded */
READ_ERROR, /* read got an error */
READ_ABORTED /* read aborted by user */
} read_status_t;
int cf_open(char *, gboolean, capture_file *);
void cf_close(capture_file *);
void cf_reload();
read_status_t cf_read(capture_file *);
int cf_start_tail(char *, gboolean, capture_file *);
read_status_t cf_continue_tail(capture_file *, int, int *);
read_status_t cf_finish_tail(capture_file *, int *);
/* size_t read_frame_header(capture_file *); */
gboolean cf_save(char *fname, capture_file * cf, packet_range_t *range, guint save_format);
gchar *cf_get_display_name(capture_file *);
gboolean filter_packets(capture_file *cf, gchar *dfilter, gboolean force);
void reftime_packets(capture_file *);
void colorize_packets(capture_file *);
Turn the code of "colorize_packet()" into a static routine that is given a word to use in the progress dialog, and a flag indicating whether the display filter is to be reevaluated or not, and: have "colorize_packet()" call that routine with "Colorizing" and FALSE as those arguments; have the filtering code call that routine with "Filtering" and TRUE as those arguments; add an exported routine to call that routine with "Reprocessing" and TRUE as those arguments, to use to re-generate the packet list and to re-filter the packets if a protocol preference has been changed. Keep track of whether preferences are changed from their initial value by a preferences file or a command-line option, or from their previous value by the "Preferences" dialog box; have "prefs_apply_all()" only call the "apply" callback for a module if they have. Call "prefs_apply_all()" after the command-line arguments have been parsed and after "OK" has been clicked in the "Preferences" dialog box, to notify modules of preference changes if they've registered a callback for that. After "OK" has been clicked in the "Preferences" dialog box, if any preferences have changed, call the reprocessing routine, as the summary line for some frames and/or the current display filter's value when applied to some frames may have changed as a result of a preference change. Do the same after "OK" or "Apply" has been clicked in the "Display Options" dialog box (as it controls a protocol preferences item. svn path=/trunk/; revision=2126
2000-07-09 03:29:42 +00:00
void redissect_packets(capture_file *cf);
int retap_packets(capture_file *cf);
typedef enum {
PP_OK,
PP_OPEN_ERROR,
PP_WRITE_ERROR
} pp_return_t;
pp_return_t print_packets(capture_file *cf, print_args_t *print_args);
pp_return_t write_pdml_packets(capture_file *cf, print_args_t *print_args);
pp_return_t write_psml_packets(capture_file *cf, print_args_t *print_args);
void change_time_formats(capture_file *);
Get rid of the EBCDIC stuff in the find dialog - it's not supported yet, so we shouldn't torment the users by offering it. Check the string type and convert it to an internal representation in the GUI code; have the search code deal only with the internal representation. Save the case-sensitivity flag, and the indication of where string searches look, along with other search parameters. Upper-casify the string, for case-insensitive searches, in the GUI code; don't save the upper-casified string, so it doesn't SHOUT at you when you next pop up a "find" dialog. Convert the hex value string to raw binary data in the GUI code, rather than doing so in the search code. Check that it's a valid string. Connect the signals to the radio buttons after the pointers have been attached to various GUI items - the signal handlers expect some of those pointers to be attached, and aren't happy if they're not. Have "find_packet()" contain a framework for searching, but not contain the matching code; instead, pass it a pointer to a matching routine and an opaque pointer to be passed to the matching routine. Have all the routines that do different types of searching have their own matching routines, and use the common "find_packet()" code, rather than duplicating that code. Search for the Info column by column type, not by name (the user can change the name). When matching on the protocol tree, don't format the entire protocol tree into a big buffer - just have a routine that matches the text representation of a protocol tree item against a string, and, if it finds a match, sets a "we found a match flag" and returns; have that routine not bother doing any more work if that flag is set. (Unfortunately, you can't abort "g_node_children_foreach()" in the middle of a traversal.) Free the generated display filter code after a find-by-display-filter finishes. svn path=/trunk/; revision=8306
2003-08-29 04:03:46 +00:00
gboolean find_packet_protocol_tree(capture_file *cf, const char *string);
gboolean find_packet_summary_line(capture_file *cf, const char *string);
gboolean find_packet_data(capture_file *cf, const guint8 *string,
size_t string_size);
gboolean find_packet_dfilter(capture_file *cf, dfilter_t *sfcode);
guint8 get_int_value(char char_val);
gboolean find_ascii(capture_file *cf, char *ascii_text, gboolean ascii_search, char *ftype, gboolean case_type);
gboolean find_in_gtk_data(capture_file *cf, gpointer *data, char *ascii_text, gboolean case_type, gboolean search_type);
gboolean goto_frame(capture_file *cf, guint fnumber);
gboolean goto_bottom_frame(capture_file *cf);
gboolean goto_top_frame(capture_file *cf);
void goto_framenum(capture_file *cf);
void select_packet(capture_file *, int);
void unselect_packet(capture_file *);
void unselect_field(capture_file *);
/*
* Mark a particular frame in a particular capture.
*/
void mark_frame(capture_file *, frame_data *);
/*
* Unmark a particular frame in a particular capture.
*/
void unmark_frame(capture_file *, frame_data *);
/* Moves or copies a file. Returns 0 on failure, 1 on success */
int file_mv(char *from, char *to);
/* Copies a file. Returns 0 on failure, 1 on success */
int file_cp(char *from, char *to);
char *cf_read_error_message(int, gchar *);
#endif /* file.h */