summaryrefslogtreecommitdiff
path: root/wiretap/iptrace.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-01-25 21:55:17 +0000
committerGuy Harris <guy@alum.mit.edu>2004-01-25 21:55:17 +0000
commitd6cd61061efe7207b298b5ac40a92e7b86b00b3e (patch)
tree392720e018248f9cf2b46db00a4a9740ff7d1fca /wiretap/iptrace.c
parent34bddb3c1a932632fd0515f7999ed96ef9974611 (diff)
downloadwireshark-d6cd61061efe7207b298b5ac40a92e7b86b00b3e.tar.gz
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with "g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed strings returned as the error info string, and change the callers of those routines to, for those errors, put the info string into the printed message or alert box for the error. Add messages for cases where those errors were returned without printing an additional message. Nobody uses the error code from "cf_read()" - "cf_read()" puts up the alert box itself for failures; get rid of the error code, so it just returns a success/failure indication. Rename "file_read_error_message()" to "cf_read_error_message()", as it handles read errors from Wiretap, and have it take an error info string as an argument. (That handles a lot of the work of putting the info string into the error message.) Make some variables in "ascend-grammar.y" static. Check the return value of "erf_read_header()" in "erf_seek_read()". Get rid of an unused #define in "i4btrace.c". svn path=/trunk/; revision=9852
Diffstat (limited to 'wiretap/iptrace.c')
-rw-r--r--wiretap/iptrace.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c
index 8d91f940de..e580155a62 100644
--- a/wiretap/iptrace.c
+++ b/wiretap/iptrace.c
@@ -1,6 +1,6 @@
/* iptrace.c
*
- * $Id: iptrace.c,v 1.49 2004/01/24 16:48:12 jmayer Exp $
+ * $Id: iptrace.c,v 1.50 2004/01/25 21:55:15 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -32,15 +32,17 @@
#include "atm.h"
#include "iptrace.h"
-static gboolean iptrace_read_1_0(wtap *wth, int *err, long *data_offset);
+static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean iptrace_seek_read_1_0(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
- int *err);
+ int *err, gchar **err_info);
-static gboolean iptrace_read_2_0(wtap *wth, int *err, long *data_offset);
+static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean iptrace_seek_read_2_0(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
- int *err);
+ int *err, gchar **err_info);
static int iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len,
int *err);
@@ -50,7 +52,7 @@ 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)
+int iptrace_open(wtap *wth, int *err, gchar **err_info _U_)
{
int bytes_read;
char name[12];
@@ -119,7 +121,8 @@ typedef struct {
#define IPTRACE_1_0_PDATA_SIZE 22 /* packet data */
/* Read the next packet */
-static gboolean iptrace_read_1_0(wtap *wth, int *err, long *data_offset)
+static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info _U_,
+ long *data_offset)
{
int ret;
guint32 packet_size;
@@ -180,9 +183,9 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, long *data_offset)
wth->phdr.ts.tv_usec = 0;
if (wth->phdr.pkt_encap == WTAP_ENCAP_UNKNOWN) {
- g_message("iptrace: interface type IFT=0x%02x unknown or unsupported",
- pkt_hdr.if_type);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("iptrace: interface type IFT=0x%02x unknown or unsupported",
+ pkt_hdr.if_type);
return FALSE;
}
@@ -208,7 +211,7 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, long *data_offset)
static gboolean iptrace_seek_read_1_0(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
- int *err)
+ int *err, gchar **err_info _U_)
{
int ret;
guint8 header[IPTRACE_1_0_PHDR_SIZE];
@@ -297,7 +300,8 @@ typedef struct {
#define IPTRACE_2_0_PDATA_SIZE 32 /* packet data */
/* Read the next packet */
-static gboolean iptrace_read_2_0(wtap *wth, int *err, long *data_offset)
+static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info _U_,
+ long *data_offset)
{
int ret;
guint32 packet_size;
@@ -362,9 +366,9 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, long *data_offset)
wth->phdr.ts.tv_usec = pntohl(&header[36]) / 1000;
if (wth->phdr.pkt_encap == WTAP_ENCAP_UNKNOWN) {
- g_message("iptrace: interface type IFT=0x%02x unknown or unsupported",
- pkt_hdr.if_type);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ *err_info = g_strdup_printf("iptrace: interface type IFT=0x%02x unknown or unsupported",
+ pkt_hdr.if_type);
return FALSE;
}
@@ -390,7 +394,7 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, long *data_offset)
static gboolean iptrace_seek_read_2_0(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
- int *err)
+ int *err, gchar **err_info _U_)
{
int ret;
guint8 header[IPTRACE_2_0_PHDR_SIZE];