From a344c9736efe5519543da1290e1ad9065d0b0cff Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 23 May 2014 10:50:02 +0000 Subject: Revert "Allow wtap_read() and wtap_seek_read() to return non-packet records." This reverts commit c0c480d08c175eed4524ea9e73ec86298f468cf4. A better way to do this is to have the record type be part of struct wtap_pkthdr; that keeps the metadata for the record together and requires fewer API changes. That is in-progress. Change-Id: Ic558f163a48e2c6d0df7f55e81a35a5e24b53bc6 Reviewed-on: https://code.wireshark.org/review/1741 Reviewed-by: Guy Harris --- wiretap/5views.c | 28 ++++++------- wiretap/aethra.c | 22 +++++----- wiretap/ascendtext.c | 20 ++++----- wiretap/ber.c | 24 +++++------ wiretap/btsnoop.c | 22 +++++----- wiretap/camins.c | 16 ++++---- wiretap/catapult_dct2000.c | 32 +++++++-------- wiretap/commview.c | 24 +++++------ wiretap/cosine.c | 26 ++++++------ wiretap/csids.c | 20 +++++---- wiretap/daintree-sna.c | 32 +++++++-------- wiretap/dbs-etherwatch.c | 48 +++++++++++----------- wiretap/dct3trace.c | 26 ++++++------ wiretap/erf.c | 34 ++++++++-------- wiretap/eyesdn.c | 28 ++++++------- wiretap/hcidump.c | 16 ++++---- wiretap/i4btrace.c | 24 +++++------ wiretap/ipfix.c | 18 ++++----- wiretap/iptrace.c | 28 ++++++------- wiretap/iseries.c | 28 ++++++------- wiretap/k12.c | 20 ++++----- wiretap/k12text.l | 16 ++++---- wiretap/lanalyzer.c | 20 +++++---- wiretap/libpcap.c | 18 ++++----- wiretap/logcat.c | 16 ++++---- wiretap/mime_file.c | 20 +++++---- wiretap/mp2t.c | 16 ++++---- wiretap/mpeg.c | 16 ++++---- wiretap/netmon.c | 32 +++++++-------- wiretap/netscaler.c | 94 +++++++++++++++++++++---------------------- wiretap/netscreen.c | 26 ++++++------ wiretap/nettl.c | 18 ++++----- wiretap/network_instruments.c | 30 +++++++------- wiretap/netxray.c | 32 +++++++-------- wiretap/ngsniffer.c | 26 ++++++------ wiretap/packetlogger.c | 26 ++++++------ wiretap/pcapng.c | 16 ++++---- wiretap/peekclassic.c | 30 +++++++------- wiretap/peektagged.c | 20 ++++----- wiretap/pppdump.c | 22 +++++----- wiretap/radcom.c | 22 +++++----- wiretap/snoop.c | 20 ++++----- wiretap/stanag4607.c | 25 +++++------- wiretap/tnef.c | 26 ++++++------ wiretap/toshiba.c | 22 +++++----- wiretap/visual.c | 22 +++++----- wiretap/vms.c | 18 ++++----- wiretap/vwr.c | 25 +++++------- wiretap/wtap-int.h | 8 ++-- wiretap/wtap.c | 22 ++++------ wiretap/wtap.h | 21 +++------- 51 files changed, 601 insertions(+), 660 deletions(-) (limited to 'wiretap') diff --git a/wiretap/5views.c b/wiretap/5views.c index fed60d05ec..db377b1570 100644 --- a/wiretap/5views.c +++ b/wiretap/5views.c @@ -99,9 +99,9 @@ typedef struct #define CST_5VW_CAPTURES_RECORD (CST_5VW_SECTION_CAPTURES << 28) /* 0x80000000 */ #define CST_5VW_SYSTEM_RECORD 0x00000000U -static int _5views_read(wtap *wth, int *err, gchar **err_info, +static gboolean _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int _5views_seek_read(wtap *wth, gint64 seek_off, +static gboolean _5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static int _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr, struct wtap_pkthdr *phdr, int *err, gchar **err_info); @@ -191,7 +191,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info) } /* Read the next packet */ -static int +static gboolean _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { t_5VW_TimeStamped_Header TimeStamped_Header; @@ -207,7 +207,7 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) /* Read record header. */ if (!_5views_read_header(wth, wth->fh, &TimeStamped_Header, &wth->phdr, err, err_info)) - return -1; + return FALSE; if (TimeStamped_Header.RecSubType == CST_5VW_FRAME_RECORD) { /* @@ -220,7 +220,7 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) * Not a packet - skip to the next record. */ if (file_seek(wth->fh, TimeStamped_Header.RecSize, SEEK_CUR, err) == -1) - return -1; + return FALSE; } while (1); if (wth->phdr.caplen > WTAP_MAX_PACKET_SIZE) { @@ -231,13 +231,11 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("5views: File has %u-byte packet, bigger than maximum of %u", wth->phdr.caplen, WTAP_MAX_PACKET_SIZE); - return -1; + return FALSE; } - if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer, - wth->phdr.caplen, err, err_info)) - return -1; - return REC_TYPE_PACKET; + return wtap_read_packet_bytes(wth->fh, wth->frame_buffer, + wth->phdr.caplen, err, err_info); } static gboolean @@ -247,7 +245,7 @@ _5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, t_5VW_TimeStamped_Header TimeStamped_Header; if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* * Read the header. @@ -256,16 +254,14 @@ _5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, phdr, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } /* * Read the packet data. */ - if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, - err, err_info)) - return -1; - return REC_TYPE_PACKET; + return wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, + err, err_info); } /* Read the header of the next packet. Return TRUE on success, FALSE diff --git a/wiretap/aethra.c b/wiretap/aethra.c index bab0091fb0..a0b783b349 100644 --- a/wiretap/aethra.c +++ b/wiretap/aethra.c @@ -112,9 +112,9 @@ typedef struct { time_t start; } aethra_t; -static int aethra_read(wtap *wth, int *err, gchar **err_info, +static gboolean aethra_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int aethra_seek_read(wtap *wth, gint64 seek_off, +static gboolean aethra_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static gboolean aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr, struct wtap_pkthdr *phdr, int *err, gchar **err_info); @@ -182,7 +182,7 @@ static guint packet = 0; #endif /* Read the next packet */ -static int aethra_read(wtap *wth, int *err, gchar **err_info, +static gboolean aethra_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { struct aethrarec_hdr hdr; @@ -196,7 +196,7 @@ static int aethra_read(wtap *wth, int *err, gchar **err_info, /* Read record header. */ if (!aethra_read_rec_header(wth, wth->fh, &hdr, &wth->phdr, err, err_info)) - return -1; + return FALSE; /* * XXX - if this is big, we might waste memory by @@ -205,7 +205,7 @@ static int aethra_read(wtap *wth, int *err, gchar **err_info, if (wth->phdr.caplen != 0) { if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer, wth->phdr.caplen, err, err_info)) - return -1; /* Read error */ + return FALSE; /* Read error */ } #if 0 packet++; @@ -270,32 +270,32 @@ packet, hdr.rec_type, wth->phdr.caplen, hdr.flags); } found: - return REC_TYPE_PACKET; + return TRUE; } -static int +static gboolean aethra_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { struct aethrarec_hdr hdr; if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; if (!aethra_read_rec_header(wth, wth->random_fh, &hdr, phdr, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } /* * Read the packet data. */ if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err, err_info)) - return -1; /* failed */ + return FALSE; /* failed */ - return REC_TYPE_PACKET; + return TRUE; } static gboolean diff --git a/wiretap/ascendtext.c b/wiretap/ascendtext.c index 58ea2fbea6..32d4d49418 100644 --- a/wiretap/ascendtext.c +++ b/wiretap/ascendtext.c @@ -74,9 +74,9 @@ static const ascend_magic_string ascend_magic[] = { { ASCEND_PFX_ETHER, "ETHER" }, }; -static int ascend_read(wtap *wth, int *err, gchar **err_info, +static gboolean ascend_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int ascend_seek_read(wtap *wth, gint64 seek_off, +static gboolean ascend_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); @@ -237,36 +237,36 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info, packet's header because we might mistake part of it for a new header. */ if (file_seek(wth->fh, ascend->next_packet_seek_start, SEEK_SET, err) == -1) - return -1; + return FALSE; offset = ascend_seek(wth, err, err_info); if (offset == -1) - return -1; + return FALSE; if (parse_ascend(ascend, wth->fh, &wth->phdr, wth->frame_buffer, wth->snapshot_length) != PARSED_RECORD) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error"); - return -1; + return FALSE; } *data_offset = offset; - return REC_TYPE_PACKET; + return TRUE; } -static int ascend_seek_read(wtap *wth, gint64 seek_off, +static gboolean ascend_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { ascend_t *ascend = (ascend_t *)wth->priv; if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; if (parse_ascend(ascend, wth->random_fh, phdr, buf, wth->snapshot_length) != PARSED_RECORD) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error"); - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } diff --git a/wiretap/ber.c b/wiretap/ber.c index 1a3f4e6bf6..59e7e28f39 100644 --- a/wiretap/ber.c +++ b/wiretap/ber.c @@ -38,14 +38,14 @@ #define BER_UNI_TAG_SEQ 16 /* SEQUENCE, SEQUENCE OF */ #define BER_UNI_TAG_SET 17 /* SET, SET OF */ -static int ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, - Buffer *buf, int *err, gchar **err_info) +static gboolean ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, + Buffer *buf, int *err, gchar **err_info) { gint64 file_size; int packet_size; if ((file_size = wtap_file_size(wth, err)) == -1) - return -1; + return FALSE; if (file_size > WTAP_MAX_PACKET_SIZE) { /* @@ -55,7 +55,7 @@ static int ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("ber: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u", file_size, WTAP_MAX_PACKET_SIZE); - return -1; + return FALSE; } packet_size = (int)file_size; @@ -67,12 +67,10 @@ static int ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, phdr->ts.secs = 0; phdr->ts.nsecs = 0; - if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info)) - return -1; - return REC_TYPE_PACKET; + return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info); } -static int ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) +static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { gint64 offset; @@ -82,24 +80,24 @@ static int ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) /* there is only ever one packet */ if (offset != 0) - return -1; + return FALSE; *data_offset = offset; return ber_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); } -static int ber_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr _U_, - Buffer *buf, int *err, gchar **err_info) +static gboolean ber_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr _U_, + Buffer *buf, int *err, gchar **err_info) { /* there is only one packet */ if(seek_off > 0) { *err = 0; - return -1; + return FALSE; } if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; return ber_read_file(wth, wth->random_fh, phdr, buf, err, err_info); } diff --git a/wiretap/btsnoop.c b/wiretap/btsnoop.c index c1e5a9881e..b7c0b4c5c5 100644 --- a/wiretap/btsnoop.c +++ b/wiretap/btsnoop.c @@ -73,11 +73,11 @@ struct btsnooprec_hdr { static const gint64 KUnixTimeBase = G_GINT64_CONSTANT(0x00dcddb30f2f8000); /* offset from symbian - unix time */ -static int btsnoop_read(wtap *wth, int *err, gchar **err_info, +static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int btsnoop_seek_read(wtap *wth, gint64 seek_off, +static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); -static int btsnoop_read_record(wtap *wth, FILE_T fh, +static gboolean btsnoop_read_record(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); int btsnoop_open(wtap *wth, int *err, gchar **err_info) @@ -160,7 +160,7 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info) return 1; } -static int btsnoop_read(wtap *wth, int *err, gchar **err_info, +static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); @@ -169,16 +169,16 @@ static int btsnoop_read(wtap *wth, int *err, gchar **err_info, err, err_info); } -static int btsnoop_seek_read(wtap *wth, gint64 seek_off, +static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; return btsnoop_read_record(wth, wth->random_fh, phdr, buf, err, err_info); } -static int btsnoop_read_record(wtap *wth, FILE_T fh, +static gboolean btsnoop_read_record(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { int bytes_read; @@ -196,7 +196,7 @@ static int btsnoop_read_record(wtap *wth, FILE_T fh, *err = file_error(fh, err_info); if (*err == 0 && bytes_read != 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } packet_size = g_ntohl(hdr.incl_len); @@ -210,7 +210,7 @@ static int btsnoop_read_record(wtap *wth, FILE_T fh, *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("btsnoop: File has %u-byte packet, bigger than maximum of %u", packet_size, WTAP_MAX_PACKET_SIZE); - return -1; + return FALSE; } ts = GINT64_FROM_BE(hdr.ts_usec); @@ -248,9 +248,7 @@ static int btsnoop_read_record(wtap *wth, FILE_T fh, /* Read packet data. */ - if (!wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info)) - return -1; - return REC_TYPE_PACKET; + return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info); } /* Returns 0 if we could write the specified encapsulation type, diff --git a/wiretap/camins.c b/wiretap/camins.c index d49cf96b80..ccc618498a 100644 --- a/wiretap/camins.c +++ b/wiretap/camins.c @@ -256,7 +256,7 @@ create_pseudo_hdr(guint8 *buf, guint8 dat_trans_type, guint16 dat_len) } -static int +static gboolean camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { @@ -266,7 +266,7 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, gint offset, bytes_read; if (!find_next_pkt_dat_type_len(fh, &dat_trans_type, &dat_len, err, err_info)) - return -1; + return FALSE; buffer_assure_space(buf, DVB_CI_PSEUDO_HDR_LEN+dat_len); p = buffer_start_ptr(buf); @@ -276,7 +276,7 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, /* shouldn't happen, all invalid packets must be detected by find_next_pkt_dat_type_len() */ *err = WTAP_ERR_INTERNAL; - return -1; + return FALSE; } bytes_read = read_packet_data(fh, dat_trans_type, @@ -284,7 +284,7 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, /* 0<=bytes_read<=dat_len is very likely a corrupted packet we let the dissector handle this */ if (bytes_read < 0) - return -1; + return FALSE; offset += bytes_read; phdr->pkt_encap = WTAP_ENCAP_DVBCI; @@ -292,11 +292,11 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, phdr->caplen = offset; phdr->len = offset; - return REC_TYPE_PACKET; + return TRUE; } -static int +static gboolean camins_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); @@ -306,12 +306,12 @@ camins_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) } -static int +static gboolean camins_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *pkthdr, Buffer *buf, int *err, gchar **err_info) { if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err)) - return -1; + return FALSE; return camins_read_packet(wth->random_fh, pkthdr, buf, err, err_info); } diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c index aece8e75fd..8b29a23880 100644 --- a/wiretap/catapult_dct2000.c +++ b/wiretap/catapult_dct2000.c @@ -103,12 +103,12 @@ static const gchar catapult_dct2000_magic[] = "Session Transcript"; /************************************************************/ /* Functions called from wiretap core */ -static int catapult_dct2000_read(wtap *wth, int *err, gchar **err_info, - gint64 *data_offset); -static int catapult_dct2000_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, - Buffer *buf, int *err, - gchar **err_info); +static gboolean catapult_dct2000_read(wtap *wth, int *err, gchar **err_info, + gint64 *data_offset); +static gboolean catapult_dct2000_seek_read(wtap *wth, gint64 seek_off, + struct wtap_pkthdr *phdr, + Buffer *buf, int *err, + gchar **err_info); static void catapult_dct2000_close(wtap *wth); static gboolean catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, @@ -331,9 +331,9 @@ static void write_timestamp_string(char *timestamp_string, int secs, int tenthou /**************************************************/ /* Read packet function. */ /* Look for and read the next usable packet */ -/* - return REC_TYPE_PACKET and details if found */ +/* - return TRUE and details if found */ /**************************************************/ -static int +static gboolean catapult_dct2000_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { @@ -370,7 +370,7 @@ catapult_dct2000_read(wtap *wth, int *err, gchar **err_info, if (!read_new_line(wth->fh, &offset, &line_length, linebuff, sizeof linebuff, err, err_info)) { if (*err != 0) - return -1; /* error */ + return FALSE; /* error */ /* No more lines can be read, so quit. */ break; } @@ -434,19 +434,19 @@ catapult_dct2000_read(wtap *wth, int *err, gchar **err_info, g_hash_table_insert(file_externals->packet_prefix_table, pkey, line_prefix_info); /* OK, we have packet details to return */ - return REC_TYPE_PACKET; + return TRUE; } } /* No packet details to return... */ - return -1; + return FALSE; } /**************************************************/ /* Read & seek function. */ /**************************************************/ -static int +static gboolean catapult_dct2000_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) @@ -476,13 +476,13 @@ catapult_dct2000_seek_read(wtap *wth, gint64 seek_off, /* Seek to beginning of packet */ if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) { - return -1; + return FALSE; } /* Re-read whole line (this really should succeed) */ if (!read_new_line(wth->random_fh, &offset, &length, linebuff, sizeof linebuff, err, err_info)) { - return -1; + return FALSE; } /* Try to parse this line again (should succeed as re-reading...) */ @@ -508,7 +508,7 @@ catapult_dct2000_seek_read(wtap *wth, gint64 seek_off, is_comment, data_chars); *err = errno = 0; - return REC_TYPE_PACKET; + return TRUE; } /* If get here, must have failed */ @@ -516,7 +516,7 @@ catapult_dct2000_seek_read(wtap *wth, gint64 seek_off, *err_info = g_strdup_printf("catapult dct2000: seek_read failed to read/parse " "line at position %" G_GINT64_MODIFIER "d", seek_off); - return -1; + return FALSE; } diff --git a/wiretap/commview.c b/wiretap/commview.c index fa7660bbff..e2a868a6b2 100644 --- a/wiretap/commview.c +++ b/wiretap/commview.c @@ -78,11 +78,11 @@ typedef struct commview_header { #define MEDIUM_WIFI 1 #define MEDIUM_TOKEN_RING 2 -static int commview_read(wtap *wth, int *err, gchar **err_info, - gint64 *data_offset); -static int commview_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, - Buffer *buf, int *err, gchar **err_info); +static gboolean commview_read(wtap *wth, int *err, gchar **err_info, + gint64 *data_offset); +static gboolean commview_seek_read(wtap *wth, gint64 seek_off, + struct wtap_pkthdr *phdr, + Buffer *buf, int *err, gchar **err_info); static gboolean commview_read_header(commview_header_t *cv_hdr, FILE_T fh, int *err, gchar **err_info); static gboolean commview_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, @@ -136,7 +136,7 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, struct tm tm; if(!commview_read_header(&cv_hdr, fh, err, err_info)) - return -1; + return FALSE; switch(cv_hdr.flags & FLAGS_MEDIUM) { @@ -162,7 +162,7 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("commview: unsupported encap: %u", cv_hdr.flags & FLAGS_MEDIUM); - return -1; + return FALSE; } tm.tm_year = cv_hdr.year - 1900; @@ -181,12 +181,10 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, phdr->ts.secs = mktime(&tm); phdr->ts.nsecs = cv_hdr.usecs * 1000; - if (!wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info)) - return -1; - return REC_TYPE_PACKET; + return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info); } -static int +static gboolean commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); @@ -195,12 +193,12 @@ commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) err_info); } -static int +static gboolean commview_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; return commview_read_packet(wth->random_fh, phdr, buf, err, err_info); } diff --git a/wiretap/cosine.c b/wiretap/cosine.c index 18b2065287..d937018796 100644 --- a/wiretap/cosine.c +++ b/wiretap/cosine.c @@ -166,13 +166,13 @@ static gboolean empty_line(const gchar *line); static gint64 cosine_seek_next_packet(wtap *wth, int *err, gchar **err_info, char *hdr); static gboolean cosine_check_file_type(wtap *wth, int *err, gchar **err_info); -static int cosine_read(wtap *wth, int *err, gchar **err_info, +static gboolean cosine_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int cosine_seek_read(wtap *wth, gint64 seek_off, +static gboolean cosine_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static int parse_cosine_rec_hdr(struct wtap_pkthdr *phdr, const char *line, int *err, gchar **err_info); -static int parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr, int pkt_len, Buffer* buf, int *err, gchar **err_info); static int parse_single_hex_dump_line(char* rec, guint8 *buf, guint byte_offset); @@ -286,7 +286,7 @@ int cosine_open(wtap *wth, int *err, gchar **err_info) } /* Find the next packet and parse it; called from wtap_read(). */ -static int cosine_read(wtap *wth, int *err, gchar **err_info, +static gboolean cosine_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { gint64 offset; @@ -296,13 +296,13 @@ static int cosine_read(wtap *wth, int *err, gchar **err_info, /* Find the next packet */ offset = cosine_seek_next_packet(wth, err, err_info, line); if (offset < 0) - return -1; + return FALSE; *data_offset = offset; /* Parse the header */ pkt_len = parse_cosine_rec_hdr(&wth->phdr, line, err, err_info); if (pkt_len == -1) - return -1; + return FALSE; /* Convert the ASCII hex dump to binary data */ return parse_cosine_hex_dump(wth->fh, &wth->phdr, pkt_len, @@ -310,7 +310,7 @@ static int cosine_read(wtap *wth, int *err, gchar **err_info, } /* Used to read packets in random-access fashion */ -static int +static gboolean cosine_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { @@ -435,9 +435,9 @@ parse_cosine_rec_hdr(struct wtap_pkthdr *phdr, const char *line, return pkt_len; } -/* Converts ASCII hex dump to binary data. Returns REC_TYPE_PACKET on success, - -1 if any error is encountered. */ -static int +/* Converts ASCII hex dump to binary data. Returns TRUE on success, + FALSE if any error is encountered. */ +static gboolean parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr, int pkt_len, Buffer* buf, int *err, gchar **err_info) { @@ -459,7 +459,7 @@ parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr, int pkt_len, if (*err == 0) { *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } if (empty_line(line)) { break; @@ -467,12 +467,12 @@ parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr, int pkt_len, if ((n = parse_single_hex_dump_line(line, pd, i*16)) == -1) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("cosine: hex dump line doesn't have 16 numbers"); - return -1; + return FALSE; } caplen += n; } phdr->caplen = caplen; - return REC_TYPE_PACKET; + return TRUE; } diff --git a/wiretap/csids.c b/wiretap/csids.c index 7145b62749..bc640f639d 100644 --- a/wiretap/csids.c +++ b/wiretap/csids.c @@ -44,9 +44,9 @@ typedef struct { gboolean byteswapped; } csids_t; -static int csids_read(wtap *wth, int *err, gchar **err_info, +static gboolean csids_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int csids_seek_read(wtap *wth, gint64 seek_off, +static gboolean csids_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static gboolean csids_read_packet(FILE_T fh, csids_t *csids, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); @@ -144,21 +144,19 @@ int csids_open(wtap *wth, int *err, gchar **err_info) } /* Find the next packet and parse it; called from wtap_read(). */ -static int csids_read(wtap *wth, int *err, gchar **err_info, +static gboolean csids_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { csids_t *csids = (csids_t *)wth->priv; *data_offset = file_tell(wth->fh); - if (!csids_read_packet( wth->fh, csids, &wth->phdr, wth->frame_buffer, - err, err_info )) - return -1; - return REC_TYPE_PACKET; + return csids_read_packet( wth->fh, csids, &wth->phdr, wth->frame_buffer, + err, err_info ); } /* Used to read packets in random-access fashion */ -static int +static gboolean csids_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, @@ -169,14 +167,14 @@ csids_seek_read(wtap *wth, csids_t *csids = (csids_t *)wth->priv; if( file_seek( wth->random_fh, seek_off, SEEK_SET, err ) == -1 ) - return -1; + return FALSE; if( !csids_read_packet( wth->random_fh, csids, phdr, buf, err, err_info ) ) { if( *err == 0 ) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } static gboolean diff --git a/wiretap/daintree-sna.c b/wiretap/daintree-sna.c index bb25611fd8..23785548d2 100644 --- a/wiretap/daintree-sna.c +++ b/wiretap/daintree-sna.c @@ -77,16 +77,16 @@ static const char daintree_magic_text[] = #define COMMENT_LINE daintree_magic_text[0] -static int daintree_sna_read(wtap *wth, int *err, gchar **err_info, +static gboolean daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int daintree_sna_seek_read(wtap *wth, gint64 seek_off, +static gboolean daintree_sna_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static gboolean daintree_sna_scan_header(struct wtap_pkthdr *phdr, char *readLine, char *readData, int *err, gchar **err_info); -static int daintree_sna_process_hex_data(struct wtap_pkthdr *phdr, +static gboolean daintree_sna_process_hex_data(struct wtap_pkthdr *phdr, Buffer *buf, char *readData, int *err, gchar **err_info); /* Open a file and determine if it's a Daintree file */ @@ -134,7 +134,7 @@ int daintree_sna_open(wtap *wth, int *err, gchar **err_info) /* Read the capture file sequentially * Wireshark scans the file with sequential reads during preview and initial display. */ -static int +static gboolean daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { char readLine[DAINTREE_MAX_LINE_SIZE]; @@ -147,14 +147,14 @@ daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) do { if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->fh) == NULL) { *err = file_error(wth->fh, err_info); - return -1; /* all done */ + return FALSE; /* all done */ } } while (readLine[0] == COMMENT_LINE); /* parse one line of capture data */ if (!daintree_sna_scan_header(&wth->phdr, readLine, readData, err, err_info)) - return -1; + return FALSE; /* process packet data */ return daintree_sna_process_hex_data(&wth->phdr, wth->frame_buffer, @@ -163,7 +163,7 @@ daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) /* Read the capture file randomly * Wireshark opens the capture file for random access when displaying user-selected packets */ -static int +static gboolean daintree_sna_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { @@ -171,20 +171,20 @@ daintree_sna_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, char readData[READDATA_BUF_SIZE]; if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* It appears only file header lines start with '#', but * if we find any others, we toss them */ do { if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->random_fh) == NULL) { *err = file_error(wth->random_fh, err_info); - return -1; /* all done */ + return FALSE; /* all done */ } } while (readLine[0] == COMMENT_LINE); /* parse one line of capture data */ if (!daintree_sna_scan_header(phdr, readLine, readData, err, err_info)) - return -1; + return FALSE; /* process packet data */ return daintree_sna_process_hex_data(phdr, buf, readData, err, @@ -226,7 +226,7 @@ daintree_sna_scan_header(struct wtap_pkthdr *phdr, char *readLine, /* Convert packet data from ASCII hex string to binary in place, * sanity-check its length against what we assume is the packet length field, * and copy it into a Buffer */ -static int +static gboolean daintree_sna_process_hex_data(struct wtap_pkthdr *phdr, Buffer *buf, char *readData, int *err, gchar **err_info) { @@ -242,7 +242,7 @@ daintree_sna_process_hex_data(struct wtap_pkthdr *phdr, Buffer *buf, if (!isxdigit((guchar)*str)) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("daintree_sna: non-hex digit in hex data"); - return -1; + return FALSE; } if(isdigit((guchar)*str)) { *p = (*str - '0') << 4; @@ -255,7 +255,7 @@ daintree_sna_process_hex_data(struct wtap_pkthdr *phdr, Buffer *buf, if (!isxdigit((guchar)*str)) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("daintree_sna: non-hex digit in hex data"); - return -1; + return FALSE; } if(isdigit((guchar)*str)) { *p += *str - '0'; @@ -274,19 +274,19 @@ daintree_sna_process_hex_data(struct wtap_pkthdr *phdr, Buffer *buf, *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("daintree_sna: Only %u bytes of packet data", bytes); - return -1; + return FALSE; } bytes -= FCS_LENGTH; if (bytes > phdr->len) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("daintree_sna: capture length (%u) > packet length (%u)", bytes, phdr->len); - return -1; + return FALSE; } phdr->caplen = bytes; buffer_assure_space(buf, bytes); memcpy(buffer_start_ptr(buf), readData, bytes); - return REC_TYPE_PACKET; + return TRUE; } diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c index 31fa9af630..0a3e9f57e1 100644 --- a/wiretap/dbs-etherwatch.c +++ b/wiretap/dbs-etherwatch.c @@ -84,11 +84,11 @@ static const char dbs_etherwatch_rec_magic[] = */ #define DBS_ETHERWATCH_MAX_PACKET_LEN 16384 -static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, +static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off, +static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); -static int parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, +static gboolean parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, int *err, gchar **err_info); static guint parse_single_hex_dump_line(char* rec, guint8 *buf, int byte_offset); @@ -196,7 +196,7 @@ int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info) } /* Find the next packet and parse it; called from wtap_read(). */ -static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, +static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { gint64 offset; @@ -204,7 +204,7 @@ static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, /* Find the next packet */ offset = dbs_etherwatch_seek_next_packet(wth, err, err_info); if (offset < 1) - return -1; + return FALSE; *data_offset = offset; /* Parse the packet */ @@ -213,12 +213,12 @@ static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, } /* Used to read packets in random-access fashion */ -static int +static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1) - return -1; + return FALSE; return parse_dbs_etherwatch_packet(phdr, wth->random_fh, buf, err, err_info); @@ -268,7 +268,7 @@ unnumbered. Unnumbered has length 1, numbered 2. */ #define CTL_UNNUMB_MASK 0x03 #define CTL_UNNUMB_VALUE 0x03 -static int +static gboolean parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, int *err, gchar **err_info) { @@ -298,7 +298,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, if (*err == 0) { *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } /* Get the destination address */ @@ -306,14 +306,14 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, if(!p) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: destination address not found"); - return -1; + return FALSE; } p += strlen(DEST_MAC_PREFIX); if(parse_hex_dump(p, &pd[eth_hdr_len], HEX_HDR_SPR, HEX_HDR_END) != MAC_ADDR_LENGTH) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: destination address not valid"); - return -1; + return FALSE; } eth_hdr_len += MAC_ADDR_LENGTH; @@ -331,7 +331,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, HEX_HDR_END) != MAC_ADDR_LENGTH) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: source address not valid"); - return -1; + return FALSE; } eth_hdr_len += MAC_ADDR_LENGTH; @@ -341,14 +341,14 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, if (*err == 0) { *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } /* Check the lines is as least as long as the length position */ if(strlen(line) < LENGTH_POS) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: line too short"); - return -1; + return FALSE; } num_items_scanned = sscanf(line + LENGTH_POS, @@ -361,7 +361,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, if (num_items_scanned != 8) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: header line not valid"); - return -1; + return FALSE; } /* Determine whether it is Ethernet II or IEEE 802 */ @@ -373,7 +373,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, HEX_HDR_END) != PROTOCOL_LENGTH) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: Ethernet II protocol value not valid"); - return -1; + return FALSE; } eth_hdr_len += PROTOCOL_LENGTH; } else { @@ -389,7 +389,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, HEX_HDR_END) != SAP_LENGTH) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: 802.2 DSAP+SSAP value not valid"); - return -1; + return FALSE; } eth_hdr_len += SAP_LENGTH; /* Get the (first part of the) control field */ @@ -397,7 +397,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, HEX_HDR_END) != CTL_UNNUMB_LENGTH) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: 802.2 control field first part not valid"); - return -1; + return FALSE; } /* Determine whether the control is numbered, and thus longer */ if((pd[eth_hdr_len] & CTL_UNNUMB_MASK) != CTL_UNNUMB_VALUE) { @@ -407,7 +407,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, HEX_HDR_SPR) != CTL_NUMB_LENGTH - CTL_UNNUMB_LENGTH) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: 802.2 control field second part value not valid"); - return -1; + return FALSE; } eth_hdr_len += CTL_NUMB_LENGTH; } else { @@ -421,7 +421,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, HEX_PID_END) != PID_LENGTH) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: 802.2 PID value not valid"); - return -1; + return FALSE; } eth_hdr_len += PID_LENGTH; } @@ -457,22 +457,22 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, if (*err == 0) { *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } if (!(line_count = parse_single_hex_dump_line(line, &pd[eth_hdr_len + count], count))) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: packet data value not valid"); - return -1; + return FALSE; } count += line_count; if (count > pkt_len) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: packet data value has too many bytes"); - return -1; + return FALSE; } } - return REC_TYPE_PACKET; + return TRUE; } /* Parse a hex dump line */ diff --git a/wiretap/dct3trace.c b/wiretap/dct3trace.c index 032df310a2..2a0eb9103a 100644 --- a/wiretap/dct3trace.c +++ b/wiretap/dct3trace.c @@ -73,9 +73,9 @@ static const char dct3trace_magic_end[] = ""; #define MAX_PACKET_LEN 23 -static int dct3trace_read(wtap *wth, int *err, gchar **err_info, +static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int dct3trace_seek_read(wtap *wth, gint64 seek_off, +static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); /* @@ -187,7 +187,7 @@ int dct3trace_open(wtap *wth, int *err, gchar **err_info) } -static int dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { char line[1024]; @@ -202,7 +202,7 @@ static int dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr, { /* Return on end of file */ *err = 0; - return -1; + return FALSE; } else if( memcmp(dct3trace_magic_record_end, line, strlen(dct3trace_magic_record_end)) == 0 ) { @@ -222,14 +222,14 @@ static int dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr, buffer_assure_space(buf, phdr->caplen); memcpy( buffer_start_ptr(buf), databuf, phdr->caplen ); - return REC_TYPE_PACKET; + return TRUE; } else { /* If not got any data return error */ *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("dct3trace: record without data"); - return -1; + return FALSE; } } else if( memcmp(dct3trace_magic_record_start, line, strlen(dct3trace_magic_record_start)) == 0 ) @@ -282,7 +282,7 @@ static int dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr, { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("dct3trace: record length %d too long", phdr->caplen); - return -1; + return FALSE; } } } @@ -322,7 +322,7 @@ static int dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr, { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("dct3trace: record length %d too long", phdr->caplen); - return -1; + return FALSE; } len += data_len; @@ -336,17 +336,17 @@ static int dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr, { *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; baddata: *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("dct3trace: record missing mandatory attributes"); - return -1; + return FALSE; } /* Find the next packet and parse it; called from wtap_read(). */ -static int dct3trace_read(wtap *wth, int *err, gchar **err_info, +static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); @@ -357,12 +357,12 @@ static int dct3trace_read(wtap *wth, int *err, gchar **err_info, /* Used to read packets in random-access fashion */ -static int dct3trace_seek_read(wtap *wth, gint64 seek_off, +static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) { - return -1; + return FALSE; } return dct3trace_get_packet(wth->random_fh, phdr, buf, err, err_info); diff --git a/wiretap/erf.c b/wiretap/erf.c index 3513642121..67b7ccab1d 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -64,11 +64,11 @@ static int erf_read_header(FILE_T fh, gchar **err_info, guint32 *bytes_read, guint32 *packet_size); -static int erf_read(wtap *wth, int *err, gchar **err_info, - gint64 *data_offset); -static int erf_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, - int *err, gchar **err_info); +static gboolean erf_read(wtap *wth, int *err, gchar **err_info, + gint64 *data_offset); +static gboolean erf_seek_read(wtap *wth, gint64 seek_off, + struct wtap_pkthdr *phdr, Buffer *buf, + int *err, gchar **err_info); static const struct { int erf_encap_value; @@ -280,7 +280,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info) } /* Read the next packet */ -static int erf_read(wtap *wth, int *err, gchar **err_info, +static gboolean erf_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { erf_header_t erf_header; @@ -292,38 +292,36 @@ static int erf_read(wtap *wth, int *err, gchar **err_info, if (!erf_read_header(wth->fh, &wth->phdr, &erf_header, err, err_info, &bytes_read, &packet_size)) { - return -1; + return FALSE; } if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer, packet_size, err, err_info)) - return -1; + return FALSE; } while ( erf_header.type == ERF_TYPE_PAD ); - return REC_TYPE_PACKET; + return TRUE; } -static int erf_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, - int *err, gchar **err_info) +static gboolean erf_seek_read(wtap *wth, gint64 seek_off, + struct wtap_pkthdr *phdr, Buffer *buf, + int *err, gchar **err_info) { erf_header_t erf_header; guint32 packet_size; if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; do { if (!erf_read_header(wth->random_fh, phdr, &erf_header, err, err_info, NULL, &packet_size)) - return -1; + return FALSE; } while ( erf_header.type == ERF_TYPE_PAD ); - if (!wtap_read_packet_bytes(wth->random_fh, buf, packet_size, - err, err_info)) - return -1; - return REC_TYPE_PACKET; + return wtap_read_packet_bytes(wth->random_fh, buf, packet_size, + err, err_info); } static int erf_read_header(FILE_T fh, diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c index 4444b0d9f5..8bd32c2249 100644 --- a/wiretap/eyesdn.c +++ b/wiretap/eyesdn.c @@ -90,9 +90,9 @@ static const unsigned char eyesdn_hdr_magic[] = */ #define EYESDN_MAX_PACKET_LEN 16384 -static int eyesdn_read(wtap *wth, int *err, gchar **err_info, +static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int eyesdn_seek_read(wtap *wth, gint64 seek_off, +static gboolean eyesdn_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static int read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer* buf, int *err, gchar **err_info); @@ -149,7 +149,7 @@ int eyesdn_open(wtap *wth, int *err, gchar **err_info) } /* Find the next packet and parse it; called from wtap_read(). */ -static int eyesdn_read(wtap *wth, int *err, gchar **err_info, +static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { gint64 offset; @@ -157,7 +157,7 @@ static int eyesdn_read(wtap *wth, int *err, gchar **err_info, /* Find the next record */ offset = eyesdn_seek_next_packet(wth, err, err_info); if (offset < 1) - return -1; + return FALSE; *data_offset = offset; /* Parse the record */ @@ -166,18 +166,18 @@ static int eyesdn_read(wtap *wth, int *err, gchar **err_info, } /* Used to read packets in random-access fashion */ -static int +static gboolean eyesdn_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; return read_eyesdn_rec(wth->random_fh, phdr, buf, err, err_info); } /* Parses a record. */ -static int +static gboolean read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { @@ -198,7 +198,7 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, *err = file_error(fh, err_info); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } /* extract information from header */ @@ -251,7 +251,7 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, *err_info = g_strdup_printf( "eyesdn: ATM cell has a length != 53 (%u)", pkt_len); - return -1; + return FALSE; } cur_off = file_tell(fh); @@ -259,10 +259,10 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, *err = file_error(fh, err_info); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } if (file_seek(fh, cur_off, SEEK_SET, err) == -1) - return -1; + return FALSE; phdr->pkt_encap = WTAP_ENCAP_ATM_PDUS_UNTRUNCATED; pseudo_header->atm.flags=ATM_RAW_CELL; pseudo_header->atm.aal=AAL_UNKNOWN; @@ -310,7 +310,7 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("eyesdn: File has %u-byte packet, bigger than maximum of %u", pkt_len, EYESDN_MAX_PACKET_LEN); - return -1; + return FALSE; } phdr->presence_flags = WTAP_HAS_TS; @@ -335,9 +335,9 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, *err_info = g_strdup("eyesdn: No flag character seen in frame"); } else *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET;; + return TRUE; } diff --git a/wiretap/hcidump.c b/wiretap/hcidump.c index 22483b7d6a..cc38a62154 100644 --- a/wiretap/hcidump.c +++ b/wiretap/hcidump.c @@ -34,7 +34,7 @@ struct dump_hdr { #define DUMP_HDR_SIZE (sizeof(struct dump_hdr)) -static int hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { struct dump_hdr dh; @@ -45,7 +45,7 @@ static int hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr, *err = file_error(fh, err_info); if (*err == 0 && bytes_read != 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } packet_size = GUINT16_FROM_LE(dh.len); @@ -57,7 +57,7 @@ static int hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr, *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("hcidump: File has %u-byte packet, bigger than maximum of %u", packet_size, WTAP_MAX_PACKET_SIZE); - return -1; + return FALSE; } phdr->presence_flags = WTAP_HAS_TS; @@ -68,12 +68,10 @@ static int hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr, phdr->pseudo_header.p2p.sent = (dh.in ? FALSE : TRUE); - if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info)) - return -1; - return REC_TYPE_PACKET; + return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info); } -static int hcidump_read(wtap *wth, int *err, gchar **err_info, +static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); @@ -82,11 +80,11 @@ static int hcidump_read(wtap *wth, int *err, gchar **err_info, err, err_info); } -static int hcidump_seek_read(wtap *wth, gint64 seek_off, +static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; return hcidump_process_packet(wth->random_fh, phdr, buf, err, err_info); } diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c index 00cf9e876c..d474ec2c8f 100644 --- a/wiretap/i4btrace.c +++ b/wiretap/i4btrace.c @@ -33,11 +33,11 @@ typedef struct { gboolean byte_swapped; } i4btrace_t; -static int i4btrace_read(wtap *wth, int *err, gchar **err_info, +static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int i4btrace_seek_read(wtap *wth, gint64 seek_off, +static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); -static gboolean i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +static int i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); /* @@ -110,23 +110,21 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info) } /* Read the next packet */ -static int i4btrace_read(wtap *wth, int *err, gchar **err_info, +static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); - if (!i4b_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer, - err, err_info)) - return -1; - return REC_TYPE_PACKET; + return i4b_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer, + err, err_info); } -static int +static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; if (!i4b_read_rec(wth, wth->random_fh, phdr, buf, err, err_info)) { /* Read error or EOF */ @@ -134,12 +132,12 @@ i4btrace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, /* EOF means "short read" in random-access mode */ *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } -static gboolean +static int i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { diff --git a/wiretap/ipfix.c b/wiretap/ipfix.c index 87de433599..061a53d79c 100644 --- a/wiretap/ipfix.c +++ b/wiretap/ipfix.c @@ -85,10 +85,10 @@ #define RECORDS_FOR_IPFIX_CHECK 20 -static int +static gboolean ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int +static gboolean ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static void @@ -280,7 +280,7 @@ ipfix_open(wtap *wth, int *err, gchar **err_info) /* classic wtap: read packet */ -static int +static gboolean ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); @@ -289,15 +289,15 @@ ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) if (!ipfix_read_message(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info)) { ipfix_debug2("ipfix_read: couldn't read message header with code: %d\n, and error '%s'", *err, *err_info); - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } /* classic wtap: seek to file position and read packet */ -static int +static gboolean ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { @@ -305,7 +305,7 @@ ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) { ipfix_debug2("ipfix_seek_read: couldn't read message header with code: %d\n, and error '%s'", *err, *err_info); - return -1; /* Seek error */ + return FALSE; /* Seek error */ } ipfix_debug1("ipfix_seek_read: reading at offset %" G_GINT64_MODIFIER "u", seek_off); @@ -314,9 +314,9 @@ ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, ipfix_debug0("ipfix_seek_read: couldn't read message header"); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c index 3f128fe205..67e8e65806 100644 --- a/wiretap/iptrace.c +++ b/wiretap/iptrace.c @@ -214,7 +214,7 @@ iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, } /* Read the next packet */ -static int iptrace_read_1_0(wtap *wth, int *err, gchar **err_info, +static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); @@ -223,7 +223,7 @@ static int iptrace_read_1_0(wtap *wth, int *err, gchar **err_info, if (!iptrace_read_rec_1_0(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info)) { /* Read error or EOF */ - return -1; + return FALSE; } /* If the per-file encapsulation isn't known, set it to this @@ -239,22 +239,22 @@ static int iptrace_read_1_0(wtap *wth, int *err, gchar **err_info, wth->file_encap = WTAP_ENCAP_PER_PACKET; } - return REC_TYPE_PACKET; + return TRUE; } -static int iptrace_seek_read_1_0(wtap *wth, gint64 seek_off, +static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* Read the packet */ if (!iptrace_read_rec_1_0(wth->random_fh, phdr, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } /*********************************************************** @@ -409,7 +409,7 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, } /* Read the next packet */ -static int iptrace_read_2_0(wtap *wth, int *err, gchar **err_info, +static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); @@ -418,7 +418,7 @@ static int iptrace_read_2_0(wtap *wth, int *err, gchar **err_info, if (!iptrace_read_rec_2_0(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info)) { /* Read error or EOF */ - return -1; + return FALSE; } /* If the per-file encapsulation isn't known, set it to this @@ -434,22 +434,22 @@ static int iptrace_read_2_0(wtap *wth, int *err, gchar **err_info, wth->file_encap = WTAP_ENCAP_PER_PACKET; } - return REC_TYPE_PACKET; + return TRUE; } -static int iptrace_seek_read_2_0(wtap *wth, gint64 seek_off, +static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* Read the packet */ if (!iptrace_read_rec_2_0(wth->random_fh, phdr, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } static int diff --git a/wiretap/iseries.c b/wiretap/iseries.c index 4c42fb4502..0a171a6341 100644 --- a/wiretap/iseries.c +++ b/wiretap/iseries.c @@ -187,9 +187,9 @@ static gboolean iseries_seek_read (wtap * wth, gint64 seek_off, static gboolean iseries_check_file_type (wtap * wth, int *err, gchar **err_info, int format); static gint64 iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info); -static int iseries_parse_packet (wtap * wth, FILE_T fh, - struct wtap_pkthdr *phdr, - Buffer * buf, int *err, gchar ** err_info); +static gboolean iseries_parse_packet (wtap * wth, FILE_T fh, + struct wtap_pkthdr *phdr, + Buffer * buf, int *err, gchar ** err_info); static int iseries_UNICODE_to_ASCII (guint8 * buf, guint bytes); static gboolean iseries_parse_hex_string (const char * ascii, guint8 * buf, size_t len); @@ -370,7 +370,7 @@ iseries_check_file_type (wtap * wth, int *err, gchar **err_info, int format) /* * Find the next packet and parse it; called from wtap_read(). */ -static int +static gboolean iseries_read (wtap * wth, int *err, gchar ** err_info, gint64 *data_offset) { gint64 offset; @@ -457,14 +457,14 @@ iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info) /* * Read packets in random-access fashion */ -static int +static gboolean iseries_seek_read (wtap * wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer * buf, int *err, gchar ** err_info) { /* seek to packet location */ if (file_seek (wth->random_fh, seek_off - 1, SEEK_SET, err) == -1) - return -1; + return FALSE; /* * Parse the packet and extract the various fields @@ -554,7 +554,7 @@ done: } /* Parses a packet. */ -static int +static gboolean iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { @@ -581,7 +581,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr, if (file_gets (data, ISERIES_LINE_LENGTH, fh) == NULL) { *err = file_error (fh, err_info); - return -1; + return FALSE; } /* Convert UNICODE data to ASCII */ if (iseries->format == ISERIES_FORMAT_UNICODE) @@ -615,7 +615,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr, { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup ("iseries: packet header isn't valid"); - return -1; + return FALSE; } phdr->presence_flags = WTAP_HAS_CAP_LEN; @@ -747,7 +747,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr, if (ascii_offset == -1) { /* Bad line. */ - return -1; + return FALSE; } continue; } @@ -769,7 +769,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr, if (ascii_offset == -1) { /* Bad line. */ - return -1; + return FALSE; } continue; } @@ -792,7 +792,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr, if (ascii_offset == -1) { /* Bad line. */ - return -1; + return FALSE; } continue; } @@ -842,11 +842,11 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr, /* free buffer allocs and return */ *err = 0; g_free (ascii_buf); - return REC_TYPE_PACKET; + return TRUE; errxit: g_free (ascii_buf); - return -1; + return FALSE; } /* diff --git a/wiretap/k12.c b/wiretap/k12.c index 013c19e6f6..cd1bbe6104 100644 --- a/wiretap/k12.c +++ b/wiretap/k12.c @@ -623,7 +623,7 @@ process_packet_data(struct wtap_pkthdr *phdr, Buffer *target, guint8 *buffer, phdr->pseudo_header.k12.stuff = k12; } -static int k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { +static gboolean k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { k12_t *k12 = (k12_t *)wth->priv; k12_src_desc_t* src_desc; guint8* buffer; @@ -644,16 +644,16 @@ static int k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) if (len < 0) { /* read error */ - return -1; + return FALSE; } else if (len == 0) { /* EOF */ *err = 0; - return -1; + return FALSE; } else if (len < K12_RECORD_SRC_ID + 4) { /* Record not large enough to contain a src ID */ *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("data record length %d too short", len); - return -1; + return FALSE; } buffer = k12->seq_read_buff; @@ -681,11 +681,11 @@ static int k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) process_packet_data(&wth->phdr, wth->frame_buffer, buffer, len, k12); - return REC_TYPE_PACKET; + return TRUE; } -static int k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { +static gboolean k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { k12_t *k12 = (k12_t *)wth->priv; guint8* buffer; gint len; @@ -694,18 +694,18 @@ static int k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, B if ( file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) { K12_DBG(5,("k12_seek_read: SEEK ERROR")); - return -1; + return FALSE; } len = get_record(k12, wth->random_fh, seek_off, TRUE, err, err_info); if (len < 0) { K12_DBG(5,("k12_seek_read: READ ERROR")); - return -1; + return FALSE; } else if (len < K12_RECORD_SRC_ID + 4) { /* Record not large enough to contain a src ID */ K12_DBG(5,("k12_seek_read: SHORT READ")); *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } buffer = k12->rand_read_buff; @@ -714,7 +714,7 @@ static int k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, B K12_DBG(5,("k12_seek_read: DONE OK")); - return REC_TYPE_PACKET; + return TRUE; } diff --git a/wiretap/k12text.l b/wiretap/k12text.l index 8db5c673c8..42de8e6875 100644 --- a/wiretap/k12text.l +++ b/wiretap/k12text.l @@ -244,7 +244,7 @@ k12text_reset(FILE_T fh) ii=0; } -static int +static gboolean k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset) { k12text_t *k12text = (k12text_t *)wth->priv; @@ -259,7 +259,7 @@ k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset) */ if ( file_seek(wth->fh, k12text->next_frame_offset, SEEK_SET, err) == -1) { - return -1; + return FALSE; } k12text_reset(wth->fh); /* init lexer buffer and vars set by lexer */ @@ -274,7 +274,7 @@ k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset) *err = WTAP_ERR_BAD_FILE; *err_info = error_str; } - return -1; + return FALSE; } *data_offset = k12text->next_frame_offset; /* file position for beginning of this frame */ @@ -285,14 +285,14 @@ k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset) buffer_assure_space(wth->frame_buffer, wth->phdr.caplen); memcpy(buffer_start_ptr(wth->frame_buffer), bb, wth->phdr.caplen); - return REC_TYPE_PACKET; + return TRUE; } -static int +static gboolean k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, char **err_info) { if ( file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) { - return -1; + return FALSE; } k12text_reset(wth->random_fh); /* init lexer buffer and vars set by lexer */ @@ -307,7 +307,7 @@ k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer * } else { *err_info = error_str; } - return -1; + return FALSE; } k12text_set_headers(phdr); @@ -315,7 +315,7 @@ k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer * buffer_assure_space(buf, phdr->caplen); memcpy(buffer_start_ptr(buf), bb, phdr->caplen); - return REC_TYPE_PACKET; + return TRUE; } int diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c index 5c4942b10e..8c2ce348a1 100644 --- a/wiretap/lanalyzer.c +++ b/wiretap/lanalyzer.c @@ -270,9 +270,9 @@ typedef struct { time_t start; } lanalyzer_t; -static int lanalyzer_read(wtap *wth, int *err, gchar **err_info, +static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int lanalyzer_seek_read(wtap *wth, gint64 seek_off, +static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static gboolean lanalyzer_dump_close(wtap_dumper *wdh, int *err); @@ -560,32 +560,30 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh, } /* Read the next packet */ -static int lanalyzer_read(wtap *wth, int *err, gchar **err_info, +static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); /* Read the record */ - if (!lanalyzer_read_trace_record(wth, wth->fh, &wth->phdr, - wth->frame_buffer, err, err_info)) - return -1; - return REC_TYPE_PACKET; + return lanalyzer_read_trace_record(wth, wth->fh, &wth->phdr, + wth->frame_buffer, err, err_info); } -static int lanalyzer_seek_read(wtap *wth, gint64 seek_off, +static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* Read the record */ if (!lanalyzer_read_trace_record(wth, wth->random_fh, phdr, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } /*--------------------------------------------------- diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index 7d467cb06c..fe9c111261 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -63,9 +63,9 @@ typedef enum { } libpcap_try_t; static libpcap_try_t libpcap_try(wtap *wth, int *err); -static int libpcap_read(wtap *wth, int *err, gchar **err_info, +static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int libpcap_seek_read(wtap *wth, gint64 seek_off, +static gboolean libpcap_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static int libpcap_read_header(wtap *wth, FILE_T fh, int *err, gchar **err_info, struct pcaprec_ss990915_hdr *hdr); @@ -590,15 +590,13 @@ static libpcap_try_t libpcap_try(wtap *wth, int *err) } /* Read the next packet */ -static int libpcap_read(wtap *wth, int *err, gchar **err_info, +static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); - if (!libpcap_read_packet(wth, wth->fh, &wth->phdr, - wth->frame_buffer, err, err_info)) - return -1; - return REC_TYPE_PACKET; + return libpcap_read_packet(wth, wth->fh, &wth->phdr, + wth->frame_buffer, err, err_info); } static gboolean @@ -606,15 +604,15 @@ libpcap_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; if (!libpcap_read_packet(wth, wth->random_fh, phdr, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } static gboolean diff --git a/wiretap/logcat.c b/wiretap/logcat.c index 022b6a2308..a1a41c0689 100644 --- a/wiretap/logcat.c +++ b/wiretap/logcat.c @@ -214,31 +214,29 @@ static gboolean logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh, return TRUE; } -static int logcat_read(wtap *wth, int *err, gchar **err_info, +static gboolean logcat_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); - if (!logcat_read_packet((struct logcat_phdr *) wth->priv, wth->fh, - &wth->phdr, wth->frame_buffer, err, err_info)) - return -1; - return REC_TYPE_PACKET; + return logcat_read_packet((struct logcat_phdr *) wth->priv, wth->fh, + &wth->phdr, wth->frame_buffer, err, err_info); } -static int logcat_seek_read(wtap *wth, gint64 seek_off, +static gboolean logcat_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; if (!logcat_read_packet((struct logcat_phdr *) wth->priv, wth->random_fh, phdr, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } int logcat_open(wtap *wth, int *err, gchar **err_info _U_) diff --git a/wiretap/mime_file.c b/wiretap/mime_file.c index 0f8934a28e..2a7d8be0e4 100644 --- a/wiretap/mime_file.c +++ b/wiretap/mime_file.c @@ -94,7 +94,7 @@ static const mime_files_t magic_files[] = { */ #define MAX_FILE_SIZE (16*1024*1024) -static int +static gboolean mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { @@ -102,7 +102,7 @@ mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, int packet_size; if ((file_size = wtap_file_size(wth, err)) == -1) - return -1; + return FALSE; if (file_size > MAX_FILE_SIZE) { /* @@ -112,7 +112,7 @@ mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("mime_file: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u", file_size, MAX_FILE_SIZE); - return -1; + return FALSE; } packet_size = (int)file_size; @@ -124,12 +124,10 @@ mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, phdr->ts.secs = 0; phdr->ts.nsecs = 0; - if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info)) - return -1; - return REC_TYPE_PACKET; + return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info); } -static int +static gboolean mime_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { gint64 offset; @@ -140,24 +138,24 @@ mime_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) /* there is only ever one packet */ if (offset != 0) - return -1; + return FALSE; *data_offset = offset; return mime_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); } -static int +static gboolean mime_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { /* there is only one packet */ if (seek_off > 0) { *err = 0; - return -1; + return FALSE; } if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; return mime_read_file(wth, wth->random_fh, phdr, buf, err, err_info); } diff --git a/wiretap/mp2t.c b/wiretap/mp2t.c index 8b44a1bd4c..844fb40a13 100644 --- a/wiretap/mp2t.c +++ b/wiretap/mp2t.c @@ -102,7 +102,7 @@ mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, gint64 offset, return TRUE; } -static int +static gboolean mp2t_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { mp2t_filetype_t *mp2t; @@ -113,27 +113,27 @@ mp2t_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) if (!mp2t_read_packet(mp2t, wth->fh, *data_offset, &wth->phdr, wth->frame_buffer, err, err_info)) { - return -1; + return FALSE; } /* if there's a trailer, skip it and go to the start of the next packet */ if (mp2t->trailer_len!=0) { if (-1 == file_seek(wth->fh, mp2t->trailer_len, SEEK_CUR, err)) { - return -1; + return FALSE; } } - return REC_TYPE_PACKET; + return TRUE; } -static int +static gboolean mp2t_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { mp2t_filetype_t *mp2t; if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err)) { - return -1; + return FALSE; } mp2t = (mp2t_filetype_t*) wth->priv; @@ -142,9 +142,9 @@ mp2t_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } int diff --git a/wiretap/mpeg.c b/wiretap/mpeg.c index 2f4998ebb3..abe87a37fe 100644 --- a/wiretap/mpeg.c +++ b/wiretap/mpeg.c @@ -220,32 +220,30 @@ mpeg_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, return TRUE; } -static int +static gboolean mpeg_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); - if (!mpeg_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer, - FALSE, err, err_info)) - return -1; - return REC_TYPE_PACKET; + return mpeg_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer, + FALSE, err, err_info); } -static int +static gboolean mpeg_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; if (!mpeg_read_packet(wth, wth->random_fh, phdr, buf, TRUE, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } struct _mpeg_magic { diff --git a/wiretap/netmon.c b/wiretap/netmon.c index 85f3234121..f12bf43a87 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -175,9 +175,9 @@ static const int netmon_encap[] = { #define NETMON_NET_DNS_CACHE 0xFFFE #define NETMON_NET_NETMON_FILTER 0xFFFF -static int netmon_read(wtap *wth, int *err, gchar **err_info, +static gboolean netmon_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int netmon_seek_read(wtap *wth, gint64 seek_off, +static gboolean netmon_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static gboolean netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info); @@ -677,7 +677,7 @@ static process_trailer_retval netmon_process_rec_trailer(netmon_t *netmon, } /* Read the next packet */ -static int netmon_read(wtap *wth, int *err, gchar **err_info, +static gboolean netmon_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { netmon_t *netmon = (netmon_t *)wth->priv; @@ -691,7 +691,7 @@ again: g_free(netmon->frame_table); netmon->frame_table = NULL; *err = 0; /* it's just an EOF, not an error */ - return -1; + return FALSE; } /* Seek to the beginning of the current record, if we're @@ -707,7 +707,7 @@ again: rec_offset = netmon->frame_table[netmon->current_frame]; if (file_tell(wth->fh) != rec_offset) { if (file_seek(wth->fh, rec_offset, SEEK_SET, err) == -1) - return -1; + return FALSE; } netmon->current_frame++; @@ -715,11 +715,11 @@ again: if (!netmon_process_rec_header(wth, wth->fh, &wth->phdr, err, err_info)) - return -1; + return FALSE; if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer, wth->phdr.caplen, err, err_info)) - return -1; /* Read error */ + return FALSE; /* Read error */ /* * For version 2.1 and later, there's additional information @@ -735,33 +735,33 @@ again: break; case FAILURE: - return -1; + return FALSE; } netmon_set_pseudo_header_info(wth->phdr.pkt_encap, &wth->phdr, wth->frame_buffer); - return REC_TYPE_PACKET; + return TRUE; } -static int +static gboolean netmon_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { netmon_t *netmon = (netmon_t *)wth->priv; if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; if (!netmon_process_rec_header(wth, wth->random_fh, phdr, err, err_info)) - return -1; + return FALSE; /* * Read the packet data. */ if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err, err_info)) - return -1; + return FALSE; /* * For version 2.1 and later, there's additional information @@ -776,18 +776,18 @@ netmon_seek_read(wtap *wth, gint64 seek_off, */ *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("netmon: saw metadata in netmon_seek_read"); - return -1; + return FALSE; case SUCCESS: break; case FAILURE: - return -1; + return FALSE; } netmon_set_pseudo_header_info(phdr->pkt_encap, phdr, buf); - return REC_TYPE_PACKET; + return TRUE; } static gboolean diff --git a/wiretap/netscaler.c b/wiretap/netscaler.c index 71e835a584..9772567ae7 100644 --- a/wiretap/netscaler.c +++ b/wiretap/netscaler.c @@ -613,24 +613,24 @@ typedef struct { } nstrace_t; static guint32 nspm_signature_version(wtap*, gchar*, gint32); -static int nstrace_read_v10(wtap *wth, int *err, gchar **err_info, - gint64 *data_offset); -static int nstrace_read_v20(wtap *wth, int *err, gchar **err_info, - gint64 *data_offset); -static int nstrace_read_v30(wtap *wth, int *err, gchar **err_info, - gint64 *data_offset); -static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, - Buffer *buf, - int *err, gchar **err_info); -static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, - Buffer *buf, - int *err, gchar **err_info); -static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, - Buffer *buf, - int *err, gchar **err_info); +static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, + gint64 *data_offset); +static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, + gint64 *data_offset); +static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info, + gint64 *data_offset); +static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off, + struct wtap_pkthdr *phdr, + Buffer *buf, + int *err, gchar **err_info); +static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off, + struct wtap_pkthdr *phdr, + Buffer *buf, + int *err, gchar **err_info); +static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off, + struct wtap_pkthdr *phdr, + Buffer *buf, + int *err, gchar **err_info); static void nstrace_close(wtap *wth); static gboolean nstrace_set_start_time_v10(wtap *wth); @@ -925,7 +925,7 @@ static gboolean nstrace_set_start_time(wtap *wth) /* ** Netscaler trace format read routines. */ -static int nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) +static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { nstrace_t *nstrace = (nstrace_t *)wth->priv; guint64 nsg_creltime = nstrace->nsg_creltime; @@ -965,7 +965,7 @@ static int nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_ nstrace->nstrace_buf_offset = nstrace_buf_offset + (phdr)->len;\ nstrace->nstrace_buflen = nstrace_buflen;\ nstrace->nsg_creltime = nsg_creltime;\ - return REC_TYPE_PACKET; + return TRUE; #define GENERATE_CASE_PART(phdr,type,acttype) \ case NSPR_PDPKTRACEPARTTX_V##type:\ @@ -988,7 +988,7 @@ static int nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_ nstrace->nstrace_buf_offset = nstrace_buf_offset + (phdr)->caplen;\ nstrace->nsg_creltime = nsg_creltime;\ nstrace->nstrace_buflen = nstrace_buflen;\ - return REC_TYPE_PACKET;\ + return TRUE;\ switch (pletoh16(&(( nspr_header_v10_t*)&nstrace_buf[nstrace_buf_offset])->ph_RecordType)) { @@ -1030,7 +1030,7 @@ static int nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_ nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - nstrace->xxx_offset)); }while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen)); - return -1; + return FALSE; } #define TIMEDEFV20(fp,type) \ @@ -1112,10 +1112,10 @@ static int nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_ nstrace->nstrace_buf_offset = nstrace_buf_offset + nspr_getv20recordsize((nspr_hd_v20_t *)fp);\ nstrace->nstrace_buflen = nstrace_buflen;\ nstrace->nsg_creltime = nsg_creltime;\ - return REC_TYPE_PACKET;\ + return TRUE;\ }while(0) -static int nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) +static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { nstrace_t *nstrace = (nstrace_t *)wth->priv; guint64 nsg_creltime = nstrace->nsg_creltime; @@ -1219,7 +1219,7 @@ static int nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_ nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - nstrace->xxx_offset)); }while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen)); - return -1; + return FALSE; } #undef PACKET_DESCRIBE @@ -1248,7 +1248,7 @@ static int nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_ nstrace->xxx_offset += nstrace_buflen;\ bytes_read = file_read(nstrace_buf, NSPR_PAGESIZE_TRACE, wth->fh);\ if (bytes_read != NSPR_PAGESIZE_TRACE) {\ - return -1;\ + return FALSE;\ } else {\ nstrace_buf_offset = 0;\ }\ @@ -1263,10 +1263,10 @@ static int nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_ nstrace->nstrace_buf_offset = nstrace_buf_offset;\ nstrace->nstrace_buflen = nstrace_buflen = ((gint32)NSPR_PAGESIZE_TRACE);\ nstrace->nsg_creltime = nsg_creltime;\ - return REC_TYPE_PACKET;\ + return TRUE;\ } while(0) -static int nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) +static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { nstrace_t *nstrace = (nstrace_t *)wth->priv; guint64 nsg_creltime = nstrace->nsg_creltime; @@ -1324,12 +1324,12 @@ static int nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *data_ nstrace_buflen = NSPR_PAGESIZE_TRACE; } while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen)); - return -1; + return FALSE; } #undef PACKET_DESCRIBE -static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off, +static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { nspr_hd_v10_t hdr; @@ -1343,7 +1343,7 @@ static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off, *err = 0; if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* ** Read the record header. @@ -1353,7 +1353,7 @@ static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off, *err = file_error(wth->random_fh, err_info); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } /* @@ -1374,7 +1374,7 @@ static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off, *err = file_error(wth->random_fh, err_info); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } } @@ -1408,7 +1408,7 @@ static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off, #undef GENERATE_CASE_FULL #undef GENERATE_CASE_PART - return REC_TYPE_PACKET; + return TRUE; } #define PACKET_DESCRIBE(phdr,FPTIMEDEF,SIZEDEF,ver,enumprefix,type,structname,TYPE)\ @@ -1417,10 +1417,10 @@ static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off, SIZEDEF##ver((phdr),fp,ver);\ TRACE_V##ver##_REC_LEN_OFF((phdr),enumprefix,type,structname);\ (phdr)->pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##TYPE;\ - return REC_TYPE_PACKET;\ + return TRUE;\ }while(0) -static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off, +static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { nspr_hd_v20_t hdr; @@ -1433,7 +1433,7 @@ static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off, *err = 0; if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* ** Read the first 2 bytes of the record header. @@ -1443,7 +1443,7 @@ static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off, *err = file_error(wth->random_fh, err_info); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } hdrlen = 2; @@ -1456,7 +1456,7 @@ static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off, *err = file_error(wth->random_fh, err_info); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } hdrlen = 3; } @@ -1479,7 +1479,7 @@ static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off, *err = file_error(wth->random_fh, err_info); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } } @@ -1532,11 +1532,11 @@ static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off, #undef GENERATE_CASE_PART #undef GENERATE_CASE_PART_V25 - return REC_TYPE_PACKET; + return TRUE; } -static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off, +static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { nspr_hd_v20_t hdr; @@ -1549,7 +1549,7 @@ static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off, *err = 0; if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* ** Read the first 2 bytes of the record header. */ @@ -1558,7 +1558,7 @@ static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off, *err = file_error(wth->random_fh, err_info); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } hdrlen = 2; @@ -1571,7 +1571,7 @@ static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off, *err = file_error(wth->random_fh, err_info); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } hdrlen = 3; } @@ -1594,7 +1594,7 @@ static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off, *err = file_error(wth->random_fh, err_info); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } } @@ -1612,7 +1612,7 @@ static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off, GENERATE_CASE_V30(phdr,30, 300); } - return REC_TYPE_PACKET; + return TRUE; } diff --git a/wiretap/netscreen.c b/wiretap/netscreen.c index 91c82c796d..bbb4a535e9 100644 --- a/wiretap/netscreen.c +++ b/wiretap/netscreen.c @@ -67,9 +67,9 @@ static gint64 netscreen_seek_next_packet(wtap *wth, int *err, gchar **err_info, char *hdr); static gboolean netscreen_check_file_type(wtap *wth, int *err, gchar **err_info); -static int netscreen_read(wtap *wth, int *err, gchar **err_info, +static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int netscreen_seek_read(wtap *wth, gint64 seek_off, +static gboolean netscreen_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static int parse_netscreen_rec_hdr(struct wtap_pkthdr *phdr, const char *line, @@ -190,7 +190,7 @@ int netscreen_open(wtap *wth, int *err, gchar **err_info) } /* Find the next packet and parse it; called from wtap_read(). */ -static int netscreen_read(wtap *wth, int *err, gchar **err_info, +static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { gint64 offset; @@ -203,19 +203,19 @@ static int netscreen_read(wtap *wth, int *err, gchar **err_info, /* Find the next packet */ offset = netscreen_seek_next_packet(wth, err, err_info, line); if (offset < 0) - return -1; + return FALSE; /* Parse the header */ pkt_len = parse_netscreen_rec_hdr(&wth->phdr, line, cap_int, &cap_dir, cap_dst, err, err_info); if (pkt_len == -1) - return -1; + return FALSE; /* Convert the ASCII hex dump to binary data, and fill in some struct wtap_pkthdr fields */ if (!parse_netscreen_hex_dump(wth->fh, pkt_len, cap_int, cap_dst, &wth->phdr, wth->frame_buffer, err, err_info)) - return -1; + return FALSE; /* * If the per-file encapsulation isn't known, set it to this @@ -233,11 +233,11 @@ static int netscreen_read(wtap *wth, int *err, gchar **err_info, } *data_offset = offset; - return REC_TYPE_PACKET; + return TRUE; } /* Used to read packets in random-access fashion */ -static int +static gboolean netscreen_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) @@ -249,7 +249,7 @@ netscreen_seek_read(wtap *wth, gint64 seek_off, char cap_dst[13]; if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) { - return -1; + return FALSE; } if (file_gets(line, NETSCREEN_LINE_LENGTH, wth->random_fh) == NULL) { @@ -257,18 +257,18 @@ netscreen_seek_read(wtap *wth, gint64 seek_off, if (*err == 0) { *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } pkt_len = parse_netscreen_rec_hdr(phdr, line, cap_int, &cap_dir, cap_dst, err, err_info); if (pkt_len == -1) - return -1; + return FALSE; if (!parse_netscreen_hex_dump(wth->random_fh, pkt_len, cap_int, cap_dst, phdr, buf, err, err_info)) - return -1; - return REC_TYPE_PACKET; + return FALSE; + return TRUE; } /* Parses a packet record header. There are a few possible formats: diff --git a/wiretap/nettl.c b/wiretap/nettl.c index 0e3c9a9f97..0c6898bbdb 100644 --- a/wiretap/nettl.c +++ b/wiretap/nettl.c @@ -175,9 +175,9 @@ typedef struct { gboolean is_hpux_11; } nettl_t; -static int nettl_read(wtap *wth, int *err, gchar **err_info, +static gboolean nettl_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int nettl_seek_read(wtap *wth, gint64 seek_off, +static gboolean nettl_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static gboolean nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, @@ -287,7 +287,7 @@ int nettl_open(wtap *wth, int *err, gchar **err_info) } /* Read the next packet */ -static int nettl_read(wtap *wth, int *err, gchar **err_info, +static gboolean nettl_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { /* Read record header. */ @@ -295,7 +295,7 @@ static int nettl_read(wtap *wth, int *err, gchar **err_info, if (!nettl_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info)) { /* Read error or EOF */ - return -1; + return FALSE; } /* @@ -313,15 +313,15 @@ static int nettl_read(wtap *wth, int *err, gchar **err_info, wth->file_encap = WTAP_ENCAP_PER_PACKET; } - return REC_TYPE_PACKET; + return TRUE; } -static int +static gboolean nettl_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* Read record header. */ if (!nettl_read_rec(wth, wth->random_fh, phdr, buf, err, err_info)) { @@ -330,9 +330,9 @@ nettl_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, /* EOF means "short read" in random-access mode */ *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } static gboolean diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c index 01ed983932..38abfab2cd 100644 --- a/wiretap/network_instruments.c +++ b/wiretap/network_instruments.c @@ -94,9 +94,9 @@ static void init_gmt_to_localtime_offset(void) } } -static int observer_read(wtap *wth, int *err, gchar **err_info, +static gboolean observer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int observer_seek_read(wtap *wth, gint64 seek_off, +static gboolean observer_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static int read_packet_header(FILE_T fh, union wtap_pseudo_header *pseudo_header, packet_entry_header *packet_header, int *err, gchar **err_info); @@ -258,7 +258,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info) } /* Reads the next packet. */ -static int observer_read(wtap *wth, int *err, gchar **err_info, +static gboolean observer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { int header_bytes_consumed; @@ -273,7 +273,7 @@ static int observer_read(wtap *wth, int *err, gchar **err_info, header_bytes_consumed = read_packet_header(wth->fh, &wth->phdr.pseudo_header, &packet_header, err, err_info); if (header_bytes_consumed <= 0) - return -1; /* EOF or error */ + return FALSE; /* EOF or error */ if (packet_header.packet_type == PACKET_TYPE_DATA_PACKET) break; @@ -281,32 +281,32 @@ static int observer_read(wtap *wth, int *err, gchar **err_info, /* skip to next packet */ if (!skip_to_next_packet(wth, packet_header.offset_to_next_packet, header_bytes_consumed, err, err_info)) { - return -1; /* EOF or error */ + return FALSE; /* EOF or error */ } } if (!process_packet_header(wth, &packet_header, &wth->phdr, err, err_info)) - return -1; + return FALSE; /* read the frame data */ data_bytes_consumed = read_packet_data(wth->fh, packet_header.offset_to_frame, header_bytes_consumed, wth->frame_buffer, wth->phdr.caplen, err, err_info); if (data_bytes_consumed < 0) { - return -1; + return FALSE; } /* skip over any extra bytes following the frame data */ if (!skip_to_next_packet(wth, packet_header.offset_to_next_packet, header_bytes_consumed + data_bytes_consumed, err, err_info)) { - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } /* Reads a packet at an offset. */ -static int observer_seek_read(wtap *wth, gint64 seek_off, +static gboolean observer_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; @@ -315,25 +315,25 @@ static int observer_seek_read(wtap *wth, gint64 seek_off, int data_bytes_consumed; if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* process the packet header, including TLVs */ offset = read_packet_header(wth->random_fh, pseudo_header, &packet_header, err, err_info); if (offset <= 0) - return -1; /* EOF or error */ + return FALSE; /* EOF or error */ if (!process_packet_header(wth, &packet_header, phdr, err, err_info)) - return -1; + return FALSE; /* read the frame data */ data_bytes_consumed = read_packet_data(wth->random_fh, packet_header.offset_to_frame, offset, buf, phdr->caplen, err, err_info); if (data_bytes_consumed < 0) { - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } static int diff --git a/wiretap/netxray.c b/wiretap/netxray.c index 782918c921..e6dd704bb3 100644 --- a/wiretap/netxray.c +++ b/wiretap/netxray.c @@ -402,9 +402,9 @@ typedef struct { guint isdn_type; /* 1 = E1 PRI, 2 = T1 PRI, 3 = BRI */ } netxray_t; -static int netxray_read(wtap *wth, int *err, gchar **err_info, +static gboolean netxray_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int netxray_seek_read(wtap *wth, gint64 seek_off, +static gboolean netxray_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static int netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, int *err, gchar **err_info); @@ -989,7 +989,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info) } /* Read the next packet */ -static int +static gboolean netxray_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { @@ -1007,7 +1007,7 @@ reread: if (*data_offset == netxray->end_offset) { /* Yes. */ *err = 0; /* it's just an EOF, not an error */ - return -1; + return FALSE; } /* Read and process record header. */ @@ -1021,7 +1021,7 @@ reread: /* * Error of some sort; give up. */ - return -1; + return FALSE; } /* We're at EOF. Wrap? @@ -1046,7 +1046,7 @@ reread: */ if (netxray->start_offset < netxray->end_offset) { *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } if (!netxray->wrapped) { @@ -1054,12 +1054,12 @@ reread: netxray->wrapped = TRUE; if (file_seek(wth->fh, CAPTUREFILE_HEADER_SIZE, SEEK_SET, err) == -1) - return -1; + return FALSE; goto reread; } /* We've already wrapped - don't wrap again. */ - return -1; + return FALSE; } /* @@ -1067,13 +1067,13 @@ reread: */ if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer, wth->phdr.caplen, err, err_info)) - return -1; + return FALSE; /* * If there's extra stuff at the end of the record, skip it. */ if (file_seek(wth->fh, padding, SEEK_CUR, err) == -1) - return -1; + return FALSE; /* * If it's an ATM packet, and we don't have enough information @@ -1081,16 +1081,16 @@ reread: * attempt to guess them from the packet data. */ netxray_guess_atm_type(wth, &wth->phdr, wth->frame_buffer); - return REC_TYPE_PACKET; + return TRUE; } -static int +static gboolean netxray_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; if (netxray_process_rec_header(wth, wth->random_fh, phdr, err, err_info) == -1) { @@ -1102,7 +1102,7 @@ netxray_seek_read(wtap *wth, gint64 seek_off, */ *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } /* @@ -1110,7 +1110,7 @@ netxray_seek_read(wtap *wth, gint64 seek_off, */ if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err, err_info)) - return -1; + return FALSE; /* * If it's an ATM packet, and we don't have enough information @@ -1118,7 +1118,7 @@ netxray_seek_read(wtap *wth, gint64 seek_off, * attempt to guess them from the packet data. */ netxray_guess_atm_type(wth, phdr, buf); - return REC_TYPE_PACKET; + return TRUE; } static int diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c index 1eafa3f150..8138a31f44 100644 --- a/wiretap/ngsniffer.c +++ b/wiretap/ngsniffer.c @@ -509,9 +509,9 @@ static int process_rec_header2_v2(wtap *wth, unsigned char *buffer, 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, gchar **err_info); -static int ngsniffer_read(wtap *wth, int *err, gchar **err_info, +static gboolean ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int ngsniffer_seek_read(wtap *wth, gint64 seek_off, +static gboolean ngsniffer_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static int ngsniffer_process_record(wtap *wth, gboolean is_random, guint *padding, struct wtap_pkthdr *phdr, Buffer *buf, int *err, @@ -1053,7 +1053,7 @@ process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length, } /* Read the next packet */ -static int +static gboolean ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { ngsniffer_t *ngsniffer; @@ -1075,7 +1075,7 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) &wth->phdr, wth->frame_buffer, err, err_info); if (ret < 0) { /* Read error or short read */ - return -1; + return FALSE; } /* @@ -1093,16 +1093,16 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) if (padding != 0) { if (!ng_file_skip_seq(wth, padding, err, err_info)) - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; case REC_EOF: /* * End of file. Return an EOF indication. */ *err = 0; /* EOF, not error */ - return -1; + return FALSE; default: /* @@ -1114,26 +1114,26 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) if (padding != 0) { if (!ng_file_skip_seq(wth, padding, err, err_info)) - return -1; + return FALSE; } break; } } } -static int +static gboolean ngsniffer_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { int ret; if (!ng_file_seek_rand(wth, seek_off, err, err_info)) - return -1; + return FALSE; ret = ngsniffer_process_record(wth, TRUE, NULL, phdr, buf, err, err_info); if (ret < 0) { /* Read error or short read */ - return -1; + return FALSE; } /* @@ -1152,10 +1152,10 @@ ngsniffer_seek_read(wtap *wth, gint64 seek_off, * "Can't happen". */ g_assert_not_reached(); - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } /* diff --git a/wiretap/packetlogger.c b/wiretap/packetlogger.c index 5970b00d20..313cf3e5b8 100644 --- a/wiretap/packetlogger.c +++ b/wiretap/packetlogger.c @@ -44,11 +44,11 @@ typedef struct packetlogger_header { guint64 ts; } packetlogger_header_t; -static int packetlogger_read(wtap *wth, int *err, gchar **err_info, - gint64 *data_offset); -static int packetlogger_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, - Buffer *buf, int *err, gchar **err_info); +static gboolean packetlogger_read(wtap *wth, int *err, gchar **err_info, + gint64 *data_offset); +static gboolean packetlogger_seek_read(wtap *wth, gint64 seek_off, + struct wtap_pkthdr *phdr, + Buffer *buf, int *err, gchar **err_info); static gboolean packetlogger_read_header(packetlogger_header_t *pl_hdr, FILE_T fh, int *err, gchar **err_info); static gboolean packetlogger_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, @@ -93,31 +93,29 @@ int packetlogger_open(wtap *wth, int *err, gchar **err_info) return 1; /* Our kind of file */ } -static int +static gboolean packetlogger_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); - if (!packetlogger_read_packet(wth->fh, &wth->phdr, - wth->frame_buffer, err, err_info)) - return -1; - return REC_TYPE_PACKET; + return packetlogger_read_packet(wth->fh, &wth->phdr, + wth->frame_buffer, err, err_info); } -static int +static gboolean packetlogger_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; if(!packetlogger_read_packet(wth->random_fh, phdr, buf, err, err_info)) { if(*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } static gboolean diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index 2132858770..a0be4a9eaa 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -2257,7 +2257,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info) /* classic wtap: read packet */ -static int +static gboolean pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { pcapng_t *pcapng = (pcapng_t *)wth->priv; @@ -2282,7 +2282,7 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) if (bytes_read <= 0) { pcapng_debug1("pcapng_read: data_offset is finally %" G_GINT64_MODIFIER "d", *data_offset); pcapng_debug0("pcapng_read: couldn't read packet block"); - return -1; + return FALSE; } switch (wblock.type) { @@ -2292,7 +2292,7 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) wth->phdr.pkt_encap = WTAP_ENCAP_UNKNOWN; *err = WTAP_ERR_UNSUPPORTED; *err_info = g_strdup_printf("pcapng: multi-section files not currently supported"); - return -1; + return FALSE; case(BLOCK_TYPE_PB): case(BLOCK_TYPE_SPB): @@ -2361,12 +2361,12 @@ got_packet: /*pcapng_debug2("Read length: %u Packet length: %u", bytes_read, wth->phdr.caplen);*/ pcapng_debug1("pcapng_read: data_offset is finally %" G_GINT64_MODIFIER "d", *data_offset + bytes_read); - return REC_TYPE_PACKET; + return TRUE; } /* classic wtap: seek to file position and read packet */ -static int +static gboolean pcapng_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) @@ -2380,7 +2380,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off, /* seek to the right file position */ bytes_read64 = file_seek(wth->random_fh, seek_off, SEEK_SET, err); if (bytes_read64 <= 0) { - return -1; /* Seek error */ + return FALSE; /* Seek error */ } pcapng_debug1("pcapng_seek_read: reading at offset %" G_GINT64_MODIFIER "u", seek_off); @@ -2393,7 +2393,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off, if (bytes_read <= 0) { pcapng_debug3("pcapng_seek_read: couldn't read packet block (err=%d, errno=%d, bytes_read=%d).", *err, errno, bytes_read); - return -1; + return FALSE; } /* block must be a "Packet Block", an "Enhanced Packet Block", @@ -2404,7 +2404,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off, return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } diff --git a/wiretap/peekclassic.c b/wiretap/peekclassic.c index 3d9e8dc086..a10ae66fd5 100644 --- a/wiretap/peekclassic.c +++ b/wiretap/peekclassic.c @@ -358,7 +358,7 @@ int peekclassic_open(wtap *wth, int *err, gchar **err_info) return 1; } -static int peekclassic_read_v7(wtap *wth, int *err, gchar **err_info, +static gboolean peekclassic_read_v7(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { int sliceLength; @@ -369,38 +369,38 @@ static int peekclassic_read_v7(wtap *wth, int *err, gchar **err_info, sliceLength = peekclassic_read_packet_v7(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); if (sliceLength < 0) - return -1; + return FALSE; /* Skip extra ignored data at the end of the packet. */ if ((guint32)sliceLength > wth->phdr.caplen) { if (!file_skip(wth->fh, sliceLength - wth->phdr.caplen, err)) - return -1; + return FALSE; } /* Records are padded to an even length, so if the slice length is odd, read the padding byte. */ if (sliceLength & 0x01) { if (!file_skip(wth->fh, 1, err)) - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } -static int peekclassic_seek_read_v7(wtap *wth, gint64 seek_off, +static gboolean peekclassic_seek_read_v7(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* Read the packet. */ if (peekclassic_read_packet_v7(wth, wth->random_fh, phdr, buf, err, err_info) == -1) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh, @@ -493,7 +493,7 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh, return sliceLength; } -static int peekclassic_read_v56(wtap *wth, int *err, gchar **err_info, +static gboolean peekclassic_read_v56(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); @@ -501,29 +501,29 @@ static int peekclassic_read_v56(wtap *wth, int *err, gchar **err_info, /* read the packet */ if (!peekclassic_read_packet_v56(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info)) - return -1; + return FALSE; /* * XXX - is the captured packet data padded to a multiple * of 2 bytes? */ - return REC_TYPE_PACKET; + return TRUE; } static gboolean peekclassic_seek_read_v56(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* read the packet */ if (!peekclassic_read_packet_v56(wth, wth->random_fh, phdr, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh, diff --git a/wiretap/peektagged.c b/wiretap/peektagged.c index 3007bdf99a..05dc8beaef 100644 --- a/wiretap/peektagged.c +++ b/wiretap/peektagged.c @@ -123,9 +123,9 @@ typedef struct { gboolean has_fcs; } peektagged_t; -static int peektagged_read(wtap *wth, int *err, gchar **err_info, +static gboolean peektagged_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int peektagged_seek_read(wtap *wth, gint64 seek_off, +static gboolean peektagged_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static int wtap_file_read_pattern (wtap *wth, const char *pattern, int *err, @@ -633,7 +633,7 @@ peektagged_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, return skip_len; } -static int peektagged_read(wtap *wth, int *err, gchar **err_info, +static gboolean peektagged_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { int skip_len; @@ -644,29 +644,29 @@ static int peektagged_read(wtap *wth, int *err, gchar **err_info, skip_len = peektagged_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); if (skip_len == -1) - return -1; + return FALSE; if (skip_len != 0) { /* Skip extra junk at the end of the packet data. */ if (!file_skip(wth->fh, skip_len, err)) - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } -static int +static gboolean peektagged_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* Read the packet. */ if (peektagged_read_packet(wth, wth->random_fh, phdr, buf, err, err_info) == -1) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c index 319ada0feb..6ba142485b 100644 --- a/wiretap/pppdump.c +++ b/wiretap/pppdump.c @@ -95,9 +95,9 @@ typedef enum { DIRECTION_RECV } direction_enum; -static int pppdump_read(wtap *wth, int *err, gchar **err_info, +static gboolean pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int pppdump_seek_read(wtap *wth, gint64 seek_off, +static gboolean pppdump_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); /* @@ -327,7 +327,7 @@ pppdump_set_phdr(struct wtap_pkthdr *phdr, int num_bytes, } /* Find the next packet and parse it; called from wtap_read(). */ -static int +static gboolean pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { int num_bytes; @@ -344,7 +344,7 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) pid = g_new(pkt_id, 1); if (!pid) { *err = errno; /* assume a malloc failed and set "errno" */ - return -1; + return FALSE; } pid->offset = 0; } else @@ -357,7 +357,7 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) pid, 0)) { if (pid != NULL) g_free(pid); - return -1; + return FALSE; } if (pid != NULL) @@ -374,7 +374,7 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) wth->phdr.ts.nsecs = state->tenths * 100000000; pppdump_set_phdr(&wth->phdr, num_bytes, direction); - return REC_TYPE_PACKET; + return TRUE; } /* Returns number of bytes copied for record, -1 if failure. @@ -715,7 +715,7 @@ done: /* Used to read packets in random-access fashion */ -static int +static gboolean pppdump_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, @@ -736,11 +736,11 @@ pppdump_seek_read(wtap *wth, if (!pid) { *err = WTAP_ERR_BAD_FILE; /* XXX - better error? */ *err_info = g_strdup("pppdump: PID not found for record"); - return -1; + return FALSE; } if (file_seek(wth->random_fh, pid->offset, SEEK_SET, err) == -1) - return -1; + return FALSE; init_state(state->seek_state); state->seek_state->offset = pid->offset; @@ -763,13 +763,13 @@ pppdump_seek_read(wtap *wth, do { if (!collate(state->seek_state, wth->random_fh, err, err_info, pd, &num_bytes, &direction, NULL, num_bytes_to_skip)) - return -1; + return FALSE; num_bytes_to_skip = 0; } while (direction != pid->dir); pppdump_set_phdr(phdr, num_bytes, pid->dir); - return REC_TYPE_PACKET; + return TRUE; } static void diff --git a/wiretap/radcom.c b/wiretap/radcom.c index 16df1397e7..e056cdd691 100644 --- a/wiretap/radcom.c +++ b/wiretap/radcom.c @@ -84,9 +84,9 @@ struct radcomrec_hdr { char xxw[9]; /* unknown */ }; -static int radcom_read(wtap *wth, int *err, gchar **err_info, +static gboolean radcom_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int radcom_seek_read(wtap *wth, gint64 seek_off, +static gboolean radcom_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static gboolean radcom_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); @@ -252,8 +252,8 @@ read_error: } /* Read the next packet */ -static int radcom_read(wtap *wth, int *err, gchar **err_info, - gint64 *data_offset) +static gboolean radcom_read(wtap *wth, int *err, gchar **err_info, + gint64 *data_offset) { int bytes_read; char fcs[2]; @@ -264,7 +264,7 @@ static int radcom_read(wtap *wth, int *err, gchar **err_info, if (!radcom_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info)) { /* Read error or EOF */ - return -1; + return FALSE; } if (wth->file_encap == WTAP_ENCAP_LAPB) { @@ -278,20 +278,20 @@ static int radcom_read(wtap *wth, int *err, gchar **err_info, *err = file_error(wth->fh, err_info); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } } - return REC_TYPE_PACKET; + return TRUE; } -static int +static gboolean radcom_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* Read record. */ if (!radcom_read_rec(wth, wth->random_fh, phdr, buf, err, @@ -301,9 +301,9 @@ radcom_seek_read(wtap *wth, gint64 seek_off, /* EOF means "short read" in random-access mode */ *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } static gboolean diff --git a/wiretap/snoop.c b/wiretap/snoop.c index 8001ddf58c..265d23f4a2 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -84,9 +84,9 @@ struct shomiti_trailer { #define RX_STATUS_FIFO_ERROR 0x0080 /* receive FIFO error */ #define RX_STATUS_TRIGGERED 0x0001 /* frame did trigger */ -static int snoop_read(wtap *wth, int *err, gchar **err_info, +static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int snoop_seek_read(wtap *wth, gint64 seek_off, +static gboolean snoop_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static int snoop_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); @@ -447,7 +447,7 @@ typedef struct { /* Read the next packet */ -static int snoop_read(wtap *wth, int *err, gchar **err_info, +static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { int padbytes; @@ -460,7 +460,7 @@ static int snoop_read(wtap *wth, int *err, gchar **err_info, padbytes = snoop_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); if (padbytes == -1) - return -1; + return FALSE; /* * Skip over the padding (don't "fseek()", as the standard @@ -482,27 +482,27 @@ static int snoop_read(wtap *wth, int *err, gchar **err_info, *err = file_error(wth->fh, err_info); if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } padbytes -= bytes_read; } - return REC_TYPE_PACKET; + return TRUE; } -static int +static gboolean snoop_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; if (snoop_read_packet(wth, wth->random_fh, phdr, buf, err, err_info) == -1) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } static int diff --git a/wiretap/stanag4607.c b/wiretap/stanag4607.c index 8c0625c74f..12bc05885c 100644 --- a/wiretap/stanag4607.c +++ b/wiretap/stanag4607.c @@ -48,8 +48,8 @@ static gboolean is_valid_id(guint16 version_id) return TRUE; } -static int stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, - Buffer *buf, int *err, gchar **err_info) +static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, + Buffer *buf, int *err, gchar **err_info) { stanag4607_t *stanag4607 = (stanag4607_t *)wth->priv; guint32 millisecs, secs, nsecs; @@ -69,7 +69,7 @@ static int stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, if (!is_valid_id(pntoh16(&stanag_pkt_hdr[0]))) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("Bad version number"); - return -1; + return FALSE; } /* The next 4 bytes are the packet length */ @@ -133,19 +133,16 @@ static int stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, /* wind back to the start of the packet ... */ if (file_seek(fh, - offset, SEEK_CUR, err) == -1) - return -1; - - if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info)) - return -1; + goto fail; - return REC_TYPE_PACKET; + return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info); fail: *err = file_error(wth->fh, err_info); - return -1; + return FALSE; } -static int stanag4607_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) +static gboolean stanag4607_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { gint64 offset; @@ -158,12 +155,12 @@ static int stanag4607_read(wtap *wth, int *err, gchar **err_info, gint64 *data_o return stanag4607_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); } -static int stanag4607_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, - Buffer *buf, int *err, gchar **err_info) +static gboolean stanag4607_seek_read(wtap *wth, gint64 seek_off, + struct wtap_pkthdr *phdr, + Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; return stanag4607_read_file(wth, wth->random_fh, phdr, buf, err, err_info); } diff --git a/wiretap/tnef.c b/wiretap/tnef.c index a08d42fb2c..5bd2fa1463 100644 --- a/wiretap/tnef.c +++ b/wiretap/tnef.c @@ -30,14 +30,14 @@ #include "buffer.h" #include "tnef.h" -static int tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, - Buffer *buf, int *err, gchar **err_info) +static gboolean tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, + Buffer *buf, int *err, gchar **err_info) { gint64 file_size; int packet_size; if ((file_size = wtap_file_size(wth, err)) == -1) - return -1; + return FALSE; if (file_size > WTAP_MAX_PACKET_SIZE) { /* @@ -47,7 +47,7 @@ static int tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("tnef: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u", file_size, WTAP_MAX_PACKET_SIZE); - return -1; + return FALSE; } packet_size = (int)file_size; @@ -59,12 +59,10 @@ static int tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, phdr->ts.secs = 0; phdr->ts.nsecs = 0; - if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info)) - return -1; - return REC_TYPE_PACKET; + return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info); } -static int tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) +static gboolean tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { gint64 offset; @@ -74,25 +72,25 @@ static int tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) /* there is only ever one packet */ if (offset) - return -1; + return FALSE; *data_offset = offset; return tnef_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); } -static int tnef_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, - Buffer *buf, int *err, gchar **err_info) +static gboolean tnef_seek_read(wtap *wth, gint64 seek_off, + struct wtap_pkthdr *phdr, + Buffer *buf, int *err, gchar **err_info) { /* there is only one packet */ if(seek_off > 0) { *err = 0; - return -1; + return FALSE; } if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; return tnef_read_file(wth, wth->random_fh, phdr, buf, err, err_info); } diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c index 6e8ab1a178..6fcf40270b 100644 --- a/wiretap/toshiba.c +++ b/wiretap/toshiba.c @@ -105,9 +105,9 @@ static const char toshiba_rec_magic[] = { '[', 'N', 'o', '.' }; */ #define TOSHIBA_MAX_PACKET_LEN 16384 -static int toshiba_read(wtap *wth, int *err, gchar **err_info, +static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int toshiba_seek_read(wtap *wth, gint64 seek_off, +static gboolean toshiba_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf, guint byte_offset); @@ -214,7 +214,7 @@ int toshiba_open(wtap *wth, int *err, gchar **err_info) } /* Find the next packet and parse it; called from wtap_read(). */ -static int toshiba_read(wtap *wth, int *err, gchar **err_info, +static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { gint64 offset; @@ -222,31 +222,29 @@ static int toshiba_read(wtap *wth, int *err, gchar **err_info, /* Find the next packet */ offset = toshiba_seek_next_packet(wth, err, err_info); if (offset < 1) - return -1; + return FALSE; *data_offset = offset; /* Parse the packet */ - if (!parse_toshiba_packet(wth->fh, &wth->phdr, wth->frame_buffer, - err, err_info)) - return -1; - return REC_TYPE_PACKET; + return parse_toshiba_packet(wth->fh, &wth->phdr, wth->frame_buffer, + err, err_info); } /* Used to read packets in random-access fashion */ -static int +static gboolean toshiba_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1) - return -1; + return FALSE; if (!parse_toshiba_packet(wth->random_fh, phdr, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } /* Parses a packet. */ diff --git a/wiretap/visual.c b/wiretap/visual.c index 67a7d481f9..cfa03bceac 100644 --- a/wiretap/visual.c +++ b/wiretap/visual.c @@ -158,9 +158,9 @@ struct visual_write_info /* Local functions to handle file reads and writes */ -static int visual_read(wtap *wth, int *err, gchar **err_info, +static gboolean visual_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int visual_seek_read(wtap *wth, gint64 seek_off, +static gboolean visual_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); static gboolean visual_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); @@ -281,7 +281,7 @@ int visual_open(wtap *wth, int *err, gchar **err_info) 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 int visual_read(wtap *wth, int *err, gchar **err_info, +static gboolean visual_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { struct visual_read_info *visual = (struct visual_read_info *)wth->priv; @@ -292,33 +292,31 @@ static int visual_read(wtap *wth, int *err, gchar **err_info, if (visual->current_pkt > visual->num_pkts) { *err = 0; /* it's just an EOF, not an error */ - return -1; + return FALSE; } visual->current_pkt++; *data_offset = file_tell(wth->fh); - if (!visual_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer, - err, err_info)) - return -1; - return REC_TYPE_PACKET; + return visual_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer, + err, err_info); } /* Read packet header and data for random access. */ -static int visual_seek_read(wtap *wth, gint64 seek_off, +static gboolean visual_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { /* Seek to the packet header */ if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* Read the packet. */ if (!visual_read_packet(wth, wth->random_fh, phdr, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } static gboolean diff --git a/wiretap/vms.c b/wiretap/vms.c index 90d5e24acc..3684c3bbbe 100644 --- a/wiretap/vms.c +++ b/wiretap/vms.c @@ -139,9 +139,9 @@ to handle them. #define VMS_HEADER_LINES_TO_CHECK 200 #define VMS_LINE_LENGTH 240 -static int vms_read(wtap *wth, int *err, gchar **err_info, +static gboolean vms_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int vms_seek_read(wtap *wth, gint64 seek_off, +static gboolean vms_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, 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); @@ -255,7 +255,7 @@ int vms_open(wtap *wth, int *err, gchar **err_info) } /* Find the next packet and parse it; called from wtap_read(). */ -static int vms_read(wtap *wth, int *err, gchar **err_info, +static gboolean vms_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { gint64 offset = 0; @@ -268,14 +268,12 @@ static int vms_read(wtap *wth, int *err, gchar **err_info, #endif if (offset < 1) { *err = file_error(wth->fh, err_info); - return -1; + return FALSE; } *data_offset = offset; /* Parse the packet */ - if (!parse_vms_packet(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info)) - return -1; - return REC_TYPE_PACKET; + return parse_vms_packet(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); } /* Used to read packets in random-access fashion */ @@ -284,14 +282,14 @@ vms_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1) - return -1; + return FALSE; if (!parse_vms_packet(wth->random_fh, phdr, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; - return -1; + return FALSE; } - return REC_TYPE_PACKET; + return TRUE; } /* isdumpline assumes that dump lines start with some non-alphanumerics diff --git a/wiretap/vwr.c b/wiretap/vwr.c index 518ebaf46c..7d0b291c62 100644 --- a/wiretap/vwr.c +++ b/wiretap/vwr.c @@ -496,8 +496,8 @@ static guint8 get_ofdm_rate(const guint8 *); static guint8 get_cck_rate(const guint8 *plcp); static void setup_defaults(vwr_t *, guint16); -static int vwr_read(wtap *, int *, gchar **, gint64 *); -static int vwr_seek_read(wtap *, gint64, struct wtap_pkthdr *phdr, +static gboolean vwr_read(wtap *, int *, gchar **, gint64 *); +static gboolean vwr_seek_read(wtap *, gint64, struct wtap_pkthdr *phdr, Buffer *, int *, gchar **); static gboolean vwr_read_rec_header(vwr_t *, FILE_T, int *, int *, int *, gchar **); @@ -571,14 +571,14 @@ int vwr_open(wtap *wth, int *err, gchar **err_info) /* frame, and a 64-byte statistics block trailer. */ /* The PLCP frame consists of a 4-byte or 6-byte PLCP header, followed by the MAC frame */ -static int vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) +static gboolean vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { vwr_t *vwr = (vwr_t *)wth->priv; int rec_size = 0, IS_TX; /* read the next frame record header in the capture file; if no more frames, return */ if (!vwr_read_rec_header(vwr, wth->fh, &rec_size, &IS_TX, err, err_info)) - return -1; /* Read error or EOF */ + return FALSE; /* Read error or EOF */ /* * We're past the header; return the offset of the header, not of @@ -589,7 +589,7 @@ static int vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) /* got a frame record; read and process it */ if (!vwr_process_rec_data(wth->fh, rec_size, &wth->phdr, wth->frame_buffer, vwr, IS_TX, err, err_info)) - return -1; + return FALSE; /* If the per-file encapsulation isn't known, set it to this packet's encapsulation. */ /* If it *is* known, and it isn't this packet's encapsulation, set it to */ @@ -602,12 +602,12 @@ static int vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) wth->file_encap = WTAP_ENCAP_PER_PACKET; } - return REC_TYPE_PACKET; + return TRUE; } /* read a random record in the middle of a file; the start of the record is @ seek_off */ -static int vwr_seek_read(wtap *wth, gint64 seek_off, +static gboolean vwr_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { vwr_t *vwr = (vwr_t *)wth->priv; @@ -615,17 +615,14 @@ static int vwr_seek_read(wtap *wth, gint64 seek_off, /* first seek to the indicated record header */ if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return -1; + return FALSE; /* read in the record header */ if (!vwr_read_rec_header(vwr, wth->random_fh, &rec_size, &IS_TX, err, err_info)) - return -1; /* Read error or EOF */ - - if (!vwr_process_rec_data(wth->random_fh, rec_size, phdr, buf, - vwr, IS_TX, err, err_info)) - return -1; + return FALSE; /* Read error or EOF */ - return REC_TYPE_PACKET; + return vwr_process_rec_data(wth->random_fh, rec_size, phdr, buf, + vwr, IS_TX, err, err_info); } /* Scan down in the input capture file to find the next frame header. */ diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h index 8291609b73..dfa3441835 100644 --- a/wiretap/wtap-int.h +++ b/wiretap/wtap-int.h @@ -40,10 +40,10 @@ WS_DLL_PUBLIC int wtap_fstat(wtap *wth, ws_statb64 *statb, int *err); -typedef int (*subtype_read_func)(struct wtap*, int*, char**, gint64*); -typedef int (*subtype_seek_read_func)(struct wtap*, gint64, - struct wtap_pkthdr *, Buffer *, - int *, char **); +typedef gboolean (*subtype_read_func)(struct wtap*, int*, char**, gint64*); +typedef gboolean (*subtype_seek_read_func)(struct wtap*, gint64, + struct wtap_pkthdr *, Buffer *buf, + int *, char **); /** * Struct holding data of the currently read file. */ diff --git a/wiretap/wtap.c b/wiretap/wtap.c index f03900cfbf..c32524be80 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -975,11 +975,9 @@ void wtap_set_cb_new_ipv6(wtap *wth, wtap_new_ipv6_callback_t add_new_ipv6) { wth->add_new_ipv6 = add_new_ipv6; } -int +gboolean wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { - int rectype; - /* * Set the packet encapsulation to the file's encapsulation * value; if that's not WTAP_ENCAP_PER_PACKET, it's the @@ -990,8 +988,7 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) */ wth->phdr.pkt_encap = wth->file_encap; - rectype = wth->subtype_read(wth, err, err_info, data_offset); - if (rectype == -1) { + if (!wth->subtype_read(wth, err, err_info, data_offset)) { /* * If we didn't get an error indication, we read * the last packet. See if there's any deferred @@ -1003,7 +1000,7 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) */ if (*err == 0) *err = file_error(wth->fh, err_info); - return rectype; /* failure */ + return FALSE; /* failure */ } /* @@ -1021,7 +1018,7 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) */ g_assert(wth->phdr.pkt_encap != WTAP_ENCAP_PER_PACKET); - return rectype; + return TRUE; /* success */ } /* @@ -1074,15 +1071,12 @@ wtap_buf_ptr(wtap *wth) return buffer_start_ptr(wth->frame_buffer); } -int +gboolean wtap_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { - int rectype; - - rectype = wth->subtype_seek_read(wth, seek_off, phdr, buf, err, err_info); - if (rectype == -1) - return rectype; + if (!wth->subtype_seek_read(wth, seek_off, phdr, buf, err, err_info)) + return FALSE; /* * It makes no sense for the captured data length to be bigger @@ -1099,5 +1093,5 @@ wtap_seek_read(wtap *wth, gint64 seek_off, */ g_assert(wth->phdr.pkt_encap != WTAP_ENCAP_PER_PACKET); - return rectype; + return TRUE; } diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 3e47b3c8dc..005d748304 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -1349,24 +1349,15 @@ typedef void (*wtap_new_ipv6_callback_t) (const void *addrp, const gchar *name); WS_DLL_PUBLIC void wtap_set_cb_new_ipv6(wtap *wth, wtap_new_ipv6_callback_t add_new_ipv6); -/* - * Values returned by wtap_read() and wtap_seek_read(). They indicate the - * type of record read by that routine. - * - * This list will expand over time, so don't assume everything will be a - * file-type-specific record or a packet record. - */ -#define REC_TYPE_FILE_TYPE_SPECIFIC 0 /* file-type-specific record */ -#define REC_TYPE_PACKET 1 /* packet */ - -/** Returns a REC_TYPE_ value if read was successful, -1 if it failed. - * *data_offset is set to the offset in the file where the data for - * the read packet is located. */ +/** Returns TRUE if read was successful. FALSE if failure. data_offset is + * set to the offset in the file where the data for the read packet is + * located. */ WS_DLL_PUBLIC -int wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); +gboolean wtap_read(wtap *wth, int *err, gchar **err_info, + gint64 *data_offset); WS_DLL_PUBLIC -int wtap_seek_read (wtap *wth, gint64 seek_off, +gboolean wtap_seek_read (wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); /*** get various information snippets about the current packet ***/ -- cgit v1.2.3