case WTAP_ERR_UNSUPPORTED:
case WTAP_ERR_UNSUPPORTED_ENCAP:
case WTAP_ERR_BAD_RECORD:
+ case WTAP_ERR_DECOMPRESS:
fprintf(stderr, "(%s)\n", err_info);
g_free(err_info);
break;
errmsg = "A full header couldn't be written to the file \"%s\".";
break;
+ case WTAP_ERR_DECOMPRESS:
+ g_snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "The compressed file \"%%s\" appears to be damaged or corrupt.\n"
+ "(%s)", err_info);
+ g_free(err_info);
+ errmsg = errmsg_errno;
+ break;
+
default:
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"The file \"%%s\" could not be %s: %s.",
errmsg = errmsg_errno;
break;
+ case WTAP_ERR_DECOMPRESS:
+ g_snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "The compressed capture file appears to be damaged or corrupt.\n"
+ "(%s)", err_info);
+ g_free(err_info);
+ errmsg = errmsg_errno;
+ break;
+
default:
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"An error occurred while reading the"
errmsg = errmsg_errno;
break;
+ case WTAP_ERR_DECOMPRESS:
+ g_snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "The compressed capture file %%s appears to be damaged or corrupt.\n"
+ "(%s)", err_info);
+ g_free(err_info);
+ errmsg = errmsg_errno;
+ break;
+
default:
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"An error occurred while reading the"
"Gzip compression not supported by this file type.");
break;
+ case WTAP_ERR_DECOMPRESS:
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "The compressed file \"%s\" appears to be damaged or corrupt.\n"
+ "(%s)", filename, err_info);
+ g_free(err_info);
+ break;
+
default:
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"The file \"%s\" could not be %s: %s.",
switch (err) {
case WTAP_ERR_UNSUPPORTED_ENCAP:
- cmdarg_err("\"%s\" has a packet with a network type that Rawshark doesn't support.\n(%s)",
+ cmdarg_err("The file \"%s\" has a packet with a network type that Rawshark doesn't support.\n(%s)",
cf->filename, err_info);
break;
case WTAP_ERR_CANT_READ:
- cmdarg_err("An attempt to read from \"%s\" failed for some unknown reason.",
+ cmdarg_err("An attempt to read from the file \"%s\" failed for some unknown reason.",
cf->filename);
break;
case WTAP_ERR_SHORT_READ:
- cmdarg_err("\"%s\" appears to have been cut short in the middle of a packet.",
+ cmdarg_err("The file \"%s\" appears to have been cut short in the middle of a packet.",
cf->filename);
break;
case WTAP_ERR_BAD_RECORD:
- cmdarg_err("\"%s\" appears to be damaged or corrupt.\n(%s)",
+ cmdarg_err("The file \"%s\" appears to be damaged or corrupt.\n(%s)",
+ cf->filename, err_info);
+ break;
+
+ case WTAP_ERR_DECOMPRESS:
+ cmdarg_err("The compressed file \"%s\" appears to be damaged or corrupt.\n(%s)",
cf->filename, err_info);
break;
default:
- cmdarg_err("An error occurred while reading \"%s\": %s.",
+ cmdarg_err("An error occurred while reading the file \"%s\": %s.",
cf->filename, wtap_strerror(err));
break;
}
switch (err) {
case WTAP_ERR_UNSUPPORTED_ENCAP:
- cmdarg_err("\"%s\" has a packet with a network type that TShark doesn't support.\n(%s)",
+ cmdarg_err("The file \"%s\" has a packet with a network type that TShark doesn't support.\n(%s)",
cf->filename, err_info);
g_free(err_info);
break;
case WTAP_ERR_CANT_READ:
- cmdarg_err("An attempt to read from \"%s\" failed for some unknown reason.",
+ cmdarg_err("An attempt to read from the file \"%s\" failed for some unknown reason.",
cf->filename);
break;
case WTAP_ERR_SHORT_READ:
- cmdarg_err("\"%s\" appears to have been cut short in the middle of a packet.",
+ cmdarg_err("The file \"%s\" appears to have been cut short in the middle of a packet.",
cf->filename);
break;
case WTAP_ERR_BAD_RECORD:
- cmdarg_err("\"%s\" appears to be damaged or corrupt.\n(%s)",
+ cmdarg_err("The file \"%s\" appears to be damaged or corrupt.\n(%s)",
cf->filename, err_info);
g_free(err_info);
break;
+ case WTAP_ERR_DECOMPRESS:
+ cmdarg_err("The compressed file \"%s\" appears to be damaged or corrupt.\n"
+ "(%s)", cf->filename, err_info);
+ break;
+
default:
- cmdarg_err("An error occurred while reading \"%s\": %s.",
+ cmdarg_err("An error occurred while reading the file \"%s\": %s.",
cf->filename, wtap_strerror(err));
break;
}
errmsg = "A full header couldn't be written to the file \"%s\".";
break;
+ case WTAP_ERR_DECOMPRESS:
+ /* Seen only when opening a capture file for reading. */
+ g_snprintf(errmsg_errno, sizeof(errmsg_errno),
+ "The compressed file \"%%s\" appears to be damaged or corrupt.\n"
+ "(%s)", err_info);
+ g_free(err_info);
+ errmsg = errmsg_errno;
+ break;
+
default:
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"The file \"%%s\" could not be %s: %s.",
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);
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;
/* 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;
/* 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;
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.
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;
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;
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;
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;
/* 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;
}
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) {
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info);
-static int wtap_file_read_pattern (wtap *wth, const char *pattern, int *err)
+static int wtap_file_read_pattern (wtap *wth, const char *pattern, int *err,
+ gchar **err_info)
{
int c;
const char *cp;
if (file_eof(wth->fh))
return 0; /* EOF */
else {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return -1; /* error */
}
}
static int wtap_file_read_till_separator (wtap *wth, char *buffer, int buflen,
- const char *separators, int *err)
+ const char *separators, int *err,
+ gchar **err_info)
{
int c;
char *cp;
if (file_eof(wth->fh))
return 0; /* EOF */
else {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return -1; /* error */
}
}
}
-static int wtap_file_read_number (wtap *wth, guint32 *num, int *err)
+static int wtap_file_read_number (wtap *wth, guint32 *num, int *err,
+ gchar **err_info)
{
int ret;
char str_num[12];
char *p;
ret = wtap_file_read_till_separator (wth, str_num, sizeof (str_num)-1, "<",
- err);
+ err, err_info);
if (ret != 1) {
/* 0 means EOF, which means "not a valid AiroPeek V9 file";
-1 means error, and "err" has been set. */
#define NUM_AIROPEEK9_ENCAPS (sizeof airopeek9_encap / sizeof airopeek9_encap[0])
airopeek9_t *airopeek9;
- wtap_file_read_unknown_bytes(&ap_hdr, sizeof(ap_hdr), wth->fh, err);
+ wtap_file_read_unknown_bytes(&ap_hdr, sizeof(ap_hdr), wth->fh, err,
+ err_info);
if (memcmp (ap_hdr.section_id, "\177ver", sizeof(ap_hdr.section_id)) != 0)
return 0; /* doesn't begin with a "\177ver" section */
* we have the file version (and possibly check to make sure all
* tags are properly opened and closed).
*/
- ret = wtap_file_read_pattern (wth, "<FileVersion>", err);
+ ret = wtap_file_read_pattern (wth, "<FileVersion>", err, err_info);
if (ret != 1) {
/* 0 means EOF, which means "not a valid AiroPeek V9 file";
-1 means error, and "err" has been set. */
return ret;
}
- ret = wtap_file_read_number (wth, &fileVersion, err);
+ ret = wtap_file_read_number (wth, &fileVersion, err, err_info);
if (ret != 1) {
/* 0 means EOF, which means "not a valid AiroPeek V9 file";
-1 means error, and "err" has been set. */
* we have the file version (and possibly check to make sure all
* tags are properly opened and closed).
*/
- ret = wtap_file_read_pattern (wth, "<MediaType>", err);
+ ret = wtap_file_read_pattern (wth, "<MediaType>", err, err_info);
if (ret == -1)
return -1;
if (ret == 0) {
}
/* XXX - this appears to be 0 in both the EtherPeek and AiroPeek
files we've seen; should we require it to be 0? */
- ret = wtap_file_read_number (wth, &mediaType, err);
+ ret = wtap_file_read_number (wth, &mediaType, err, err_info);
if (ret == -1)
return -1;
if (ret == 0) {
return -1;
}
- ret = wtap_file_read_pattern (wth, "<MediaSubType>", err);
+ ret = wtap_file_read_pattern (wth, "<MediaSubType>", err, err_info);
if (ret == -1)
return -1;
if (ret == 0) {
*err_info = g_strdup("airopeekv9: <MediaSubType> tag not found");
return -1;
}
- ret = wtap_file_read_number (wth, &mediaSubType, err);
+ ret = wtap_file_read_number (wth, &mediaSubType, err, err_info);
if (ret == -1)
return -1;
if (ret == 0) {
return -1;
}
- ret = wtap_file_read_pattern (wth, "pkts", err);
+ ret = wtap_file_read_pattern (wth, "pkts", err, err_info);
if (ret == -1)
return -1;
if (ret == 0) {
XXX - this assumes all values are 4 bytes long. */
bytes_read = file_read(tag_value, sizeof tag_value, fh);
if (bytes_read != (int) sizeof tag_value) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
if (bytes_read > 0)
*err = WTAP_ERR_SHORT_READ;
/* read the frame data */
buffer_assure_space(wth->frame_buffer, hdr_info.sliceLength);
wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer),
- hdr_info.sliceLength, wth->fh, err);
+ hdr_info.sliceLength, wth->fh, err,
+ err_info);
wth->data_offset += hdr_info.sliceLength;
/* recalculate and fill in packet time stamp */
* XXX - should "errno" be set in "wtap_file_read_expected_bytes()"?
*/
errno = WTAP_ERR_CANT_READ;
- wtap_file_read_expected_bytes(pd, length, wth->random_fh, err);
+ wtap_file_read_expected_bytes(pd, length, wth->random_fh, err, err_info);
return TRUE;
}
/* Seeks to the beginning of the next packet, and returns the
byte offset at which the header for that packet begins.
Returns -1 on failure. */
-static gint64 ascend_seek(wtap *wth, int *err)
+static gint64 ascend_seek(wtap *wth, int *err, gchar **err_info)
{
int byte;
gint64 date_off = -1, cur_off, packet_off;
cur_off = file_tell(wth->fh);
if (cur_off == -1) {
/* Error. */
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return -1;
}
} else {
/* We (presumably) got an error (there's no equivalent to "ferror()"
in zlib, alas, so we don't have a wrapper to check for an error). */
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
}
return -1;
return packet_off;
}
-int ascend_open(wtap *wth, int *err, gchar **err_info _U_)
+int ascend_open(wtap *wth, int *err, gchar **err_info)
{
gint64 offset;
struct stat statbuf;
fill it in. */
wth->priv = NULL;
- offset = ascend_seek(wth, err);
+ offset = ascend_seek(wth, err, err_info);
if (offset == -1) {
if (*err == 0)
return 0;
SEEK_SET, err) == -1)
return FALSE;
- offset = ascend_seek(wth, err);
+ offset = ascend_seek(wth, err, err_info);
if (offset == -1)
return FALSE;
if (parse_ascend(wth->fh, buf, &wth->pseudo_header.ascend, &header,
buffer_assure_space(wth->frame_buffer, packet_size);
buf = buffer_start_ptr(wth->frame_buffer);
- wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err);
+ wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err, err_info);
wth->data_offset += packet_size;
}
static gboolean ber_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header _U_,
- guint8 *pd, int length, int *err, gchar **err_info _U_)
+ guint8 *pd, int length, int *err, gchar **err_info)
{
int packet_size = length;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
- wtap_file_read_expected_bytes(pd, packet_size, wth->random_fh, err);
+ wtap_file_read_expected_bytes(pd, packet_size, wth->random_fh, err, err_info);
return TRUE;
}
-int ber_open(wtap *wth, int *err, gchar **err_info _U_)
+int ber_open(wtap *wth, int *err, gchar **err_info)
{
#define BER_BYTES_TO_CHECK 8
guint8 bytes[BER_BYTES_TO_CHECK];
bytes_read = file_read(&bytes, BER_BYTES_TO_CHECK, wth->fh);
if (bytes_read != BER_BYTES_TO_CHECK) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return (*err != 0) ? -1 : 0;
}
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info);
-static gboolean snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err);
+static gboolean snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
+ gchar **err_info);
-int btsnoop_open(wtap *wth, int *err, gchar **err_info _U_)
+int btsnoop_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
char magic[sizeof btsnoop_magic];
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;
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;
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 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
buffer_assure_space(wth->frame_buffer, packet_size);
if (!snoop_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;
static gboolean btsnoop_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 bytes_read;
struct btsnooprec_hdr hdr;
guint32 flags;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, sizeof hdr, wth->random_fh);
if (bytes_read != sizeof hdr) {
- *err = file_error(wth->random_fh);
+ *err = file_error(wth->random_fh, err_info);
if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
/*
* Read the packet data.
*/
- if (!snoop_read_rec_data(wth->random_fh, pd, length, err))
+ if (!snoop_read_rec_data(wth->random_fh, pd, length, err, err_info))
return FALSE; /* failed */
if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR)
}
static gboolean
-snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
+snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
+ gchar **err_info)
{
int bytes_read;
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;
#define MEDIUM_WIFI 1
#define MEDIUM_TOKEN_RING 2
-static gboolean commview_read(wtap *wth, int *err, gchar **err_info _U_,
+static gboolean commview_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean commview_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header,
guchar *pd, int length, int *err,
- gchar **err_info _U_);
+ gchar **err_info);
static gboolean commview_read_header(commview_header_t *cv_hdr, FILE_T fh,
- int *err);
+ int *err, gchar **err_info);
static gboolean commview_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header _U_,
const guchar *pd, int *err);
-int commview_open(wtap *wth, int *err, gchar **err_info _U_)
+int commview_open(wtap *wth, int *err, gchar **err_info)
{
commview_header_t cv_hdr;
- if(!commview_read_header(&cv_hdr, wth->fh, err))
+ if(!commview_read_header(&cv_hdr, wth->fh, err, err_info))
return -1;
/* If any of these fields do not match what we expect, bail out. */
}
static gboolean
-commview_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset)
+commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
commview_header_t cv_hdr;
struct tm tm;
*data_offset = wth->data_offset;
- if(!commview_read_header(&cv_hdr, wth->fh, err))
+ if(!commview_read_header(&cv_hdr, wth->fh, err, err_info))
return FALSE;
wth->data_offset += COMMVIEW_HEADER_SIZE;
bytes_read = file_read(buffer_start_ptr(wth->frame_buffer),
cv_hdr.data_len, wth->fh);
if(bytes_read != cv_hdr.data_len) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if(*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
static gboolean
commview_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header
*pseudo_header, guchar *pd, int length, int *err,
- gchar **err_info _U_)
+ gchar **err_info)
{
commview_header_t cv_hdr;
int bytes_read;
if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
- if(!commview_read_header(&cv_hdr, wth->random_fh, err)) {
+ if(!commview_read_header(&cv_hdr, wth->random_fh, err, err_info)) {
if(*err == 0)
*err = WTAP_ERR_SHORT_READ;
bytes_read = file_read(pd, cv_hdr.data_len, wth->random_fh);
if(bytes_read != cv_hdr.data_len) {
- *err = file_error(wth->random_fh);
+ *err = file_error(wth->random_fh, err_info);
if(*err == 0)
*err = WTAP_ERR_SHORT_READ;
}
static gboolean
-commview_read_header(commview_header_t *cv_hdr, FILE_T fh, int *err)
+commview_read_header(commview_header_t *cv_hdr, FILE_T fh, int *err,
+ gchar **err_info)
{
int bytes_read = 0;
cv_hdr->usecs = GUINT32_FROM_LE(cv_hdr->usecs);
if(bytes_read < COMMVIEW_HEADER_SIZE) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if(*err == 0 && bytes_read > 0)
*err = WTAP_ERR_SHORT_READ;
#define COSINE_MAX_PACKET_LEN 65536
static gboolean empty_line(const gchar *line);
-static gint64 cosine_seek_next_packet(wtap *wth, int *err, char *hdr);
-static gboolean cosine_check_file_type(wtap *wth, int *err);
+static gint64 cosine_seek_next_packet(wtap *wth, int *err, gchar **err_info,
+ char *hdr);
+static gboolean cosine_check_file_type(wtap *wth, int *err, gchar **err_info);
static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean cosine_seek_read(wtap *wth, gint64 seek_off,
/* Seeks to the beginning of the next packet, and returns the
byte offset. Copy the header line to hdr. Returns -1 on failure,
- and sets "*err" to the error and set hdr as NULL. */
-static gint64 cosine_seek_next_packet(wtap *wth, int *err, char *hdr)
+ and sets "*err" to the error, sets "*err_info" to null or an
+ additional error string, and sets hdr to NULL. */
+static gint64 cosine_seek_next_packet(wtap *wth, int *err, gchar **err_info,
+ char *hdr)
{
gint64 cur_off;
char buf[COSINE_LINE_LENGTH];
cur_off = file_tell(wth->fh);
if (cur_off == -1) {
/* Error */
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
hdr = NULL;
return -1;
}
*err = 0;
} else {
/* We got an error. */
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
}
break;
}
* a CoSine L2 debug output.
*
* Returns TRUE if it is, FALSE if it isn't or if we get an I/O error;
- * if we get an I/O error, "*err" will be set to a non-zero value.
+ * if we get an I/O error, "*err" will be set to a non-zero value and
+ * "*err_info" will be set to null or an additional error string.
*/
-static gboolean cosine_check_file_type(wtap *wth, int *err)
+static gboolean cosine_check_file_type(wtap *wth, int *err, gchar **err_info)
{
char buf[COSINE_LINE_LENGTH];
gsize reclen;
if (file_eof(wth->fh))
*err = 0;
else
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return FALSE;
}
}
}
-int cosine_open(wtap *wth, int *err, gchar **err_info _U_)
+int cosine_open(wtap *wth, int *err, gchar **err_info)
{
/* Look for CoSine header */
- if (!cosine_check_file_type(wth, err)) {
+ if (!cosine_check_file_type(wth, err, err_info)) {
if (*err == 0)
return 0;
else
char line[COSINE_LINE_LENGTH];
/* Find the next packet */
- offset = cosine_seek_next_packet(wth, err, line);
+ offset = cosine_seek_next_packet(wth, err, err_info, line);
if (offset < 0)
return FALSE;
return FALSE;
if (file_gets(line, COSINE_LINE_LENGTH, wth->random_fh) == NULL) {
- *err = file_error(wth->random_fh);
+ *err = file_error(wth->random_fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
for (i = 0; i < hex_lines; i++) {
if (file_gets(line, COSINE_LINE_LENGTH, fh) == NULL) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
} csids_t;
/* XXX - return -1 on I/O error and actually do something with 'err'. */
-int csids_open(wtap *wth, int *err, gchar **err_info _U_)
+int csids_open(wtap *wth, int *err, gchar **err_info)
{
/* There is no file header. There is only a header for each packet
* so we read a packet header and compare the caplen with iplen. They
/* check the file to make sure it is a csids file. */
bytesRead = file_read( &hdr, sizeof( struct csids_header), wth->fh );
if( bytesRead != sizeof( struct csids_header) ) {
- *err = file_error( wth->fh );
+ *err = file_error( wth->fh, err_info );
if( *err != 0 ) {
return -1;
} else {
hdr.caplen = pntohs( &hdr.caplen );
bytesRead = file_read( &tmp, 2, wth->fh );
if( bytesRead != 2 ) {
- *err = file_error( wth->fh );
+ *err = file_error( wth->fh, err_info );
if( *err != 0 ) {
return -1;
} else {
}
bytesRead = file_read( &iplen, 2, wth->fh );
if( bytesRead != 2 ) {
- *err = file_error( wth->fh );
+ *err = file_error( wth->fh, err_info );
if( *err != 0 ) {
return -1;
} else {
}
/* Find the next packet and parse it; called from wtap_read(). */
-static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_,
+static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
csids_t *csids = (csids_t *)wth->priv;
bytesRead = file_read( &hdr, sizeof( struct csids_header) , wth->fh );
if( bytesRead != sizeof( struct csids_header) ) {
- *err = file_error( wth->fh );
+ *err = file_error( wth->fh, err_info );
if (*err == 0 && bytesRead != 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
bytesRead = file_read( buf, hdr.caplen, wth->fh );
if( bytesRead != hdr.caplen ) {
- *err = file_error( wth->fh );
+ *err = file_error( wth->fh, err_info );
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
bytesRead = file_read( &hdr, sizeof( struct csids_header), wth->random_fh );
if( bytesRead != sizeof( struct csids_header) ) {
- *err = file_error( wth->random_fh );
+ *err = file_error( wth->random_fh, err_info );
if( *err == 0 ) {
*err = WTAP_ERR_SHORT_READ;
}
bytesRead = file_read( pd, hdr.caplen, wth->random_fh );
if( bytesRead != hdr.caplen ) {
- *err = file_error( wth->random_fh );
+ *err = file_error( wth->random_fh, err_info );
if( *err == 0 ) {
*err = WTAP_ERR_SHORT_READ;
}
static char readData[READDATA_BUF_SIZE];
static char seekData[SEEKDATA_BUF_SIZE];
-static gboolean daintree_sna_read(wtap *wth, int *err, gchar **err_info _U_,
+static gboolean daintree_sna_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean daintree_sna_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header _U_,
guchar *pd, int len, int *err,
- gchar **err_info _U_);
+ gchar **err_info);
static guint daintree_sna_hex_char(guchar *str, int *err);
/* Read the capture file sequentially
* Wireshark scans the file with sequential reads during preview and initial display. */
static gboolean
-daintree_sna_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset)
+daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
guint64 seconds;
* if others appear in the file, they are tossed */
do {
if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->fh) == NULL) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return FALSE; /* all done */
}
wth->data_offset += strlen(readLine);
static gboolean
daintree_sna_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header
*pseudo_header _U_, guchar *pd, int len, int *err,
- gchar **err_info _U_)
+ gchar **err_info)
{
guint pkt_len;
* if we find any others, we toss them */
do {
if (file_gets(seekLine, DAINTREE_MAX_LINE_SIZE, wth->random_fh) == NULL) {
- *err = file_error(wth->random_fh);
+ *err = file_error(wth->random_fh, err_info);
return FALSE; /* all done */
}
} while (seekLine[0] == COMMENT_LINE);
static guint parse_hex_dump(char* dump, guint8 *buf, char seperator, char end);
/* Seeks to the beginning of the next packet, and returns the
- byte offset. Returns -1 on failure, and sets "*err" to the error. */
-static gint64 dbs_etherwatch_seek_next_packet(wtap *wth, int *err)
+ byte offset. Returns -1 on failure, and sets "*err" to the error
+ and "*err_info" to null or an additional error string. */
+static gint64 dbs_etherwatch_seek_next_packet(wtap *wth, int *err,
+ gchar **err_info)
{
int byte;
unsigned int level = 0;
cur_off = file_tell(wth->fh);
if (cur_off == -1) {
/* Error. */
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return -1;
}
return cur_off + 1;
*err = 0;
} else {
/* We got an error. */
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
}
return -1;
}
* a DBS Ethertrace text trace file.
*
* Returns TRUE if it is, FALSE if it isn't or if we get an I/O error;
- * if we get an I/O error, "*err" will be set to a non-zero value.
+ * if we get an I/O error, "*err" will be set to a non-zero value and
+ * "*err_info" will be set to null or an error string.
*/
-static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err)
+static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err,
+ gchar **err_info)
{
char buf[DBS_ETHERWATCH_LINE_LENGTH];
int line, byte;
if (file_eof(wth->fh))
*err = 0;
else
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return FALSE;
}
}
}
-int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info _U_)
+int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info)
{
/* Look for DBS ETHERWATCH header */
- if (!dbs_etherwatch_check_file_type(wth, err)) {
+ if (!dbs_etherwatch_check_file_type(wth, err, err_info)) {
if (*err == 0)
return 0;
else
int pkt_len;
/* Find the next packet */
- offset = dbs_etherwatch_seek_next_packet(wth, err);
+ offset = dbs_etherwatch_seek_next_packet(wth, err, err_info);
if (offset < 1)
return FALSE;
* extract the useful information
*/
if (file_gets(line, DBS_ETHERWATCH_LINE_LENGTH, fh) == NULL) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
/* Read the next line of the record header */
if (file_gets(line, DBS_ETHERWATCH_LINE_LENGTH, fh) == NULL) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
count = 0;
while (count < pkt_len) {
if (file_gets(line, DBS_ETHERWATCH_LINE_LENGTH, fh) == NULL) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
* a DCT3 trace file.
*
* Returns TRUE if it is, FALSE if it isn't or if we get an I/O error;
- * if we get an I/O error, "*err" will be set to a non-zero value.
+ * if we get an I/O error, "*err" will be set to a non-zero value
+ * and "*err_info" will be set to null or an additional error string.
*/
-static gboolean dct3trace_check_file_type(wtap *wth, int *err)
+static gboolean dct3trace_check_file_type(wtap *wth, int *err, gchar **err_info)
{
char line1[64], line2[64];
if (file_eof(wth->fh))
*err = 0;
else
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
}
return FALSE;
}
-int dct3trace_open(wtap *wth, int *err, gchar **err_info _U_)
+int dct3trace_open(wtap *wth, int *err, gchar **err_info)
{
/* Look for Gammu DCT3 trace header */
- if (!dct3trace_check_file_type(wth, err))
+ if (!dct3trace_check_file_type(wth, err, err_info))
{
if (*err == 0)
return 0;
}
}
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
{
*err = WTAP_ERR_SHORT_READ;
union wtap_pseudo_header *pseudo_header, guchar *pd,
int length, int *err, gchar **err_info);
-extern int erf_open(wtap *wth, int *err, gchar **err_info _U_)
+extern int erf_open(wtap *wth, int *err, gchar **err_info)
{
int i, n, records_for_erf_check = RECORDS_FOR_ERF_CHECK;
int valid_prev = 0;
if (r == 0 ) break;
if (r != sizeof(header)) {
- if ((*err = file_error(wth->fh)) != 0) {
+ if ((*err = file_error(wth->fh, err_info)) != 0) {
return -1;
} else {
/* ERF header too short accept the file,
type = header.type;
while (type & 0x80){
if (file_read(&erf_ext_header, sizeof(erf_ext_header),wth->fh) != sizeof(erf_ext_header)) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return -1;
}
packet_size -= (guint32)sizeof(erf_ext_header);
case ERF_TYPE_COLOR_MC_HDLC_POS:
case ERF_TYPE_AAL2: /* not an MC type but has a similar 'AAL2 ext' header */
if (file_read(&mc_hdr,sizeof(mc_hdr),wth->fh) != sizeof(mc_hdr)) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return -1;
}
packet_size -= (guint32)sizeof(mc_hdr);
case ERF_TYPE_COLOR_ETH:
case ERF_TYPE_DSM_COLOR_ETH:
if (file_read(ð_hdr,sizeof(eth_hdr),wth->fh) != sizeof(eth_hdr)) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return -1;
}
packet_size -= (guint32)sizeof(eth_hdr);
buffer_assure_space(wth->frame_buffer, packet_size);
wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer),
- (gint32)(packet_size), wth->fh, err );
+ (gint32)(packet_size), wth->fh, err, err_info);
wth->data_offset += packet_size;
} while ( erf_header.type == ERF_TYPE_PAD );
return FALSE;
} while ( erf_header.type == ERF_TYPE_PAD );
- wtap_file_read_expected_bytes(pd, (int)packet_size, wth->random_fh, err);
+ wtap_file_read_expected_bytes(pd, (int)packet_size, wth->random_fh, err,
+ err_info);
return TRUE;
}
guint32 skiplen=0;
int i = 0 , max = sizeof(pseudo_header->erf.ehdr_list)/sizeof(struct erf_ehdr);
- wtap_file_read_expected_bytes(erf_header, sizeof(*erf_header), fh, err);
+ wtap_file_read_expected_bytes(erf_header, sizeof(*erf_header), fh, err,
+ err_info);
if (bytes_read != NULL) {
*bytes_read = sizeof(*erf_header);
}
/* Copy the ERF extension header into the pseudo header */
type = erf_header->type;
while (type & 0x80){
- wtap_file_read_expected_bytes(&erf_exhdr, sizeof(erf_exhdr), fh, err);
+ wtap_file_read_expected_bytes(&erf_exhdr, sizeof(erf_exhdr), fh, err,
+ err_info);
if (bytes_read != NULL)
*bytes_read += (guint32)sizeof(erf_exhdr);
*packet_size -= (guint32)sizeof(erf_exhdr);
case ERF_TYPE_ETH:
case ERF_TYPE_COLOR_ETH:
case ERF_TYPE_DSM_COLOR_ETH:
- wtap_file_read_expected_bytes(ð_hdr, sizeof(eth_hdr), fh, err);
+ wtap_file_read_expected_bytes(ð_hdr, sizeof(eth_hdr), fh, err,
+ err_info);
if (bytes_read != NULL)
*bytes_read += (guint32)sizeof(eth_hdr);
*packet_size -= (guint32)sizeof(eth_hdr);
case ERF_TYPE_MC_AAL2:
case ERF_TYPE_COLOR_MC_HDLC_POS:
case ERF_TYPE_AAL2: /* not an MC type but has a similar 'AAL2 ext' header */
- wtap_file_read_expected_bytes(&mc_hdr, sizeof(mc_hdr), fh, err);
+ wtap_file_read_expected_bytes(&mc_hdr, sizeof(mc_hdr), fh, err,
+ err_info);
if (bytes_read != NULL)
*bytes_read += (guint32)sizeof(mc_hdr);
*packet_size -= (guint32)sizeof(mc_hdr);
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info);
-int etherpeek_open(wtap *wth, int *err, gchar **err_info _U_)
+int etherpeek_open(wtap *wth, int *err, gchar **err_info)
{
etherpeek_header_t ep_hdr;
struct timeval reference_time;
*/
g_assert(sizeof(ep_hdr.master) == ETHERPEEK_MASTER_HDR_SIZE);
wtap_file_read_unknown_bytes(
- &ep_hdr.master, sizeof(ep_hdr.master), wth->fh, err);
+ &ep_hdr.master, sizeof(ep_hdr.master), wth->fh, err, err_info);
wth->data_offset += sizeof(ep_hdr.master);
/*
ETHERPEEK_V567_HDR_SIZE);
wtap_file_read_unknown_bytes(
&ep_hdr.secondary.v567,
- sizeof(ep_hdr.secondary.v567), wth->fh, err);
+ sizeof(ep_hdr.secondary.v567), wth->fh, err, err_info);
wth->data_offset += sizeof(ep_hdr.secondary.v567);
if ((0 != ep_hdr.secondary.v567.reserved[0]) ||
*data_offset = wth->data_offset;
- wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->fh, err);
+ wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->fh, err,
+ err_info);
wth->data_offset += sizeof(ep_pkt);
/* Extract the fields from the packet */
*err_info = g_strdup("etherpeek: packet not long enough for 802.11 radio header");
return FALSE;
}
- wtap_file_read_expected_bytes(&radio_hdr, 4, wth->fh, err);
+ wtap_file_read_expected_bytes(&radio_hdr, 4, wth->fh, err,
+ err_info);
/*
* We don't treat the radio information as packet data.
/* read the frame data */
buffer_assure_space(wth->frame_buffer, sliceLength);
wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer),
- sliceLength, wth->fh, err);
+ sliceLength, wth->fh, err, err_info);
wth->data_offset += sliceLength;
/* fill in packet header values */
/* Read the packet header. */
wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->random_fh,
- err);
+ err, err_info);
status = ep_pkt[ETHERPEEK_V7_STATUS_OFFSET];
switch (wth->file_encap) {
return FALSE;
}
wtap_file_read_expected_bytes(&radio_hdr, 4, wth->random_fh,
- err);
+ err, err_info);
etherpeek_fill_pseudo_header_v7(pseudo_header,
&radio_hdr);
* XXX - should "errno" be set in "wtap_file_read_expected_bytes()"?
*/
errno = WTAP_ERR_CANT_READ;
- wtap_file_read_expected_bytes(pd, length, wth->random_fh, err);
+ wtap_file_read_expected_bytes(pd, length, wth->random_fh, err,
+ err_info);
return TRUE;
}
pseudo_header->ieee_802_11.signal_level = radio_hdr->signal_level;
}
-static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_,
+static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
etherpeek_t *etherpeek = (etherpeek_t *)wth->priv;
*/
*data_offset = wth->data_offset;
- wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->fh, err);
+ wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->fh, err,
+ err_info);
wth->data_offset += sizeof(ep_pkt);
/* Extract the fields from the packet */
/* read the frame data */
buffer_assure_space(wth->frame_buffer, sliceLength);
wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer),
- sliceLength, wth->fh, err);
+ sliceLength, wth->fh, err, err_info);
wth->data_offset += sliceLength;
/* fill in packet header values */
static gboolean
etherpeek_seek_read_v56(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)
{
guchar ep_pkt[ETHERPEEK_V56_PKT_SIZE];
int pkt_encap;
return FALSE;
wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->random_fh,
- err);
+ err, err_info);
protoNum = pntohs(&ep_pkt[ETHERPEEK_V56_PROTONUM_OFFSET]);
pkt_encap = WTAP_ENCAP_UNKNOWN;
* XXX - should "errno" be set in "wtap_file_read_expected_bytes()"?
*/
errno = WTAP_ERR_CANT_READ;
- wtap_file_read_expected_bytes(pd, length, wth->random_fh, err);
+ wtap_file_read_expected_bytes(pd, length, wth->random_fh, err,
+ err_info);
return TRUE;
}
union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
/* Seeks to the beginning of the next packet, and returns the
- byte offset. Returns -1 on failure, and sets "*err" to the error. */
-static gint64 eyesdn_seek_next_packet(wtap *wth, int *err)
+ byte offset. Returns -1 on failure, and sets "*err" to the error
+ and "*err_info" to null or an additional error string. */
+static gint64 eyesdn_seek_next_packet(wtap *wth, int *err, gchar **err_info)
{
int byte;
gint64 cur_off;
cur_off = file_tell(wth->fh);
if (cur_off == -1) {
/* Error. */
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return -1;
}
return cur_off;
*err = 0;
} else {
/* We got an error. */
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
}
return -1;
}
-int eyesdn_open(wtap *wth, int *err, gchar **err_info _U_)
+int eyesdn_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
char magic[EYESDN_HDR_MAGIC_SIZE];
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;
int pkt_len;
/* Find the next packet */
- offset = eyesdn_seek_next_packet(wth, err);
+ offset = eyesdn_seek_next_packet(wth, err, err_info);
if (offset < 1)
return FALSE;
* information.
*/
if (esc_read(hdr, EYESDN_HDR_LENGTH, fh) != EYESDN_HDR_LENGTH) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return -1;
cur_off = file_tell(fh);
if (esc_read(cell, CELL_LEN, fh) != CELL_LEN) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return -1;
bytes_read = esc_read(buf, pkt_len, fh);
if (bytes_read != pkt_len) {
if (bytes_read == -2) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
} else if (bytes_read == -1) {
int seek; /* true if seek request pending */
/* error information */
int err; /* error code */
+ char *err_info; /* additional error information string for some errors */
unsigned int avail_in; /* number of bytes available at next_in */
unsigned char *next_in; /* next input byte */
if (state->avail_in == 0 && fill_in_buffer(state) == -1)
break;
if (state->avail_in == 0) {
- state->err = WTAP_ERR_ZLIB + Z_DATA_ERROR;
+ /* EOF */
+ state->err = WTAP_ERR_SHORT_READ;
break;
}
ret = inflate(strm, Z_BLOCK);
state->avail_in = strm->avail_in;
state->next_in = strm->next_in;
- if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {
- state->err = WTAP_ERR_ZLIB + Z_STREAM_ERROR;
+ if (ret == Z_STREAM_ERROR) {
+ state->err = WTAP_ERR_DECOMPRESS;
+ state->err_info = strm->msg;
+ break;
+ }
+ if (ret == Z_NEED_DICT) {
+ state->err = WTAP_ERR_DECOMPRESS;
+ state->err_info = "preset dictionary needed";
break;
}
if (ret == Z_MEM_ERROR) {
break;
}
if (ret == Z_DATA_ERROR) { /* deflate stream invalid */
- state->err = WTAP_ERR_ZLIB + Z_DATA_ERROR;
+ state->err = WTAP_ERR_DECOMPRESS;
+ state->err_info = strm->msg;
break;
}
/*
if (ret == Z_STREAM_END) {
if (gz_next4(state, &crc) != -1 &&
gz_next4(state, &len) != -1) {
- if (crc != strm->adler)
- state->err = WTAP_ERR_ZLIB + Z_DATA_ERROR;
- if (len != (strm->total_out & 0xffffffffL))
- state->err = WTAP_ERR_ZLIB + Z_DATA_ERROR;
+ if (crc != strm->adler) {
+ state->err = WTAP_ERR_DECOMPRESS;
+ state->err_info = "bad CRC";
+ } else if (len != (strm->total_out & 0xffffffffL)) {
+ state->err = WTAP_ERR_DECOMPRESS;
+ state->err_info = "length field wrong";
+ }
}
state->compression = UNKNOWN; /* ready for next stream, once have is 0 */
g_free(state->fast_seek_cur);
if (gz_next1(state, &cm) == -1)
return -1;
if (cm != 8) {
- state->err = WTAP_ERR_ZLIB + Z_DATA_ERROR;
+ state->err = WTAP_ERR_DECOMPRESS;
+ state->err_info = "unknown compression method";
return -1;
}
if (gz_next1(state, &flags) == -1)
return -1;
if (flags & 0xe0) { /* reserved flag bits */
- state->err = WTAP_ERR_ZLIB + Z_DATA_ERROR;
+ state->err = WTAP_ERR_DECOMPRESS;
+ state->err_info = "reserved flag bits set";
return -1;
}
state->seek = 0; /* no seek request pending */
state->err = 0; /* clear error */
+ state->err_info = NULL;
state->pos = 0; /* no uncompressed data yet */
state->avail_in = 0; /* no input data yet */
}
file->eof = 0;
file->seek = 0;
file->err = 0;
+ file->err_info = NULL;
file->avail_in = 0;
#ifdef HAVE_LIBZ
file->eof = 0;
file->seek = 0;
file->err = 0;
+ file->err_info = NULL;
file->avail_in = 0;
file->pos += offset;
return file->pos;
/*
* Routine to return a Wiretap error code (0 for no error, an errno
* for a file error, or a WTAP_ERR_ code for other errors) for an
- * I/O stream.
+ * I/O stream. Also returns an error string for some errors.
*/
int
-file_error(FILE_T fh)
+file_error(FILE_T fh, gchar **err_info)
{
- return fh->err;
+ if (fh->err != 0) {
+ *err_info = (fh->err_info == NULL) ? NULL : g_strdup(fh->err_info);
+ return fh->err;
+ }
+ return 0;
}
void
{
/* clear error and end-of-file */
stream->err = 0;
+ stream->err_info = NULL;
stream->eof = 0;
}
}
g_free(file->fast_seek_cur);
file->err = 0;
+ file->err_info = NULL;
g_free(file);
return close(fd);
}
extern gint64 file_seek(FILE_T stream, gint64 offset, int whence, int *err);
extern gint64 file_tell(FILE_T stream);
-extern int file_error(FILE_T fh);
+extern int file_error(FILE_T fh, gchar **err_info);
extern FILE_T file_open(const char *path);
extern FILE_T filed_open(int fildes);
bytes_read = file_read(&dh, DUMP_HDR_SIZE, wth->fh);
if (bytes_read != DUMP_HDR_SIZE) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
bytes_read = file_read(buf, packet_size, wth->fh);
if (bytes_read != packet_size) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guint8 *pd, int length,
- int *err, gchar **err_info _U_)
+ int *err, gchar **err_info)
{
struct dump_hdr dh;
int bytes_read;
bytes_read = file_read(&dh, DUMP_HDR_SIZE, wth->random_fh);
if (bytes_read != DUMP_HDR_SIZE) {
- *err = file_error(wth->random_fh);
+ *err = file_error(wth->random_fh, err_info);
if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
bytes_read = file_read(pd, length, wth->random_fh);
if (bytes_read != length) {
- *err = file_error(wth->random_fh);
+ *err = file_error(wth->random_fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
return TRUE;
}
-int hcidump_open(wtap *wth, int *err, gchar **err_info _U_)
+int hcidump_open(wtap *wth, int *err, gchar **err_info)
{
struct dump_hdr dh;
guint8 type;
bytes_read = file_read(&dh, DUMP_HDR_SIZE, wth->fh);
if (bytes_read != DUMP_HDR_SIZE) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return (*err != 0) ? -1 : 0;
}
bytes_read = file_read(&type, 1, wth->fh);
if (bytes_read != 1) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return (*err != 0) ? -1 : 0;
}
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);
(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;
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;
/* 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;
*/
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;
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;
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) {
/*
* 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) {
}
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;
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;
static gboolean
ipfix_read_message_header(ipfix_message_header_t *pfx_hdr, FILE_T fh, int *err, gchar **err_info)
{
- wtap_file_read_expected_bytes(pfx_hdr, IPFIX_MSG_HDR_SIZE, fh, err); /* macro which does a return if read fails */
+ wtap_file_read_expected_bytes(pfx_hdr, IPFIX_MSG_HDR_SIZE, fh, err, err_info); /* macro which does a return if read fails */
/* fix endianess, because IPFIX files are always big-endian */
pfx_hdr->version = g_ntohs(pfx_hdr->version);
/* check each Set in IPFIX Message for sanity */
while (checked_len < msg_hdr.message_length) {
- wtap_file_read_expected_bytes(&set_hdr, IPFIX_SET_HDR_SIZE, wth->fh, err);
+ wtap_file_read_expected_bytes(&set_hdr, IPFIX_SET_HDR_SIZE, wth->fh, err, err_info);
set_hdr.set_length = g_ntohs(set_hdr.set_length);
if ((set_hdr.set_length < IPFIX_SET_HDR_SIZE) ||
((set_hdr.set_length + checked_len) > msg_hdr.message_length)) {
buffer_assure_space(wth->frame_buffer, msg_hdr.message_length);
wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer),
- msg_hdr.message_length, wth->fh, err);
+ msg_hdr.message_length, wth->fh, err, err_info);
wth->phdr.len = msg_hdr.message_length;
wth->phdr.caplen = msg_hdr.message_length;
return FALSE;
}
- wtap_file_read_expected_bytes(pd, length, wth->random_fh, err);
+ wtap_file_read_expected_bytes(pd, length, wth->random_fh, err, err_info);
return TRUE;
}
int *err, gchar **err_info);
static int iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len,
- int *err);
+ int *err, gchar **err_info);
static gboolean iptrace_read_rec_data(FILE_T fh, guint8 *data_ptr,
- int packet_size, int *err);
+ int packet_size, int *err, gchar **err_info);
static void fill_in_pseudo_header(int encap, const guint8 *pd, guint32 len,
union wtap_pseudo_header *pseudo_header, guint8 *header);
static int wtap_encap_ift(unsigned int ift);
-int iptrace_open(wtap *wth, int *err, gchar **err_info _U_)
+int iptrace_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
char name[12];
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(name, 11, wth->fh);
if (bytes_read != 11) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
#define IPTRACE_1_0_PDATA_SIZE 22 /* packet data */
/* Read the next packet */
-static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info _U_,
+static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
int ret;
/* Read the descriptor data */
*data_offset = wth->data_offset;
ret = iptrace_read_rec_header(wth->fh, header, IPTRACE_1_0_PHDR_SIZE,
- err);
+ err, err_info);
if (ret <= 0) {
/* Read error or EOF */
return FALSE;
/*
* Read the padding.
*/
- if (!iptrace_read_rec_data(wth->fh, fddi_padding, 3, err))
+ if (!iptrace_read_rec_data(wth->fh, fddi_padding, 3, err,
+ err_info))
return FALSE; /* Read error */
}
buffer_assure_space( wth->frame_buffer, packet_size );
data_ptr = buffer_start_ptr( wth->frame_buffer );
- if (!iptrace_read_rec_data(wth->fh, data_ptr, packet_size, err))
+ if (!iptrace_read_rec_data(wth->fh, data_ptr, packet_size, err,
+ err_info))
return FALSE; /* Read error */
wth->data_offset += packet_size;
static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
- int *err, gchar **err_info _U_)
+ int *err, gchar **err_info)
{
int ret;
guint8 header[IPTRACE_1_0_PHDR_SIZE];
/* Read the descriptor data */
ret = iptrace_read_rec_header(wth->random_fh, header,
- IPTRACE_1_0_PHDR_SIZE, err);
+ IPTRACE_1_0_PHDR_SIZE, err, err_info);
if (ret <= 0) {
/* Read error or EOF */
if (ret == 0) {
/*
* Read the padding.
*/
- if (!iptrace_read_rec_data(wth->random_fh, fddi_padding, 3, err))
+ if (!iptrace_read_rec_data(wth->random_fh, fddi_padding, 3,
+ err, err_info))
return FALSE; /* Read error */
}
/* Get the packet data */
- if (!iptrace_read_rec_data(wth->random_fh, pd, packet_size, err))
+ if (!iptrace_read_rec_data(wth->random_fh, pd, packet_size, err,
+ err_info))
return FALSE;
/* Fill in the pseudo_header. */
#define IPTRACE_2_0_PDATA_SIZE 32 /* packet data */
/* Read the next packet */
-static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info _U_,
+static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
int ret;
/* Read the descriptor data */
*data_offset = wth->data_offset;
ret = iptrace_read_rec_header(wth->fh, header, IPTRACE_2_0_PHDR_SIZE,
- err);
+ err, err_info);
if (ret <= 0) {
/* Read error or EOF */
return FALSE;
/*
* Read the padding.
*/
- if (!iptrace_read_rec_data(wth->fh, fddi_padding, 3, err))
+ if (!iptrace_read_rec_data(wth->fh, fddi_padding, 3, err,
+ err_info))
return FALSE; /* Read error */
}
buffer_assure_space( wth->frame_buffer, packet_size );
data_ptr = buffer_start_ptr( wth->frame_buffer );
- if (!iptrace_read_rec_data(wth->fh, data_ptr, packet_size, err))
+ if (!iptrace_read_rec_data(wth->fh, data_ptr, packet_size, err,
+ err_info))
return FALSE; /* Read error */
wth->data_offset += packet_size;
static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
- int *err, gchar **err_info _U_)
+ int *err, gchar **err_info)
{
int ret;
guint8 header[IPTRACE_2_0_PHDR_SIZE];
/* Read the descriptor data */
ret = iptrace_read_rec_header(wth->random_fh, header,
- IPTRACE_2_0_PHDR_SIZE, err);
+ IPTRACE_2_0_PHDR_SIZE, err, err_info);
if (ret <= 0) {
/* Read error or EOF */
if (ret == 0) {
/*
* Read the padding.
*/
- if (!iptrace_read_rec_data(wth->random_fh, fddi_padding, 3, err))
+ if (!iptrace_read_rec_data(wth->random_fh, fddi_padding, 3,
+ err, err_info))
return FALSE; /* Read error */
}
/* Get the packet data */
- if (!iptrace_read_rec_data(wth->random_fh, pd, packet_size, err))
+ if (!iptrace_read_rec_data(wth->random_fh, pd, packet_size, err,
+ err_info))
return FALSE;
/* Fill in the pseudo-header. */
}
static int
-iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len, int *err)
+iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len, int *err,
+ gchar **err_info)
{
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(header, header_len, fh);
if (bytes_read != header_len) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err != 0)
return -1;
if (bytes_read != 0) {
}
static gboolean
-iptrace_read_rec_data(FILE_T fh, guint8 *data_ptr, int packet_size, int *err)
+iptrace_read_rec_data(FILE_T fh, guint8 *data_ptr, int packet_size, int *err,
+ gchar **err_info)
{
int bytes_read;
bytes_read = file_read( data_ptr, packet_size, fh );
if (bytes_read != packet_size) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
union wtap_pseudo_header *pseudo_header,
guint8 * pd, int len, int *err,
gchar ** err_info);
-static gboolean iseries_check_file_type (wtap * wth, int *err, int format);
-static gint64 iseries_seek_next_packet (wtap * wth, int *err);
+static gboolean iseries_check_file_type (wtap * wth, int *err, gchar **err_info,
+ int format);
+static gint64 iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info);
static int iseries_parse_packet (wtap * wth, FILE_T fh,
union wtap_pseudo_header *pseudo_header,
guint8 * pd, int *err, gchar ** err_info);
int len);
int
-iseries_open (wtap * wth, int *err, gchar ** err_info _U_)
+iseries_open (wtap * wth, int *err, gchar ** err_info)
{
int bytes_read;
char magic[ISERIES_HDR_MAGIC_LEN];
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;
* Do some basic sanity checking to ensure we can handle the
* contents of this trace
*/
- if (!iseries_check_file_type (wth, err, ISERIES_FORMAT_ASCII))
+ if (!iseries_check_file_type (wth, err, err_info, ISERIES_FORMAT_ASCII))
{
if (*err == 0)
return 0;
* Do some basic sanity checking to ensure we can handle the
* contents of this trace
*/
- if (!iseries_check_file_type (wth, err, ISERIES_FORMAT_UNICODE))
+ if (!iseries_check_file_type (wth, err, err_info, ISERIES_FORMAT_UNICODE))
{
if (*err == 0)
return 0;
* requisit requirements and additional information.
*/
static gboolean
-iseries_check_file_type (wtap * wth, int *err, int format)
+iseries_check_file_type (wtap * wth, int *err, gchar **err_info, int format)
{
guint line;
int num_items_scanned;
if (file_eof (wth->fh))
*err = 0;
else
- *err = file_error (wth->fh);
+ *err = file_error (wth->fh, err_info);
return FALSE;
}
}
/*
* Locate the next packet
*/
- offset = iseries_seek_next_packet (wth, err);
+ offset = iseries_seek_next_packet (wth, err, err_info);
if (offset < 1)
return FALSE;
/*
* Seeks to the beginning of the next packet, and returns the
- * byte offset. Returns -1 on failure, and sets "*err" to the error.
+ * byte offset. Returns -1 on failure, and sets "*err" to the error
+ * and "*err_info" to null or an additional error string.
*/
static gint64
-iseries_seek_next_packet (wtap * wth, int *err)
+iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info)
{
iseries_t *iseries = (iseries_t *)wth->priv;
char buf[ISERIES_LINE_LENGTH];
/*
* Seeks to the beginning of the next packet, and returns the
- * byte offset. Returns -1 on failure, and sets "*err" to the error.
+ * byte offset. Returns -1 on failure, and sets "*err" to the error
+ * and "*err_info" to null or an additional error string.
*/
for (line = 0; line < ISERIES_MAX_TRACE_LEN; line++)
{
cur_off = file_tell (wth->fh);
if (cur_off == -1)
{
- *err = file_error (wth->fh);
+ *err = file_error (wth->fh, err_info);
return -1;
}
if (file_seek (wth->fh, cur_off - buflen, SEEK_SET, err) == -1)
else
{
/* We got an error. */
- *err = file_error (wth->fh);
+ *err = file_error (wth->fh, err_info);
}
return -1;
}
cur_off = file_tell (fh);
if (file_gets (data, ISERIES_LINE_LENGTH, fh) == NULL)
{
- *err = file_error (fh);
+ *err = file_error (fh, err_info);
if (*err == 0)
{
*err = WTAP_ERR_SHORT_READ;
}
else
{
- *err = file_error (fh);
+ *err = file_error (fh, err_info);
if (*err == 0)
{
*err = WTAP_ERR_SHORT_READ;
if (cur_off == -1)
{
/* Error. */
- *err = file_error (fh);
+ *err = file_error (fh, err_info);
return -1;
}
if (file_seek (fh, cur_off - buflen, SEEK_SET, err) == -1)
buffer_assure_space(wth->frame_buffer, packet_size);
buf = buffer_start_ptr(wth->frame_buffer);
- wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err);
+ wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err, err_info);
wth->data_offset += packet_size;
return FALSE;
}
- wtap_file_read_expected_bytes(pd, packet_size, wth->random_fh, err);
+ wtap_file_read_expected_bytes(pd, packet_size, wth->random_fh, err,
+ err_info);
*err = 0;
*err_info = NULL;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic_buf, sizeof(magic_buf), wth->fh);
if (bytes_read != (int) sizeof(magic_buf)) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0) {
*err_info = NULL;
ret = -1;
return 0;
} else if ( bytes_read < 0x14 ){
K12_DBG(1,("get_record: SHORT READ OR ERROR"));
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
return 0;
} else if ( bytes_read != 0x4 ) {
K12_DBG(1,("get_record: SHORT READ OR ERROR"));
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
if ( last_read != left ) {
K12_DBG(1,("get_record: SHORT READ OR ERROR"));
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
if ( last_read != junky_offset ) {
K12_DBG(1,("get_record: SHORT READ OR ERROR, read=%d expected=%d",last_read, junky_offset));
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
if ( last_read != 0x10 ) {
K12_DBG(1,("get_record: SHORT READ OR ERROR"));
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
if ( file_read(header_buffer,0x200,wth->fh) != 0x200 ) {
K12_DBG(1,("k12_open: FILE HEADER TOO SHORT OR READ ERROR"));
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0) {
return -1;
}
bytes_read = file_read(LE_record_type, 2, wth->fh);
bytes_read += file_read(LE_record_length, 2, wth->fh);
if (bytes_read != 4) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
bytes_read = file_read(LE_record_type, 2, wth->fh);
bytes_read += file_read(LE_record_length, 2, wth->fh);
if (bytes_read != 4) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0) {
g_free(wth->priv);
return -1;
bytes_read = file_read(summary, sizeof summary,
wth->fh);
if (bytes_read != sizeof summary) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0) {
g_free(wth->priv);
return -1;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(LE_record_type, 2, wth->fh);
if (bytes_read != 2) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) {
*err = WTAP_ERR_SHORT_READ;
}
wth->data_offset += 2;
bytes_read = file_read(LE_record_length, 2, wth->fh);
if (bytes_read != 2) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(descriptor, DESCRIPTOR_LEN, wth->fh);
if (bytes_read != DESCRIPTOR_LEN) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
packet_size, wth->fh);
if (bytes_read != packet_size) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
static gboolean lanalyzer_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 bytes_read;
*/
bytes_read = file_read(pd, length, wth->random_fh);
if (bytes_read != length) {
- *err = file_error(wth->random_fh);
+ *err = file_error(wth->random_fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
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);
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;
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;
/*
* 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 */
}
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;
/*
* 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) {
}
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;
}
}
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;
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;
}
static int
-mpeg_read_header(wtap *wth, int *err, gchar **err_info _U_,
- guint32 *n)
+mpeg_read_header(wtap *wth, int *err, gchar **err_info, guint32 *n)
{
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(n, sizeof *n, wth->fh);
if (bytes_read != sizeof *n) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ;
return -1;
}
static gboolean
-mpeg_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
+mpeg_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
+ gchar **err_info)
{
int bytes_read;
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;
#define SCRHZ 27000000
static gboolean
-mpeg_read(wtap *wth, int *err, gchar **err_info _U_,
- gint64 *data_offset)
+mpeg_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
mpeg_t *mpeg = (mpeg_t *)wth->priv;
guint32 n;
bytes_read = file_read(&stream, sizeof stream, wth->fh);
if (bytes_read != sizeof stream) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return FALSE;
}
bytes_read = file_read(&pack1, sizeof pack1, wth->fh);
if (bytes_read != sizeof pack1) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
}
bytes_read = file_read(&pack0, sizeof pack0, wth->fh);
if (bytes_read != sizeof pack0) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
bytes_read = file_read(&stuffing,
sizeof stuffing, wth->fh);
if (bytes_read != sizeof stuffing) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return FALSE;
}
stuffing &= 0x07;
guint16 length;
bytes_read = file_read(&length, sizeof length, wth->fh);
if (bytes_read != sizeof length) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
buffer_assure_space(wth->frame_buffer, packet_size);
if (!mpeg_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer),
- packet_size, err))
+ packet_size, err, err_info))
return FALSE;
wth->data_offset += packet_size;
wth->phdr.ts = ts;
static gboolean
mpeg_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header _U_, 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;
- return mpeg_read_rec_data(wth->random_fh, pd, length, err);
+ return mpeg_read_rec_data(wth->random_fh, pd, length, err, err_info);
}
struct _mpeg_magic {
};
int
-mpeg_open(wtap *wth, int *err, gchar **err_info _U_)
+mpeg_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
char magic_buf[16];
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic_buf, sizeof magic_buf, wth->fh);
if (bytes_read != (int) sizeof magic_buf) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info);
static gboolean netmon_read_atm_pseudoheader(FILE_T fh,
- union wtap_pseudo_header *pseudo_header, int *err);
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
static gboolean netmon_read_rec_data(FILE_T fh, guchar *pd, int length,
- int *err);
+ int *err, gchar **err_info);
static void netmon_sequential_close(wtap *wth);
static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
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;
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;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(frame_table, frame_table_length, wth->fh);
if ((guint32)bytes_read != frame_table_length) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
g_free(frame_table);
bytes_read = file_read(&hdr, hdr_size, wth->fh);
if (bytes_read != hdr_size) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) {
*err = WTAP_ERR_SHORT_READ;
}
return FALSE;
}
if (!netmon_read_atm_pseudoheader(wth->fh, &wth->pseudo_header,
- err))
+ err, err_info))
return FALSE; /* Read error */
/*
buffer_assure_space(wth->frame_buffer, packet_size);
data_ptr = buffer_start_ptr(wth->frame_buffer);
- if (!netmon_read_rec_data(wth->fh, data_ptr, packet_size, err))
+ if (!netmon_read_rec_data(wth->fh, data_ptr, packet_size, err,
+ err_info))
return FALSE; /* Read error */
wth->data_offset += packet_size;
bytes_read = file_read(&trlr, trlr_size, wth->fh);
if (bytes_read != trlr_size) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0) {
*err = WTAP_ERR_SHORT_READ;
}
static gboolean
netmon_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;
case WTAP_ENCAP_ATM_PDUS:
if (!netmon_read_atm_pseudoheader(wth->random_fh, pseudo_header,
- err)) {
+ err, err_info)) {
/* Read error */
return FALSE;
}
/*
* Read the packet data.
*/
- if (!netmon_read_rec_data(wth->random_fh, pd, length, err))
+ if (!netmon_read_rec_data(wth->random_fh, pd, length, err, err_info))
return FALSE;
/*
static gboolean
netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
- int *err)
+ int *err, gchar **err_info)
{
struct netmon_atm_hdr atm_phdr;
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&atm_phdr, sizeof (struct netmon_atm_hdr), fh);
if (bytes_read != sizeof (struct netmon_atm_hdr)) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
}
static gboolean
-netmon_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
+netmon_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
+ gchar **err_info)
{
int bytes_read;
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;
gboolean nstrace_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);
void nstrace_close(wtap *wth);
void nstrace_sequential_close(wtap *wth);
if ((file_seek(wth->fh, 0, SEEK_SET, err)) == -1)
{
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
g_free(nstrace_buf);
return 0;
}
bytes_read = file_read(nstrace_buf, page_size, wth->fh);
if (bytes_read != page_size)
{
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
g_free(nstrace_buf);
return 0;
}
/* Reset the read pointer to start of the file. */
if ((file_seek(wth->fh, 0, SEEK_SET, err)) == -1)
{
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
g_free(nstrace->pnstrace_buf);
g_free(nstrace);
return 0;
bytes_read = file_read(nstrace_buf, page_size, wth->fh);
if (bytes_read != page_size)
{
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
g_free(nstrace->pnstrace_buf);
g_free(nstrace);
return 0;
gboolean nstrace_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 bytes_read;
** Read the packet data.
*/
bytes_read = file_read(pd, length, wth->random_fh);
- if (bytes_read != length)
+ if (bytes_read != length) {
+ *err = file_error(wth->random_fh, err_info);
+ if (*err == 0)
+ *err = WTAP_ERR_SHORT_READ;
return FALSE;
+ }
if (wth->file_type == WTAP_FILE_NETSCALER_1_0)
{
static gboolean empty_line(const gchar *line);
static gboolean info_line(const gchar *line);
-static gint64 netscreen_seek_next_packet(wtap *wth, int *err, char *hdr);
-static gboolean netscreen_check_file_type(wtap *wth, int *err);
+static gint64 netscreen_seek_next_packet(wtap *wth, int *err, gchar **err_info,
+ char *hdr);
+static gboolean netscreen_check_file_type(wtap *wth, int *err,
+ gchar **err_info);
static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean netscreen_seek_read(wtap *wth, gint64 seek_off,
/* Seeks to the beginning of the next packet, and returns the
byte offset. Copy the header line to hdr. Returns -1 on failure,
- and sets "*err" to the error and set hdr as NULL. */
-static gint64 netscreen_seek_next_packet(wtap *wth, int *err, char *hdr)
+ and sets "*err" to the error, sets "*err_info" to null or an
+ additional error string, and sets hdr to NULL. */
+static gint64 netscreen_seek_next_packet(wtap *wth, int *err, gchar **err_info,
+ char *hdr)
{
gint64 cur_off;
char buf[NETSCREEN_LINE_LENGTH];
cur_off = file_tell(wth->fh);
if (cur_off == -1) {
/* Error */
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
hdr = NULL;
return -1;
}
*err = 0;
} else {
/* We got an error. */
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
}
break;
}
* NetScreen snoop output.
*
* Returns TRUE if it is, FALSE if it isn't or if we get an I/O error;
- * if we get an I/O error, "*err" will be set to a non-zero value.
+ * if we get an I/O error, "*err" will be set to a non-zero value and
+ * "*err_info" is set to null or an additional error string.
*/
-static gboolean netscreen_check_file_type(wtap *wth, int *err)
+static gboolean netscreen_check_file_type(wtap *wth, int *err, gchar **err_info)
{
char buf[NETSCREEN_LINE_LENGTH];
guint reclen, line;
if (file_eof(wth->fh))
*err = 0;
else
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return FALSE;
}
}
}
-int netscreen_open(wtap *wth, int *err, gchar **err_info _U_)
+int netscreen_open(wtap *wth, int *err, gchar **err_info)
{
/* Look for a NetScreen snoop header line */
- if (!netscreen_check_file_type(wth, err)) {
+ if (!netscreen_check_file_type(wth, err, err_info)) {
if (*err == 0)
return 0;
else
gchar dststr[13];
/* Find the next packet */
- offset = netscreen_seek_next_packet(wth, err, line);
+ offset = netscreen_seek_next_packet(wth, err, err_info, line);
if (offset < 0)
return FALSE;
}
if (file_gets(line, NETSCREEN_LINE_LENGTH, wth->random_fh) == NULL) {
- *err = file_error(wth->random_fh);
+ *err = file_error(wth->random_fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
struct wtap_pkthdr *phdr, union wtap_pseudo_header *pseudo_header,
int *err, gchar **err_info, gboolean *fddihack);
static gboolean nettl_read_rec_data(FILE_T fh, guchar *pd, int length,
- int *err, gboolean fddihack);
+ int *err, gchar **err_info, gboolean fddihack);
static gboolean nettl_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
-int nettl_open(wtap *wth, int *err, gchar **err_info _U_)
+int nettl_open(wtap *wth, int *err, gchar **err_info)
{
struct nettl_file_hdr file_hdr;
guint16 dummy[2];
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(file_hdr.magic, MAGIC_SIZE, wth->fh);
if (bytes_read != MAGIC_SIZE) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
bytes_read = file_read(file_hdr.file_name, FILE_HDR_SIZE - MAGIC_SIZE,
wth->fh);
if (bytes_read != FILE_HDR_SIZE - MAGIC_SIZE) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
*/
buffer_assure_space(wth->frame_buffer, wth->phdr.caplen);
if (!nettl_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer),
- wth->phdr.caplen, err, fddihack))
+ wth->phdr.caplen, err, err_info, fddihack))
return FALSE; /* Read error */
wth->data_offset += wth->phdr.caplen;
return TRUE;
/*
* Read the packet data.
*/
- return nettl_read_rec_data(wth->random_fh, pd, length, err, fddihack);
+ return nettl_read_rec_data(wth->random_fh, pd, length, err, err_info,
+ fddihack);
}
static int
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&rec_hdr.hdr_len, sizeof rec_hdr.hdr_len, fh);
if (bytes_read != sizeof rec_hdr.hdr_len) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err != 0)
return -1;
if (bytes_read != 0) {
}
bytes_read = file_read(&rec_hdr.subsys, NETTL_REC_HDR_LEN - 2, fh);
if (bytes_read != NETTL_REC_HDR_LEN - 2) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return -1;
/* outbound appears to have variable padding */
bytes_read = file_read(dummyc, 9, fh);
if (bytes_read != 9) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return -1;
phdr->pkt_encap = WTAP_ENCAP_NETTL_ETHERNET;
bytes_read = file_read(&drv_eth_hdr, NS_LS_DRV_ETH_HDR_LEN, fh);
if (bytes_read != NS_LS_DRV_ETH_HDR_LEN) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return -1;
}
static gboolean
-nettl_read_rec_data(FILE_T fh, guchar *pd, int length, int *err, gboolean fddihack)
+nettl_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
+ gchar **err_info, gboolean fddihack)
{
int bytes_read;
guchar *p=NULL;
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;
/* read in the buffer file header */
bytes_read = file_read(&file_header, sizeof file_header, wth->fh);
if (bytes_read != sizeof file_header) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
/* read the TLV header */
bytes_read = file_read(&tlvh, sizeof tlvh, wth->fh);
if (bytes_read != sizeof tlvh) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return -1;
/* pull off the packet header */
bytes_read = file_read(&packet_header, sizeof packet_header, wth->fh);
if (bytes_read != sizeof packet_header) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
/* pull off the packet header */
bytes_read = file_read(packet_header, sizeof *packet_header, fh);
if (bytes_read != sizeof *packet_header) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err != 0)
return -1;
return 0; /* EOF */
/* read the TLV header */
bytes_read = file_read(&tlvh, sizeof tlvh, fh);
if (bytes_read != sizeof tlvh) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return -1;
}
/* read in the packet */
- wtap_file_read_expected_bytes(pd, length, fh, err);
+ wtap_file_read_expected_bytes(pd, length, fh, err, err_info);
return TRUE;
}
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info);
static int netxray_read_rec_header(wtap *wth, FILE_T fh,
- union netxrayrec_hdr *hdr, int *err);
+ union netxrayrec_hdr *hdr, int *err, gchar **err_info);
static guint netxray_set_pseudo_header(wtap *wth, const guint8 *pd, int len,
union wtap_pseudo_header *pseudo_header, union netxrayrec_hdr *hdr);
static gboolean netxray_read_rec_data(FILE_T fh, guint8 *data_ptr,
- guint32 packet_size, int *err);
+ guint32 packet_size, int *err, gchar **err_info);
static gboolean netxray_dump_1_1(wtap_dumper *wdh,
const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
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;
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;
}
/* Read the next packet */
-static gboolean netxray_read(wtap *wth, int *err, gchar **err_info _U_,
+static gboolean netxray_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
netxray_t *netxray = (netxray_t *)wth->priv;
return FALSE;
}
/* Read record header. */
- hdr_size = netxray_read_rec_header(wth, wth->fh, &hdr, err);
+ hdr_size = netxray_read_rec_header(wth, wth->fh, &hdr, err, err_info);
if (hdr_size == 0) {
/*
* Error or EOF.
packet_size = pletohs(&hdr.hdr_1_x.incl_len);
buffer_assure_space(wth->frame_buffer, packet_size);
pd = buffer_start_ptr(wth->frame_buffer);
- if (!netxray_read_rec_data(wth->fh, pd, packet_size, err))
+ if (!netxray_read_rec_data(wth->fh, pd, packet_size, err, err_info))
return FALSE;
wth->data_offset += packet_size;
static gboolean
netxray_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)
{
union netxrayrec_hdr hdr;
gboolean ret;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
- if (!netxray_read_rec_header(wth, wth->random_fh, &hdr, err)) {
+ if (!netxray_read_rec_header(wth, wth->random_fh, &hdr, err,
+ err_info)) {
if (*err == 0) {
/*
* EOF - we report that as a short read, as
/*
* Read the packet data.
*/
- ret = netxray_read_rec_data(wth->random_fh, pd, length, err);
+ ret = netxray_read_rec_data(wth->random_fh, pd, length, err, err_info);
if (!ret)
return FALSE;
static int
netxray_read_rec_header(wtap *wth, FILE_T fh, union netxrayrec_hdr *hdr,
- int *err)
+ int *err, gchar **err_info)
{
netxray_t *netxray = (netxray_t *)wth->priv;
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(hdr, hdr_size, fh);
if (bytes_read != hdr_size) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return 0;
if (bytes_read != 0) {
static gboolean
netxray_read_rec_data(FILE_T fh, guint8 *data_ptr, guint32 packet_size,
- int *err)
+ int *err, gchar **err_info)
{
int bytes_read;
bytes_read = file_read(data_ptr, packet_size, fh);
if (bytes_read <= 0 || (guint32)bytes_read != packet_size) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
int *err, gchar **err_info);
static int ngsniffer_read_rec_header(wtap *wth, gboolean is_random,
- guint16 *typep, guint16 *lengthp, int *err);
+ guint16 *typep, guint16 *lengthp, int *err, gchar **err_info);
static gboolean ngsniffer_read_frame2(wtap *wth, gboolean is_random,
- struct frame2_rec *frame2, int *err);
+ struct frame2_rec *frame2, int *err, gchar **err_info);
static void set_pseudo_header_frame2(wtap *wth,
union wtap_pseudo_header *pseudo_header, struct frame2_rec *frame2);
static gboolean ngsniffer_read_frame4(wtap *wth, gboolean is_random,
- struct frame4_rec *frame4, int *err);
+ struct frame4_rec *frame4, int *err, gchar **err_info);
static void set_pseudo_header_frame4(union wtap_pseudo_header *pseudo_header,
struct frame4_rec *frame4);
static gboolean ngsniffer_read_frame6(wtap *wth, gboolean is_random,
- struct frame6_rec *frame6, int *err);
+ struct frame6_rec *frame6, int *err, gchar **err_info);
static void set_pseudo_header_frame6(wtap *wth,
union wtap_pseudo_header *pseudo_header, struct frame6_rec *frame6);
static gboolean ngsniffer_read_rec_data(wtap *wth, gboolean is_random,
- guchar *pd, unsigned int length, int *err);
+ guchar *pd, unsigned int length, int *err, gchar **err_info);
static int infer_pkt_encap(const guint8 *pd, int len);
static int fix_pseudo_header(int encap, const guint8 *pd, int len,
union wtap_pseudo_header *pseudo_header);
static int SnifferDecompress( unsigned char * inbuf, size_t inlen,
unsigned char * outbuf, size_t outlen, int *err );
static gint64 ng_file_read(void *buffer, unsigned int nbytes, wtap *wth,
- gboolean is_random, int *err);
+ gboolean is_random, int *err, gchar **err_info);
static int read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream,
- int *err);
-static gint64 ng_file_seek_seq(wtap *wth, gint64 offset, int whence, int *err);
-static gint64 ng_file_seek_rand(wtap *wth, gint64 offset, int whence, int *err);
+ int *err, gchar **err_info);
+static gint64 ng_file_seek_seq(wtap *wth, gint64 offset, int whence, int *err,
+ gchar **err_info);
+static gint64 ng_file_seek_rand(wtap *wth, gint64 offset, int whence, int *err,
+ gchar **err_info);
int
ngsniffer_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;
bytes_read = file_read(record_type, 2, wth->fh);
bytes_read += file_read(record_length, 4, wth->fh);
if (bytes_read != 6) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&version, sizeof version, wth->fh);
if (bytes_read != sizeof version) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(record_type, 2, wth->fh);
if (bytes_read != 2) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
if (bytes_read != 0) {
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(record_length, 4, wth->fh);
if (bytes_read != 4) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return -1;
bytes_read = file_read(buffer, 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) {
*err = WTAP_ERR_SHORT_READ;
return -1;
*/
*data_offset = wth->data_offset;
ret = ngsniffer_read_rec_header(wth, FALSE, &type, &length,
- err);
+ err, err_info);
if (ret <= 0) {
/* Read error or EOF */
return FALSE;
}
/* Read the f_frame2_struct */
- if (!ngsniffer_read_frame2(wth, FALSE, &frame2, err)) {
+ if (!ngsniffer_read_frame2(wth, FALSE, &frame2, err,
+ err_info)) {
/* Read error */
return FALSE;
}
}
/* Read the f_frame4_struct */
- if (!ngsniffer_read_frame4(wth, FALSE, &frame4, err)) {
+ if (!ngsniffer_read_frame4(wth, FALSE, &frame4, err,
+ err_info)) {
/* Read error */
return FALSE;
}
case REC_FRAME6:
/* Read the f_frame6_struct */
- if (!ngsniffer_read_frame6(wth, FALSE, &frame6, err)) {
+ if (!ngsniffer_read_frame6(wth, FALSE, &frame6, err,
+ err_info)) {
/* Read error */
return FALSE;
}
* it is but can't handle it. Skip past the data
* portion, and keep looping.
*/
- if (ng_file_seek_seq(wth, length, SEEK_CUR, err) == -1)
+ if (ng_file_seek_seq(wth, length, SEEK_CUR, err, err_info)
+ == -1)
return FALSE;
wth->data_offset += length;
}
*/
buffer_assure_space(wth->frame_buffer, length);
pd = buffer_start_ptr(wth->frame_buffer);
- if (!ngsniffer_read_rec_data(wth, FALSE, pd, length, err))
+ if (!ngsniffer_read_rec_data(wth, FALSE, pd, length, err, err_info))
return FALSE; /* Read error */
wth->data_offset += length;
static gboolean
ngsniffer_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
- int *err, gchar **err_info _U_)
+ int *err, gchar **err_info)
{
int ret;
guint16 type, length;
struct frame4_rec frame4;
struct frame6_rec frame6;
- if (ng_file_seek_rand(wth, seek_off, SEEK_SET, err) == -1)
+ if (ng_file_seek_rand(wth, seek_off, SEEK_SET, err, err_info) == -1)
return FALSE;
- ret = ngsniffer_read_rec_header(wth, TRUE, &type, &length, err);
+ ret = ngsniffer_read_rec_header(wth, TRUE, &type, &length, err,
+ err_info);
if (ret <= 0) {
/* Read error or EOF */
if (ret == 0) {
case REC_FRAME2:
/* Read the f_frame2_struct */
- if (!ngsniffer_read_frame2(wth, TRUE, &frame2, err)) {
+ if (!ngsniffer_read_frame2(wth, TRUE, &frame2, err, err_info)) {
/* Read error */
return FALSE;
}
case REC_FRAME4:
/* Read the f_frame4_struct */
- if (!ngsniffer_read_frame4(wth, TRUE, &frame4, err)) {
+ if (!ngsniffer_read_frame4(wth, TRUE, &frame4, err, err_info)) {
/* Read error */
return FALSE;
}
case REC_FRAME6:
/* Read the f_frame6_struct */
- if (!ngsniffer_read_frame6(wth, TRUE, &frame6, err)) {
+ if (!ngsniffer_read_frame6(wth, TRUE, &frame6, err, err_info)) {
/* Read error */
return FALSE;
}
/*
* Got the pseudo-header (if any), now get the data.
*/
- if (!ngsniffer_read_rec_data(wth, TRUE, pd, packet_size, err))
+ if (!ngsniffer_read_rec_data(wth, TRUE, pd, packet_size, err, err_info))
return FALSE;
fix_pseudo_header(wth->file_encap, pd, packet_size, pseudo_header);
static int
ngsniffer_read_rec_header(wtap *wth, gboolean is_random, guint16 *typep,
- guint16 *lengthp, int *err)
+ guint16 *lengthp, int *err, gchar **err_info)
{
gint64 bytes_read;
char record_type[2];
/*
* Read the record header.
*/
- bytes_read = ng_file_read(record_type, 2, wth, is_random, err);
+ bytes_read = ng_file_read(record_type, 2, wth, is_random, err,
+ err_info);
if (bytes_read != 2) {
if (*err != 0)
return -1;
}
return 0;
}
- bytes_read = ng_file_read(record_length, 4, wth, is_random, err);
+ bytes_read = ng_file_read(record_length, 4, wth, is_random, err,
+ err_info);
if (bytes_read != 4) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
static gboolean
ngsniffer_read_frame2(wtap *wth, gboolean is_random, struct frame2_rec *frame2,
- int *err)
+ int *err, gchar **err_info)
{
gint64 bytes_read;
/* Read the f_frame2_struct */
bytes_read = ng_file_read(frame2, (unsigned int)sizeof *frame2, wth,
- is_random, err);
+ is_random, err, err_info);
if (bytes_read != sizeof *frame2) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
static gboolean
ngsniffer_read_frame4(wtap *wth, gboolean is_random, struct frame4_rec *frame4,
- int *err)
+ int *err, gchar **err_info)
{
gint64 bytes_read;
/* Read the f_frame4_struct */
bytes_read = ng_file_read(frame4, (unsigned int)sizeof *frame4, wth,
- is_random, err);
+ is_random, err, err_info);
if (bytes_read != sizeof *frame4) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
static gboolean
ngsniffer_read_frame6(wtap *wth, gboolean is_random, struct frame6_rec *frame6,
- int *err)
+ int *err, gchar **err_info)
{
gint64 bytes_read;
/* Read the f_frame6_struct */
bytes_read = ng_file_read(frame6, (unsigned int)sizeof *frame6, wth,
- is_random, err);
+ is_random, err, err_info);
if (bytes_read != sizeof *frame6) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
static gboolean
ngsniffer_read_rec_data(wtap *wth, gboolean is_random, guchar *pd,
- unsigned int length, int *err)
+ unsigned int length, int *err, gchar **err_info)
{
gint64 bytes_read;
- bytes_read = ng_file_read(pd, length, wth, is_random, err);
+ bytes_read = ng_file_read(pd, length, wth, is_random, err, err_info);
if (bytes_read != (gint64) length) {
if (*err == 0)
static gint64
ng_file_read(void *buffer, unsigned int nbytes, wtap *wth, gboolean is_random,
- int *err)
+ int *err, gchar **err_info)
{
ngsniffer_t *ngsniffer;
FILE_T infile;
errno = WTAP_ERR_CANT_READ;
copied_bytes = file_read(buffer, copybytes, infile);
if ((unsigned int) copied_bytes != copybytes)
- *err = file_error(infile);
+ *err = file_error(infile, err_info);
return copied_bytes;
}
}
/* Now read the first blob into the buffer. */
- if (read_blob(infile, comp_stream, err) < 0)
+ if (read_blob(infile, comp_stream, err, err_info) < 0)
return -1;
}
while (copybytes > 0) {
}
}
- if (read_blob(infile, comp_stream, err) < 0)
+ if (read_blob(infile, comp_stream, err, err_info) < 0)
return -1;
bytes_left = comp_stream->nbytes - comp_stream->nextout;
}
}
/* Read a blob from a compressed stream.
- Return -1 and set "*err" on error, otherwise return 0. */
+ Return -1 and set "*err" and "*err_info" on error, otherwise return 0. */
static int
-read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err)
+read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err,
+ gchar **err_info)
{
int in_len;
size_t read_len;
errno = WTAP_ERR_CANT_READ;
read_len = file_read(&blob_len, 2, infile);
if (2 != read_len) {
- *err = file_error(infile);
+ *err = file_error(infile, err_info);
return -1;
}
comp_stream->comp_offset += 2;
errno = WTAP_ERR_CANT_READ;
read_len = file_read(file_inbuf, in_len, infile);
if ((size_t) in_len != read_len) {
- *err = file_error(infile);
+ *err = file_error(infile, err_info);
g_free(file_inbuf);
return -1;
}
/* Seek in the sequential data stream; we can only seek forward, and we
do it on compressed files by skipping forward. */
static gint64
-ng_file_seek_seq(wtap *wth, gint64 offset, int whence, int *err)
+ng_file_seek_seq(wtap *wth, gint64 offset, int whence, int *err,
+ gchar **err_info)
{
gint64 delta;
char *buf;
else
amount_to_read = (unsigned int) delta;
- if (ng_file_read(buf, amount_to_read, wth, FALSE, err) < 0) {
+ if (ng_file_read(buf, amount_to_read, wth, FALSE, err, err_info) < 0) {
g_free(buf);
return -1; /* error */
}
position within the blob we have in memory (whether it's the blob we
already had in memory or, if necessary, the one we read in). */
static gint64
-ng_file_seek_rand(wtap *wth, gint64 offset, int whence, int *err)
+ng_file_seek_rand(wtap *wth, gint64 offset, int whence, int *err,
+ gchar **err_info)
{
ngsniffer_t *ngsniffer;
gint64 delta;
ngsniffer->rand.comp_offset = new_blob->blob_comp_offset;
/* Now fill the buffer. */
- if (read_blob(wth->random_fh, &ngsniffer->rand, err) < 0)
+ if (read_blob(wth->random_fh, &ngsniffer->rand, err, err_info) < 0)
return -1;
/* Set "delta" to the amount to move within this blob; it had
#define PACKETLOGGER_HEADER_SIZE 12
-static gboolean packetlogger_read(wtap *wth, int *err, gchar **err_info _U_,
+static gboolean packetlogger_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean packetlogger_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header _U_,
guchar *pd, int length, int *err,
- gchar **err_info _U_);
+ gchar **err_info);
static gboolean packetlogger_read_header(packetlogger_header_t *pl_hdr,
- FILE_T fh, int *err);
+ FILE_T fh, int *err, gchar **err_info);
-int packetlogger_open(wtap *wth, int *err, gchar **err_info _U_)
+int packetlogger_open(wtap *wth, int *err, gchar **err_info)
{
packetlogger_header_t pl_hdr;
guint8 type;
- if(!packetlogger_read_header(&pl_hdr, wth->fh, err))
+ if(!packetlogger_read_header(&pl_hdr, wth->fh, err, err_info))
return -1;
if (file_read(&type, 1, wth->fh) <= 0)
*data_offset = wth->data_offset;
- if(!packetlogger_read_header(&pl_hdr, wth->fh, err))
+ if(!packetlogger_read_header(&pl_hdr, wth->fh, err, err_info))
return FALSE;
if (pl_hdr.len < 8) {
pl_hdr.len - 8,
wth->fh);
if(bytes_read != pl_hdr.len - 8) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if(*err == 0)
*err = WTAP_ERR_SHORT_READ;
static gboolean
packetlogger_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header
*pseudo_header _U_, guchar *pd, int length, int *err,
- gchar **err_info _U_)
+ gchar **err_info)
{
packetlogger_header_t pl_hdr;
guint bytes_read;
if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
- if(!packetlogger_read_header(&pl_hdr, wth->random_fh, err)) {
+ if(!packetlogger_read_header(&pl_hdr, wth->random_fh, err, err_info)) {
if(*err == 0)
*err = WTAP_ERR_SHORT_READ;
bytes_read = file_read(pd, pl_hdr.len - 8, wth->random_fh);
if(bytes_read != (pl_hdr.len - 8)) {
- *err = file_error(wth->random_fh);
+ *err = file_error(wth->random_fh, err_info);
if(*err == 0)
*err = WTAP_ERR_SHORT_READ;
}
static gboolean
-packetlogger_read_header(packetlogger_header_t *pl_hdr, FILE_T fh, int *err)
+packetlogger_read_header(packetlogger_header_t *pl_hdr, FILE_T fh, int *err,
+ gchar **err_info)
{
guint bytes_read = 0;
pl_hdr->ts = GUINT64_FROM_BE(pl_hdr->ts);
if(bytes_read < PACKETLOGGER_HEADER_SIZE) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if(*err == 0 && bytes_read > 0)
*err = WTAP_ERR_SHORT_READ;
static gboolean
pcap_read_sunatm_pseudoheader(FILE_T fh,
- union wtap_pseudo_header *pseudo_header, int *err)
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{
guint8 atm_phdr[SUNATM_LEN];
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(atm_phdr, SUNATM_LEN, fh);
if (bytes_read != SUNATM_LEN) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
static gboolean
pcap_read_nokiaatm_pseudoheader(FILE_T fh,
- union wtap_pseudo_header *pseudo_header, int *err)
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{
guint8 atm_phdr[NOKIAATM_LEN];
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(atm_phdr, NOKIAATM_LEN, fh);
if (bytes_read != NOKIAATM_LEN) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(irda_phdr, IRDA_SLL_LEN, fh);
if (bytes_read != IRDA_SLL_LEN) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
}
static gboolean
-pcap_read_mtp2_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info _U_)
+pcap_read_mtp2_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{
guint8 mtp2_hdr[MTP2_HDR_LEN];
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(mtp2_hdr, MTP2_HDR_LEN, fh);
if (bytes_read != MTP2_HDR_LEN) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(lapd_phdr, LAPD_SLL_LEN, fh);
if (bytes_read != LAPD_SLL_LEN) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
}
static gboolean
-pcap_read_sita_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info _U_)
+pcap_read_sita_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{
guint8 sita_phdr[SITA_HDR_LEN];
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(sita_phdr, SITA_HDR_LEN, fh);
if (bytes_read != SITA_HDR_LEN) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
static gboolean
pcap_read_bt_pseudoheader(FILE_T fh,
- union wtap_pseudo_header *pseudo_header, int *err)
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{
int bytes_read;
struct libpcap_bt_phdr phdr;
bytes_read = file_read(&phdr,
sizeof (struct libpcap_bt_phdr), fh);
if (bytes_read != sizeof (struct libpcap_bt_phdr)) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
static gboolean
pcap_read_ppp_pseudoheader(FILE_T fh,
- union wtap_pseudo_header *pseudo_header, int *err)
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{
int bytes_read;
struct libpcap_ppp_phdr phdr;
bytes_read = file_read(&phdr,
sizeof (struct libpcap_ppp_phdr), fh);
if (bytes_read != sizeof (struct libpcap_ppp_phdr)) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
static gboolean
pcap_read_erf_pseudoheader(FILE_T fh, struct wtap_pkthdr *whdr,
- union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info _U_)
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{
guint8 erf_hdr[sizeof(struct erf_phdr)];
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(erf_hdr, sizeof(struct erf_phdr), fh);
if (bytes_read != sizeof(struct erf_phdr)) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
*/
static gboolean
pcap_read_erf_exheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
- int *err, gchar **err_info _U_, guint * psize)
+ int *err, gchar **err_info, guint * psize)
{
int bytes_read = 0;
guint8 erf_exhdr[8];
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(erf_exhdr, 8, fh);
if (bytes_read != 8 ) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
*/
static gboolean
pcap_read_erf_subheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
- int *err, gchar **err_info _U_, guint * psize)
+ int *err, gchar **err_info, guint * psize)
{
guint8 erf_subhdr[sizeof(union erf_subhdr)];
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(erf_subhdr, sizeof(erf_mc_header_t), fh);
if (bytes_read != sizeof(erf_mc_header_t) ) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(erf_subhdr, sizeof(erf_eth_header_t), fh);
if (bytes_read != sizeof(erf_eth_header_t) ) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
}
static gboolean
-pcap_read_i2c_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info _U_)
+pcap_read_i2c_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{
struct i2c_file_hdr i2c_hdr;
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&i2c_hdr, sizeof (i2c_hdr), fh);
if (bytes_read != sizeof (i2c_hdr)) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
return -1;
}
if (!pcap_read_nokiaatm_pseudoheader(fh,
- pseudo_header, err))
+ pseudo_header, err, err_info))
return -1; /* Read error */
phdr_len = NOKIAATM_LEN;
return -1;
}
if (!pcap_read_sunatm_pseudoheader(fh,
- pseudo_header, err))
+ pseudo_header, err, err_info))
return -1; /* Read error */
phdr_len = SUNATM_LEN;
return -1;
}
if (!pcap_read_bt_pseudoheader(fh,
- pseudo_header, err))
+ pseudo_header, err, err_info))
return -1; /* Read error */
phdr_len = (int)sizeof (struct libpcap_bt_phdr);
return -1;
}
if (!pcap_read_ppp_pseudoheader(fh,
- pseudo_header, err))
+ pseudo_header, err, err_info))
return -1; /* Read error */
phdr_len = (int)sizeof (struct libpcap_ppp_phdr);
static int
pcapng_read_option(FILE_T fh, pcapng_t *pn, pcapng_option_header_t *oh,
- char *content, int len, int *err, gchar **err_info _U_)
+ char *content, int len, int *err, gchar **err_info)
{
int bytes_read;
int block_read;
bytes_read = file_read(oh, sizeof (*oh), fh);
if (bytes_read != sizeof (*oh)) {
pcapng_debug0("pcapng_read_option: failed to read option");
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err != 0)
return -1;
return 0;
bytes_read = file_read(content, oh->option_length, fh);
if (bytes_read != oh->option_length) {
pcapng_debug1("pcapng_read_if_descr_block: failed to read content of option %u", oh->option_code);
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err != 0)
return -1;
return 0;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&shb, sizeof shb, fh);
if (bytes_read != sizeof shb) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
if (first_block) {
/*
/* "Interface Description Block" */
static int
pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
- wtapng_block_t *wblock, int *err, gchar **err_info _U_)
+ wtapng_block_t *wblock, int *err, gchar **err_info)
{
guint64 time_units_per_second;
int bytes_read;
bytes_read = file_read(&idb, sizeof idb, fh);
if (bytes_read != sizeof idb) {
pcapng_debug0("pcapng_read_if_descr_block: failed to read IDB");
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err != 0)
return -1;
return 0;
static int
-pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock, int *err, gchar **err_info _U_, gboolean enhanced)
+pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock, int *err, gchar **err_info, gboolean enhanced)
{
int bytes_read;
int block_read;
bytes_read = file_read(&epb, sizeof epb, fh);
if (bytes_read != sizeof epb) {
pcapng_debug0("pcapng_read_packet_block: failed to read packet data");
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
return 0;
}
block_read = bytes_read;
bytes_read = file_read(&pb, sizeof pb, fh);
if (bytes_read != sizeof pb) {
pcapng_debug0("pcapng_read_packet_block: failed to read packet data");
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
return 0;
}
block_read = bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read((guchar *) (wblock->frame_buffer), wblock->data.packet.cap_len - pseudo_header_len, fh);
if (bytes_read != (int) (wblock->data.packet.cap_len - pseudo_header_len)) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
pcapng_debug1("pcapng_read_packet_block: couldn't read %u bytes of captured data",
wblock->data.packet.cap_len - pseudo_header_len);
if (*err == 0)
static int
-pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock, int *err, gchar **err_info _U_)
+pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock, int *err, gchar **err_info)
{
int bytes_read;
int block_read;
bytes_read = file_read(&spb, sizeof spb, fh);
if (bytes_read != sizeof spb) {
pcapng_debug0("pcapng_read_simple_packet_block: failed to read packet data");
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
return 0;
}
block_read = bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read((guchar *) (wblock->frame_buffer), wblock->data.simple_packet.cap_len, fh);
if (bytes_read != (int) wblock->data.simple_packet.cap_len) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
pcapng_debug1("pcapng_read_simple_packet_block: couldn't read %u bytes of captured data",
wblock->data.simple_packet.cap_len);
if (*err == 0)
/* IPv6 + MAXNAMELEN */
#define MAX_NRB_REC_SIZE (16 + 64)
static int
-pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock _U_,int *err, gchar **err_info _U_)
+pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock _U_,int *err, gchar **err_info)
{
int bytes_read = 0;
int block_read = 0;
bytes_read = file_read(&nrb, sizeof nrb, fh);
if (bytes_read != sizeof nrb) {
pcapng_debug0("pcapng_read_name_resolution_block: failed to read record header");
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
return 0;
}
block_read += bytes_read;
bytes_read = file_read(nrb_rec, nrb.record_len, fh);
if (bytes_read != nrb.record_len) {
pcapng_debug0("pcapng_read_name_resolution_block: failed to read IPv4 record data");
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
return 0;
}
block_read += bytes_read;
bytes_read = file_read(nrb_rec, nrb.record_len, fh);
if (bytes_read != nrb.record_len) {
pcapng_debug0("pcapng_read_name_resolution_block: failed to read IPv6 record data");
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
return 0;
}
block_read += bytes_read;
}
static int
-pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock,int *err, gchar **err_info _U_)
+pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wtapng_block_t *wblock,int *err, gchar **err_info)
{
int bytes_read;
int block_read;
bytes_read = file_read(&isb, sizeof isb, fh);
if (bytes_read != sizeof isb) {
pcapng_debug0("pcapng_read_interface_statistics_block: failed to read packet data");
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
return 0;
}
block_read = bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&bh, sizeof bh, fh);
if (bytes_read != sizeof bh) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
pcapng_debug3("pcapng_read_block: file_read() returned %d instead of %u, err = %d.", bytes_read, (unsigned int)sizeof bh, *err);
if (*err != 0)
return -1;
bytes_read = file_read(&block_total_length, sizeof block_total_length, fh);
if (bytes_read != sizeof block_total_length) {
pcapng_debug0("pcapng_read_block: couldn't read second block length");
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return -1;
bytes_read = pcapng_read_block(wth->fh, TRUE, &pn, &wblock, err, err_info);
if (bytes_read <= 0) {
pcapng_debug0("pcapng_open: couldn't read first SHB");
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
/* read the block */
bytes_read = pcapng_read_block(wth->random_fh, FALSE, pcapng, &wblock, err, err_info);
if (bytes_read <= 0) {
- *err = file_error(wth->random_fh);
+ *err = file_error(wth->random_fh, err_info);
pcapng_debug3("pcapng_seek_read: couldn't read packet block (err=%d, errno=%d, bytes_read=%d).",
*err, errno, bytes_read);
return FALSE;
static int
process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd,
- int *err, pkt_id *pid);
+ int *err, gchar **err_info, pkt_id *pid);
static gboolean
collate(pppdump_t*, FILE_T fh, int *err, gchar **err_info, guint8 *pd,
int
-pppdump_open(wtap *wth, int *err, gchar **err_info _U_)
+pppdump_open(wtap *wth, int *err, gchar **err_info)
{
guint8 buffer[6]; /* Looking for: 0x07 t3 t2 t1 t0 ID */
pppdump_t *state;
* representing the timestamp.
*/
- wtap_file_read_unknown_bytes(buffer, sizeof(buffer), wth->fh, err);
+ wtap_file_read_unknown_bytes(buffer, sizeof(buffer), wth->fh, err,
+ err_info);
if (buffer[0] == PPPD_RESET_TIME &&
(buffer[5] == PPPD_SENT_DATA ||
*/
static int
process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd,
- int *err, pkt_id *pid)
+ int *err, gchar **err_info, pkt_id *pid)
{
int c;
int num_bytes = n;
for (; num_bytes > 0; --num_bytes) {
c = file_getc(fh);
if (c == EOF) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
g_assert(num_bytes_to_skip == 0);
pkt = state->pkt;
num_written = process_data(state, fh, pkt, state->num_bytes,
- pd, err, pid);
+ pd, err, err_info, pid);
if (num_written < 0) {
return FALSE;
n--;
}
num_written = process_data(state, fh, pkt, n,
- pd, err, pid);
+ pd, err, err_info, pid);
if (num_written < 0) {
return FALSE;
break;
case PPPD_RESET_TIME:
- wtap_file_read_unknown_bytes(&time_long, sizeof(guint32), fh, err);
+ wtap_file_read_unknown_bytes(&time_long, sizeof(guint32), fh, err, err_info);
state->offset += sizeof(guint32);
state->timestamp = pntohl(&time_long);
state->tenths = 0;
break;
case PPPD_TIME_STEP_LONG:
- wtap_file_read_unknown_bytes(&time_long, sizeof(guint32), fh, err);
+ wtap_file_read_unknown_bytes(&time_long, sizeof(guint32), fh, err, err_info);
state->offset += sizeof(guint32);
state->tenths += pntohl(&time_long);
break;
case PPPD_TIME_STEP_SHORT:
- wtap_file_read_unknown_bytes(&time_short, sizeof(guint8), fh, err);
+ wtap_file_read_unknown_bytes(&time_short, sizeof(guint8), fh, err, err_info);
state->offset += sizeof(guint8);
state->tenths += time_short;
}
done:
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
if (state->offset != start_offset) {
/*
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info);
static int radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *hdr,
- int *err);
+ int *err, gchar **err_info);
static gboolean radcom_read_rec_data(FILE_T fh, guchar *pd, int length,
- int *err);
+ int *err, gchar **err_info);
int radcom_open(wtap *wth, int *err, gchar **err_info)
{
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(r_magic, 8, wth->fh);
if (bytes_read != 8) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(t_magic, 11, wth->fh);
if (bytes_read != 11) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(t_magic, 11, wth->fh);
if (bytes_read != 11) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
bytes_read = file_read(&start_date, sizeof(struct frame_date),
wth->fh);
if (bytes_read != sizeof(struct frame_date)) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
return 1;
read_error:
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
}
/* Read the next packet */
-static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_,
+static gboolean radcom_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
int ret;
/* Read record header. */
*data_offset = wth->data_offset;
- ret = radcom_read_rec_header(wth->fh, &hdr, err);
+ ret = radcom_read_rec_header(wth->fh, &hdr, err, err_info);
if (ret <= 0) {
/* Read error or EOF */
return FALSE;
* XXX - is this stuff a pseudo-header?
* The direction appears to be in the "hdr.dce" field.
*/
- if (!radcom_read_rec_data(wth->fh, phdr, sizeof phdr, err))
+ if (!radcom_read_rec_data(wth->fh, phdr, sizeof phdr, err,
+ err_info))
return FALSE; /* Read error */
wth->data_offset += 8;
length -= 8;
*/
buffer_assure_space(wth->frame_buffer, length);
if (!radcom_read_rec_data(wth->fh,
- buffer_start_ptr(wth->frame_buffer), length, err))
+ buffer_start_ptr(wth->frame_buffer), length, err, err_info))
return FALSE; /* Read error */
wth->data_offset += length;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&fcs, sizeof fcs, wth->fh);
if (bytes_read != sizeof fcs) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
static gboolean
radcom_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;
struct radcomrec_hdr hdr;
return FALSE;
/* Read record header. */
- ret = radcom_read_rec_header(wth->random_fh, &hdr, err);
+ ret = radcom_read_rec_header(wth->random_fh, &hdr, err, err_info);
if (ret <= 0) {
/* Read error or EOF */
if (ret == 0) {
* The direction appears to be in the "hdr.dce" field.
*/
if (!radcom_read_rec_data(wth->random_fh, phdr, sizeof phdr,
- err))
+ err, err_info))
return FALSE; /* Read error */
break;
}
/*
* Read the packet data.
*/
- return radcom_read_rec_data(wth->random_fh, pd, length, err);
+ return radcom_read_rec_data(wth->random_fh, pd, length, err, err_info);
}
static int
-radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *hdr, int *err)
+radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *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) {
}
static gboolean
-radcom_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
+radcom_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
+ gchar **err_info)
{
int bytes_read;
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;
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);
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
static gboolean snoop_read_shomiti_wireless_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info,
int *header_size);
static gboolean snoop_read_rec_data(FILE_T fh, guchar *pd, int length,
- int *err);
+ int *err, gchar **err_info);
static gboolean snoop_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
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;
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;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&rec_hdr, sizeof rec_hdr, wth->fh);
if (bytes_read != sizeof rec_hdr) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ;
if (*err != 0) {
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 && bytes_read != 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
return FALSE;
}
if (!snoop_read_atm_pseudoheader(wth->fh, &wth->pseudo_header,
- err))
+ err, err_info))
return FALSE; /* Read error */
/*
buffer_assure_space(wth->frame_buffer, packet_size);
if (!snoop_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;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(padbuf, 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)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
case WTAP_ENCAP_ATM_PDUS:
if (!snoop_read_atm_pseudoheader(wth->random_fh, pseudo_header,
- err)) {
+ err, err_info)) {
/* Read error */
return FALSE;
}
/*
* Read the packet data.
*/
- if (!snoop_read_rec_data(wth->random_fh, pd, length, err))
+ if (!snoop_read_rec_data(wth->random_fh, pd, length, err, err_info))
return FALSE; /* failed */
/*
static gboolean
snoop_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
- int *err)
+ int *err, gchar **err_info)
{
struct snoop_atm_hdr atm_phdr;
int bytes_read;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&atm_phdr, sizeof (struct snoop_atm_hdr), fh);
if (bytes_read != sizeof (struct snoop_atm_hdr)) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&whdr, sizeof (shomiti_wireless_header), fh);
if (bytes_read != sizeof (shomiti_wireless_header)) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
}
static gboolean
-snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
+snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err,
+ gchar **err_info)
{
int bytes_read;
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;
buffer_assure_space(wth->frame_buffer, packet_size);
buf = buffer_start_ptr(wth->frame_buffer);
- wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err);
+ wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err, err_info);
wth->data_offset += packet_size;
static gboolean tnef_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header _U_,
- guint8 *pd, int length, int *err, gchar **err_info _U_)
+ guint8 *pd, int length, int *err, gchar **err_info)
{
int packet_size = length;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
- wtap_file_read_expected_bytes(pd, packet_size, wth->random_fh, err);
+ wtap_file_read_expected_bytes(pd, packet_size, wth->random_fh, err, err_info);
return TRUE;
}
-int tnef_open(wtap *wth, int *err, gchar **err_info _U_)
+int tnef_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
guint32 magic;
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);
return (*err != 0) ? -1 : 0;
}
union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
/* Seeks to the beginning of the next packet, and returns the
- byte offset. Returns -1 on failure, and sets "*err" to the error. */
-static gint64 toshiba_seek_next_packet(wtap *wth, int *err)
+ byte offset. Returns -1 on failure, and sets "*err" to the error
+ and "*err_info" to null or an additional error string. */
+static gint64 toshiba_seek_next_packet(wtap *wth, int *err, gchar **err_info)
{
int byte;
guint level = 0;
cur_off = file_tell(wth->fh);
if (cur_off == -1) {
/* Error. */
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return -1;
}
return cur_off + 1;
*err = 0;
} else {
/* We got an error. */
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
}
return -1;
}
* a Toshiba trace file.
*
* Returns TRUE if it is, FALSE if it isn't or if we get an I/O error;
- * if we get an I/O error, "*err" will be set to a non-zero value.
+ * if we get an I/O error, "*err" will be set to a non-zero value and
+ * "*err_info" will be set to null or an additional error string.
*/
-static gboolean toshiba_check_file_type(wtap *wth, int *err)
+static gboolean toshiba_check_file_type(wtap *wth, int *err, gchar **err_info)
{
char buf[TOSHIBA_LINE_LENGTH];
guint i, reclen, level, line;
if (file_eof(wth->fh))
*err = 0;
else
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return FALSE;
}
}
}
-int toshiba_open(wtap *wth, int *err, gchar **err_info _U_)
+int toshiba_open(wtap *wth, int *err, gchar **err_info)
{
/* Look for Toshiba header */
- if (!toshiba_check_file_type(wth, err)) {
+ if (!toshiba_check_file_type(wth, err, err_info)) {
if (*err == 0)
return 0;
else
int pkt_len;
/* Find the next packet */
- offset = toshiba_seek_next_packet(wth, err);
+ offset = toshiba_seek_next_packet(wth, err, err_info);
if (offset < 1)
return FALSE;
* extract the useful information
*/
if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) == NULL) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
*/
do {
if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) == NULL) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
for (i = 0; i < hex_lines; i++) {
if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) == NULL) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_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;
bytes_read = file_read(&vfile_hdr, sizeof vfile_hdr, wth->fh);
if (bytes_read != sizeof vfile_hdr)
{
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
bytes_read = file_read(&vpkt_hdr, phdr_size, wth->fh);
if (bytes_read != phdr_size)
{
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0)
{
*err = WTAP_ERR_SHORT_READ;
bytes_read = file_read(&vatm_hdr, ahdr_size, wth->fh);
if (bytes_read != ahdr_size)
{
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0)
{
*err = WTAP_ERR_SHORT_READ;
if (bytes_read != (int) packet_size)
{
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
the direction flag works. */
static gboolean visual_seek_read (wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
- int *err, gchar **err_info _U_)
+ int *err, gchar **err_info)
{
struct visual_pkt_hdr vpkt_hdr;
struct visual_atm_hdr vatm_hdr;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&vpkt_hdr, phdr_size, wth->random_fh);
if (bytes_read != phdr_size) {
- *err = file_error(wth->random_fh);
+ *err = file_error(wth->random_fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
bytes_read = file_read(&vatm_hdr, ahdr_size, wth->random_fh);
if (bytes_read != ahdr_size)
{
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
if (*err == 0 && bytes_read != 0)
{
*err = WTAP_ERR_SHORT_READ;
cur_off = file_tell(wth->fh);
if (cur_off == -1) {
/* Error */
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
hdr = NULL;
return -1;
}
equivalent to "ferror()" in zlib, alas,
so we don't have a wrapper to check for
an error). */
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
}
break;
}
* a VMS trace file.
*
* Returns TRUE if it is, FALSE if it isn't or if we get an I/O error;
- * if we get an I/O error, "*err" will be set to a non-zero value.
+ * if we get an I/O error, "*err" will be set to a non-zero value and
+ * "*err_info will be set to null or an additional error string.
*
* Leaves file handle at begining of line that contains the VMS Magic
* identifier.
*/
-static gboolean vms_check_file_type(wtap *wth, int *err)
+static gboolean vms_check_file_type(wtap *wth, int *err, gchar **err_info)
{
char buf[VMS_LINE_LENGTH];
guint reclen, line;
mpos = file_tell(wth->fh);
if (mpos == -1) {
/* Error. */
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return FALSE;
}
if (file_gets(buf, VMS_LINE_LENGTH, wth->fh) != NULL) {
if (file_eof(wth->fh))
*err = 0;
else
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return FALSE;
}
}
}
-int vms_open(wtap *wth, int *err, gchar **err_info _U_)
+int vms_open(wtap *wth, int *err, gchar **err_info)
{
/* Look for VMS header */
- if (!vms_check_file_type(wth, err)) {
+ if (!vms_check_file_type(wth, err, err_info)) {
if (*err == 0)
return 0;
else
offset = file_tell(wth->fh);
#endif
if (offset < 1) {
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return FALSE;
}
/* Skip lines until one starts with a hex number */
do {
if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if ((*err == 0) && (csec != 101)) {
*err = WTAP_ERR_SHORT_READ;
}
for (i = 0; i < pkt_len; i += 16) {
if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
if (i == 0) {
while (! isdumpline(line)) { /* advance to start of hex data */
if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
* Wiretap API, we should parse those lines and return "n" as
* a packet drop count. */
if (!file_gets(line, VMS_LINE_LENGTH, fh)) {
- *err = file_error(fh);
+ *err = file_error(fh, err_info);
if (*err == 0) {
/* There is no next line, so there's no "TCPIPtrace could not
* save n packets" line; not an error. */
}
#endif
-#define wtap_file_read_unknown_bytes(target, num_bytes, fh, err) \
+#define wtap_file_read_unknown_bytes(target, num_bytes, fh, err, err_info) \
G_STMT_START \
{ \
int _bytes_read; \
_bytes_read = file_read((target), (num_bytes), (fh)); \
if (_bytes_read != (int) (num_bytes)) { \
- *(err) = file_error((fh)); \
+ *(err) = file_error((fh), (err_info)); \
return FALSE; \
} \
} \
G_STMT_END
-#define wtap_file_read_expected_bytes(target, num_bytes, fh, err) \
+#define wtap_file_read_expected_bytes(target, num_bytes, fh, err, err_info) \
G_STMT_START \
{ \
int _bytes_read; \
_bytes_read = file_read((target), (num_bytes), (fh)); \
if (_bytes_read != (int) (num_bytes)) { \
- *(err) = file_error((fh)); \
+ *(err) = file_error((fh), (err_info)); \
if (*(err) == 0 && _bytes_read > 0) { \
*(err) = WTAP_ERR_SHORT_READ; \
} \
"Uncompression error: data oddly truncated",
"Uncompression error: data would overflow buffer",
"Uncompression error: bad LZ77 offset",
- "The standard input cannot be opened for random access"
+ "The standard input cannot be opened for random access",
+ "That file format doesn't support compression",
+ NULL,
+ "Uncompression error"
};
#define WTAP_ERRLIST_SIZE (sizeof wtap_errlist / sizeof wtap_errlist[0])
* last packet of the file.
*/
if (*err == 0)
- *err = file_error(wth->fh);
+ *err = file_error(wth->fh, err_info);
return FALSE; /* failure */
}
/* LZ77 compressed data has bad offset to string */
#define WTAP_ERR_RANDOM_OPEN_STDIN -18
/* We're trying to open the standard input for random access */
-#define WTAP_ERR_COMPRESSION_NOT_SUPPORTED -19
+#define WTAP_ERR_COMPRESSION_NOT_SUPPORTED -19
/* The filetype doesn't support output compression */
#define WTAP_ERR_CANT_SEEK -20
/* An attempt to seek failed, reason unknown */
+#define WTAP_ERR_DECOMPRESS -21
+ /* Error decompressing */
/* Errors from zlib; zlib error Z_xxx turns into Wiretap error
WTAP_ERR_ZLIB + Z_xxx.