diff options
Diffstat (limited to 'wiretap')
54 files changed, 564 insertions, 409 deletions
diff --git a/wiretap/5views.c b/wiretap/5views.c index 327653e8f2..23f63445f5 100644 --- a/wiretap/5views.c +++ b/wiretap/5views.c @@ -1,6 +1,6 @@ /* 5views.c * - * $Id: 5views.c,v 1.3 2003/10/01 07:11:46 guy Exp $ + * $Id: 5views.c,v 1.4 2004/01/25 21:55:11 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -102,10 +102,15 @@ typedef struct #define CST_5VW_CAPTURES_RECORD (CST_5VW_SECTION_CAPTURES << 28) /* 0x80000000 */ #define CST_5VW_SYSTEM_RECORD 0x00000000 -static gboolean _5views_read(wtap *wth, int *err, long *data_offset); -static gboolean _5views_read_rec_data(FILE_T fh, guchar *pd, int length,int *err); -static int _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr, int *err); -static gboolean _5views_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err); +static gboolean _5views_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); +static gboolean _5views_read_rec_data(FILE_T fh, guchar *pd, int length, + int *err); +static int _5views_read_header(wtap *wth, FILE_T fh, + t_5VW_TimeStamped_Header *hdr, int *err); +static gboolean _5views_seek_read(wtap *wth, long seek_off, + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info); static gboolean _5views_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, @@ -113,7 +118,7 @@ static gboolean _5views_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, static gboolean _5views_dump_close(wtap_dumper *wdh, int *err); -int _5views_open(wtap *wth, int *err) +int _5views_open(wtap *wth, int *err, gchar **err_info) { int bytes_read; t_5VW_Capture_Header Capture_Header; @@ -145,8 +150,8 @@ int _5views_open(wtap *wth, int *err) break; default: - g_message("5views: header version %u unsupported", Capture_Header.Info_Header.Version); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("5views: header version %u unsupported", Capture_Header.Info_Header.Version); return -1; } @@ -155,8 +160,8 @@ int _5views_open(wtap *wth, int *err) pletohl(&Capture_Header.Info_Header.FileType); if((Capture_Header.Info_Header.FileType & CST_5VW_CAPTURE_FILE_TYPE_MASK) != CST_5VW_CAPTURE_FILEID) { - g_message("5views: file is not a capture file (filetype is %u)", Capture_Header.Info_Header.Version); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("5views: file is not a capture file (filetype is %u)", Capture_Header.Info_Header.Version); return -1; } @@ -169,9 +174,9 @@ int _5views_open(wtap *wth, int *err) break; */ default: - g_message("5views: network type %u unknown or unsupported", - Capture_Header.Info_Header.FileType); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("5views: network type %u unknown or unsupported", + Capture_Header.Info_Header.FileType); return -1; } @@ -197,7 +202,7 @@ int _5views_open(wtap *wth, int *err) /* Read the next packet */ static gboolean -_5views_read(wtap *wth, int *err, long *data_offset) +_5views_read(wtap *wth, int *err, gchar **err_info _U_, long *data_offset) { t_5VW_TimeStamped_Header TimeStamped_Header; int bytes_read; @@ -309,7 +314,8 @@ _5views_read_header(wtap *wth _U_, FILE_T fh, t_5VW_TimeStamped_Header *hdr, static gboolean _5views_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err) + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info _U_) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; diff --git a/wiretap/5views.h b/wiretap/5views.h index d626d6c622..69f84f2675 100644 --- a/wiretap/5views.h +++ b/wiretap/5views.h @@ -1,6 +1,6 @@ /* 5views.h * - * $Id: 5views.h,v 1.1 2003/07/29 19:42:00 guy Exp $ + * $Id: 5views.h,v 1.2 2004/01/25 21:55:12 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -23,7 +23,7 @@ #ifndef __5VIEWS_H__ #define __5VIEWS_H__ -int _5views_open(wtap *wth, int *err); +int _5views_open(wtap *wth, int *err, gchar **err_info); gboolean _5views_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err); int _5views_dump_can_write_encap(int encap); diff --git a/wiretap/airopeek9.c b/wiretap/airopeek9.c index 81ad4a61c4..777628934a 100644 --- a/wiretap/airopeek9.c +++ b/wiretap/airopeek9.c @@ -1,7 +1,7 @@ /* airopeek9.c * Routines for opening AiroPeek V9 files * - * $Id: airopeek9.c,v 1.3 2003/12/03 19:47:36 guy Exp $ + * $Id: airopeek9.c,v 1.4 2004/01/25 21:55:12 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -69,9 +69,11 @@ typedef struct airopeek_utime { static const unsigned int mac2unix = 2082844800u; -static gboolean airopeek_read_v9(wtap *wth, int *err, long *data_offset); +static gboolean airopeek_read_v9(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean airopeek_seek_read_v9(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err); + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info); static int wtap_file_read_pattern (wtap *wth, char *pattern, int *err) { @@ -162,7 +164,7 @@ static int wtap_file_read_number (wtap *wth, guint32 *num, int *err) } -int airopeek9_open(wtap *wth, int *err) +int airopeek9_open(wtap *wth, int *err, gchar **err_info) { airopeek_section_header_t ap_hdr; int ret; @@ -199,8 +201,9 @@ int airopeek9_open(wtap *wth, int *err) /* If we got this far, we assume it's an AiroPeek V9 file. */ if (fileVersion != 9) { /* We only support version 9 and later. */ - g_message("airopeekv9: version %u unsupported", fileVersion); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("airopeekv9: version %u unsupported", + fileVersion); return -1; } @@ -218,8 +221,8 @@ int airopeek9_open(wtap *wth, int *err) if (ret == -1) return -1; if (ret == 0) { - g_message("airopeekv9: <MediaType> tag not found"); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup("airopeekv9: <MediaType> tag not found"); return -1; } /* XXX - this appears to be 0, which is also the media type for @@ -229,8 +232,8 @@ int airopeek9_open(wtap *wth, int *err) if (ret == -1) return -1; if (ret == 0) { - g_message("airopeekv9: <MediaType> value not found"); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup("airopeekv9: <MediaType> value not found"); return -1; } @@ -264,7 +267,8 @@ int airopeek9_open(wtap *wth, int *err) return 1; } -static gboolean airopeek_read_v9(wtap *wth, int *err, long *data_offset) +static gboolean airopeek_read_v9(wtap *wth, int *err, gchar **err_info _U_, + long *data_offset) { guchar ap_pkt[AIROPEEK_V9_PKT_SIZE]; guint32 length; @@ -341,7 +345,8 @@ static gboolean airopeek_read_v9(wtap *wth, int *err, long *data_offset) static gboolean airopeek_seek_read_v9(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err) + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info _U_) { guchar ap_pkt[AIROPEEK_V9_PKT_SIZE]; diff --git a/wiretap/airopeek9.h b/wiretap/airopeek9.h index ce2435db1a..f7ad4bd820 100644 --- a/wiretap/airopeek9.h +++ b/wiretap/airopeek9.h @@ -1,6 +1,6 @@ /* airopeek9.h * - * $Id: airopeek9.h,v 1.1 2003/12/02 19:37:05 guy Exp $ + * $Id: airopeek9.h,v 1.2 2004/01/25 21:55:12 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -24,6 +24,6 @@ #ifndef __W_AIROPEEK9_H__ #define __W_AIROPEEK9_H__ -int airopeek9_open(wtap *wth, int *err); +int airopeek9_open(wtap *wth, int *err, gchar **err_info); #endif diff --git a/wiretap/ascend-grammar.y b/wiretap/ascend-grammar.y index 8a32a2ec02..fd0e776567 100644 --- a/wiretap/ascend-grammar.y +++ b/wiretap/ascend-grammar.y @@ -1,7 +1,7 @@ %{ /* ascend-grammar.y * - * $Id: ascend-grammar.y,v 1.25 2004/01/06 20:05:39 guy Exp $ + * $Id: ascend-grammar.y,v 1.26 2004/01/25 21:55:12 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -117,16 +117,16 @@ XMIT-Max7:20: (task "_brouterControlTask" at 0xb094ac20, time: 1481.51) 20 octet #define NO_USER "<none>" -extern int at_eof; - int yyparse(void); void yyerror(char *); -unsigned int bcur = 0, bcount; -guint32 start_time, secs, usecs, caplen, wirelen; -ascend_pkthdr *header; +gchar *ascend_parse_error; + +static unsigned int bcur = 0, bcount; +static guint32 start_time, secs, usecs, caplen, wirelen; +static ascend_pkthdr *header; struct ascend_phdr *pseudo_header; -guint8 *pkt_data; +static guint8 *pkt_data; %} @@ -409,6 +409,7 @@ parse_ascend(FILE_T fh, guint8 *pd, struct ascend_phdr *phdr, } void -yyerror (char *s _U_) +yyerror (char *s) { + ascend_parse_error = s; } diff --git a/wiretap/ascend-int.h b/wiretap/ascend-int.h index acfd94f334..9a506a0e0d 100644 --- a/wiretap/ascend-int.h +++ b/wiretap/ascend-int.h @@ -2,7 +2,7 @@ * Definitions for routines common to multiple modules in the Lucent/Ascend * capture file reading code code, but not used outside that code. * - * $Id: ascend-int.h,v 1.10 2004/01/06 20:05:39 guy Exp $ + * $Id: ascend-int.h,v 1.11 2004/01/25 21:55:12 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -34,6 +34,10 @@ typedef struct { guint32 len; } ascend_pkthdr; +extern int at_eof; + +extern gchar *ascend_parse_error; + /* * Pointer to the pseudo-header for the current packet. */ diff --git a/wiretap/ascend.c b/wiretap/ascend.c index c62b8d15e8..31f76eecb7 100644 --- a/wiretap/ascend.c +++ b/wiretap/ascend.c @@ -1,6 +1,6 @@ /* ascend.c * - * $Id: ascend.c,v 1.31 2002/08/28 20:30:44 jmayer Exp $ + * $Id: ascend.c,v 1.32 2004/01/25 21:55:12 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -101,9 +101,11 @@ static const char ascend_w2magic[] = { 'W', 'D', '_', 'D', 'I', 'A', 'L', 'O', ' #define ASCEND_W1_SIZE (sizeof ascend_w1magic / sizeof ascend_w1magic[0]) #define ASCEND_W2_SIZE (sizeof ascend_w2magic / sizeof ascend_w2magic[0]) -static gboolean ascend_read(wtap *wth, int *err, long *data_offset); -static gboolean ascend_seek_read (wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err); +static gboolean ascend_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); +static gboolean ascend_seek_read(wtap *wth, long seek_off, + union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, + int *err, gchar **err_info); static void ascend_close(wtap *wth); /* Seeks to the beginning of the next packet, and returns the @@ -232,7 +234,7 @@ found: return packet_off; } -int ascend_open(wtap *wth, int *err) +int ascend_open(wtap *wth, int *err, gchar **err_info _U_) { long offset; struct stat statbuf; @@ -283,7 +285,8 @@ int ascend_open(wtap *wth, int *err) } /* Read the next packet; called from wtap_loop(). */ -static gboolean ascend_read(wtap *wth, int *err, long *data_offset) +static gboolean ascend_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { long offset; guint8 *buf = buffer_start_ptr(wth->frame_buffer); @@ -301,6 +304,7 @@ static gboolean ascend_read(wtap *wth, int *err, long *data_offset) return FALSE; if (! parse_ascend(wth->fh, buf, &wth->pseudo_header.ascend, &header, 0)) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error"); return FALSE; } @@ -336,13 +340,15 @@ static gboolean ascend_read(wtap *wth, int *err, long *data_offset) return TRUE; } -static gboolean ascend_seek_read (wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err) +static gboolean ascend_seek_read(wtap *wth, long seek_off, + union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, + int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; if (! parse_ascend(wth->random_fh, pd, &pseudo_header->ascend, NULL, len)) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error"); return FALSE; } return TRUE; diff --git a/wiretap/ascend.h b/wiretap/ascend.h index 50e2c89583..4f462957fd 100644 --- a/wiretap/ascend.h +++ b/wiretap/ascend.h @@ -1,6 +1,6 @@ /* ascend.h * - * $Id: ascend.h,v 1.9 2002/08/28 20:30:44 jmayer Exp $ + * $Id: ascend.h,v 1.10 2004/01/25 21:55:12 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -28,6 +28,6 @@ #define ASCEND_MAX_DATA_COLS 16 #define ASCEND_MAX_PKT_LEN (ASCEND_MAX_DATA_ROWS * ASCEND_MAX_DATA_COLS) -int ascend_open(wtap *wth, int *err); +int ascend_open(wtap *wth, int *err, gchar **err_info); #endif diff --git a/wiretap/cosine.c b/wiretap/cosine.c index 3eeddbd250..4c0e541db4 100644 --- a/wiretap/cosine.c +++ b/wiretap/cosine.c @@ -1,6 +1,6 @@ /* cosine.c * - * $Id: cosine.c,v 1.7 2004/01/24 16:48:12 jmayer Exp $ + * $Id: cosine.c,v 1.8 2004/01/25 21:55:12 guy Exp $ * * CoSine IPNOS L2 debug output parsing * Copyright (c) 2002 by Motonori Shindo <mshindo@mshindo.net> @@ -169,14 +169,15 @@ static gboolean empty_line(const gchar *line); static long cosine_seek_next_packet(wtap *wth, int *err, char *hdr); static gboolean cosine_check_file_type(wtap *wth, int *err); -static gboolean cosine_read(wtap *wth, int *err, long *data_offset); +static gboolean cosine_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean cosine_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, - int len, int *err); + int len, int *err, gchar **err_info); static int parse_cosine_rec_hdr(wtap *wth, const char *line, - union wtap_pseudo_header *pseudo_header, int *err); + union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info); static int parse_cosine_hex_dump(FILE_T fh, int pkt_len, guint8* buf, - int *err); + int *err, gchar **err_info); static int parse_single_hex_dump_line(char* rec, guint8 *buf, guint byte_offset); @@ -279,7 +280,7 @@ static gboolean cosine_check_file_type(wtap *wth, int *err) } -int cosine_open(wtap *wth, int *err) +int cosine_open(wtap *wth, int *err, gchar **err_info _U_) { /* Look for CoSine header */ if (!cosine_check_file_type(wth, err)) { @@ -303,7 +304,8 @@ int cosine_open(wtap *wth, int *err) } /* Find the next packet and parse it; called from wtap_loop(). */ -static gboolean cosine_read(wtap *wth, int *err, long *data_offset) +static gboolean cosine_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { long offset; guint8 *buf; @@ -316,7 +318,8 @@ static gboolean cosine_read(wtap *wth, int *err, long *data_offset) return FALSE; /* Parse the header */ - pkt_len = parse_cosine_rec_hdr(wth, line, &wth->pseudo_header, err); + pkt_len = parse_cosine_rec_hdr(wth, line, &wth->pseudo_header, err, + err_info); if (pkt_len == -1) return FALSE; @@ -325,7 +328,8 @@ static gboolean cosine_read(wtap *wth, int *err, long *data_offset) buf = buffer_start_ptr(wth->frame_buffer); /* Convert the ASCII hex dump to binary data */ - if ((caplen = parse_cosine_hex_dump(wth->fh, pkt_len, buf, err)) == -1) + if ((caplen = parse_cosine_hex_dump(wth->fh, pkt_len, buf, err, + err_info)) == -1) return FALSE; wth->data_offset = offset; @@ -337,7 +341,8 @@ static gboolean cosine_read(wtap *wth, int *err, long *data_offset) /* Used to read packets in random-access fashion */ static gboolean cosine_seek_read (wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err) + union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, + int *err, gchar **err_info) { char line[COSINE_LINE_LENGTH]; @@ -352,10 +357,10 @@ cosine_seek_read (wtap *wth, long seek_off, return FALSE; } - if (parse_cosine_rec_hdr(NULL, line, pseudo_header, err) == -1) + if (parse_cosine_rec_hdr(NULL, line, pseudo_header, err, err_info) == -1) return FALSE; - return parse_cosine_hex_dump(wth->random_fh, len, pd, err); + return parse_cosine_hex_dump(wth->random_fh, len, pd, err, err_info); } /* Parses a packet record header. There are two possible formats: @@ -364,7 +369,8 @@ cosine_seek_read (wtap *wth, long seek_off, 2) output to PE without date and time l2-tx (FR:3/7/1:1), Length:18, Pro:0, Off:0, Pri:0, RM:0, Err:0 [0x4000, 0x0] */ static int -parse_cosine_rec_hdr(wtap *wth, const char *line, union wtap_pseudo_header *pseudo_header, int *err) +parse_cosine_rec_hdr(wtap *wth, const char *line, + union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info) { int num_items_scanned; int yy, mm, dd, hr, min, sec, csec, pkt_len; @@ -385,6 +391,7 @@ parse_cosine_rec_hdr(wtap *wth, const char *line, union wtap_pseudo_header *pseu if (num_items_scanned != 17) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("cosine: purported control blade line doesn't have code values"); return -1; } } else { @@ -397,6 +404,7 @@ parse_cosine_rec_hdr(wtap *wth, const char *line, union wtap_pseudo_header *pseu if (num_items_scanned != 10) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("cosine: header line is neither control blade nor PE output"); return -1; } yy = mm = dd = hr = min = sec = csec = 0; @@ -455,7 +463,8 @@ parse_cosine_rec_hdr(wtap *wth, const char *line, union wtap_pseudo_header *pseu /* Converts ASCII hex dump to binary data. Returns the capture length. If any error is encountered, -1 is returned. */ static int -parse_cosine_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err) +parse_cosine_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err, + gchar **err_info) { gchar line[COSINE_LINE_LENGTH]; int i, hex_lines, n, caplen = 0; @@ -477,6 +486,7 @@ parse_cosine_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err) } if ((n = parse_single_hex_dump_line(line, buf, i*16)) == -1) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("cosine: hex dump line doesn't have 16 numbers"); return -1; } caplen += n; diff --git a/wiretap/cosine.h b/wiretap/cosine.h index f2eeaf44cd..db74316c9d 100644 --- a/wiretap/cosine.h +++ b/wiretap/cosine.h @@ -1,6 +1,6 @@ /* cosine.h * - * $Id: cosine.h,v 1.2 2002/08/28 20:30:44 jmayer Exp $ + * $Id: cosine.h,v 1.3 2004/01/25 21:55:12 guy Exp $ * * CoSine IPNOS L2 debug output parsing * Copyright (c) 2002 by Motonori Shindo <mshindo@mshindo.net> @@ -27,6 +27,6 @@ #ifndef __W_COSINE_H__ #define __W_COSINE_H__ -int cosine_open(wtap *wth, int *err); +int cosine_open(wtap *wth, int *err, gchar **err_info); #endif diff --git a/wiretap/csids.c b/wiretap/csids.c index 09b9455fb6..5b19959627 100644 --- a/wiretap/csids.c +++ b/wiretap/csids.c @@ -1,6 +1,6 @@ /* csids.c * - * $Id: csids.c,v 1.15 2002/08/28 20:30:44 jmayer Exp $ + * $Id: csids.c,v 1.16 2004/01/25 21:55:12 guy Exp $ * * Copyright (c) 2000 by Mike Hall <mlh@io.com> * Copyright (c) 2000 by Cisco Systems @@ -44,9 +44,11 @@ * ethereal. */ -static gboolean csids_read(wtap *wth, int *err, long *data_offset); +static gboolean csids_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean csids_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err); + union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, + int *err, gchar **err_info); static void csids_close(wtap *wth); struct csids_header { @@ -56,7 +58,7 @@ struct csids_header { }; /* XXX - return -1 on I/O error and actually do something with 'err'. */ -int csids_open(wtap *wth, int *err) +int csids_open(wtap *wth, int *err, gchar **err_info _U_) { /* 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 @@ -141,7 +143,8 @@ int csids_open(wtap *wth, int *err) } /* Find the next packet and parse it; called from wtap_loop(). */ -static gboolean csids_read(wtap *wth, int *err, long *data_offset) +static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_, + long *data_offset) { guint8 *buf; int bytesRead = 0; @@ -201,7 +204,8 @@ csids_seek_read (wtap *wth, union wtap_pseudo_header *pseudo_header _U_, guint8 *pd, int len, - int *err) + int *err, + gchar **err_info) { int bytesRead; struct csids_header hdr; @@ -222,6 +226,8 @@ csids_seek_read (wtap *wth, if( len != hdr.caplen ) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("csids: record length %u doesn't match requested length %d", + hdr.caplen, len); return FALSE; } diff --git a/wiretap/csids.h b/wiretap/csids.h index fecb608187..00fbf69ab9 100644 --- a/wiretap/csids.h +++ b/wiretap/csids.h @@ -1,6 +1,6 @@ /* csids.h * - * $Id: csids.h,v 1.3 2002/08/28 20:30:44 jmayer Exp $ + * $Id: csids.h,v 1.4 2004/01/25 21:55:13 guy Exp $ * * Copyright (c) 2000 by Mike Hall <mlh@io.com> * Copyright (c) Cisco Systems @@ -24,6 +24,6 @@ #ifndef __CSIDS_H__ #define __CSIDS_H__ -int csids_open(wtap *wth, int *err); +int csids_open(wtap *wth, int *err, gchar **err_info); #endif diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c index ad50f228b9..b41521258e 100644 --- a/wiretap/dbs-etherwatch.c +++ b/wiretap/dbs-etherwatch.c @@ -1,6 +1,6 @@ /* dbs-etherwatch.c * - * $Id: dbs-etherwatch.c,v 1.14 2004/01/24 16:48:12 jmayer Exp $ + * $Id: dbs-etherwatch.c,v 1.15 2004/01/25 21:55:13 guy Exp $ * * Wiretap Library * Copyright (c) 2001 by Marc Milgram <ethereal@mmilgram.NOSPAMmail.net> @@ -84,11 +84,13 @@ static const char dbs_etherwatch_rec_magic[] = */ #define DBS_ETHERWATCH_MAX_PACKET_LEN 16384 -static gboolean dbs_etherwatch_read(wtap *wth, int *err, long *data_offset); +static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean dbs_etherwatch_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err); + union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, + int *err, gchar **err_info); static int parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, - int *err); + int *err, gchar **err_info); static guint parse_single_hex_dump_line(char* rec, guint8 *buf, int byte_offset); static guint parse_hex_dump(char* dump, guint8 *buf, char seperator, char end); @@ -181,7 +183,7 @@ static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err) } -int dbs_etherwatch_open(wtap *wth, int *err) +int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info _U_) { /* Look for DBS ETHERWATCH header */ if (!dbs_etherwatch_check_file_type(wth, err)) { @@ -202,7 +204,8 @@ int dbs_etherwatch_open(wtap *wth, int *err) } /* Find the next packet and parse it; called from wtap_loop(). */ -static gboolean dbs_etherwatch_read(wtap *wth, int *err, long *data_offset) +static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { long offset; guint8 *buf; @@ -218,7 +221,7 @@ static gboolean dbs_etherwatch_read(wtap *wth, int *err, long *data_offset) buf = buffer_start_ptr(wth->frame_buffer); /* Parse the packet */ - pkt_len = parse_dbs_etherwatch_packet(wth, wth->fh, buf, err); + pkt_len = parse_dbs_etherwatch_packet(wth, wth->fh, buf, err, err_info); if (pkt_len == -1) return FALSE; @@ -236,18 +239,22 @@ static gboolean dbs_etherwatch_read(wtap *wth, int *err, long *data_offset) static gboolean dbs_etherwatch_seek_read (wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header _U_, - guint8 *pd, int len, int *err) + guint8 *pd, int len, int *err, gchar **err_info) { int pkt_len; if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1) return FALSE; - pkt_len = parse_dbs_etherwatch_packet(NULL, wth->random_fh, pd, err); + pkt_len = parse_dbs_etherwatch_packet(NULL, wth->random_fh, pd, err, + err_info); if (pkt_len != len) { - if (pkt_len != -1) + if (pkt_len != -1) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("dbs_etherwatch: packet length %d doesn't match requested length %d", + pkt_len, len); + } return FALSE; } @@ -304,7 +311,8 @@ unnumbered. Unnumbered has length 1, numbered 2. #define CTL_UNNUMB_MASK 0x03 #define CTL_UNNUMB_VALUE 0x03 static int -parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err) +parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err, + gchar **err_info) { char line[DBS_ETHERWATCH_LINE_LENGTH]; int num_items_scanned; @@ -333,12 +341,14 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err) p = strstr(line, DEST_MAC_PREFIX); if(!p) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("dbs_etherwatch: destination address not found"); return -1; } p += strlen(DEST_MAC_PREFIX); if(parse_hex_dump(p, &buf[eth_hdr_len], HEX_HDR_SPR, HEX_HDR_END) != MAC_ADDR_LENGTH) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("dbs_etherwatch: destination address not valid"); return -1; } eth_hdr_len += MAC_ADDR_LENGTH; @@ -356,6 +366,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err) if(parse_hex_dump(p, &buf[eth_hdr_len], HEX_HDR_SPR, HEX_HDR_END) != MAC_ADDR_LENGTH) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("dbs_etherwatch: source address not valid"); return -1; } eth_hdr_len += MAC_ADDR_LENGTH; @@ -372,6 +383,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err) /* Check the lines is as least as long as the length position */ if(strlen(line) < LENGTH_POS) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("dbs_etherwatch: line too short"); return -1; } @@ -384,6 +396,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err) if (num_items_scanned != 8) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("dbs_etherwatch: header line not valid"); return -1; } @@ -395,6 +408,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err) if(parse_hex_dump(&line[PROTOCOL_POS], &buf[eth_hdr_len], HEX_HDR_SPR, HEX_HDR_END) != PROTOCOL_LENGTH) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("dbs_etherwatch: Ethernet II protocol value not valid"); return -1; } eth_hdr_len += PROTOCOL_LENGTH; @@ -410,6 +424,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err) if(parse_hex_dump(&line[SAP_POS], &buf[eth_hdr_len], HEX_HDR_SPR, HEX_HDR_END) != SAP_LENGTH) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("dbs_etherwatch: 802.2 DSAP+SSAP value not valid"); return -1; } eth_hdr_len += SAP_LENGTH; @@ -417,6 +432,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err) if(parse_hex_dump(&line[CTL_POS], &buf[eth_hdr_len], HEX_HDR_SPR, HEX_HDR_END) != CTL_UNNUMB_LENGTH) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("dbs_etherwatch: 802.2 control field first part not valid"); return -1; } /* Determine whether the control is numbered, and thus longer */ @@ -426,6 +442,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err) &buf[eth_hdr_len + CTL_UNNUMB_LENGTH], HEX_HDR_END, HEX_HDR_SPR) != CTL_NUMB_LENGTH - CTL_UNNUMB_LENGTH) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("dbs_etherwatch: 802.2 control field second part value not valid"); return -1; } eth_hdr_len += CTL_NUMB_LENGTH; @@ -439,6 +456,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err) if(parse_hex_dump(&line[PID_POS], &buf[eth_hdr_len], HEX_HDR_SPR, HEX_PID_END) != PID_LENGTH) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("dbs_etherwatch: 802.2 PID value not valid"); return -1; } eth_hdr_len += PID_LENGTH; @@ -477,11 +495,13 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err) if (!(line_count = parse_single_hex_dump_line(line, &buf[eth_hdr_len + count], count))) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("dbs_etherwatch: packet data value not valid"); return -1; } count += line_count; if (count > pkt_len) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("dbs_etherwatch: packet data value has too many bytes"); return -1; } } @@ -590,7 +610,6 @@ parse_single_hex_dump_line(char* rec, guint8 *buf, int byte_offset) { /* Parse a hex dump */ static guint parse_hex_dump(char* dump, guint8 *buf, char seperator, char end) { - int pos, count; /* Parse the hex dump */ diff --git a/wiretap/dbs-etherwatch.h b/wiretap/dbs-etherwatch.h index 0c29783510..5a6ecb836a 100644 --- a/wiretap/dbs-etherwatch.h +++ b/wiretap/dbs-etherwatch.h @@ -1,6 +1,6 @@ /* dbs-etherwatch.h * - * $Id: dbs-etherwatch.h,v 1.4 2003/01/17 23:54:19 guy Exp $ + * $Id: dbs-etherwatch.h,v 1.5 2004/01/25 21:55:13 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -24,6 +24,6 @@ #ifndef __W_DBS_ETHERWATCH_H__ #define __W_DBS_ETHERWATCH_H__ -int dbs_etherwatch_open(wtap *wth, int *err); +int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info); #endif diff --git a/wiretap/erf.c b/wiretap/erf.c index 57341ac413..777b860f2c 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -32,7 +32,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * -* $Id: erf.c,v 1.6 2004/01/05 17:33:27 ulfl Exp $ +* $Id: erf.c,v 1.7 2004/01/25 21:55:13 guy Exp $ */ /* @@ -61,12 +61,14 @@ static int erf_read_header( erf_header_t *erf_header, erf_t *erf, int *err, + gchar **err_info, guint32 *bytes_read, guint32 *packet_size); -static gboolean erf_read(wtap *wth, int *err, long *data_offset); +static gboolean erf_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean erf_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, - int length, int *err); + int length, int *err, gchar **err_info); static void erf_close(wtap *wth); static int erf_encap_to_wtap_encap(erf_t *erf, guint8 erf_encap); static void erf_set_pseudo_header( @@ -76,7 +78,7 @@ static void erf_set_pseudo_header( int length, union wtap_pseudo_header *pseudo_header); -int erf_open(wtap *wth, int *err) +int erf_open(wtap *wth, int *err, gchar **err_info _U_) { guint32 i, n; char *s; @@ -213,7 +215,8 @@ int erf_open(wtap *wth, int *err) } /* Read the next packet */ -static gboolean erf_read(wtap *wth, int *err, long *data_offset) +static gboolean erf_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { erf_header_t erf_header; guint32 packet_size, bytes_read; @@ -224,7 +227,7 @@ static gboolean erf_read(wtap *wth, int *err, long *data_offset) if (!erf_read_header( wth->fh, &wth->phdr, &wth->pseudo_header, &erf_header, wth->capture.erf, - err, &bytes_read, &packet_size)) { + err, err_info, &bytes_read, &packet_size)) { return FALSE; } wth->data_offset += bytes_read; @@ -255,7 +258,7 @@ static gboolean erf_read(wtap *wth, int *err, long *data_offset) static gboolean erf_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, - int length, int *err) + int length, int *err, gchar **err_info) { erf_header_t erf_header; guint32 packet_size; @@ -264,7 +267,9 @@ static gboolean erf_seek_read(wtap *wth, long seek_off, if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - erf_read_header(wth->random_fh, NULL, pseudo_header, &erf_header, wth->capture.erf, err, NULL, &packet_size); + if (!erf_read_header(wth->random_fh, NULL, pseudo_header, &erf_header, + wth->capture.erf, err, err_info, NULL, &packet_size)) + return FALSE; if (wth->capture.erf->is_rawatm) { wtap_file_read_expected_bytes(pd, (int)sizeof(atm_hdr_t), wth->random_fh, err); @@ -291,6 +296,7 @@ static int erf_read_header( erf_header_t *erf_header, erf_t *erf, int *err, + gchar **err_info, guint32 *bytes_read, guint32 *packet_size) { @@ -310,9 +316,9 @@ static int erf_read_header( * Probably a corrupt capture file; don't blow up trying * to allocate space for an immensely-large packet. */ - g_message("erf: File has %u-byte packet, bigger than maximum of %u", - *packet_size, WTAP_MAX_PACKET_SIZE); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("erf: File has %u-byte packet, bigger than maximum of %u", + *packet_size, WTAP_MAX_PACKET_SIZE); return FALSE; } @@ -339,7 +345,6 @@ static int erf_read_header( case TYPE_ATM: case TYPE_AAL5: - if (phdr != NULL) { if (erf_header->type == TYPE_AAL5) { phdr->caplen = phdr->len = *packet_size - sizeof(atm_hdr_t); @@ -393,6 +398,8 @@ static int erf_read_header( break; default: *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("erf: unknown record encapsulation %u", + erf_header->type); return FALSE; } diff --git a/wiretap/erf.h b/wiretap/erf.h index ff9daa2dbd..2c1e404de1 100644 --- a/wiretap/erf.h +++ b/wiretap/erf.h @@ -32,7 +32,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * -* $Id: erf.h,v 1.1 2003/08/26 07:10:38 guy Exp $ +* $Id: erf.h,v 1.2 2004/01/25 21:55:13 guy Exp $ */ #ifndef __W_ERF_H__ @@ -96,6 +96,6 @@ typedef struct erf_record { #define HDLC_WLEN(h, e) (g_htons((h)->wlen)) #define HDLC_SLEN(h, e) min(HDLC_WLEN(h, e), g_htons((h)->rlen) - sizeof(*(h))) -int erf_open(wtap *wth, int *err); +int erf_open(wtap *wth, int *err, gchar **err_info); #endif /* __W_ERF_H__ */ diff --git a/wiretap/etherpeek.c b/wiretap/etherpeek.c index 53bd8f66f4..9da771ae03 100644 --- a/wiretap/etherpeek.c +++ b/wiretap/etherpeek.c @@ -2,7 +2,7 @@ * Routines for opening EtherPeek (and TokenPeek?) files * Copyright (c) 2001, Daniel Thompson <d.thompson@gmx.net> * - * $Id: etherpeek.c,v 1.25 2003/12/18 03:43:40 guy Exp $ + * $Id: etherpeek.c,v 1.26 2004/01/25 21:55:13 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -136,15 +136,19 @@ static const etherpeek_encap_lookup_t etherpeek_encap[] = { #define NUM_ETHERPEEK_ENCAPS \ (sizeof (etherpeek_encap) / sizeof (etherpeek_encap[0])) -static gboolean etherpeek_read_v7(wtap *wth, int *err, long *data_offset); +static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean etherpeek_seek_read_v7(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err); -static gboolean etherpeek_read_v56(wtap *wth, int *err, long *data_offset); + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info); +static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean etherpeek_seek_read_v56(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err); + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info); static void etherpeek_close(wtap *wth); -int etherpeek_open(wtap *wth, int *err) +int etherpeek_open(wtap *wth, int *err, gchar **err_info _U_) { etherpeek_header_t ep_hdr; struct timeval reference_time; @@ -349,7 +353,8 @@ static void etherpeek_close(wtap *wth) g_free(wth->capture.etherpeek); } -static gboolean etherpeek_read_v7(wtap *wth, int *err, long *data_offset) +static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info, + long *data_offset) { guchar ep_pkt[ETHERPEEK_V7_PKT_SIZE]; guint16 protoNum; @@ -400,6 +405,7 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, long *data_offset) * We don't *have* 4 bytes of packet data. */ *err = WTAP_ERR_BAD_RECORD; + *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); @@ -458,7 +464,8 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, long *data_offset) static gboolean etherpeek_seek_read_v7(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err) + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info) { guchar ep_pkt[ETHERPEEK_V7_PKT_SIZE]; guint8 status; @@ -484,6 +491,7 @@ etherpeek_seek_read_v7(wtap *wth, long seek_off, * We don't *have* 4 bytes of packet data. */ *err = WTAP_ERR_BAD_RECORD; + *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->random_fh, @@ -510,7 +518,8 @@ etherpeek_seek_read_v7(wtap *wth, long seek_off, return TRUE; } -static gboolean etherpeek_read_v56(wtap *wth, int *err, long *data_offset) +static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_, + long *data_offset) { guchar ep_pkt[ETHERPEEK_V56_PKT_SIZE]; guint16 length; @@ -594,7 +603,8 @@ static gboolean etherpeek_read_v56(wtap *wth, int *err, long *data_offset) static gboolean etherpeek_seek_read_v56(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err) + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info _U_) { guchar ep_pkt[ETHERPEEK_V56_PKT_SIZE]; int pkt_encap; diff --git a/wiretap/etherpeek.h b/wiretap/etherpeek.h index d0da41a915..7d28a0abad 100644 --- a/wiretap/etherpeek.h +++ b/wiretap/etherpeek.h @@ -1,6 +1,6 @@ /* etherpeek.h * - * $Id: etherpeek.h,v 1.3 2002/08/28 20:30:44 jmayer Exp $ + * $Id: etherpeek.h,v 1.4 2004/01/25 21:55:13 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -24,6 +24,6 @@ #ifndef __W_ETHERPEEK_H__ #define __W_ETHERPEEK_H__ -int etherpeek_open(wtap *wth, int *err); +int etherpeek_open(wtap *wth, int *err, gchar **err_info); #endif diff --git a/wiretap/file_access.c b/wiretap/file_access.c index 47d475a198..b6cb870ded 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -1,6 +1,6 @@ /* file_access.c * - * $Id: file_access.c,v 1.8 2003/12/02 19:37:05 guy Exp $ + * $Id: file_access.c,v 1.9 2004/01/25 21:55:13 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -91,7 +91,7 @@ * should be discovered as a libpcap file, not a toshiba file. */ -static int (*const open_routines[])(wtap *, int *) = { +static int (*const open_routines[])(wtap *, int *, char **) = { /* Files that have magic bytes in fixed locations. These * are easy to identify. */ @@ -156,7 +156,8 @@ static int (*const open_routines[])(wtap *, int *) = { so that it can do sequential I/O to a capture file that's being written to as new packets arrive independently of random I/O done to display protocol trees for packets when they're selected. */ -wtap* wtap_open_offline(const char *filename, int *err, gboolean do_random) +wtap* wtap_open_offline(const char *filename, int *err, char **err_info, + gboolean do_random) { struct stat statb; wtap *wth; @@ -257,7 +258,7 @@ wtap* wtap_open_offline(const char *filename, int *err, gboolean do_random) return NULL; } wth->data_offset = 0; - switch ((*open_routines[i])(wth, err)) { + switch ((*open_routines[i])(wth, err, err_info)) { case -1: /* I/O error - give up */ diff --git a/wiretap/hcidump.c b/wiretap/hcidump.c index 9d79792fbd..6de99d1291 100644 --- a/wiretap/hcidump.c +++ b/wiretap/hcidump.c @@ -1,6 +1,6 @@ /* hcidump.c * - * $Id: hcidump.c,v 1.2 2003/10/30 11:53:48 guy Exp $ + * $Id: hcidump.c,v 1.3 2004/01/25 21:55:13 guy Exp $ * * Copyright (c) 2003 by Marcel Holtmann <marcel@holtmann.org> * @@ -38,7 +38,8 @@ struct dump_hdr { #define DUMP_HDR_SIZE (sizeof(struct dump_hdr)) -static gboolean hcidump_read(wtap *wth, int *err, long *data_offset) +static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { struct dump_hdr dh; guint8 *buf; @@ -61,9 +62,9 @@ static gboolean hcidump_read(wtap *wth, int *err, long *data_offset) * Probably a corrupt capture file; don't blow up trying * to allocate space for an immensely-large packet. */ - g_message("hcidump: File has %u-byte packet, bigger than maximum of %u", - packet_size, WTAP_MAX_PACKET_SIZE); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("hcidump: File has %u-byte packet, bigger than maximum of %u", + packet_size, WTAP_MAX_PACKET_SIZE); return FALSE; } @@ -90,7 +91,9 @@ static gboolean hcidump_read(wtap *wth, int *err, long *data_offset) return TRUE; } -static gboolean hcidump_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int length, int *err) +static gboolean hcidump_seek_read(wtap *wth, long seek_off, + union wtap_pseudo_header *pseudo_header, guint8 *pd, int length, + int *err, gchar **err_info _U_) { struct dump_hdr dh; int bytes_read; @@ -119,7 +122,7 @@ static gboolean hcidump_seek_read(wtap *wth, long seek_off, union wtap_pseudo_he return TRUE; } -int hcidump_open(wtap *wth, int *err) +int hcidump_open(wtap *wth, int *err, gchar **err_info _U_) { struct dump_hdr dh; guint8 type; diff --git a/wiretap/hcidump.h b/wiretap/hcidump.h index 134fbf0fb4..e1d0b0c4de 100644 --- a/wiretap/hcidump.h +++ b/wiretap/hcidump.h @@ -1,6 +1,6 @@ /* hcidump.h * - * $Id: hcidump.h,v 1.1 2003/10/30 03:11:02 guy Exp $ + * $Id: hcidump.h,v 1.2 2004/01/25 21:55:14 guy Exp $ * * Copyright (c) 2003 by Marcel Holtmann <marcel@holtmann.org> * @@ -23,6 +23,6 @@ #ifndef __HCIDUMP_H__ #define __HCIDUMP_H__ -int hcidump_open(wtap *wth, int *err); +int hcidump_open(wtap *wth, int *err, gchar **err_info); #endif diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c index 4e1cb3feb5..fc0be6ac31 100644 --- a/wiretap/i4btrace.c +++ b/wiretap/i4btrace.c @@ -1,6 +1,6 @@ /* i4btrace.c * - * $Id: i4btrace.c,v 1.23 2002/10/31 07:12:41 guy Exp $ + * $Id: i4btrace.c,v 1.24 2004/01/25 21:55:15 guy Exp $ * * Wiretap Library * Copyright (c) 1999 by Bert Driehuis <driehuis@playbeing.org> @@ -32,9 +32,11 @@ #include "buffer.h" #include "i4b_trace.h" -static gboolean i4btrace_read(wtap *wth, int *err, long *data_offset); +static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean i4btrace_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err); + 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 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); @@ -50,7 +52,7 @@ static void i4btrace_close(wtap *wth); (unsigned)hdr.type > 4 || (unsigned)hdr.dir > 2 || \ (unsigned)hdr.trunc > 2048)) -int i4btrace_open(wtap *wth, int *err) +int i4btrace_open(wtap *wth, int *err, gchar **err_info _U_) { int bytes_read; i4b_trace_hdr_t hdr; @@ -110,10 +112,9 @@ int i4btrace_open(wtap *wth, int *err) return 1; } -#define V120SABME "\010\001\177" - /* Read the next packet */ -static gboolean i4btrace_read(wtap *wth, int *err, long *data_offset) +static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { int ret; i4b_trace_hdr_t hdr; @@ -131,6 +132,8 @@ static gboolean i4btrace_read(wtap *wth, int *err, long *data_offset) i4b_byte_swap_header(wth, &hdr); if (hdr.length < sizeof(hdr)) { *err = WTAP_ERR_BAD_RECORD; /* record length < header! */ + *err_info = g_strdup_printf("i4btrace: record length %u < header length %u", + hdr.length, sizeof(hdr)); return FALSE; } length = hdr.length - sizeof(hdr); @@ -178,7 +181,8 @@ static gboolean i4btrace_read(wtap *wth, int *err, long *data_offset) static gboolean i4btrace_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err) + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info _U_) { int ret; i4b_trace_hdr_t hdr; diff --git a/wiretap/i4btrace.h b/wiretap/i4btrace.h index 28bd99e13f..56bbfbc7f9 100644 --- a/wiretap/i4btrace.h +++ b/wiretap/i4btrace.h @@ -1,6 +1,6 @@ /* i4btrace.h * - * $Id: i4btrace.h,v 1.3 2002/08/28 20:30:44 jmayer Exp $ + * $Id: i4btrace.h,v 1.4 2004/01/25 21:55:15 guy Exp $ * * Wiretap Library * Copyright (c) 1999 by Bert Driehuis <driehuis@playbeing.org> @@ -24,6 +24,6 @@ #ifndef __I4BTRACE_H__ #define __I4BTRACE_H__ -int i4btrace_open(wtap *wth, int *err); +int i4btrace_open(wtap *wth, int *err, gchar **err_info); #endif 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]; diff --git a/wiretap/iptrace.h b/wiretap/iptrace.h index 0a0f53d63a..617b7bc3ab 100644 --- a/wiretap/iptrace.h +++ b/wiretap/iptrace.h @@ -1,6 +1,6 @@ /* iptrace.h * - * $Id: iptrace.h,v 1.7 2002/08/28 20:30:44 jmayer Exp $ + * $Id: iptrace.h,v 1.8 2004/01/25 21:55:15 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -24,6 +24,6 @@ #ifndef __IPTRACE_H__ #define __IPTRACE_H__ -int iptrace_open(wtap *wth, int *err); +int iptrace_open(wtap *wth, int *err, gchar **err_info); #endif diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c index dff4ddf008..51bec6af0b 100644 --- a/wiretap/lanalyzer.c +++ b/wiretap/lanalyzer.c @@ -1,6 +1,6 @@ /* lanalyzer.c * - * $Id: lanalyzer.c,v 1.45 2004/01/07 04:50:21 guy Exp $ + * $Id: lanalyzer.c,v 1.46 2004/01/25 21:55:15 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -117,13 +117,15 @@ static const guint8 LA_CyclicInformationFake[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; -static gboolean lanalyzer_read(wtap *wth, int *err, long *data_offset); +static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean lanalyzer_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err); + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info); static void lanalyzer_close(wtap *wth); static gboolean lanalyzer_dump_close(wtap_dumper *wdh, int *err); -int lanalyzer_open(wtap *wth, int *err) +int lanalyzer_open(wtap *wth, int *err, gchar **err_info) { int bytes_read; char LE_record_type[2]; @@ -242,10 +244,10 @@ int lanalyzer_open(wtap *wth, int *err) wth->file_encap = WTAP_ENCAP_TOKEN_RING; break; default: - g_message("lanalyzer: board type %u unknown", - board_type); g_free(wth->capture.lanalyzer); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("lanalyzer: board type %u unknown", + board_type); return -1; } break; @@ -270,7 +272,8 @@ int lanalyzer_open(wtap *wth, int *err) #define DESCRIPTOR_LEN 32 /* Read the next packet */ -static gboolean lanalyzer_read(wtap *wth, int *err, long *data_offset) +static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { int packet_size = 0; int bytes_read; @@ -308,9 +311,9 @@ static gboolean lanalyzer_read(wtap *wth, int *err, long *data_offset) * the middle of reading packets. If any other record type exists * after a Trace Packet Data Record, mark it as an error. */ if (record_type != RT_PacketData) { - g_message("lanalyzer: record type %u seen after trace summary record", - record_type); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("lanalyzer: record type %u seen after trace summary record", + record_type); return FALSE; } else { @@ -357,8 +360,8 @@ static gboolean lanalyzer_read(wtap *wth, int *err, long *data_offset) /* * Yes - treat this as an error. */ - g_message("lanalyzer: Record length is less than packet size"); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("lanalyzer: Record length is less than packet size"); return FALSE; } @@ -396,7 +399,8 @@ static gboolean lanalyzer_read(wtap *wth, int *err, long *data_offset) } static gboolean lanalyzer_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err) + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info _U_) { int bytes_read; diff --git a/wiretap/lanalyzer.h b/wiretap/lanalyzer.h index b896558bdb..7f597da6db 100644 --- a/wiretap/lanalyzer.h +++ b/wiretap/lanalyzer.h @@ -1,6 +1,6 @@ /* lanalyzer.h * - * $Id: lanalyzer.h,v 1.8 2002/08/28 20:30:44 jmayer Exp $ + * $Id: lanalyzer.h,v 1.9 2004/01/25 21:55:15 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -169,7 +169,7 @@ typedef struct { int lastlen; } LA_TmpInfo; -int lanalyzer_open(wtap *wth, int *err); +int lanalyzer_open(wtap *wth, int *err, gchar **err_info); gboolean lanalyzer_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err); int lanalyzer_dump_can_write_encap(int encap); diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index fad1c2204d..5dc5b02e97 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -1,6 +1,6 @@ /* libpcap.c * - * $Id: libpcap.c,v 1.107 2004/01/24 16:48:12 jmayer Exp $ + * $Id: libpcap.c,v 1.108 2004/01/25 21:55:15 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -79,20 +79,22 @@ typedef enum { } libpcap_try_t; static libpcap_try_t libpcap_try(wtap *wth, int *err); -static gboolean libpcap_read(wtap *wth, int *err, long *data_offset); +static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean libpcap_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err); -static int libpcap_read_header(wtap *wth, int *err, - struct pcaprec_ss990915_hdr *hdr, gboolean silent); + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info); +static int libpcap_read_header(wtap *wth, int *err, gchar **err_info, + struct pcaprec_ss990915_hdr *hdr); static void adjust_header(wtap *wth, struct pcaprec_hdr *hdr); static void libpcap_get_atm_pseudoheader(const struct sunatm_hdr *atm_phdr, union wtap_pseudo_header *pseudo_header); static gboolean libpcap_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err); static gboolean libpcap_get_irda_pseudoheader(const struct irda_sll_hdr *irda_phdr, - union wtap_pseudo_header *pseudo_header, int *err); + union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info); static gboolean libpcap_read_irda_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 libpcap_read_rec_data(FILE_T fh, guchar *pd, int length, int *err); static void libpcap_close(wtap *wth); @@ -490,7 +492,7 @@ int wtap_pcap_encap_to_wtap_encap(int encap) } -int libpcap_open(wtap *wth, int *err) +int libpcap_open(wtap *wth, int *err, gchar **err_info) { int bytes_read; guint32 magic; @@ -568,9 +570,9 @@ int libpcap_open(wtap *wth, int *err) } if (hdr.version_major < 2) { /* We only support version 2.0 and later. */ - g_message("pcap: major version %u unsupported", - hdr.version_major); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("pcap: major version %u unsupported", + hdr.version_major); return -1; } @@ -636,9 +638,9 @@ int libpcap_open(wtap *wth, int *err) } file_encap = wtap_pcap_encap_to_wtap_encap(hdr.network); if (file_encap == WTAP_ENCAP_UNKNOWN) { - g_message("pcap: network type %u unknown or unsupported", - hdr.network); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("pcap: network type %u unknown or unsupported", + hdr.network); return -1; } @@ -883,7 +885,7 @@ static libpcap_try_t libpcap_try(wtap *wth, int *err) /* * Attempt to read the first record's header. */ - if (libpcap_read_header(wth, err, &first_rec_hdr, TRUE) == -1) { + if (libpcap_read_header(wth, err, NULL, &first_rec_hdr) == -1) { if (*err == 0 || *err == WTAP_ERR_SHORT_READ) { /* * EOF or short read - assume the file is in this @@ -922,7 +924,7 @@ static libpcap_try_t libpcap_try(wtap *wth, int *err) /* * Now attempt to read the second record's header. */ - if (libpcap_read_header(wth, err, &second_rec_hdr, TRUE) == -1) { + if (libpcap_read_header(wth, err, NULL, &second_rec_hdr) == -1) { if (*err == 0 || *err == WTAP_ERR_SHORT_READ) { /* * EOF or short read - assume the file is in this @@ -960,7 +962,8 @@ static libpcap_try_t libpcap_try(wtap *wth, int *err) } /* Read the next packet */ -static gboolean libpcap_read(wtap *wth, int *err, long *data_offset) +static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { struct pcaprec_ss990915_hdr hdr; guint packet_size; @@ -968,7 +971,7 @@ static gboolean libpcap_read(wtap *wth, int *err, long *data_offset) int bytes_read; guchar fddi_padding[3]; - bytes_read = libpcap_read_header(wth, err, &hdr, FALSE); + bytes_read = libpcap_read_header(wth, err, err_info, &hdr); if (bytes_read == -1) { /* * We failed to read the header. @@ -1018,9 +1021,9 @@ static gboolean libpcap_read(wtap *wth, int *err, long *data_offset) * Uh-oh, the packet isn't big enough to even * have a pseudo-header. */ - g_message("libpcap: SunATM file has a %u-byte packet, too small to have even an ATM pseudo-header\n", - packet_size); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("libpcap: SunATM file has a %u-byte packet, too small to have even an ATM pseudo-header\n", + packet_size); return FALSE; } if (!libpcap_read_atm_pseudoheader(wth->fh, &wth->pseudo_header, @@ -1048,13 +1051,13 @@ static gboolean libpcap_read(wtap *wth, int *err, long *data_offset) * Uh-oh, the packet isn't big enough to even * have a pseudo-header. */ - g_message("libpcap: IrDA file has a %u-byte packet, too small to have even an IrDA pseudo-header\n", - packet_size); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("libpcap: IrDA file has a %u-byte packet, too small to have even an IrDA pseudo-header\n", + packet_size); return FALSE; } if (!libpcap_read_irda_pseudoheader(wth->fh, &wth->pseudo_header, - err)) + err, err_info)) return FALSE; /* Read error */ /* @@ -1093,7 +1096,8 @@ static gboolean libpcap_read(wtap *wth, int *err, long *data_offset) static gboolean libpcap_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err) + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; @@ -1117,7 +1121,7 @@ libpcap_seek_read(wtap *wth, long seek_off, case WTAP_ENCAP_IRDA: if (!libpcap_read_irda_pseudoheader(wth->random_fh, pseudo_header, - err)) { + err, err_info)) { /* Read error */ return FALSE; } @@ -1140,13 +1144,11 @@ libpcap_seek_read(wtap *wth, long seek_off, return TRUE; } -/* Read the header of the next packet; if "silent" is TRUE, don't complain - to the console, as we're testing to see if the file appears to be of a - particular type. +/* Read the header of the next packet. Return -1 on an error, or the number of bytes of header read on success. */ -static int libpcap_read_header(wtap *wth, int *err, - struct pcaprec_ss990915_hdr *hdr, gboolean silent) +static int libpcap_read_header(wtap *wth, int *err, gchar **err_info, + struct pcaprec_ss990915_hdr *hdr) { int bytes_to_read, bytes_read; @@ -1196,11 +1198,11 @@ static int libpcap_read_header(wtap *wth, int *err, * this is can tell when it's not the type we're guessing * it is. */ - if (!silent) { - g_message("pcap: File has %u-byte packet, bigger than maximum of %u", + *err = WTAP_ERR_BAD_RECORD; + if (err_info != NULL) { + *err_info = g_strdup_printf("pcap: File has %u-byte packet, bigger than maximum of %u", hdr->hdr.incl_len, WTAP_MAX_PACKET_SIZE); } - *err = WTAP_ERR_BAD_RECORD; return -1; } @@ -1213,11 +1215,11 @@ static int libpcap_read_header(wtap *wth, int *err, * this is can tell when it's not the type we're guessing * it is. */ - if (!silent) { - g_message("pcap: File has %u-byte packet, bigger than maximum of %u", + *err = WTAP_ERR_BAD_RECORD; + if (err_info != NULL) { + *err_info = g_strdup_printf("pcap: File has %u-byte packet, bigger than maximum of %u", hdr->hdr.orig_len, WTAP_MAX_PACKET_SIZE); } - *err = WTAP_ERR_BAD_RECORD; return -1; } @@ -1369,22 +1371,23 @@ libpcap_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header static gboolean libpcap_get_irda_pseudoheader(const struct irda_sll_hdr *irda_phdr, - union wtap_pseudo_header *pseudo_header, int *err) + union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info) { if (pntohs(&irda_phdr->sll_protocol) != 0x0017) { - g_message("libpcap: IrDA capture has a packet with an invalid sll_protocol field\n"); *err = WTAP_ERR_BAD_RECORD; + if (err_info != NULL) + *err_info = g_strdup("libpcap: IrDA capture has a packet with an invalid sll_protocol field\n"); return FALSE; } pseudo_header->irda.pkttype = pntohs(&irda_phdr->sll_pkttype); - return TRUE; + return TRUE; } static gboolean libpcap_read_irda_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, - int *err) + int *err, gchar **err_info) { struct irda_sll_hdr irda_phdr; int bytes_read; @@ -1398,7 +1401,8 @@ libpcap_read_irda_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_heade return FALSE; } - return libpcap_get_irda_pseudoheader(&irda_phdr, pseudo_header, err); + return libpcap_get_irda_pseudoheader(&irda_phdr, pseudo_header, err, + err_info); } static gboolean @@ -1529,7 +1533,7 @@ wtap_process_pcap_packet(gint linktype, const struct pcap_pkthdr *phdr, return NULL; } if (!libpcap_get_irda_pseudoheader((const struct irda_sll_hdr *)pd, - pseudo_header, err)) + pseudo_header, err, NULL)) return NULL; /* diff --git a/wiretap/libpcap.h b/wiretap/libpcap.h index 0b39214339..98a2c36f6d 100644 --- a/wiretap/libpcap.h +++ b/wiretap/libpcap.h @@ -1,6 +1,6 @@ /* libpcap.h * - * $Id: libpcap.h,v 1.14 2002/08/28 20:30:44 jmayer Exp $ + * $Id: libpcap.h,v 1.15 2004/01/25 21:55:15 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -91,7 +91,7 @@ struct pcaprec_nokia_hdr { guint8 stuff[4]; /* mysterious stuff */ }; -int libpcap_open(wtap *wth, int *err); +int libpcap_open(wtap *wth, int *err, gchar **err_info); gboolean libpcap_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err); int libpcap_dump_can_write_encap(int encap); diff --git a/wiretap/netmon.c b/wiretap/netmon.c index 2beefcdbe2..c5c48411e9 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -1,6 +1,6 @@ /* netmon.c * - * $Id: netmon.c,v 1.67 2003/12/23 00:15:02 ulfl Exp $ + * $Id: netmon.c,v 1.68 2004/01/25 21:55:15 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -104,9 +104,11 @@ struct netmon_atm_hdr { guint16 vci; /* VCI */ }; -static gboolean netmon_read(wtap *wth, int *err, long *data_offset); +static gboolean netmon_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean netmon_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err); + 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); static gboolean netmon_read_rec_data(FILE_T fh, guchar *pd, int length, @@ -117,7 +119,7 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err); static gboolean netmon_dump_close(wtap_dumper *wdh, int *err); -int netmon_open(wtap *wth, int *err) +int netmon_open(wtap *wth, int *err, gchar **err_info) { int bytes_read; char magic[sizeof netmon_1_x_magic]; @@ -184,17 +186,17 @@ int netmon_open(wtap *wth, int *err) break; default: - g_message("netmon: major version %u unsupported", hdr.ver_major); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("netmon: major version %u unsupported", hdr.ver_major); return -1; } hdr.network = pletohs(&hdr.network); if (hdr.network >= NUM_NETMON_ENCAPS || netmon_encap[hdr.network] == WTAP_ENCAP_UNKNOWN) { - g_message("netmon: network type %u unknown or unsupported", - hdr.network); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("netmon: network type %u unknown or unsupported", + hdr.network); return -1; } @@ -256,15 +258,15 @@ int netmon_open(wtap *wth, int *err) frame_table_length = pletohl(&hdr.frametablelength); frame_table_size = frame_table_length / sizeof (guint32); if ((frame_table_size * sizeof (guint32)) != frame_table_length) { - g_message("netmon: frame table length is %u, which is not a multiple of the size of an entry", - frame_table_length); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("netmon: frame table length is %u, which is not a multiple of the size of an entry", + frame_table_length); return -1; } if (frame_table_size == 0) { - g_message("netmon: frame table length is %u, which means it's less than one entry in size", - frame_table_length); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("netmon: frame table length is %u, which means it's less than one entry in size", + frame_table_length); return -1; } if (file_seek(wth->fh, frame_table_offset, SEEK_SET, err) == -1) { @@ -298,7 +300,8 @@ int netmon_open(wtap *wth, int *err) } /* Read the next packet */ -static gboolean netmon_read(wtap *wth, int *err, long *data_offset) +static gboolean netmon_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { netmon_t *netmon = wth->capture.netmon; guint32 packet_size = 0; @@ -377,9 +380,9 @@ static gboolean netmon_read(wtap *wth, int *err, long *data_offset) * Probably a corrupt capture file; don't blow up trying * to allocate space for an immensely-large packet. */ - g_message("netmon: File has %u-byte packet, bigger than maximum of %u", - packet_size, WTAP_MAX_PACKET_SIZE); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("netmon: File has %u-byte packet, bigger than maximum of %u", + packet_size, WTAP_MAX_PACKET_SIZE); return FALSE; } @@ -400,9 +403,9 @@ static gboolean netmon_read(wtap *wth, int *err, long *data_offset) * Uh-oh, the packet isn't big enough to even * have a pseudo-header. */ - g_message("netmon: ATM file has a %u-byte packet, too small to have even an ATM pseudo-header\n", - packet_size); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("netmon: ATM file has a %u-byte packet, too small to have even an ATM pseudo-header\n", + packet_size); return FALSE; } if (!netmon_read_atm_pseudoheader(wth->fh, &wth->pseudo_header, @@ -465,7 +468,8 @@ static gboolean netmon_read(wtap *wth, int *err, long *data_offset) static gboolean netmon_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err) + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info _U_) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; diff --git a/wiretap/netmon.h b/wiretap/netmon.h index 44a60dbb0a..d1c2659560 100644 --- a/wiretap/netmon.h +++ b/wiretap/netmon.h @@ -1,6 +1,6 @@ /* netmon.h * - * $Id: netmon.h,v 1.11 2002/08/28 20:30:45 jmayer Exp $ + * $Id: netmon.h,v 1.12 2004/01/25 21:55:15 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -23,7 +23,7 @@ #ifndef __NETMON_H__ #define __NETMON_H__ -int netmon_open(wtap *wth, int *err); +int netmon_open(wtap *wth, int *err, gchar **err_info); gboolean netmon_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err); int netmon_dump_can_write_encap(int encap); diff --git a/wiretap/nettl.c b/wiretap/nettl.c index a4252d4c06..32cc110731 100644 --- a/wiretap/nettl.c +++ b/wiretap/nettl.c @@ -1,6 +1,6 @@ /* nettl.c * - * $Id: nettl.c,v 1.33 2003/10/01 07:11:48 guy Exp $ + * $Id: nettl.c,v 1.34 2004/01/25 21:55:16 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -123,18 +123,19 @@ struct nettlrec_ns_ls_drv_eth_hdr { }; -static gboolean nettl_read(wtap *wth, int *err, long *data_offset); +static gboolean nettl_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean nettl_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, - int length, int *err); + int length, int *err, gchar **err_info); static int nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, union wtap_pseudo_header *pseudo_header, - int *err); + int *err, gchar **err_info); static gboolean nettl_read_rec_data(FILE_T fh, guchar *pd, int length, int *err); static void nettl_close(wtap *wth); -int nettl_open(wtap *wth, int *err) +int nettl_open(wtap *wth, int *err, gchar **err_info _U_) { char magic[12], os_vers[2]; int bytes_read; @@ -185,14 +186,15 @@ int nettl_open(wtap *wth, int *err) } /* Read the next packet */ -static gboolean nettl_read(wtap *wth, int *err, long *data_offset) +static gboolean nettl_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { int ret; /* Read record header. */ *data_offset = wth->data_offset; ret = nettl_read_rec_header(wth, wth->fh, &wth->phdr, &wth->pseudo_header, - err); + err, err_info); if (ret <= 0) { /* Read error or EOF */ return FALSE; @@ -213,7 +215,7 @@ static gboolean nettl_read(wtap *wth, int *err, long *data_offset) static gboolean nettl_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, - int length, int *err) + int length, int *err, gchar **err_info) { int ret; struct wtap_pkthdr phdr; @@ -223,7 +225,7 @@ nettl_seek_read(wtap *wth, long seek_off, /* Read record header. */ ret = nettl_read_rec_header(wth, wth->random_fh, &phdr, pseudo_header, - err); + err, err_info); if (ret <= 0) { /* Read error or EOF */ if (ret == 0) { @@ -241,7 +243,8 @@ nettl_seek_read(wtap *wth, long seek_off, static int nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, - union wtap_pseudo_header *pseudo_header, int *err) + union wtap_pseudo_header *pseudo_header, int *err, + gchar **err_info) { int bytes_read; struct nettlrec_sx25l2_hdr lapb_hdr; @@ -435,9 +438,9 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, (lapb_hdr.from_dce & 0x20 ? FROM_DCE : 0x00); break; default: - g_message("nettl: network type %u unknown or unsupported", - encap[3]); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("nettl: network type %u unknown or unsupported", + encap[3]); return -1; } return offset; diff --git a/wiretap/nettl.h b/wiretap/nettl.h index 2202fa1fe2..acad0ce7ce 100644 --- a/wiretap/nettl.h +++ b/wiretap/nettl.h @@ -1,6 +1,6 @@ /* nettl.h * - * $Id: nettl.h,v 1.9 2003/05/05 01:01:36 guy Exp $ + * $Id: nettl.h,v 1.10 2004/01/25 21:55:16 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -80,6 +80,6 @@ #define NETTL_SUBSYS_IGELAN 0xFC -int nettl_open(wtap *wth, int *err); +int nettl_open(wtap *wth, int *err, gchar **err_info); #endif diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c index 594945eebd..4bd41fda4e 100644 --- a/wiretap/network_instruments.c +++ b/wiretap/network_instruments.c @@ -1,5 +1,5 @@ /* - * $Id: network_instruments.c,v 1.6 2004/01/05 17:33:28 ulfl Exp $ + * $Id: network_instruments.c,v 1.7 2004/01/25 21:55:16 guy Exp $ */ /*************************************************************************** @@ -96,14 +96,16 @@ static void init_time_offset(void) } static gboolean fill_time_struct(guint64 ns_since2000, observer_time* time_conversion); -static gboolean observer_read(wtap *wth, int *err, long *data_offset); +static gboolean observer_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean observer_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err); + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info); static gboolean observer_dump_close(wtap_dumper *wdh, int *err); static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err); -int network_instruments_open(wtap *wth, int *err) +int network_instruments_open(wtap *wth, int *err, gchar **err_info) { int bytes_read; @@ -128,8 +130,8 @@ int network_instruments_open(wtap *wth, int *err) /* check the version */ if (strncmp(network_instruments_magic, file_header.observer_version, 30)!=0) { - g_message("Observer: unsupported file version %s", file_header.observer_version); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("Observer: unsupported file version %s", file_header.observer_version); return -1; } @@ -155,15 +157,15 @@ int network_instruments_open(wtap *wth, int *err) /* check the packet's magic number; the magic number is all 8's, so the byte order doesn't matter */ if (packet_header.packet_magic != observer_packet_magic) { - g_message("Observer: unsupported packet version %ul", packet_header.packet_magic); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("Observer: unsupported packet version %ul", packet_header.packet_magic); return -1; } /* Check the data link type. */ if (packet_header.network_type >= NUM_OBSERVER_ENCAPS) { - g_message("observer: network type %u unknown or unsupported", packet_header.network_type); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("observer: network type %u unknown or unsupported", packet_header.network_type); return -1; } wth->file_encap = observer_encap[packet_header.network_type]; @@ -192,7 +194,8 @@ int network_instruments_open(wtap *wth, int *err) } /* reads the next packet */ -static gboolean observer_read(wtap *wth, int *err, long *data_offset) +static gboolean observer_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { int bytes_read; long seek_increment; @@ -217,8 +220,8 @@ static gboolean observer_read(wtap *wth, int *err, long *data_offset) /* check the packet's magic number; the magic number is all 8's, so the byte order doesn't matter */ if (packet_header.packet_magic != observer_packet_magic) { - g_message("Observer: bad record"); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("Observer: bad record"); return FALSE; } @@ -244,10 +247,10 @@ static gboolean observer_read(wtap *wth, int *err, long *data_offset) packet_header.offset_to_frame = GUINT16_FROM_LE(packet_header.offset_to_frame); if (packet_header.offset_to_frame < sizeof(packet_header)) { - g_message("Observer: bad record (offset to frame %u < %lu)", + *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("Observer: bad record (offset to frame %u < %lu)", packet_header.offset_to_frame, (unsigned long)sizeof(packet_header)); - *err = WTAP_ERR_BAD_RECORD; return FALSE; } seek_increment = packet_header.offset_to_frame - sizeof(packet_header); @@ -276,7 +279,8 @@ static gboolean observer_read(wtap *wth, int *err, long *data_offset) /* reads a packet at an offset */ static gboolean observer_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err) + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info) { packet_entry_header packet_header; @@ -296,8 +300,8 @@ static gboolean observer_seek_read(wtap *wth, long seek_off, /* check the packets magic number */ if (packet_header.packet_magic != observer_packet_magic) { - g_message("Observer: bad record in observer_seek_read"); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("Observer: bad magic number for record in observer_seek_read"); return FALSE; } @@ -305,7 +309,6 @@ static gboolean observer_seek_read(wtap *wth, long seek_off, bytes_read = file_read(pd, 1, length, wth->random_fh); if (bytes_read != length) { *err = file_error(wth->fh); - g_message("Observer: read error in observer_seek_read"); return FALSE; } diff --git a/wiretap/network_instruments.h b/wiretap/network_instruments.h index 7760f1580a..63c6b83302 100644 --- a/wiretap/network_instruments.h +++ b/wiretap/network_instruments.h @@ -1,5 +1,5 @@ /* - * $Id: network_instruments.h,v 1.4 2003/11/06 22:45:28 guy Exp $ + * $Id: network_instruments.h,v 1.5 2004/01/25 21:55:16 guy Exp $ */ /*************************************************************************** @@ -22,7 +22,7 @@ #ifndef __NETWORK_INSTRUMENTS_H__ #define __NETWORK_INSTRUMENTS_H__ -int network_instruments_open(wtap *wth, int *err); +int network_instruments_open(wtap *wth, int *err, gchar **err_info); int network_instruments_dump_can_write_encap(int encap); gboolean network_instruments_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err); diff --git a/wiretap/netxray.c b/wiretap/netxray.c index c604fd223c..8922a8b429 100644 --- a/wiretap/netxray.c +++ b/wiretap/netxray.c @@ -1,6 +1,6 @@ /* netxray.c * - * $Id: netxray.c,v 1.86 2004/01/19 02:23:18 guy Exp $ + * $Id: netxray.c,v 1.87 2004/01/25 21:55:16 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -151,9 +151,11 @@ union netxrayrec_hdr { struct netxrayrec_2_x_hdr hdr_2_x; }; -static gboolean netxray_read(wtap *wth, int *err, long *data_offset); +static gboolean netxray_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean netxray_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err); + 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); static guint netxray_set_pseudo_header(wtap *wth, const guint8 *pd, int len, @@ -170,7 +172,7 @@ static gboolean netxray_dump_2_0(wtap_dumper *wdh, const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err); static gboolean netxray_dump_close_2_0(wtap_dumper *wdh, int *err); -int netxray_open(wtap *wth, int *err) +int netxray_open(wtap *wth, int *err, gchar **err_info) { int bytes_read; char magic[sizeof netxray_magic]; @@ -274,8 +276,8 @@ int netxray_open(wtap *wth, int *err) version_minor = 2; file_type = WTAP_FILE_NETXRAY_2_00x; } else { - g_message("netxray: version \"%.8s\" unsupported", hdr.version); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("netxray: version \"%.8s\" unsupported", hdr.version); return -1; } } @@ -302,17 +304,17 @@ int netxray_open(wtap *wth, int *err) break; default: - g_message("netxray: the byte after the network type has the value %u, which I don't understand", - hdr.xxz[0]); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("netxray: the byte after the network type has the value %u, which I don't understand", + hdr.xxz[0]); return -1; } if (network_type >= NUM_NETXRAY_ENCAPS || netxray_encap[network_type] == WTAP_ENCAP_UNKNOWN) { - g_message("netxray: network type %u (%u) unknown or unsupported", - network_type, hdr.xxz[0]); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("netxray: network type %u (%u) unknown or unsupported", + network_type, hdr.xxz[0]); return -1; } @@ -380,9 +382,9 @@ int netxray_open(wtap *wth, int *err) } } else { if (hdr.timeunit > NUM_NETXRAY_TIMEUNITS) { - g_message("netxray: Unknown timeunit %u", - hdr.timeunit); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("netxray: Unknown timeunit %u", + hdr.timeunit); return -1; } timeunit = TpS[hdr.timeunit]; @@ -442,9 +444,9 @@ int netxray_open(wtap *wth, int *err) break; default: - g_message("netxray: WAN HDLC capture subsubtype 0x%02x unknown or unsupported", - hdr.xxb[28]); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("netxray: WAN HDLC capture subsubtype 0x%02x unknown or unsupported", + hdr.xxb[28]); return -1; } break; @@ -457,9 +459,9 @@ int netxray_open(wtap *wth, int *err) break; default: - g_message("netxray: WAN capture subtype 0x%02x unknown or unsupported", - hdr.xxb[20]); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("netxray: WAN capture subtype 0x%02x unknown or unsupported", + hdr.xxb[20]); return -1; } } else @@ -544,7 +546,8 @@ int netxray_open(wtap *wth, int *err) } /* Read the next packet */ -static gboolean netxray_read(wtap *wth, int *err, long *data_offset) +static gboolean netxray_read(wtap *wth, int *err, gchar **err_info _U_, + long *data_offset) { guint32 packet_size; union netxrayrec_hdr hdr; @@ -650,7 +653,8 @@ reread: static gboolean netxray_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err) + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info _U_) { union netxrayrec_hdr hdr; gboolean ret; diff --git a/wiretap/netxray.h b/wiretap/netxray.h index e4b4914814..0aae12380a 100644 --- a/wiretap/netxray.h +++ b/wiretap/netxray.h @@ -1,6 +1,6 @@ /* netxray.h * - * $Id: netxray.h,v 1.11 2003/01/30 22:38:47 guy Exp $ + * $Id: netxray.h,v 1.12 2004/01/25 21:55:16 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -23,7 +23,7 @@ #ifndef __NETXRAY_H__ #define __NETXRAY_H__ -int netxray_open(wtap *wth, int *err); +int netxray_open(wtap *wth, int *err, gchar **err_info); int netxray_dump_can_write_encap_1_1(int encap); gboolean netxray_dump_open_1_1(wtap_dumper *wdh, gboolean cant_seek, int *err); int netxray_dump_can_write_encap_2_0(int encap); diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c index b0994cfcda..fcabc3f20e 100644 --- a/wiretap/ngsniffer.c +++ b/wiretap/ngsniffer.c @@ -1,6 +1,6 @@ /* ngsniffer.c * - * $Id: ngsniffer.c,v 1.112 2003/10/25 07:17:27 guy Exp $ + * $Id: ngsniffer.c,v 1.113 2004/01/25 21:55:16 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -353,15 +353,17 @@ struct frame6_rec { #define NUM_NGSNIFF_TIMEUNITS 7 static double Usec[] = { 15.0, 0.838096, 15.0, 0.5, 2.0, 1.0, 0.1 }; -static int process_header_records(wtap *wth, int *err, gint16 maj_vers); +static int process_header_records(wtap *wth, int *err, gchar **err_info, + gint16 maj_vers); static int process_rec_header2_v2(wtap *wth, unsigned char *buffer, - guint16 length, int *err); + guint16 length, int *err, gchar **err_info); static int process_rec_header2_v145(wtap *wth, unsigned char *buffer, - guint16 length, gint16 maj_vers, int *err); -static gboolean ngsniffer_read(wtap *wth, int *err, long *data_offset); + guint16 length, gint16 maj_vers, int *err, gchar **err_info); +static gboolean ngsniffer_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean ngsniffer_seek_read(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 ngsniffer_read_rec_header(wtap *wth, gboolean is_random, guint16 *typep, guint16 *lengthp, int *err); static gboolean ngsniffer_read_frame2(wtap *wth, gboolean is_random, @@ -395,7 +397,7 @@ static int read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, static long ng_file_seek_seq(wtap *wth, long offset, int whence, int *err); static long ng_file_seek_rand(wtap *wth, long offset, int whence, int *err); -int ngsniffer_open(wtap *wth, int *err) +int ngsniffer_open(wtap *wth, int *err, gchar **err_info) { int bytes_read; char magic[sizeof ngsniffer_magic]; @@ -457,8 +459,8 @@ int ngsniffer_open(wtap *wth, int *err) length = pletohs(record_length); if (type != REC_VERS) { - g_message("ngsniffer: Sniffer file doesn't start with a version record"); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("ngsniffer: Sniffer file doesn't start with a version record"); return -1; } @@ -475,16 +477,16 @@ int ngsniffer_open(wtap *wth, int *err) /* Check the data link type. */ if (version.network >= NUM_NGSNIFF_ENCAPS || sniffer_encap[version.network] == WTAP_ENCAP_UNKNOWN) { - g_message("ngsniffer: network type %u unknown or unsupported", - version.network); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("ngsniffer: network type %u unknown or unsupported", + version.network); return -1; } /* Check the time unit */ if (version.timeunit >= NUM_NGSNIFF_TIMEUNITS) { - g_message("ngsniffer: Unknown timeunit %u", version.timeunit); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("ngsniffer: Unknown timeunit %u", version.timeunit); return -1; } @@ -515,7 +517,7 @@ int ngsniffer_open(wtap *wth, int *err) * the DOS Sniffer understands? */ maj_vers = pletohs(&version.maj_vers); - if (process_header_records(wth, err, maj_vers) < 0) + if (process_header_records(wth, err, err_info, maj_vers) < 0) return -1; if (wth->file_encap == WTAP_ENCAP_PER_PACKET) { /* @@ -630,7 +632,7 @@ int ngsniffer_open(wtap *wth, int *err) } static int -process_header_records(wtap *wth, int *err, gint16 maj_vers) +process_header_records(wtap *wth, int *err, gchar **err_info, gint16 maj_vers) { int bytes_read; char record_type[2]; @@ -713,7 +715,7 @@ process_header_records(wtap *wth, int *err, gint16 maj_vers) case 2: if (process_rec_header2_v2(wth, buffer, - length, err) < 0) + length, err, err_info) < 0) return -1; break; @@ -721,7 +723,7 @@ process_header_records(wtap *wth, int *err, gint16 maj_vers) case 4: case 5: if (process_rec_header2_v145(wth, buffer, - length, maj_vers, err) < 0) + length, maj_vers, err, err_info) < 0) return -1; break; } @@ -745,7 +747,7 @@ process_header_records(wtap *wth, int *err, gint16 maj_vers) static int process_rec_header2_v2(wtap *wth, unsigned char *buffer, guint16 length, - int *err) + int *err, gchar **err_info) { static const char x_25_str[] = "HDLC\nX.25\n"; @@ -760,20 +762,20 @@ process_rec_header2_v2(wtap *wth, unsigned char *buffer, guint16 length, /* * There's not enough data to compare. */ - g_message("ngsniffer: WAN capture has too-short protocol list"); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("ngsniffer: WAN capture has too-short protocol list"); return -1; } - if (strncmp(buffer, x_25_str, sizeof x_25_str - 1) == 0) { + if (strncmp((char *)buffer, x_25_str, sizeof x_25_str - 1) == 0) { /* * X.25. */ wth->file_encap = WTAP_ENCAP_LAPB; } else { - g_message("ngsniffer: WAN capture protocol string %.*s unknown", - length, buffer); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("ngsniffer: WAN capture protocol string %.*s unknown", + length, buffer); return -1; } return 0; @@ -781,7 +783,7 @@ process_rec_header2_v2(wtap *wth, unsigned char *buffer, guint16 length, static int process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length, - gint16 maj_vers, int *err) + gint16 maj_vers, int *err, gchar **err_info) { /* * The 5th byte of the REC_HEADER2 record appears to be a @@ -791,8 +793,8 @@ process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length, /* * There is no 5th byte; give up. */ - g_message("ngsniffer: WAN capture has no network subtype"); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup("ngsniffer: WAN capture has no network subtype"); return -1; } @@ -860,8 +862,8 @@ process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length, /* * There is no 5th byte; give up. */ - g_message("ngsniffer: WAN bridge/router capture has no ISDN flag"); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup("ngsniffer: WAN bridge/router capture has no ISDN flag"); return -1; } if (buffer[6] == 0x01) @@ -878,16 +880,17 @@ process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length, /* * Reject these until we can figure them out. */ - g_message("ngsniffer: WAN network subtype %u unknown or unsupported", - buffer[4]); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("ngsniffer: WAN network subtype %u unknown or unsupported", + buffer[4]); return -1; } return 0; } /* Read the next packet */ -static gboolean ngsniffer_read(wtap *wth, int *err, long *data_offset) +static gboolean ngsniffer_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { int ret; guint16 type, length; @@ -919,8 +922,8 @@ static gboolean ngsniffer_read(wtap *wth, int *err, long *data_offset) * We shouldn't get a frame2 record in * an ATM capture. */ - g_message("ngsniffer: REC_FRAME2 record in an ATM Sniffer file"); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("ngsniffer: REC_FRAME2 record in an ATM Sniffer file"); return FALSE; } @@ -951,8 +954,8 @@ static gboolean ngsniffer_read(wtap *wth, int *err, long *data_offset) * We shouldn't get a frame2 record in * a non-ATM capture. */ - g_message("ngsniffer: REC_FRAME4 record in a non-ATM Sniffer file"); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("ngsniffer: REC_FRAME4 record in a non-ATM Sniffer file"); return FALSE; } @@ -1048,8 +1051,8 @@ found: /* * Yes - treat this as an error. */ - g_message("ngsniffer: Record length is less than packet size"); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("ngsniffer: Record length is less than packet size"); return FALSE; } @@ -1078,7 +1081,7 @@ found: static gboolean ngsniffer_seek_read(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; guint16 type, length; diff --git a/wiretap/ngsniffer.h b/wiretap/ngsniffer.h index 2d3e48b338..c861e9c4e8 100644 --- a/wiretap/ngsniffer.h +++ b/wiretap/ngsniffer.h @@ -1,6 +1,6 @@ /* ngsniffer.h * - * $Id: ngsniffer.h,v 1.12 2002/08/28 20:30:45 jmayer Exp $ + * $Id: ngsniffer.h,v 1.13 2004/01/25 21:55:16 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -23,7 +23,7 @@ #ifndef __NGSNIFFER_H__ #define __NGSNIFFER_H__ -int ngsniffer_open(wtap *wth, int *err); +int ngsniffer_open(wtap *wth, int *err, gchar **err_info); gboolean ngsniffer_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err); int ngsniffer_dump_can_write_encap(int encap); diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c index 2fe86b40bd..914460c977 100644 --- a/wiretap/pppdump.c +++ b/wiretap/pppdump.c @@ -1,6 +1,6 @@ /* pppdump.c * - * $Id: pppdump.c,v 1.24 2002/08/28 20:30:45 jmayer Exp $ + * $Id: pppdump.c,v 1.25 2004/01/25 21:55:17 guy Exp $ * * Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu> * @@ -98,9 +98,11 @@ typedef enum { DIRECTION_RECV } direction_enum; -static gboolean pppdump_read(wtap *wth, int *err, long *data_offset); +static gboolean pppdump_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean pppdump_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err); + union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, + int *err, gchar **err_info); /* * Information saved about a packet, during the initial sequential pass @@ -211,8 +213,9 @@ process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd, int *err, pkt_id *pid); static gboolean -collate(pppdump_t*, FILE_T fh, int *err, guint8 *pd, int *num_bytes, - direction_enum *direction, pkt_id *pid, int num_bytes_to_skip); +collate(pppdump_t*, FILE_T fh, int *err, gchar **err_info, guint8 *pd, + int *num_bytes, direction_enum *direction, pkt_id *pid, + int num_bytes_to_skip); static void pppdump_close(wtap *wth); @@ -244,7 +247,7 @@ init_state(pppdump_t *state) int -pppdump_open(wtap *wth, int *err) +pppdump_open(wtap *wth, int *err, gchar **err_info _U_) { guint8 buffer[6]; /* Looking for: 0x07 t3 t2 t1 t0 ID */ pppdump_t *state; @@ -308,7 +311,7 @@ pppdump_open(wtap *wth, int *err) /* Find the next packet and parse it; called from wtap_loop(). */ static gboolean -pppdump_read(wtap *wth, int *err, long *data_offset) +pppdump_read(wtap *wth, int *err, gchar **err_info, long *data_offset) { int num_bytes; direction_enum direction; @@ -333,7 +336,7 @@ pppdump_read(wtap *wth, int *err, long *data_offset) } else pid = NULL; /* sequential only */ - if (!collate(state, wth->fh, err, buf, &num_bytes, &direction, + if (!collate(state, wth->fh, err, err_info, buf, &num_bytes, &direction, pid, 0)) { if (pid != NULL) g_free(pid); @@ -522,8 +525,9 @@ process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd, /* Returns TRUE if packet data copied, FALSE if error occurred or EOF (no more records). */ static gboolean -collate(pppdump_t* state, FILE_T fh, int *err, guint8 *pd, int *num_bytes, - direction_enum *direction, pkt_id *pid, int num_bytes_to_skip) +collate(pppdump_t* state, FILE_T fh, int *err, gchar **err_info, guint8 *pd, + int *num_bytes, direction_enum *direction, pkt_id *pid, + int num_bytes_to_skip) { int id; pkt_t *pkt = NULL; @@ -660,8 +664,8 @@ collate(pppdump_t* state, FILE_T fh, int *err, guint8 *pd, int *num_bytes, default: /* XXX - bad file */ - g_message("pppdump: bad ID byte 0x%02x", id); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("pppdump: bad ID byte 0x%02x", id); return FALSE; } @@ -680,7 +684,8 @@ pppdump_seek_read(wtap *wth, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, - int *err) + int *err, + gchar **err_info) { int num_bytes; direction_enum direction; @@ -693,6 +698,7 @@ pppdump_seek_read(wtap *wth, pid = g_ptr_array_index(state->pids, seek_off); if (!pid) { *err = WTAP_ERR_BAD_RECORD; /* XXX - better error? */ + *err_info = g_strdup("pppdump: PID not found for record"); return FALSE; } @@ -715,14 +721,16 @@ pppdump_seek_read(wtap *wth, */ num_bytes_to_skip = pid->num_bytes_to_skip; do { - if (!collate(state->seek_state, wth->random_fh, err, pd, - &num_bytes, &direction, NULL, num_bytes_to_skip)) + if (!collate(state->seek_state, wth->random_fh, err, err_info, + pd, &num_bytes, &direction, NULL, num_bytes_to_skip)) return FALSE; num_bytes_to_skip = 0; } while (direction != pid->dir); if (len != num_bytes) { *err = WTAP_ERR_BAD_RECORD; /* XXX - better error? */ + *err_info = g_strdup_printf("pppdump: requested length %d doesn't match record length %d", + len, num_bytes); return FALSE; } diff --git a/wiretap/pppdump.h b/wiretap/pppdump.h index d57548ad92..49ea0eda40 100644 --- a/wiretap/pppdump.h +++ b/wiretap/pppdump.h @@ -1,6 +1,6 @@ /* pppdump.h * - * $Id: pppdump.h,v 1.3 2002/08/28 20:30:45 jmayer Exp $ + * $Id: pppdump.h,v 1.4 2004/01/25 21:55:17 guy Exp $ * * Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu> * @@ -23,6 +23,6 @@ #ifndef __PPPDUMP_H__ #define __PPPDUMP_H__ -int pppdump_open(wtap *wth, int *err); +int pppdump_open(wtap *wth, int *err, gchar **err_info); #endif diff --git a/wiretap/radcom.c b/wiretap/radcom.c index 7754c1555e..0c93110908 100644 --- a/wiretap/radcom.c +++ b/wiretap/radcom.c @@ -1,6 +1,6 @@ /* radcom.c * - * $Id: radcom.c,v 1.43 2004/01/24 16:48:12 jmayer Exp $ + * $Id: radcom.c,v 1.44 2004/01/25 21:55:17 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -89,16 +89,17 @@ struct radcomrec_hdr { char xxw[9]; /* unknown */ }; -static gboolean radcom_read(wtap *wth, int *err, long *data_offset); +static gboolean radcom_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean radcom_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, - int *err); + int *err, gchar **err_info); static int radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *hdr, int *err); static gboolean radcom_read_rec_data(FILE_T fh, guchar *pd, int length, int *err); -int radcom_open(wtap *wth, int *err) +int radcom_open(wtap *wth, int *err, gchar **err_info) { int bytes_read; guint8 r_magic[8], t_magic[11], search_encap[7]; @@ -218,8 +219,8 @@ int radcom_open(wtap *wth, int *err) else if (memcmp(search_encap, "ATM/", 4) == 0) wth->file_encap = WTAP_ENCAP_ATM_RFC1483; else { - g_message("pcap: network type \"%.4s\" unknown", search_encap); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("radcom: network type \"%.4s\" unknown", search_encap); return -1; } @@ -264,7 +265,8 @@ read_error: } /* Read the next packet */ -static gboolean radcom_read(wtap *wth, int *err, long *data_offset) +static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_, + long *data_offset) { int ret; struct radcomrec_hdr hdr; @@ -372,7 +374,8 @@ static gboolean radcom_read(wtap *wth, int *err, long *data_offset) static gboolean radcom_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err) + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info _U_) { int ret; struct radcomrec_hdr hdr; diff --git a/wiretap/radcom.h b/wiretap/radcom.h index 81051fbe63..a345a0f0ff 100644 --- a/wiretap/radcom.h +++ b/wiretap/radcom.h @@ -1,6 +1,6 @@ /* radcom.h * - * $Id: radcom.h,v 1.7 2002/08/28 20:30:45 jmayer Exp $ + * $Id: radcom.h,v 1.8 2004/01/25 21:55:17 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -24,6 +24,6 @@ #ifndef __RADCOM_H__ #define __RADCOM_H__ -int radcom_open(wtap *wth, int *err); +int radcom_open(wtap *wth, int *err, gchar **err_info); #endif diff --git a/wiretap/snoop.c b/wiretap/snoop.c index 2003a4ad5f..bc3a8811c4 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -1,6 +1,6 @@ /* snoop.c * - * $Id: snoop.c,v 1.67 2004/01/05 17:33:28 ulfl Exp $ + * $Id: snoop.c,v 1.68 2004/01/25 21:55:17 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -88,9 +88,11 @@ struct shomiti_trailer { #define RX_STATUS_FIFO_ERROR 0x0080 /* receive FIFO error */ #define RX_STATUS_TRIGGERED 0x0001 /* frame did trigger */ -static gboolean snoop_read(wtap *wth, int *err, long *data_offset); +static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean snoop_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err); + 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); static gboolean snoop_read_rec_data(FILE_T fh, guchar *pd, int length, @@ -171,7 +173,7 @@ static gboolean snoop_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, * and distinguishing 4MB from 16MB Token Ring, and distinguishing both * of them from the "Shomiti" versions of same. */ -int snoop_open(wtap *wth, int *err) +int snoop_open(wtap *wth, int *err, gchar **err_info) { int bytes_read; char magic[sizeof snoop_magic]; @@ -269,8 +271,8 @@ int snoop_open(wtap *wth, int *err) break; default: - g_message("snoop: version %u unsupported", hdr.version); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("snoop: version %u unsupported", hdr.version); return -1; } @@ -364,9 +366,9 @@ int snoop_open(wtap *wth, int *err) if (is_shomiti) { if (hdr.network >= NUM_SHOMITI_ENCAPS || shomiti_encap[hdr.network] == WTAP_ENCAP_UNKNOWN) { - g_message("snoop: Shomiti network type %u unknown or unsupported", - hdr.network); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("snoop: Shomiti network type %u unknown or unsupported", + hdr.network); return -1; } file_encap = shomiti_encap[hdr.network]; @@ -376,9 +378,9 @@ int snoop_open(wtap *wth, int *err) } else { if (hdr.network >= NUM_SNOOP_ENCAPS || snoop_encap[hdr.network] == WTAP_ENCAP_UNKNOWN) { - g_message("snoop: network type %u unknown or unsupported", - hdr.network); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("snoop: network type %u unknown or unsupported", + hdr.network); return -1; } file_encap = snoop_encap[hdr.network]; @@ -400,7 +402,8 @@ int snoop_open(wtap *wth, int *err) } /* Read the next packet */ -static gboolean snoop_read(wtap *wth, int *err, long *data_offset) +static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { guint32 rec_size; guint32 packet_size; @@ -430,18 +433,18 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset) * Probably a corrupt capture file; don't blow up trying * to allocate space for an immensely-large packet. */ - g_message("snoop: File has %u-byte packet, bigger than maximum of %u", - packet_size, WTAP_MAX_PACKET_SIZE); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("snoop: File has %u-byte packet, bigger than maximum of %u", + packet_size, WTAP_MAX_PACKET_SIZE); return FALSE; } if (packet_size > rec_size) { /* * Probably a corrupt capture file. */ - g_message("snoop: File has %u-byte packet, bigger than record size %u", - packet_size, rec_size); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("snoop: File has %u-byte packet, bigger than record size %u", + packet_size, rec_size); return FALSE; } @@ -461,9 +464,9 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset) * Uh-oh, the packet isn't big enough to even * have a pseudo-header. */ - g_message("snoop: atmsnoop file has a %u-byte packet, too small to have even an ATM pseudo-header\n", - packet_size); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("snoop: atmsnoop file has a %u-byte packet, too small to have even an ATM pseudo-header\n", + packet_size); return FALSE; } if (!snoop_read_atm_pseudoheader(wth->fh, &wth->pseudo_header, @@ -525,9 +528,9 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset) /* * What, *negative* padding? Bogus. */ - g_message("snoop: File has %u-byte record with packet size of %u", - rec_size, packet_size); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("snoop: File has %u-byte record with packet size of %u", + rec_size, packet_size); return FALSE; } padbytes = rec_size - (sizeof hdr + packet_size); @@ -552,7 +555,8 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset) static gboolean snoop_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err) + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info _U_) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; diff --git a/wiretap/snoop.h b/wiretap/snoop.h index 3571c6bbaa..7be282ab04 100644 --- a/wiretap/snoop.h +++ b/wiretap/snoop.h @@ -1,6 +1,6 @@ /* snoop.h * - * $Id: snoop.h,v 1.12 2002/08/28 20:30:45 jmayer Exp $ + * $Id: snoop.h,v 1.13 2004/01/25 21:55:17 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -23,7 +23,7 @@ #ifndef __W_SNOOP_H__ #define __W_SNOOP_H__ -int snoop_open(wtap *wth, int *err); +int snoop_open(wtap *wth, int *err, gchar **err_info); gboolean snoop_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err); int snoop_dump_can_write_encap(int encap); diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c index 68370ecaa6..315ab9649a 100644 --- a/wiretap/toshiba.c +++ b/wiretap/toshiba.c @@ -1,6 +1,6 @@ /* toshiba.c * - * $Id: toshiba.c,v 1.28 2004/01/05 17:33:28 ulfl Exp $ + * $Id: toshiba.c,v 1.29 2004/01/25 21:55:17 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -109,15 +109,17 @@ static const char toshiba_rec_magic[] = { '[', 'N', 'o', '.' }; */ #define TOSHIBA_MAX_PACKET_LEN 16384 -static gboolean toshiba_read(wtap *wth, int *err, long *data_offset); +static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean toshiba_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err); + union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, + int *err, gchar **err_info); static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf, guint byte_offset); static gboolean parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf, - int *err); + int *err, gchar **err_info); static int parse_toshiba_rec_hdr(wtap *wth, FILE_T fh, - union wtap_pseudo_header *pseudo_header, int *err); + 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. */ @@ -208,7 +210,7 @@ static gboolean toshiba_check_file_type(wtap *wth, int *err) } -int toshiba_open(wtap *wth, int *err) +int toshiba_open(wtap *wth, int *err, gchar **err_info _U_) { /* Look for Toshiba header */ if (!toshiba_check_file_type(wth, err)) { @@ -229,7 +231,8 @@ int toshiba_open(wtap *wth, int *err) } /* Find the next packet and parse it; called from wtap_loop(). */ -static gboolean toshiba_read(wtap *wth, int *err, long *data_offset) +static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { long offset; guint8 *buf; @@ -241,7 +244,8 @@ static gboolean toshiba_read(wtap *wth, int *err, long *data_offset) return FALSE; /* Parse the header */ - pkt_len = parse_toshiba_rec_hdr(wth, wth->fh, &wth->pseudo_header, err); + pkt_len = parse_toshiba_rec_hdr(wth, wth->fh, &wth->pseudo_header, + err, err_info); if (pkt_len == -1) return FALSE; @@ -250,7 +254,7 @@ static gboolean toshiba_read(wtap *wth, int *err, long *data_offset) buf = buffer_start_ptr(wth->frame_buffer); /* Convert the ASCII hex dump to binary data */ - if (!parse_toshiba_hex_dump(wth->fh, pkt_len, buf, err)) + if (!parse_toshiba_hex_dump(wth->fh, pkt_len, buf, err, err_info)) return FALSE; wth->data_offset = offset; @@ -261,7 +265,8 @@ static gboolean toshiba_read(wtap *wth, int *err, long *data_offset) /* Used to read packets in random-access fashion */ static gboolean toshiba_seek_read (wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err) + union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, + int *err, gchar **err_info) { int pkt_len; @@ -269,21 +274,24 @@ toshiba_seek_read (wtap *wth, long seek_off, return FALSE; pkt_len = parse_toshiba_rec_hdr(NULL, wth->random_fh, pseudo_header, - err); + err, err_info); if (pkt_len != len) { - if (pkt_len != -1) + if (pkt_len != -1) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("toshiba: requested length %d doesn't match record length %d", + len, pkt_len); + } return FALSE; } - return parse_toshiba_hex_dump(wth->random_fh, pkt_len, pd, err); + return parse_toshiba_hex_dump(wth->random_fh, pkt_len, pd, err, err_info); } /* Parses a packet record header. */ static int parse_toshiba_rec_hdr(wtap *wth, FILE_T fh, - union wtap_pseudo_header *pseudo_header, int *err) + union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info) { char line[TOSHIBA_LINE_LENGTH]; int num_items_scanned; @@ -310,6 +318,7 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh, if (num_items_scanned != 7) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("toshiba: record header isn't valid"); return -1; } @@ -339,6 +348,7 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh, num_items_scanned = sscanf(line+64, "LEN=%d", &pkt_len); if (num_items_scanned != 1) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("toshiba: OFFSET line doesn't have valid LEN item"); return -1; } @@ -376,7 +386,8 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh, /* Converts ASCII hex dump to binary data */ static gboolean -parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err) +parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err, + gchar **err_info) { char line[TOSHIBA_LINE_LENGTH]; int i, hex_lines; @@ -395,6 +406,7 @@ parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err) } if (!parse_single_hex_dump_line(line, buf, i * 16)) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup("toshiba: hex dump not valid"); return FALSE; } } diff --git a/wiretap/toshiba.h b/wiretap/toshiba.h index 146a7d1b41..1dd684fb6d 100644 --- a/wiretap/toshiba.h +++ b/wiretap/toshiba.h @@ -1,6 +1,6 @@ /* toshiba.h * - * $Id: toshiba.h,v 1.5 2002/08/28 20:30:45 jmayer Exp $ + * $Id: toshiba.h,v 1.6 2004/01/25 21:55:17 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -18,12 +18,11 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * */ #ifndef __W_TOSHIBA_H__ #define __W_TOSHIBA_H__ -int toshiba_open(wtap *wth, int *err); +int toshiba_open(wtap *wth, int *err, gchar **err_info); #endif diff --git a/wiretap/visual.c b/wiretap/visual.c index 013634a47c..0447b4b7e7 100644 --- a/wiretap/visual.c +++ b/wiretap/visual.c @@ -2,7 +2,7 @@ * File read and write routines for Visual Networks cap files. * Copyright (c) 2001, Tom Nisbet tnisbet@visualnetworks.com * - * $Id: visual.c,v 1.14 2003/10/25 07:17:28 guy Exp $ + * $Id: visual.c,v 1.15 2004/01/25 21:55:17 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -112,11 +112,12 @@ struct visual_write_info /* Local functions to handle file reads and writes */ -static gboolean visual_read(wtap *wth, int *err, long *data_offset); +static gboolean visual_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static void visual_close(wtap *wth); static gboolean visual_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size, - int *err); + int *err, gchar **err_info); static void visual_set_pseudo_header(int encap, struct visual_pkt_hdr *vpkt_hdr, union wtap_pseudo_header *pseudo_header); static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, @@ -126,7 +127,7 @@ static void visual_dump_free(wtap_dumper *wdh); /* Open a file for reading */ -int visual_open(wtap *wth, int *err) +int visual_open(wtap *wth, int *err, gchar **err_info) { int bytes_read; char magic[sizeof visual_magic]; @@ -164,8 +165,8 @@ int visual_open(wtap *wth, int *err) vfile_hdr.file_version = pletohs(&vfile_hdr.file_version); if (vfile_hdr.file_version != 1) { - g_message("visual: file version %u unsupported", vfile_hdr.file_version); *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("visual: file version %u unsupported", vfile_hdr.file_version); return -1; } @@ -195,9 +196,9 @@ int visual_open(wtap *wth, int *err) break; default: - g_message("visual: network type %u unknown or unsupported", - vfile_hdr.media_type); *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("visual: network type %u unknown or unsupported", + vfile_hdr.media_type); return -1; } @@ -230,7 +231,8 @@ int visual_open(wtap *wth, int *err) in a loop to sequentially read the entire file one time. After the file has been read once, any Future access to the packets is done through seek_read. */ -static gboolean visual_read(wtap *wth, int *err, long *data_offset) +static gboolean visual_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { struct visual_read_info *visual = wth->capture.generic; guint32 packet_size = 0; @@ -271,9 +273,9 @@ static gboolean visual_read(wtap *wth, int *err, long *data_offset) { /* Probably a corrupt capture file; don't blow up trying to allocate space for an immensely-large packet. */ - g_message("visual: File has %u-byte packet, bigger than maximum of %u", - packet_size, WTAP_MAX_PACKET_SIZE); *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("visual: File has %u-byte packet, bigger than maximum of %u", + packet_size, WTAP_MAX_PACKET_SIZE); return FALSE; } buffer_assure_space(wth->frame_buffer, packet_size); @@ -330,7 +332,8 @@ static void visual_close(wtap *wth) This gets the packet data and rebuilds the pseudo header so that the direction flag works. */ static gboolean visual_seek_read (wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err) + union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, + int *err, gchar **err_info _U_) { struct visual_pkt_hdr vpkt_hdr; int phdr_size = sizeof(vpkt_hdr); diff --git a/wiretap/visual.h b/wiretap/visual.h index 6ef65146e0..7becff9bf7 100644 --- a/wiretap/visual.h +++ b/wiretap/visual.h @@ -5,7 +5,7 @@ * * Based on the code that handles netmon files. * - * $Id: visual.h,v 1.5 2002/08/28 20:30:45 jmayer Exp $ + * $Id: visual.h,v 1.6 2004/01/25 21:55:17 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -28,7 +28,7 @@ #ifndef __VISUAL_H__ #define __VISUAL_H__ -int visual_open(wtap *wth, int *err); +int visual_open(wtap *wth, int *err, gchar **err_info); gboolean visual_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err); int visual_dump_can_write_encap(int encap); diff --git a/wiretap/vms.c b/wiretap/vms.c index 9258b234d7..a8f9ee7d60 100644 --- a/wiretap/vms.c +++ b/wiretap/vms.c @@ -1,6 +1,6 @@ /* vms.c * - * $Id: vms.c,v 1.20 2004/01/24 16:48:12 jmayer Exp $ + * $Id: vms.c,v 1.21 2004/01/25 21:55:17 guy Exp $ * * Wiretap Library * Copyright (c) 2001 by Marc Milgram <ethereal@mmilgram.NOSPAMmail.net> @@ -143,14 +143,16 @@ to handle them. #define VMS_HEADER_LINES_TO_CHECK 200 #define VMS_LINE_LENGTH 240 -static gboolean vms_read(wtap *wth, int *err, long *data_offset); +static gboolean vms_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); static gboolean vms_seek_read(wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err); + union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, + int *err, gchar **err_info); static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf, long byte_offset, int in_off, int remaining_bytes); static gboolean parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, - int *err); -static int parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err); + int *err, gchar **err_info); +static int parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err, gchar **err_info); #ifdef TCPIPTRACE_FRAGMENTS_HAVE_HEADER_LINE /* Seeks to the beginning of the next packet, and returns the @@ -253,7 +255,7 @@ static gboolean vms_check_file_type(wtap *wth, int *err) } -int vms_open(wtap *wth, int *err) +int vms_open(wtap *wth, int *err, gchar **err_info _U_) { /* Look for VMS header */ if (!vms_check_file_type(wth, err)) { @@ -274,7 +276,8 @@ int vms_open(wtap *wth, int *err) } /* Find the next packet and parse it; called from wtap_loop(). */ -static gboolean vms_read(wtap *wth, int *err, long *data_offset) +static gboolean vms_read(wtap *wth, int *err, gchar **err_info, + long *data_offset) { long offset = 0; guint8 *buf; @@ -290,7 +293,7 @@ static gboolean vms_read(wtap *wth, int *err, long *data_offset) return FALSE; /* Parse the header */ - pkt_len = parse_vms_rec_hdr(wth, wth->fh, err); + pkt_len = parse_vms_rec_hdr(wth, wth->fh, err, err_info); if (pkt_len == -1) return FALSE; @@ -299,7 +302,7 @@ static gboolean vms_read(wtap *wth, int *err, long *data_offset) buf = buffer_start_ptr(wth->frame_buffer); /* Convert the ASCII hex dump to binary data */ - if (!parse_vms_hex_dump(wth->fh, pkt_len, buf, err)) + if (!parse_vms_hex_dump(wth->fh, pkt_len, buf, err, err_info)) return FALSE; wth->data_offset = offset; @@ -311,22 +314,25 @@ static gboolean vms_read(wtap *wth, int *err, long *data_offset) static gboolean vms_seek_read (wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header _U_, - guint8 *pd, int len, int *err) + guint8 *pd, int len, int *err, gchar **err_info) { int pkt_len; if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1) return FALSE; - pkt_len = parse_vms_rec_hdr(NULL, wth->random_fh, err); + pkt_len = parse_vms_rec_hdr(NULL, wth->random_fh, err, err_info); if (pkt_len != len) { - if (pkt_len != -1) + if (pkt_len != -1) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("vms: requested length %d doesn't match length %d", + len, pkt_len); + } return FALSE; } - return parse_vms_hex_dump(wth->random_fh, pkt_len, pd, err); + return parse_vms_hex_dump(wth->random_fh, pkt_len, pd, err, err_info); } /* isdumpline assumes that dump lines start with some non-alphanumerics @@ -356,7 +362,7 @@ isdumpline( gchar *line ) /* Parses a packet record header. */ static int -parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err) +parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err, gchar **err_info) { char line[VMS_LINE_LENGTH + 1]; int num_items_scanned; @@ -406,6 +412,7 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err) /* We will need to add code to handle new format */ if (num_items_scanned != 8) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("vms: header line not valid"); return -1; } } @@ -416,6 +423,7 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err) if ( !*p ) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("vms: Length field not valid"); return -1; } @@ -444,7 +452,8 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err) /* Converts ASCII hex dump to binary data */ static gboolean -parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err) +parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err, + gchar **err_info) { gchar line[VMS_LINE_LENGTH + 1]; int i; @@ -476,6 +485,7 @@ parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err) if (!parse_single_hex_dump_line(line, buf, i, offset, pkt_len - i)) { *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("vms: hex dump not valid"); return FALSE; } } diff --git a/wiretap/vms.h b/wiretap/vms.h index 799df5f62a..23cfdf3fab 100644 --- a/wiretap/vms.h +++ b/wiretap/vms.h @@ -1,6 +1,6 @@ /* vms.h * - * $Id: vms.h,v 1.2 2003/01/17 23:54:19 guy Exp $ + * $Id: vms.h,v 1.3 2004/01/25 21:55:17 guy Exp $ * * Wiretap Library * Copyright (c) 2001 by Marc Milgram <ethereal@mmilgram.NOSPAMmail.net> @@ -24,6 +24,6 @@ #ifndef __W_VMS_H__ #define __W_VMS_H__ -int vms_open(wtap *wth, int *err); +int vms_open(wtap *wth, int *err, gchar **err_info); #endif diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h index 53fe4e59fe..0900220c5c 100644 --- a/wiretap/wtap-int.h +++ b/wiretap/wtap-int.h @@ -1,6 +1,6 @@ /* wtap-int.h * - * $Id: wtap-int.h,v 1.43 2004/01/05 17:33:28 ulfl Exp $ + * $Id: wtap-int.h,v 1.44 2004/01/25 21:55:17 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -130,9 +130,9 @@ typedef struct { gboolean is_ppp; } erf_t; -typedef gboolean (*subtype_read_func)(struct wtap*, int*, long*); +typedef gboolean (*subtype_read_func)(struct wtap*, int*, char**, long*); typedef gboolean (*subtype_seek_read_func)(struct wtap*, long, union wtap_pseudo_header*, - guint8*, int, int *); + guint8*, int, int *, char **); struct wtap { FILE_T fh; int fd; /* File descriptor for cap file */ diff --git a/wiretap/wtap.c b/wiretap/wtap.c index ce016140c0..106bbae972 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -1,6 +1,6 @@ /* wtap.c * - * $Id: wtap.c,v 1.86 2003/12/18 19:07:13 guy Exp $ + * $Id: wtap.c,v 1.87 2004/01/25 21:55:17 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -315,9 +315,9 @@ wtap_close(wtap *wth) } gboolean -wtap_read(wtap *wth, int *err, long *data_offset) +wtap_read(wtap *wth, int *err, gchar **err_info, long *data_offset) { - if (!wth->subtype_read(wth, err, data_offset)) + if (!wth->subtype_read(wth, err, err_info, data_offset)) return FALSE; /* failure */ /* @@ -348,7 +348,8 @@ wtap_buf_ptr(wtap *wth) } gboolean -wtap_loop(wtap *wth, int count, wtap_handler callback, guchar* user, int *err) +wtap_loop(wtap *wth, int count, wtap_handler callback, guchar* user, int *err, + gchar **err_info) { long data_offset; int loop = 0; @@ -356,7 +357,7 @@ wtap_loop(wtap *wth, int count, wtap_handler callback, guchar* user, int *err) /* Start by clearing error flag */ *err = 0; - while ( (wtap_read(wth, err, &data_offset)) ) { + while ( (wtap_read(wth, err, err_info, &data_offset)) ) { callback(user, &wth->phdr, data_offset, &wth->pseudo_header, buffer_start_ptr(wth->frame_buffer)); if (count > 0 && ++loop >= count) @@ -372,8 +373,8 @@ wtap_loop(wtap *wth, int count, wtap_handler callback, guchar* user, int *err) gboolean wtap_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, - int *err) + int *err, gchar **err_info) { return wth->subtype_seek_read(wth, seek_off, pseudo_header, pd, len, - err); + err, err_info); } diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 3b2133a7f8..9dfed9bf96 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -1,6 +1,6 @@ /* wtap.h * - * $Id: wtap.h,v 1.147 2003/12/18 19:07:14 guy Exp $ + * $Id: wtap.h,v 1.148 2004/01/25 21:55:17 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -427,16 +427,19 @@ typedef struct wtap_dumper wtap_dumper; * * a negative number, indicating the type of error, on other failures. */ -struct wtap* wtap_open_offline(const char *filename, int *err, gboolean do_random); +struct wtap* wtap_open_offline(const char *filename, int *err, + gchar **err_info, gboolean do_random); /* Returns TRUE if entire loop-reading was successful. If read failure * happened, FALSE is returned and err is set. */ -gboolean wtap_loop(wtap *wth, int, wtap_handler, guchar*, int *err); +gboolean wtap_loop(wtap *wth, int, wtap_handler, guchar*, int *err, + gchar **err_info); /* Returns TRUE if read was successful. FALSE if failure. data_offset is * set the the offset in the file where the data for the read packet is * located. */ -gboolean wtap_read(wtap *wth, int *err, long *data_offset); +gboolean wtap_read(wtap *wth, int *err, gchar **err_info, + long *data_offset); struct wtap_pkthdr *wtap_phdr(wtap *wth); union wtap_pseudo_header *wtap_pseudoheader(wtap *wth); @@ -459,7 +462,8 @@ const char *wtap_strerror(int err); void wtap_sequential_close(wtap *wth); void wtap_close(wtap *wth); gboolean wtap_seek_read (wtap *wth, long seek_off, - union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err); + union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, + int *err, gchar **err_info); gboolean wtap_dump_can_open(int filetype); gboolean wtap_dump_can_write_encap(int filetype, int encap); |