aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/libpcap.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/libpcap.c
parent0315e063e4267b97fc7716301350af07dd0f2bea (diff)
downloadwireshark-6cbf6ce16c45c4855ebddd3516465885e3c476d5.tar.gz
wireshark-6cbf6ce16c45c4855ebddd3516465885e3c476d5.tar.bz2
wireshark-6cbf6ce16c45c4855ebddd3516465885e3c476d5.zip
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/libpcap.c')
-rw-r--r--wiretap/libpcap.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index 5e65da7183..4557839b89 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -76,7 +76,7 @@ static int libpcap_read_header(wtap *wth, int *err, gchar **err_info,
struct pcaprec_ss990915_hdr *hdr);
static void adjust_header(wtap *wth, struct pcaprec_hdr *hdr);
static gboolean libpcap_read_rec_data(FILE_T fh, guchar *pd, int length,
- int *err);
+ int *err, gchar **err_info);
static gboolean libpcap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
@@ -95,7 +95,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
@@ -166,7 +166,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
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;
@@ -635,7 +635,8 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
/*
* Read the padding.
*/
- if (!libpcap_read_rec_data(wth->fh, fddi_padding, 3, err))
+ if (!libpcap_read_rec_data(wth->fh, fddi_padding, 3, err,
+ err_info))
return FALSE; /* Read error */
}
@@ -657,7 +658,7 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
buffer_assure_space(wth->frame_buffer, packet_size);
if (!libpcap_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;
@@ -723,7 +724,7 @@ libpcap_seek_read(wtap *wth, gint64 seek_off,
/*
* Read the packet data.
*/
- if (!libpcap_read_rec_data(wth->random_fh, pd, length, err))
+ if (!libpcap_read_rec_data(wth->random_fh, pd, length, err, err_info))
return FALSE; /* failed */
if (wth->file_encap == WTAP_ENCAP_ATM_PDUS) {
@@ -789,7 +790,7 @@ static int libpcap_read_header(wtap *wth, int *err, gchar **err_info,
}
bytes_read = file_read(hdr, bytes_to_read, wth->fh);
if (bytes_read != bytes_to_read) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) {
*err = WTAP_ERR_SHORT_READ;
}
@@ -875,7 +876,8 @@ adjust_header(wtap *wth, struct pcaprec_hdr *hdr)
}
static gboolean
-libpcap_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
+libpcap_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
+ gchar **err_info)
{
int bytes_read;
@@ -883,7 +885,7 @@ libpcap_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;