diff options
author | Guy Harris <guy@alum.mit.edu> | 2011-04-21 09:41:52 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2011-04-21 09:41:52 +0000 |
commit | 6cbf6ce16c45c4855ebddd3516465885e3c476d5 (patch) | |
tree | 299ce4fc08cb26cc0c0712c6b54de9c76893e7ca /wiretap/5views.c | |
parent | 0315e063e4267b97fc7716301350af07dd0f2bea (diff) | |
download | wireshark-6cbf6ce16c45c4855ebddd3516465885e3c476d5.tar.gz |
Add a new WTAP_ERR_DECOMPRESS error, and use that for errors discovered
by the gunzipping code. Have it also supply a err_info string, and
report it. Have file_error() supply an err_info string.
Put "the file" - or, for WTAP_ERR_DECOMPRESS, "the compressed file", to
suggest a decompression error - into the rawshark and tshark errors,
along the lines of what other programs print.
Fix a case in the Netscaler code where we weren't fetching the error
code on a read failure.
svn path=/trunk/; revision=36748
Diffstat (limited to 'wiretap/5views.c')
-rw-r--r-- | wiretap/5views.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/wiretap/5views.c b/wiretap/5views.c index 5352a7be4c..729c478caf 100644 --- a/wiretap/5views.c +++ b/wiretap/5views.c @@ -106,9 +106,9 @@ typedef struct static gboolean _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean _5views_read_rec_data(FILE_T fh, guchar *pd, int length, - int *err); + int *err, gchar **err_info); static int _5views_read_header(wtap *wth, FILE_T fh, - t_5VW_TimeStamped_Header *hdr, int *err); + t_5VW_TimeStamped_Header *hdr, int *err, gchar **err_info); static gboolean _5views_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); @@ -128,7 +128,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info) errno = WTAP_ERR_CANT_READ; bytes_read = file_read(&Capture_Header.Info_Header, sizeof(t_5VW_Info_Header), wth->fh); if (bytes_read != sizeof(t_5VW_Info_Header)) { - *err = file_error(wth->fh); + *err = file_error(wth->fh, err_info); if (*err != 0) return -1; return 0; @@ -184,7 +184,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info) /* read the remaining header information */ bytes_read = file_read(&Capture_Header.HeaderDateCreation, sizeof (t_5VW_Capture_Header) - sizeof(t_5VW_Info_Header), wth->fh); if (bytes_read != sizeof (t_5VW_Capture_Header)- sizeof(t_5VW_Info_Header) ) { - *err = file_error(wth->fh); + *err = file_error(wth->fh, err_info); if (*err != 0) return -1; return 0; @@ -204,7 +204,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info) /* Read the next packet */ static gboolean -_5views_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset) +_5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { t_5VW_TimeStamped_Header TimeStamped_Header; int bytes_read; @@ -213,7 +213,7 @@ _5views_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset) do { - bytes_read = _5views_read_header(wth, wth->fh, &TimeStamped_Header, err); + bytes_read = _5views_read_header(wth, wth->fh, &TimeStamped_Header, err, err_info); if (bytes_read == -1) { /* * We failed to read the header. @@ -245,7 +245,7 @@ _5views_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset) buffer_assure_space(wth->frame_buffer, packet_size); if (!_5views_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), - packet_size, err)) + packet_size, err, err_info)) return FALSE; /* Read error */ wth->data_offset += packet_size; @@ -271,7 +271,8 @@ _5views_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset) static gboolean -_5views_read_rec_data(FILE_T fh, guchar *pd, int length, int *err) +_5views_read_rec_data(FILE_T fh, guchar *pd, int length, int *err, + gchar **err_info) { int bytes_read; @@ -279,7 +280,7 @@ _5views_read_rec_data(FILE_T fh, guchar *pd, int length, int *err) bytes_read = file_read(pd, length, fh); if (bytes_read != length) { - *err = file_error(fh); + *err = file_error(fh, err_info); if (*err == 0) *err = WTAP_ERR_SHORT_READ; return FALSE; @@ -294,7 +295,7 @@ _5views_read_rec_data(FILE_T fh, guchar *pd, int length, int *err) Return -1 on an error, or the number of bytes of header read on success. */ static int -_5views_read_header(wtap *wth _U_, FILE_T fh, t_5VW_TimeStamped_Header *hdr, int *err) +_5views_read_header(wtap *wth _U_, FILE_T fh, t_5VW_TimeStamped_Header *hdr, int *err, gchar **err_info) { int bytes_read, bytes_to_read; @@ -303,7 +304,7 @@ _5views_read_header(wtap *wth _U_, FILE_T fh, t_5VW_TimeStamped_Header *hdr, /* Read record header. */ bytes_read = file_read(hdr, bytes_to_read, fh); if (bytes_read != bytes_to_read) { - *err = file_error(fh); + *err = file_error(fh, err_info); if (*err == 0 && bytes_read != 0) { *err = WTAP_ERR_SHORT_READ; } @@ -316,14 +317,14 @@ _5views_read_header(wtap *wth _U_, FILE_T fh, t_5VW_TimeStamped_Header *hdr, static gboolean _5views_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, - int *err, gchar **err_info _U_) + int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; /* * Read the packet data. */ - if (!_5views_read_rec_data(wth->random_fh, pd, length, err)) + if (!_5views_read_rec_data(wth->random_fh, pd, length, err, err_info)) return FALSE; switch (wth->file_encap) { |