summaryrefslogtreecommitdiff
path: root/wiretap/i4btrace.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-04-21 09:41:52 +0000
committerGuy Harris <guy@alum.mit.edu>2011-04-21 09:41:52 +0000
commit6cbf6ce16c45c4855ebddd3516465885e3c476d5 (patch)
tree299ce4fc08cb26cc0c0712c6b54de9c76893e7ca /wiretap/i4btrace.c
parent0315e063e4267b97fc7716301350af07dd0f2bea (diff)
downloadwireshark-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/i4btrace.c')
-rw-r--r--wiretap/i4btrace.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c
index 6b1c7d5013..6c39798683 100644
--- a/wiretap/i4btrace.c
+++ b/wiretap/i4btrace.c
@@ -42,9 +42,11 @@ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info);
-static int i4b_read_rec_header(FILE_T fh, i4b_trace_hdr_t *hdr, int *err);
+static int i4b_read_rec_header(FILE_T fh, i4b_trace_hdr_t *hdr, int *err,
+ gchar **err_info);
static void i4b_byte_swap_header(wtap *wth, i4b_trace_hdr_t *hdr);
-static gboolean i4b_read_rec_data(FILE_T fh, guchar *pd, int length, int *err);
+static gboolean i4b_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
+ gchar **err_info);
static void i4b_set_pseudo_header(i4b_trace_hdr_t *hdr,
union wtap_pseudo_header *pseudo_header);
@@ -56,7 +58,7 @@ static void i4b_set_pseudo_header(i4b_trace_hdr_t *hdr,
(unsigned)hdr.unit > 4 || (unsigned)hdr.type > 4 || \
(unsigned)hdr.dir > 2 || (unsigned)hdr.trunc > 2048))
-int i4btrace_open(wtap *wth, int *err, gchar **err_info _U_)
+int i4btrace_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
i4b_trace_hdr_t hdr;
@@ -67,7 +69,7 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info _U_)
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, sizeof(hdr), wth->fh);
if (bytes_read != sizeof(hdr)) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
@@ -129,7 +131,7 @@ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
/* Read record header. */
*data_offset = wth->data_offset;
- ret = i4b_read_rec_header(wth->fh, &hdr, err);
+ ret = i4b_read_rec_header(wth->fh, &hdr, err, err_info);
if (ret <= 0) {
/* Read error or EOF */
return FALSE;
@@ -155,7 +157,7 @@ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
*/
buffer_assure_space(wth->frame_buffer, length);
bufp = buffer_start_ptr(wth->frame_buffer);
- if (!i4b_read_rec_data(wth->fh, bufp, length, err))
+ if (!i4b_read_rec_data(wth->fh, bufp, length, err, err_info))
return FALSE; /* Read error */
wth->data_offset += length;
@@ -188,7 +190,7 @@ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
static gboolean
i4btrace_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)
{
int ret;
i4b_trace_hdr_t hdr;
@@ -197,7 +199,7 @@ i4btrace_seek_read(wtap *wth, gint64 seek_off,
return FALSE;
/* Read record header. */
- ret = i4b_read_rec_header(wth->random_fh, &hdr, err);
+ ret = i4b_read_rec_header(wth->random_fh, &hdr, err, err_info);
if (ret <= 0) {
/* Read error or EOF */
if (ret == 0) {
@@ -213,18 +215,18 @@ i4btrace_seek_read(wtap *wth, gint64 seek_off,
/*
* Read the packet data.
*/
- return i4b_read_rec_data(wth->random_fh, pd, length, err);
+ return i4b_read_rec_data(wth->random_fh, pd, length, err, err_info);
}
static int
-i4b_read_rec_header(FILE_T fh, i4b_trace_hdr_t *hdr, int *err)
+i4b_read_rec_header(FILE_T fh, i4b_trace_hdr_t *hdr, int *err, gchar **err_info)
{
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(hdr, sizeof *hdr, fh);
if (bytes_read != sizeof *hdr) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err != 0)
return -1;
if (bytes_read != 0) {
@@ -257,7 +259,7 @@ i4b_byte_swap_header(wtap *wth, i4b_trace_hdr_t *hdr)
}
static gboolean
-i4b_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
+i4b_read_rec_data(FILE_T fh, guchar *pd, int length, int *err, gchar **err_info)
{
int bytes_read;
@@ -265,7 +267,7 @@ i4b_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;