diff options
author | Guy Harris <guy@alum.mit.edu> | 2004-01-25 21:55:17 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2004-01-25 21:55:17 +0000 |
commit | d6cd61061efe7207b298b5ac40a92e7b86b00b3e (patch) | |
tree | 392720e018248f9cf2b46db00a4a9740ff7d1fca /wiretap/snoop.c | |
parent | 34bddb3c1a932632fd0515f7999ed96ef9974611 (diff) | |
download | wireshark-d6cd61061efe7207b298b5ac40a92e7b86b00b3e.tar.gz wireshark-d6cd61061efe7207b298b5ac40a92e7b86b00b3e.tar.bz2 wireshark-d6cd61061efe7207b298b5ac40a92e7b86b00b3e.zip |
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
Diffstat (limited to 'wiretap/snoop.c')
-rw-r--r-- | wiretap/snoop.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/wiretap/snoop.c b/wiretap/snoop.c index 2003a4ad5f..bc3a8811c4 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -1,6 +1,6 @@ /* snoop.c * - * $Id: snoop.c,v 1.67 2004/01/05 17:33:28 ulfl Exp $ + * $Id: snoop.c,v 1.68 2004/01/25 21:55:17 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -88,9 +88,11 @@ struct shomiti_trailer { #define RX_STATUS_FIFO_ERROR 0x0080 /* receive FIFO error */ #define RX_STATUS_TRIGGERED 0x0001 /* frame did trigger */ -static gboolean snoop_read(wtap *wth, int *err, long *data_offset); +static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean snoop_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err); + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info); static gboolean snoop_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err); static gboolean snoop_read_rec_data(FILE_T fh, guchar *pd, int length, @@ -171,7 +173,7 @@ static gboolean snoop_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, * and distinguishing 4MB from 16MB Token Ring, and distinguishing both * of them from the "Shomiti" versions of same. */ -int snoop_open(wtap *wth, int *err) +int snoop_open(wtap *wth, int *err, gchar **err_info) { int bytes_read; char magic[sizeof snoop_magic]; @@ -269,8 +271,8 @@ int snoop_open(wtap *wth, int *err) break; default: - g_message("snoop: version %u unsupported", hdr.version); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("snoop: version %u unsupported", hdr.version); return -1; } @@ -364,9 +366,9 @@ int snoop_open(wtap *wth, int *err) if (is_shomiti) { if (hdr.network >= NUM_SHOMITI_ENCAPS || shomiti_encap[hdr.network] == WTAP_ENCAP_UNKNOWN) { - g_message("snoop: Shomiti network type %u unknown or unsupported", - hdr.network); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("snoop: Shomiti network type %u unknown or unsupported", + hdr.network); return -1; } file_encap = shomiti_encap[hdr.network]; @@ -376,9 +378,9 @@ int snoop_open(wtap *wth, int *err) } else { if (hdr.network >= NUM_SNOOP_ENCAPS || snoop_encap[hdr.network] == WTAP_ENCAP_UNKNOWN) { - g_message("snoop: network type %u unknown or unsupported", - hdr.network); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("snoop: network type %u unknown or unsupported", + hdr.network); return -1; } file_encap = snoop_encap[hdr.network]; @@ -400,7 +402,8 @@ int snoop_open(wtap *wth, int *err) } /* Read the next packet */ -static gboolean snoop_read(wtap *wth, int *err, long *data_offset) +static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { guint32 rec_size; guint32 packet_size; @@ -430,18 +433,18 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset) * Probably a corrupt capture file; don't blow up trying * to allocate space for an immensely-large packet. */ - g_message("snoop: File has %u-byte packet, bigger than maximum of %u", - packet_size, WTAP_MAX_PACKET_SIZE); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("snoop: File has %u-byte packet, bigger than maximum of %u", + packet_size, WTAP_MAX_PACKET_SIZE); return FALSE; } if (packet_size > rec_size) { /* * Probably a corrupt capture file. */ - g_message("snoop: File has %u-byte packet, bigger than record size %u", - packet_size, rec_size); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("snoop: File has %u-byte packet, bigger than record size %u", + packet_size, rec_size); return FALSE; } @@ -461,9 +464,9 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset) * Uh-oh, the packet isn't big enough to even * have a pseudo-header. */ - g_message("snoop: atmsnoop file has a %u-byte packet, too small to have even an ATM pseudo-header\n", - packet_size); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("snoop: atmsnoop file has a %u-byte packet, too small to have even an ATM pseudo-header\n", + packet_size); return FALSE; } if (!snoop_read_atm_pseudoheader(wth->fh, &wth->pseudo_header, @@ -525,9 +528,9 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset) /* * What, *negative* padding? Bogus. */ - g_message("snoop: File has %u-byte record with packet size of %u", - rec_size, packet_size); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("snoop: File has %u-byte record with packet size of %u", + rec_size, packet_size); return FALSE; } padbytes = rec_size - (sizeof hdr + packet_size); @@ -552,7 +555,8 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset) static gboolean snoop_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err) + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info _U_) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; |