diff options
-rw-r--r-- | file.c | 6 | ||||
-rw-r--r-- | wiretap/ascend.c | 12 | ||||
-rw-r--r-- | wiretap/csids.c | 18 | ||||
-rw-r--r-- | wiretap/dbs-etherwatch.c | 33 | ||||
-rw-r--r-- | wiretap/file.c | 10 | ||||
-rw-r--r-- | wiretap/i4btrace.c | 20 | ||||
-rw-r--r-- | wiretap/iptrace.c | 32 | ||||
-rw-r--r-- | wiretap/netmon.c | 42 | ||||
-rw-r--r-- | wiretap/nettl.c | 23 | ||||
-rw-r--r-- | wiretap/ngsniffer.c | 78 | ||||
-rw-r--r-- | wiretap/pppdump.c | 16 | ||||
-rw-r--r-- | wiretap/radcom.c | 23 | ||||
-rw-r--r-- | wiretap/snoop.c | 42 | ||||
-rw-r--r-- | wiretap/toshiba.c | 31 | ||||
-rw-r--r-- | wiretap/visual.c | 14 | ||||
-rw-r--r-- | wiretap/vms.c | 33 | ||||
-rw-r--r-- | wiretap/wtap-int.h | 6 | ||||
-rw-r--r-- | wiretap/wtap.c | 4 | ||||
-rw-r--r-- | wiretap/wtap.h | 6 |
19 files changed, 227 insertions, 222 deletions
@@ -1,7 +1,7 @@ /* file.c * File I/O routines * - * $Id: file.c,v 1.265 2002/03/05 05:58:27 guy Exp $ + * $Id: file.c,v 1.266 2002/03/05 08:40:27 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1791,8 +1791,8 @@ save_cap_file(char *fname, capture_file *cf, gboolean save_filtered, gboolean sa hdr.caplen = fdata->cap_len; hdr.len = fdata->pkt_len; hdr.pkt_encap = fdata->lnk_t; - if (wtap_seek_read(cf->wth, fdata->file_off, &pseudo_header, - pd, fdata->cap_len, &err) == -1) { + if (!wtap_seek_read(cf->wth, fdata->file_off, &pseudo_header, + pd, fdata->cap_len, &err)) { simple_dialog(ESD_TYPE_CRIT, NULL, file_read_error_message(err), cf->filename); wtap_dump_close(pdh, &err); diff --git a/wiretap/ascend.c b/wiretap/ascend.c index 1f93052025..6710cadece 100644 --- a/wiretap/ascend.c +++ b/wiretap/ascend.c @@ -1,6 +1,6 @@ /* ascend.c * - * $Id: ascend.c,v 1.28 2002/03/05 05:58:40 guy Exp $ + * $Id: ascend.c,v 1.29 2002/03/05 08:39:29 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -102,7 +102,7 @@ static const char ascend_w2magic[] = { 'W', 'D', '_', 'D', 'I', 'A', 'L', 'O', ' #define ASCEND_W2_SIZE (sizeof ascend_w2magic / sizeof ascend_w2magic[0]) static gboolean ascend_read(wtap *wth, int *err, long *data_offset); -static int ascend_seek_read (wtap *wth, long seek_off, +static gboolean ascend_seek_read (wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err); static void ascend_close(wtap *wth); @@ -340,18 +340,18 @@ static gboolean ascend_read(wtap *wth, int *err, long *data_offset) return TRUE; } -static int ascend_seek_read (wtap *wth, long seek_off, +static gboolean ascend_seek_read (wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err) { if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { *err = file_error(wth->random_fh); - return -1; + return FALSE; } if (! parse_ascend(wth->random_fh, pd, &pseudo_header->ascend, NULL, len)) { *err = WTAP_ERR_BAD_RECORD; - return -1; + return FALSE; } - return 0; + return TRUE; } static void ascend_close(wtap *wth) diff --git a/wiretap/csids.c b/wiretap/csids.c index 8fd03e4ed4..fd830246d8 100644 --- a/wiretap/csids.c +++ b/wiretap/csids.c @@ -1,6 +1,6 @@ /* csids.c * - * $Id: csids.c,v 1.12 2002/03/05 05:58:40 guy Exp $ + * $Id: csids.c,v 1.13 2002/03/05 08:39:29 guy Exp $ * * Copyright (c) 2000 by Mike Hall <mlh@io.com> * Copyright (c) 2000 by Cisco Systems @@ -45,7 +45,7 @@ */ static gboolean csids_read(wtap *wth, int *err, long *data_offset); -static int csids_seek_read(wtap *wth, long seek_off, +static gboolean csids_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err); static void csids_close(wtap *wth); @@ -197,7 +197,7 @@ static gboolean csids_read(wtap *wth, int *err, long *data_offset) } /* Used to read packets in random-access fashion */ -static int +static gboolean csids_seek_read (wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header _U_, @@ -205,12 +205,12 @@ csids_seek_read (wtap *wth, int len, int *err) { - int bytesRead = 0; + int bytesRead; struct csids_header hdr; if( file_seek( wth->random_fh, seek_off, SEEK_SET ) == -1 ) { *err = file_error( wth->random_fh ); - return -1; + return FALSE; } bytesRead = file_read( &hdr, 1, sizeof( struct csids_header), wth->random_fh ); @@ -219,14 +219,14 @@ csids_seek_read (wtap *wth, if( *err == 0 ) { *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } hdr.seconds = pntohl(&hdr.seconds); hdr.caplen = pntohs(&hdr.caplen); if( len != hdr.caplen ) { *err = WTAP_ERR_BAD_RECORD; - return -1; + return FALSE; } bytesRead = file_read( pd, 1, hdr.caplen, wth->random_fh ); @@ -235,7 +235,7 @@ csids_seek_read (wtap *wth, if( *err == 0 ) { *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } if( wth->capture.csids->byteswapped == TRUE ) { @@ -248,7 +248,7 @@ csids_seek_read (wtap *wth, *(swap) = BSWAP16(*swap); /* ip flags and fragoff */ } - return 0; + return TRUE; } static void diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c index 8c104df761..fbe3d582fd 100644 --- a/wiretap/dbs-etherwatch.c +++ b/wiretap/dbs-etherwatch.c @@ -1,6 +1,6 @@ /* dbs-etherwatch.c * - * $Id: dbs-etherwatch.c,v 1.6 2002/03/05 05:58:40 guy Exp $ + * $Id: dbs-etherwatch.c,v 1.7 2002/03/05 08:39:29 guy Exp $ * * Wiretap Library * Copyright (c) 2001 by Marc Milgram <mmilgram@arrayinc.com> @@ -76,10 +76,12 @@ 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 int dbs_etherwatch_seek_read(wtap *wth, long seek_off, +static gboolean dbs_etherwatch_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err); -static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf, long byte_offset); -static int parse_dbs_etherwatch_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err); +static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf, + long byte_offset); +static gboolean parse_dbs_etherwatch_hex_dump(FILE_T fh, int pkt_len, + guint8* buf, int *err); static int parse_dbs_etherwatch_rec_hdr(wtap *wth, FILE_T fh, int *err); /* Seeks to the beginning of the next packet, and returns the @@ -193,7 +195,7 @@ 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) { - long offset = 0; + long offset; guint8 *buf; int pkt_len; @@ -212,7 +214,7 @@ static gboolean dbs_etherwatch_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_dbs_etherwatch_hex_dump(wth->fh, pkt_len, buf, err) == -1) + if (!parse_dbs_etherwatch_hex_dump(wth->fh, pkt_len, buf, err)) return FALSE; wth->data_offset = offset; @@ -221,7 +223,7 @@ static gboolean dbs_etherwatch_read(wtap *wth, int *err, long *data_offset) } /* Used to read packets in random-access fashion */ -static int +static gboolean dbs_etherwatch_seek_read (wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header _U_, guint8 *pd, int len, int *err) @@ -230,7 +232,7 @@ dbs_etherwatch_seek_read (wtap *wth, long seek_off, if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET) == -1) { *err = file_error(wth->random_fh); - return -1; + return FALSE; } pkt_len = parse_dbs_etherwatch_rec_hdr(NULL, wth->random_fh, err); @@ -238,13 +240,10 @@ dbs_etherwatch_seek_read (wtap *wth, long seek_off, if (pkt_len != len) { if (pkt_len != -1) *err = WTAP_ERR_BAD_RECORD; - return -1; + return FALSE; } - if (parse_dbs_etherwatch_hex_dump(wth->random_fh, pkt_len, pd, err) == -1) - return -1; - - return 0; + return parse_dbs_etherwatch_hex_dump(wth->random_fh, pkt_len, pd, err); } /* Parses a packet record header. */ @@ -312,7 +311,7 @@ parse_dbs_etherwatch_rec_hdr(wtap *wth, FILE_T fh, int *err) } /* Converts ASCII hex dump to binary data */ -static int +static gboolean parse_dbs_etherwatch_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err) { guchar line[DBS_ETHERWATCH_LINE_LENGTH]; @@ -328,14 +327,14 @@ parse_dbs_etherwatch_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err) if (*err == 0) { *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } if (!parse_single_hex_dump_line(line, buf, i * 16)) { *err = WTAP_ERR_BAD_RECORD; - return -1; + return FALSE; } } - return 0; + return TRUE; } /* diff --git a/wiretap/file.c b/wiretap/file.c index 8dfa405eb8..fa1bbba222 100644 --- a/wiretap/file.c +++ b/wiretap/file.c @@ -1,6 +1,6 @@ /* file.c * - * $Id: file.c,v 1.84 2002/03/05 05:58:40 guy Exp $ + * $Id: file.c,v 1.85 2002/03/05 08:39:29 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -122,7 +122,7 @@ static int (*open_routines[])(wtap *, int *) = { #define N_FILE_TYPES (sizeof open_routines / sizeof open_routines[0]) -int wtap_def_seek_read(wtap *wth, long seek_off, +gboolean wtap_def_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header _U_, guint8 *pd, int len, int *err) { @@ -130,7 +130,7 @@ int wtap_def_seek_read(wtap *wth, long seek_off, if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { *err = file_error(wth->random_fh); - return -1; + return FALSE; } bytes_read = file_read(pd, sizeof(guint8), len, wth->random_fh); @@ -138,9 +138,9 @@ int wtap_def_seek_read(wtap *wth, long seek_off, *err = file_error(wth->random_fh); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return 0; + return TRUE; } /* diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c index 0565cdae52..0c2294f521 100644 --- a/wiretap/i4btrace.c +++ b/wiretap/i4btrace.c @@ -1,6 +1,6 @@ /* i4btrace.c * - * $Id: i4btrace.c,v 1.18 2002/03/05 05:58:40 guy Exp $ + * $Id: i4btrace.c,v 1.19 2002/03/05 08:39:29 guy Exp $ * * Wiretap Library * Copyright (c) 1999 by Bert Driehuis <driehuis@playbeing.org> @@ -33,11 +33,11 @@ #include "i4b_trace.h" static gboolean i4btrace_read(wtap *wth, int *err, long *data_offset); -static int i4btrace_seek_read(wtap *wth, long seek_off, +static gboolean i4btrace_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err); 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 int i4b_read_rec_data(FILE_T fh, u_char *pd, int length, int *err); +static gboolean i4b_read_rec_data(FILE_T fh, u_char *pd, int length, int *err); static void i4b_set_pseudo_header(wtap *wth, i4b_trace_hdr_t *hdr, union wtap_pseudo_header *pseudo_header); static void i4btrace_close(wtap *wth); @@ -151,7 +151,7 @@ static gboolean i4btrace_read(wtap *wth, int *err, long *data_offset) */ buffer_assure_space(wth->frame_buffer, length); bufp = buffer_start_ptr(wth->frame_buffer); - if (i4b_read_rec_data(wth->fh, bufp, length, err) < 0) + if (!i4b_read_rec_data(wth->fh, bufp, length, err)) return FALSE; /* Read error */ wth->data_offset += length; @@ -223,7 +223,7 @@ static gboolean i4btrace_read(wtap *wth, int *err, long *data_offset) return TRUE; } -static int +static gboolean i4btrace_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err) { @@ -232,7 +232,7 @@ i4btrace_seek_read(wtap *wth, long seek_off, if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { *err = file_error(wth->random_fh); - return -1; + return FALSE; } /* Read record header. */ @@ -243,7 +243,7 @@ i4btrace_seek_read(wtap *wth, long seek_off, /* EOF means "short read" in random-access mode */ *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } i4b_byte_swap_header(wth, &hdr); @@ -293,7 +293,7 @@ i4b_byte_swap_header(wtap *wth, i4b_trace_hdr_t *hdr) } } -static int +static gboolean i4b_read_rec_data(FILE_T fh, u_char *pd, int length, int *err) { int bytes_read; @@ -305,9 +305,9 @@ i4b_read_rec_data(FILE_T fh, u_char *pd, int length, int *err) *err = file_error(fh); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return 0; + return TRUE; } static void diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c index e53442e2a6..d6ad89b66e 100644 --- a/wiretap/iptrace.c +++ b/wiretap/iptrace.c @@ -1,6 +1,6 @@ /* iptrace.c * - * $Id: iptrace.c,v 1.37 2002/03/05 05:58:40 guy Exp $ + * $Id: iptrace.c,v 1.38 2002/03/05 08:39:29 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -32,19 +32,19 @@ #include "iptrace.h" static gboolean iptrace_read_1_0(wtap *wth, int *err, long *data_offset); -static int iptrace_seek_read_1_0(wtap *wth, long seek_off, +static gboolean iptrace_seek_read_1_0(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size, int *err); static gboolean iptrace_read_2_0(wtap *wth, int *err, long *data_offset); -static int iptrace_seek_read_2_0(wtap *wth, long seek_off, +static gboolean iptrace_seek_read_2_0(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size, int *err); static int iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len, int *err); -static int iptrace_read_rec_data(FILE_T fh, guint8 *data_ptr, int packet_size, - int *err); +static gboolean iptrace_read_rec_data(FILE_T fh, guint8 *data_ptr, + int packet_size, int *err); static void get_atm_pseudo_header(union wtap_pseudo_header *pseudo_header, guint8 *header); static int wtap_encap_ift(unsigned int ift); @@ -119,7 +119,7 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, long *data_offset) packet_size = pntohl(&header[0]) - 0x16; buffer_assure_space( wth->frame_buffer, packet_size ); data_ptr = buffer_start_ptr( wth->frame_buffer ); - if (iptrace_read_rec_data(wth->fh, data_ptr, packet_size, err) < 0) + if (!iptrace_read_rec_data(wth->fh, data_ptr, packet_size, err)) return FALSE; /* Read error */ wth->data_offset += packet_size; @@ -163,7 +163,7 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, long *data_offset) return TRUE; } -static int iptrace_seek_read_1_0(wtap *wth, long seek_off, +static gboolean iptrace_seek_read_1_0(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size, int *err) { @@ -172,7 +172,7 @@ static int iptrace_seek_read_1_0(wtap *wth, long seek_off, if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { *err = file_error(wth->random_fh); - return -1; + return FALSE; } /* Read the descriptor data */ @@ -183,7 +183,7 @@ static int iptrace_seek_read_1_0(wtap *wth, long seek_off, /* EOF means "short read" in random-access mode */ *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } if ( wtap_encap_ift(header[28]) == WTAP_ENCAP_ATM_SNIFFER ) { @@ -234,7 +234,7 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, long *data_offset) packet_size = pntohl(&header[0]) - 32; buffer_assure_space( wth->frame_buffer, packet_size ); data_ptr = buffer_start_ptr( wth->frame_buffer ); - if (iptrace_read_rec_data(wth->fh, data_ptr, packet_size, err) < 0) + if (!iptrace_read_rec_data(wth->fh, data_ptr, packet_size, err)) return FALSE; /* Read error */ wth->data_offset += packet_size; @@ -282,7 +282,7 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, long *data_offset) return TRUE; } -static int iptrace_seek_read_2_0(wtap *wth, long seek_off, +static gboolean iptrace_seek_read_2_0(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size, int *err) { @@ -291,7 +291,7 @@ static int iptrace_seek_read_2_0(wtap *wth, long seek_off, if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { *err = file_error(wth->random_fh); - return -1; + return FALSE; } /* Read the descriptor data */ @@ -302,7 +302,7 @@ static int iptrace_seek_read_2_0(wtap *wth, long seek_off, /* EOF means "short read" in random-access mode */ *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } if ( wtap_encap_ift(header[28]) == WTAP_ENCAP_ATM_SNIFFER ) { @@ -333,7 +333,7 @@ iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len, int *err) return 1; } -static int +static gboolean iptrace_read_rec_data(FILE_T fh, guint8 *data_ptr, int packet_size, int *err) { int bytes_read; @@ -345,9 +345,9 @@ iptrace_read_rec_data(FILE_T fh, guint8 *data_ptr, int packet_size, int *err) *err = file_error(fh); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return 0; + return TRUE; } /* diff --git a/wiretap/netmon.c b/wiretap/netmon.c index 5c7188b7fe..7a93df39a5 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -1,6 +1,6 @@ /* netmon.c * - * $Id: netmon.c,v 1.50 2002/03/05 05:58:40 guy Exp $ + * $Id: netmon.c,v 1.51 2002/03/05 08:39:29 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -107,11 +107,12 @@ struct netmon_atm_hdr { }; static gboolean netmon_read(wtap *wth, int *err, long *data_offset); -static int netmon_seek_read(wtap *wth, long seek_off, +static gboolean netmon_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err); -static int netmon_read_atm_pseudoheader(FILE_T fh, +static gboolean netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err); -static int netmon_read_rec_data(FILE_T fh, u_char *pd, int length, int *err); +static gboolean netmon_read_rec_data(FILE_T fh, u_char *pd, int length, + int *err); static void netmon_close(wtap *wth); static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const union wtap_pseudo_header *pseudo_header, const u_char *pd, int *err); @@ -404,8 +405,8 @@ static gboolean netmon_read(wtap *wth, int *err, long *data_offset) *err = WTAP_ERR_BAD_RECORD; return FALSE; } - if (netmon_read_atm_pseudoheader(wth->fh, &wth->pseudo_header, - err) < 0) + if (!netmon_read_atm_pseudoheader(wth->fh, &wth->pseudo_header, + err)) return FALSE; /* Read error */ /* @@ -417,8 +418,8 @@ static gboolean netmon_read(wtap *wth, int *err, long *data_offset) } buffer_assure_space(wth->frame_buffer, packet_size); - if (netmon_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), - packet_size, err) < 0) + if (!netmon_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), + packet_size, err)) return FALSE; /* Read error */ wth->data_offset += packet_size; @@ -445,23 +446,20 @@ static gboolean netmon_read(wtap *wth, int *err, long *data_offset) return TRUE; } -static int +static gboolean netmon_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err) { - int ret; - if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { *err = file_error(wth->random_fh); - return -1; + return FALSE; } if (wth->file_encap == WTAP_ENCAP_ATM_SNIFFER) { - ret = netmon_read_atm_pseudoheader(wth->random_fh, pseudo_header, - err); - if (ret < 0) { + if (!netmon_read_atm_pseudoheader(wth->random_fh, pseudo_header, + err)) { /* Read error */ - return ret; + return FALSE; } } @@ -471,7 +469,7 @@ netmon_seek_read(wtap *wth, long seek_off, return netmon_read_rec_data(wth->random_fh, pd, length, err); } -static int +static gboolean netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err) { @@ -484,7 +482,7 @@ netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, *err = file_error(fh); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } pseudo_header->ngsniffer_atm.Vpi = ntohs(atm_phdr.vpi); @@ -503,10 +501,10 @@ netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, pseudo_header->ngsniffer_atm.AppTrafType = ATT_AAL5|ATT_HL_UNKNOWN; pseudo_header->ngsniffer_atm.AppHLType = AHLT_UNKNOWN; - return 0; + return TRUE; } -static int +static gboolean netmon_read_rec_data(FILE_T fh, u_char *pd, int length, int *err) { int bytes_read; @@ -518,9 +516,9 @@ netmon_read_rec_data(FILE_T fh, u_char *pd, int length, int *err) *err = file_error(fh); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return 0; + return TRUE; } static void diff --git a/wiretap/nettl.c b/wiretap/nettl.c index d6c812e607..28a111befe 100644 --- a/wiretap/nettl.c +++ b/wiretap/nettl.c @@ -1,6 +1,6 @@ /* nettl.c * - * $Id: nettl.c,v 1.24 2002/03/05 05:58:40 guy Exp $ + * $Id: nettl.c,v 1.25 2002/03/05 08:39:29 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -67,13 +67,14 @@ struct nettlrec_ns_ls_ip_hdr { /* header is followed by data and once again the total length (2 bytes) ! */ static gboolean nettl_read(wtap *wth, int *err, long *data_offset); -static int nettl_seek_read(wtap *wth, long seek_off, +static gboolean nettl_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err); static int nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, union wtap_pseudo_header *pseudo_header, int *err); -static int nettl_read_rec_data(FILE_T fh, u_char *pd, int length, int *err); +static gboolean nettl_read_rec_data(FILE_T fh, u_char *pd, int length, + int *err); static void nettl_close(wtap *wth); int nettl_open(wtap *wth, int *err) @@ -149,14 +150,14 @@ static gboolean nettl_read(wtap *wth, int *err, long *data_offset) * Read the packet data. */ buffer_assure_space(wth->frame_buffer, wth->phdr.caplen); - if (nettl_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), - wth->phdr.caplen, err) < 0) + if (!nettl_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), + wth->phdr.caplen, err)) return FALSE; /* Read error */ wth->data_offset += wth->phdr.caplen; return TRUE; } -static int +static gboolean nettl_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err) @@ -166,7 +167,7 @@ nettl_seek_read(wtap *wth, long seek_off, if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { *err = file_error(wth->random_fh); - return -1; + return FALSE; } /* Read record header. */ @@ -178,7 +179,7 @@ nettl_seek_read(wtap *wth, long seek_off, /* EOF means "short read" in random-access mode */ *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } /* @@ -310,7 +311,7 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, return offset; } -static int +static gboolean nettl_read_rec_data(FILE_T fh, u_char *pd, int length, int *err) { int bytes_read; @@ -321,9 +322,9 @@ nettl_read_rec_data(FILE_T fh, u_char *pd, int length, int *err) *err = file_error(fh); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return 0; + return TRUE; } static void nettl_close(wtap *wth) diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c index c0d1d9e6a6..88b29b5daa 100644 --- a/wiretap/ngsniffer.c +++ b/wiretap/ngsniffer.c @@ -1,6 +1,6 @@ /* ngsniffer.c * - * $Id: ngsniffer.c,v 1.75 2002/03/05 05:58:40 guy Exp $ + * $Id: ngsniffer.c,v 1.76 2002/03/05 08:39:29 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -285,25 +285,25 @@ static double Usec[] = { 15.0, 0.838096, 15.0, 0.5, 2.0, 1.0, 0.1 }; static int skip_header_records(wtap *wth, int *err, gint16 version); static gboolean ngsniffer_read(wtap *wth, int *err, long *data_offset); -static int ngsniffer_seek_read(wtap *wth, long seek_off, +static gboolean ngsniffer_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size, int *err); static int ngsniffer_read_rec_header(wtap *wth, gboolean is_random, guint16 *typep, guint16 *lengthp, int *err); -static int ngsniffer_read_frame2(wtap *wth, gboolean is_random, +static gboolean ngsniffer_read_frame2(wtap *wth, gboolean is_random, struct frame2_rec *frame2, int *err); static void set_pseudo_header_frame2(union wtap_pseudo_header *pseudo_header, struct frame2_rec *frame2); -static int ngsniffer_read_frame4(wtap *wth, gboolean is_random, +static gboolean ngsniffer_read_frame4(wtap *wth, gboolean is_random, struct frame4_rec *frame4, int *err); static void set_pseudo_header_frame4(union wtap_pseudo_header *pseudo_header, struct frame4_rec *frame4); -static int ngsniffer_read_frame6(wtap *wth, gboolean is_random, +static gboolean ngsniffer_read_frame6(wtap *wth, gboolean is_random, struct frame6_rec *frame6, int *err); static void set_pseudo_header_frame6(union wtap_pseudo_header *pseudo_header, struct frame6_rec *frame6); -static int ngsniffer_read_rec_data(wtap *wth, gboolean is_random, u_char *pd, - int length, int *err); +static gboolean ngsniffer_read_rec_data(wtap *wth, gboolean is_random, + u_char *pd, int length, int *err); static void fix_pseudo_header(wtap *wth, union wtap_pseudo_header *pseudo_header); static void ngsniffer_sequential_close(wtap *wth); @@ -696,8 +696,7 @@ static gboolean ngsniffer_read(wtap *wth, int *err, long *data_offset) } /* Read the f_frame2_struct */ - ret = ngsniffer_read_frame2(wth, FALSE, &frame2, err); - if (ret < 0) { + if (!ngsniffer_read_frame2(wth, FALSE, &frame2, err)) { /* Read error */ return FALSE; } @@ -728,7 +727,10 @@ static gboolean ngsniffer_read(wtap *wth, int *err, long *data_offset) } /* Read the f_frame4_struct */ - ret = ngsniffer_read_frame4(wth, FALSE, &frame4, err); + if (!ngsniffer_read_frame4(wth, FALSE, &frame4, err)) { + /* Read error */ + return FALSE; + } wth->data_offset += sizeof frame4; time_low = pletohs(&frame4.time_low); time_med = pletohs(&frame4.time_med); @@ -757,7 +759,10 @@ static gboolean ngsniffer_read(wtap *wth, int *err, long *data_offset) } /* Read the f_frame6_struct */ - ret = ngsniffer_read_frame6(wth, FALSE, &frame6, err); + if (!ngsniffer_read_frame6(wth, FALSE, &frame6, err)) { + /* Read error */ + return FALSE; + } wth->data_offset += sizeof frame6; time_low = pletohs(&frame6.time_low); time_med = pletohs(&frame6.time_med); @@ -820,7 +825,7 @@ found: */ buffer_assure_space(wth->frame_buffer, length); pd = buffer_start_ptr(wth->frame_buffer); - if (ngsniffer_read_rec_data(wth, FALSE, pd, length, err) < 0) + if (!ngsniffer_read_rec_data(wth, FALSE, pd, length, err)) return FALSE; /* Read error */ wth->data_offset += length; @@ -872,7 +877,7 @@ found: return TRUE; } -static int ngsniffer_seek_read(wtap *wth, long seek_off, +static gboolean ngsniffer_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size, int *err) { @@ -883,7 +888,7 @@ static int ngsniffer_seek_read(wtap *wth, long seek_off, struct frame6_rec frame6; if (ng_file_seek_rand(wth, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; ret = ngsniffer_read_rec_header(wth, TRUE, &type, &length, err); if (ret <= 0) { @@ -892,17 +897,16 @@ static int ngsniffer_seek_read(wtap *wth, long seek_off, /* EOF means "short read" in random-access mode */ *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } switch (type) { case REC_FRAME2: /* Read the f_frame2_struct */ - ret = ngsniffer_read_frame2(wth, TRUE, &frame2, err); - if (ret < 0) { + if (!ngsniffer_read_frame2(wth, TRUE, &frame2, err)) { /* Read error */ - return ret; + return FALSE; } length -= sizeof frame2; /* we already read that much */ @@ -912,7 +916,10 @@ static int ngsniffer_seek_read(wtap *wth, long seek_off, case REC_FRAME4: /* Read the f_frame4_struct */ - ret = ngsniffer_read_frame4(wth, TRUE, &frame4, err); + if (!ngsniffer_read_frame4(wth, TRUE, &frame4, err)) { + /* Read error */ + return FALSE; + } length -= sizeof frame4; /* we already read that much */ @@ -921,7 +928,10 @@ static int ngsniffer_seek_read(wtap *wth, long seek_off, case REC_FRAME6: /* Read the f_frame6_struct */ - ret = ngsniffer_read_frame6(wth, TRUE, &frame6, err); + if (!ngsniffer_read_frame6(wth, TRUE, &frame6, err)) { + /* Read error */ + return FALSE; + } length -= sizeof frame6; /* we already read that much */ @@ -933,7 +943,7 @@ static int ngsniffer_seek_read(wtap *wth, long seek_off, * "Can't happen". */ g_assert_not_reached(); - return -1; + return FALSE; } /* @@ -980,7 +990,7 @@ static int ngsniffer_read_rec_header(wtap *wth, gboolean is_random, return 1; /* success */ } -static int ngsniffer_read_frame2(wtap *wth, gboolean is_random, +static gboolean ngsniffer_read_frame2(wtap *wth, gboolean is_random, struct frame2_rec *frame2, int *err) { int bytes_read; @@ -991,9 +1001,9 @@ static int ngsniffer_read_frame2(wtap *wth, gboolean is_random, if (bytes_read != sizeof *frame2) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return 0; + return TRUE; } static void set_pseudo_header_frame2(union wtap_pseudo_header *pseudo_header, @@ -1023,7 +1033,7 @@ static void set_pseudo_header_frame2(union wtap_pseudo_header *pseudo_header, pseudo_header->x25.flags = (frame2->fs & 0x80) ? 0x00 : 0x80; } -static int ngsniffer_read_frame4(wtap *wth, gboolean is_random, +static gboolean ngsniffer_read_frame4(wtap *wth, gboolean is_random, struct frame4_rec *frame4, int *err) { int bytes_read; @@ -1034,9 +1044,9 @@ static int ngsniffer_read_frame4(wtap *wth, gboolean is_random, if (bytes_read != sizeof *frame4) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return 0; + return TRUE; } static void set_pseudo_header_frame4(union wtap_pseudo_header *pseudo_header, @@ -1053,7 +1063,7 @@ static void set_pseudo_header_frame4(union wtap_pseudo_header *pseudo_header, pseudo_header->ngsniffer_atm.aal5t_chksum = pletohl(&frame4->atm_info.Trailer.aal5t_chksum); } -static int ngsniffer_read_frame6(wtap *wth, gboolean is_random, +static gboolean ngsniffer_read_frame6(wtap *wth, gboolean is_random, struct frame6_rec *frame6, int *err) { int bytes_read; @@ -1064,9 +1074,9 @@ static int ngsniffer_read_frame6(wtap *wth, gboolean is_random, if (bytes_read != sizeof *frame6) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return 0; + return TRUE; } static void set_pseudo_header_frame6( @@ -1076,8 +1086,8 @@ static void set_pseudo_header_frame6( /* XXX - Once the frame format is divined, something will most likely go here */ } -static int ngsniffer_read_rec_data(wtap *wth, gboolean is_random, u_char *pd, - int length, int *err) +static gboolean ngsniffer_read_rec_data(wtap *wth, gboolean is_random, + u_char *pd, int length, int *err) { int bytes_read; @@ -1086,9 +1096,9 @@ static int ngsniffer_read_rec_data(wtap *wth, gboolean is_random, u_char *pd, if (bytes_read != length) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return 0; + return TRUE; } static void fix_pseudo_header(wtap *wth, diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c index 0988e1ef8f..2997759040 100644 --- a/wiretap/pppdump.c +++ b/wiretap/pppdump.c @@ -1,6 +1,6 @@ /* pppdump.c * - * $Id: pppdump.c,v 1.16 2002/03/05 05:58:40 guy Exp $ + * $Id: pppdump.c,v 1.17 2002/03/05 08:39:29 guy Exp $ * * Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu> * @@ -94,7 +94,7 @@ typedef enum { } direction_enum; static gboolean pppdump_read(wtap *wth, int *err, long *data_offset); -static int pppdump_seek_read(wtap *wth, long seek_off, +static gboolean pppdump_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err); typedef struct { @@ -520,7 +520,7 @@ collate(pppdump_t* state, FILE_T fh, int *err, guint8 *pd, int *num_bytes, /* Used to read packets in random-access fashion */ -static int +static gboolean pppdump_seek_read (wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, @@ -541,12 +541,12 @@ pppdump_seek_read (wtap *wth, pid = g_ptr_array_index(state->pids, seek_off); if (!pid) { *err = WTAP_ERR_BAD_RECORD; /* XXX - better error? */ - return -1; + return FALSE; } if (file_seek(wth->random_fh, pid->offset, SEEK_SET) == -1) { *err = file_error(wth->random_fh); - return -1; + return FALSE; } init_state(state->seek_state); @@ -557,7 +557,7 @@ pppdump_seek_read (wtap *wth, &direction, NULL); if (!retval) { - return -1; + return FALSE; } if (direction != pid->dir) { @@ -567,12 +567,12 @@ pppdump_seek_read (wtap *wth, if (len != num_bytes) { *err = WTAP_ERR_BAD_RECORD; /* XXX - better error? */ - return -1; + return FALSE; } pseudo_header->p2p.sent = (pid->dir == DIRECTION_SENT ? TRUE : FALSE); - return 0; + return TRUE; } static void diff --git a/wiretap/radcom.c b/wiretap/radcom.c index 610d934e38..4337ea1dda 100644 --- a/wiretap/radcom.c +++ b/wiretap/radcom.c @@ -1,6 +1,6 @@ /* radcom.c * - * $Id: radcom.c,v 1.34 2002/03/05 05:58:40 guy Exp $ + * $Id: radcom.c,v 1.35 2002/03/05 08:39:29 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -68,12 +68,13 @@ struct radcomrec_hdr { }; static gboolean radcom_read(wtap *wth, int *err, long *data_offset); -static int radcom_seek_read(wtap *wth, long seek_off, +static gboolean radcom_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err); static int radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *hdr, int *err); -static int radcom_read_rec_data(FILE_T fh, u_char *pd, int length, int *err); +static gboolean radcom_read_rec_data(FILE_T fh, u_char *pd, int length, + int *err); int radcom_open(wtap *wth, int *err) { @@ -284,8 +285,8 @@ static gboolean radcom_read(wtap *wth, int *err, long *data_offset) * Read the packet data. */ buffer_assure_space(wth->frame_buffer, length); - if (radcom_read_rec_data(wth->fh, - buffer_start_ptr(wth->frame_buffer), length, err) < 0) + if (!radcom_read_rec_data(wth->fh, + buffer_start_ptr(wth->frame_buffer), length, err)) return FALSE; /* Read error */ wth->data_offset += length; @@ -308,7 +309,7 @@ static gboolean radcom_read(wtap *wth, int *err, long *data_offset) return TRUE; } -static int +static gboolean radcom_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err) { @@ -317,7 +318,7 @@ radcom_seek_read(wtap *wth, long seek_off, if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { *err = file_error(wth->random_fh); - return -1; + return FALSE; } /* Read record header. */ @@ -328,7 +329,7 @@ radcom_seek_read(wtap *wth, long seek_off, /* EOF means "short read" in random-access mode */ *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } pseudo_header->x25.flags = (hdr.dce & 0x1) ? 0x00 : 0x80; @@ -359,7 +360,7 @@ radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *hdr, int *err) return 1; } -static int +static gboolean radcom_read_rec_data(FILE_T fh, u_char *pd, int length, int *err) { int bytes_read; @@ -371,7 +372,7 @@ radcom_read_rec_data(FILE_T fh, u_char *pd, int length, int *err) *err = file_error(fh); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return 0; + return TRUE; } diff --git a/wiretap/snoop.c b/wiretap/snoop.c index 62713f3628..21c09c1d2d 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -1,6 +1,6 @@ /* snoop.c * - * $Id: snoop.c,v 1.43 2002/03/05 05:58:40 guy Exp $ + * $Id: snoop.c,v 1.44 2002/03/05 08:39:29 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -57,11 +57,12 @@ struct snooprec_hdr { }; static gboolean snoop_read(wtap *wth, int *err, long *data_offset); -static int snoop_seek_read(wtap *wth, long seek_off, +static gboolean snoop_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err); -static int snoop_read_atm_pseudoheader(FILE_T fh, +static gboolean snoop_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err); -static int snoop_read_rec_data(FILE_T fh, u_char *pd, int length, int *err); +static gboolean snoop_read_rec_data(FILE_T fh, u_char *pd, int length, + int *err); static gboolean snoop_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const union wtap_pseudo_header *pseudo_header, const u_char *pd, int *err); @@ -350,8 +351,8 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset) *err = WTAP_ERR_BAD_RECORD; return FALSE; } - if (snoop_read_atm_pseudoheader(wth->fh, &wth->pseudo_header, - err) < 0) + if (!snoop_read_atm_pseudoheader(wth->fh, &wth->pseudo_header, + err)) return FALSE; /* Read error */ /* @@ -364,8 +365,8 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset) } buffer_assure_space(wth->frame_buffer, packet_size); - if (snoop_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), - packet_size, err) < 0) + if (!snoop_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), + packet_size, err)) return FALSE; /* Read error */ wth->data_offset += packet_size; @@ -402,23 +403,20 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset) return TRUE; } -static int +static gboolean snoop_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err) { - int ret; - if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { *err = file_error(wth->random_fh); - return -1; + return FALSE; } if (wth->file_encap == WTAP_ENCAP_ATM_SNIFFER) { - ret = snoop_read_atm_pseudoheader(wth->random_fh, pseudo_header, - err); - if (ret < 0) { + if (!snoop_read_atm_pseudoheader(wth->random_fh, pseudo_header, + err)) { /* Read error */ - return ret; + return FALSE; } } @@ -428,7 +426,7 @@ snoop_seek_read(wtap *wth, long seek_off, return snoop_read_rec_data(wth->random_fh, pd, length, err); } -static int +static gboolean snoop_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err) { @@ -441,7 +439,7 @@ snoop_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, *err = file_error(fh); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } pseudo_header->ngsniffer_atm.channel = (atm_phdr[0] & 0x80) ? 1 : 0; @@ -466,10 +464,10 @@ snoop_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, pseudo_header->ngsniffer_atm.AppTrafType = ATT_AAL5|ATT_HL_UNKNOWN; pseudo_header->ngsniffer_atm.AppHLType = AHLT_UNKNOWN; - return 0; + return TRUE; } -static int +static gboolean snoop_read_rec_data(FILE_T fh, u_char *pd, int length, int *err) { int bytes_read; @@ -481,9 +479,9 @@ snoop_read_rec_data(FILE_T fh, u_char *pd, int length, int *err) *err = file_error(fh); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return 0; + return TRUE; } static const int wtap_encap[] = { diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c index c356959286..06d2a9ed47 100644 --- a/wiretap/toshiba.c +++ b/wiretap/toshiba.c @@ -1,6 +1,6 @@ /* toshiba.c * - * $Id: toshiba.c,v 1.22 2002/03/05 05:58:41 guy Exp $ + * $Id: toshiba.c,v 1.23 2002/03/05 08:39:29 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -110,10 +110,12 @@ 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 int toshiba_seek_read(wtap *wth, long seek_off, +static gboolean toshiba_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err); -static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf, guint byte_offset); -static int parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err); +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); static int parse_toshiba_rec_hdr(wtap *wth, FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err); @@ -248,7 +250,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) == -1) + if (!parse_toshiba_hex_dump(wth->fh, pkt_len, buf, err)) return FALSE; wth->data_offset = offset; @@ -257,7 +259,7 @@ static gboolean toshiba_read(wtap *wth, int *err, long *data_offset) } /* Used to read packets in random-access fashion */ -static int +static gboolean toshiba_seek_read (wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err) { @@ -265,7 +267,7 @@ toshiba_seek_read (wtap *wth, long seek_off, if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET) == -1) { *err = file_error(wth->random_fh); - return -1; + return FALSE; } pkt_len = parse_toshiba_rec_hdr(NULL, wth->random_fh, pseudo_header, @@ -274,13 +276,10 @@ toshiba_seek_read (wtap *wth, long seek_off, if (pkt_len != len) { if (pkt_len != -1) *err = WTAP_ERR_BAD_RECORD; - return -1; + return FALSE; } - if (parse_toshiba_hex_dump(wth->random_fh, pkt_len, pd, err) == -1) - return -1; - - return 0; + return parse_toshiba_hex_dump(wth->random_fh, pkt_len, pd, err); } /* Parses a packet record header. */ @@ -373,7 +372,7 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh, } /* Converts ASCII hex dump to binary data */ -static int +static gboolean parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err) { char line[TOSHIBA_LINE_LENGTH]; @@ -389,14 +388,14 @@ parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err) if (*err == 0) { *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } if (!parse_single_hex_dump_line(line, buf, i * 16)) { *err = WTAP_ERR_BAD_RECORD; - return -1; + return FALSE; } } - return 0; + return TRUE; } /* diff --git a/wiretap/visual.c b/wiretap/visual.c index dcb11910dd..faa5a99084 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.4 2002/03/05 05:58:41 guy Exp $ + * $Id: visual.c,v 1.5 2002/03/05 08:39:29 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -114,7 +114,7 @@ struct visual_write_info /* Local functions to handle file reads and writes */ static gboolean visual_read(wtap *wth, int *err, long *data_offset); static void visual_close(wtap *wth); -static int visual_seek_read(wtap *wth, long seek_off, +static gboolean visual_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size, int *err); static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, @@ -328,7 +328,7 @@ static void visual_close(wtap *wth) /* Read packet data for random access. This gets the packet data and rebuilds the pseudo header so that the direction flag works. */ -static int visual_seek_read (wtap *wth, long seek_off, +static gboolean visual_seek_read (wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err) { struct visual_pkt_hdr vpkt_hdr; @@ -340,7 +340,7 @@ static int visual_seek_read (wtap *wth, long seek_off, if (file_seek(wth->random_fh, seek_off - sizeof(struct visual_pkt_hdr), SEEK_SET) == -1) { *err = file_error(wth->random_fh); - return -1; + return FALSE; } /* Read the packet header to get the status flags. */ @@ -350,7 +350,7 @@ static int visual_seek_read (wtap *wth, long seek_off, *err = file_error(wth->random_fh); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } /* Read the packet data. */ @@ -359,7 +359,7 @@ static int visual_seek_read (wtap *wth, long seek_off, if (bytes_read != len) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } /* Set status flags. The only status currently supported for all @@ -380,7 +380,7 @@ static int visual_seek_read (wtap *wth, long seek_off, break; } - return 0; + return TRUE; } diff --git a/wiretap/vms.c b/wiretap/vms.c index 9b0da71330..7fe8ad9cf6 100644 --- a/wiretap/vms.c +++ b/wiretap/vms.c @@ -1,6 +1,6 @@ /* vms.c * - * $Id: vms.c,v 1.9 2002/03/05 05:58:41 guy Exp $ + * $Id: vms.c,v 1.10 2002/03/05 08:39:29 guy Exp $ * * Wiretap Library * Copyright (c) 2001 by Marc Milgram <mmilgram@arrayinc.com> @@ -72,10 +72,12 @@ static const char vms_hdr_magic[] = #define VMS_REC_MAGIC_SIZE (sizeof vms_rec_magic / sizeof vms_rec_magic[0]) static gboolean vms_read(wtap *wth, int *err, long *data_offset); -static int vms_seek_read(wtap *wth, long seek_off, +static gboolean vms_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err); -static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf, long byte_offset, int in_off, int remaining_bytes); -static int parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err); +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); @@ -227,7 +229,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) == -1) + if (!parse_vms_hex_dump(wth->fh, pkt_len, buf, err)) return FALSE; wth->data_offset = offset; @@ -236,7 +238,7 @@ static gboolean vms_read(wtap *wth, int *err, long *data_offset) } /* Used to read packets in random-access fashion */ -static int +static gboolean vms_seek_read (wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header _U_, guint8 *pd, int len, int *err) @@ -245,7 +247,7 @@ vms_seek_read (wtap *wth, long seek_off, if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET) == -1) { *err = file_error(wth->random_fh); - return -1; + return FALSE; } pkt_len = parse_vms_rec_hdr(NULL, wth->random_fh, err); @@ -253,13 +255,10 @@ vms_seek_read (wtap *wth, long seek_off, if (pkt_len != len) { if (pkt_len != -1) *err = WTAP_ERR_BAD_RECORD; - return -1; + return FALSE; } - if (parse_vms_hex_dump(wth->random_fh, pkt_len, pd, err) == -1) - return -1; - - return 0; + return parse_vms_hex_dump(wth->random_fh, pkt_len, pd, err); } /* isdumpline assumes that dump lines start with some spaces followed by a @@ -358,7 +357,7 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err) } /* Converts ASCII hex dump to binary data */ -static int +static gboolean parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err) { guchar line[VMS_LINE_LENGTH]; @@ -371,7 +370,7 @@ parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err) if (*err == 0) { *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } if (i == 0) { while (! isdumpline(line)) /* advance to start of hex data */ @@ -380,7 +379,7 @@ parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err) if (*err == 0) { *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } while (line[offset] && !isxdigit(line[offset])) offset++; @@ -388,13 +387,13 @@ 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; - return -1; + return FALSE; } } /* Avoid TCPIPTRACE-W-BUFFERSFUL, TCPIPtrace could not save n packets. * errors. */ file_gets(line, VMS_LINE_LENGTH, fh); - return 0; + return TRUE; } /* diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h index 965b59fc32..6b8e04f49a 100644 --- a/wiretap/wtap-int.h +++ b/wiretap/wtap-int.h @@ -1,6 +1,6 @@ /* wtap-int.h * - * $Id: wtap-int.h,v 1.21 2002/03/05 05:58:41 guy Exp $ + * $Id: wtap-int.h,v 1.22 2002/03/05 08:39:30 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -119,8 +119,8 @@ typedef struct { struct timeval reference_time; } etherpeek_t; -typedef int (*subtype_read_func)(struct wtap*, int*, long*); -typedef int (*subtype_seek_read_func)(struct wtap*, long, union wtap_pseudo_header*, +typedef gboolean (*subtype_read_func)(struct wtap*, int*, long*); +typedef gboolean (*subtype_seek_read_func)(struct wtap*, long, union wtap_pseudo_header*, guint8*, int, int *); struct wtap { FILE_T fh; diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 2bc0191f99..dd6a6ff558 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -1,6 +1,6 @@ /* wtap.c * - * $Id: wtap.c,v 1.62 2002/03/05 05:58:41 guy Exp $ + * $Id: wtap.c,v 1.63 2002/03/05 08:39:30 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -310,7 +310,7 @@ wtap_loop(wtap *wth, int count, wtap_handler callback, u_char* user, int *err) return FALSE; /* failure */ } -int +gboolean wtap_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err) diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 07881a7180..c3a29319c5 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -1,6 +1,6 @@ /* wtap.h * - * $Id: wtap.h,v 1.106 2002/03/05 05:58:41 guy Exp $ + * $Id: wtap.h,v 1.107 2002/03/05 08:39:30 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -341,9 +341,9 @@ int wtap_short_string_to_encap(const char *short_name); const char *wtap_strerror(int err); void wtap_sequential_close(wtap *wth); void wtap_close(wtap *wth); -int wtap_seek_read (wtap *wth, long seek_off, +gboolean wtap_seek_read (wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err); -int wtap_def_seek_read (wtap *wth, long seek_off, +gboolean wtap_def_seek_read (wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err); gboolean wtap_dump_can_open(int filetype); |