Allow wtap_read() and wtap_seek_read() to return non-packet records.

This is the first step towards implementing the mechanisms requestd in
bug 8590; currently, we don't return any records other than packet
records from libwiretap, and just ignore non-packet records in the rest
of Wireshark, but this at least gets the ball rolling.

Change-Id: I34a45b54dd361f69fdad1a758d8ca4f42d67d574
Reviewed-on: https://code.wireshark.org/review/1736
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2014-05-22 20:01:31 -07:00
parent 6287efb9c0
commit c0c480d08c
78 changed files with 1343 additions and 1222 deletions

View File

@ -803,6 +803,7 @@ static int
process_cap_file(wtap *wth, const char *filename)
{
int status = 0;
int rec_type;
int err;
gchar *err_info;
gint64 size;
@ -828,51 +829,53 @@ process_cap_file(wtap *wth, const char *filename)
cf_info.encap_counts = g_new0(int,WTAP_NUM_ENCAP_TYPES);
/* Tally up data that we need to parse through the file to find */
while (wtap_read(wth, &err, &err_info, &data_offset)) {
phdr = wtap_phdr(wth);
if (phdr->presence_flags & WTAP_HAS_TS) {
prev_time = cur_time;
cur_time = nstime_to_sec(&phdr->ts);
if (packet == 0) {
start_time = cur_time;
stop_time = cur_time;
prev_time = cur_time;
}
if (cur_time < prev_time) {
order = NOT_IN_ORDER;
}
if (cur_time < start_time) {
start_time = cur_time;
}
if (cur_time > stop_time) {
stop_time = cur_time;
}
} else {
have_times = FALSE; /* at least one packet has no time stamp */
if (order != NOT_IN_ORDER)
order = ORDER_UNKNOWN;
}
bytes+=phdr->len;
packet++;
/* If caplen < len for a rcd, then presumably */
/* 'Limit packet capture length' was done for this rcd. */
/* Keep track as to the min/max actual snapshot lengths */
/* seen for this file. */
if (phdr->caplen < phdr->len) {
if (phdr->caplen < snaplen_min_inferred)
snaplen_min_inferred = phdr->caplen;
if (phdr->caplen > snaplen_max_inferred)
snaplen_max_inferred = phdr->caplen;
}
/* Per-packet encapsulation */
if (wtap_file_encap(wth) == WTAP_ENCAP_PER_PACKET) {
if ((phdr->pkt_encap > 0) && (phdr->pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
cf_info.encap_counts[phdr->pkt_encap] += 1;
while ((rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1) {
if (rec_type == REC_TYPE_PACKET) {
phdr = wtap_phdr(wth);
if (phdr->presence_flags & WTAP_HAS_TS) {
prev_time = cur_time;
cur_time = nstime_to_sec(&phdr->ts);
if (packet == 0) {
start_time = cur_time;
stop_time = cur_time;
prev_time = cur_time;
}
if (cur_time < prev_time) {
order = NOT_IN_ORDER;
}
if (cur_time < start_time) {
start_time = cur_time;
}
if (cur_time > stop_time) {
stop_time = cur_time;
}
} else {
fprintf(stderr, "capinfos: Unknown per-packet encapsulation: %d [frame number: %d]\n", phdr->pkt_encap, packet);
have_times = FALSE; /* at least one packet has no time stamp */
if (order != NOT_IN_ORDER)
order = ORDER_UNKNOWN;
}
bytes+=phdr->len;
packet++;
/* If caplen < len for a rcd, then presumably */
/* 'Limit packet capture length' was done for this rcd. */
/* Keep track as to the min/max actual snapshot lengths */
/* seen for this file. */
if (phdr->caplen < phdr->len) {
if (phdr->caplen < snaplen_min_inferred)
snaplen_min_inferred = phdr->caplen;
if (phdr->caplen > snaplen_max_inferred)
snaplen_max_inferred = phdr->caplen;
}
/* Per-packet encapsulation */
if (wtap_file_encap(wth) == WTAP_ENCAP_PER_PACKET) {
if ((phdr->pkt_encap > 0) && (phdr->pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
cf_info.encap_counts[phdr->pkt_encap] += 1;
} else {
fprintf(stderr, "capinfos: Unknown per-packet encapsulation: %d [frame number: %d]\n", phdr->pkt_encap, packet);
}
}
}

View File

@ -390,9 +390,9 @@ capture_input_new_file(capture_session *cap_session, gchar *new_file)
}
/* capture child tells us we have new packets to read */
/* capture child tells us we have new records to read */
void
capture_input_new_packets(capture_session *cap_session, int to_read)
capture_input_new_records(capture_session *cap_session, int to_read)
{
capture_options *capture_opts = cap_session->capture_opts;
int err;
@ -435,7 +435,7 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
#endif
if(capture_opts->show_info)
capture_info_new_packets(to_read);
capture_info_new_records(to_read);
}

View File

@ -232,9 +232,11 @@ gboolean capture_info_new_file(const char *new_filename)
}
/* new packets arrived */
void capture_info_new_packets(int to_read)
/* new records arrived */
void capture_info_new_records(int to_read)
{
int rec_type;
int packets_read = 0;
int err;
gchar *err_info;
gint64 data_offset;
@ -244,25 +246,27 @@ void capture_info_new_packets(int to_read)
const guchar *buf;
info_data.ui.new_packets = to_read;
/*g_warning("new packets: %u", to_read);*/
while (to_read > 0) {
wtap_cleareof(info_data.wtap);
if (wtap_read(info_data.wtap, &err, &err_info, &data_offset)) {
phdr = wtap_phdr(info_data.wtap);
pseudo_header = &phdr->pseudo_header;
wtap_linktype = phdr->pkt_encap;
buf = wtap_buf_ptr(info_data.wtap);
if ((rec_type = wtap_read(info_data.wtap, &err, &err_info, &data_offset)) != -1) {
if (rec_type == REC_TYPE_PACKET) {
phdr = wtap_phdr(info_data.wtap);
pseudo_header = &phdr->pseudo_header;
wtap_linktype = phdr->pkt_encap;
buf = wtap_buf_ptr(info_data.wtap);
capture_info_packet(&info_data.counts, wtap_linktype, buf, phdr->caplen, pseudo_header);
capture_info_packet(&info_data.counts, wtap_linktype, buf, phdr->caplen, pseudo_header);
packets_read++;
/*g_warning("new packet");*/
/*g_warning("new packet");*/
}
to_read--;
}
}
info_data.ui.new_packets = packets_read;
capture_info_ui_update(&info_data.ui);
}

View File

@ -43,8 +43,8 @@ extern void capture_info_open(capture_session *cap_session);
/* new file arrived - (eventually close old wtap), open wtap */
extern gboolean capture_info_new_file(const char *new_filename);
/* new packets arrived - read from wtap, count */
extern void capture_info_new_packets(int to_read);
/* new records arrived - read from wtap, count */
extern void capture_info_new_records(int to_read);
/* close the info - close wtap, destroy dialog */
extern void capture_info_close(void);

View File

@ -1776,7 +1776,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
case SP_PACKET_COUNT:
npackets = atoi(buffer);
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_input_cb: new packets %u", npackets);
capture_input_new_packets(cap_session, npackets);
capture_input_new_records(cap_session, npackets);
break;
case SP_ERROR_MSG:
/* convert primary message */

View File

@ -99,10 +99,10 @@ extern gboolean
capture_input_new_file(capture_session *cap_session, gchar *new_file);
/**
* Capture child told us we have new packets to read.
* Capture child told us we have new records to read.
*/
extern void
capture_input_new_packets(capture_session *cap_session, int to_read);
capture_input_new_records(capture_session *cap_session, int to_read);
/**
* Capture child told us how many dropped packets it counted.

642
editcap.c
View File

@ -842,7 +842,7 @@ main(int argc, char *argv[])
int i, j, err;
gchar *err_info;
int opt;
int rec_type;
char *p;
guint32 snaplen = 0; /* No limit */
chop_t chop = {0, 0, 0, 0, 0, 0}; /* No chop */
@ -1192,154 +1192,173 @@ main(int argc, char *argv[])
}
}
while (wtap_read(wth, &err, &err_info, &data_offset)) {
read_count++;
phdr = wtap_phdr(wth);
buf = wtap_buf_ptr(wth);
if (nstime_is_unset(&block_start)) { /* should only be the first packet */
block_start.secs = phdr->ts.secs;
block_start.nsecs = phdr->ts.nsecs;
if (split_packet_count > 0 || secs_per_block > 0) {
if (!fileset_extract_prefix_suffix(argv[optind+1], &fprefix, &fsuffix))
exit(2);
filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
} else {
filename = g_strdup(argv[optind+1]);
}
/* If we don't have an application name add Editcap */
if (shb_hdr->shb_user_appl == NULL) {
shb_hdr->shb_user_appl = "Editcap " VERSION;
}
pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
FALSE /* compressed */, shb_hdr, idb_inf, &err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
filename, wtap_strerror(err));
exit(2);
}
}
g_assert(filename);
if (secs_per_block > 0) {
while ((phdr->ts.secs - block_start.secs > secs_per_block)
|| (phdr->ts.secs - block_start.secs == secs_per_block
&& phdr->ts.nsecs >= block_start.nsecs )) { /* time for the next file */
if (!wtap_dump_close(pdh, &err)) {
fprintf(stderr, "editcap: Error writing to %s: %s\n",
filename, wtap_strerror(err));
exit(2);
}
block_start.secs = block_start.secs + secs_per_block; /* reset for next interval */
g_free(filename);
filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
g_assert(filename);
if (verbose)
fprintf(stderr, "Continuing writing in file %s\n", filename);
pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
FALSE /* compressed */, shb_hdr, idb_inf, &err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
filename, wtap_strerror(err));
exit(2);
}
}
}
if (split_packet_count > 0) {
/* time for the next file? */
if (written_count > 0 && written_count % split_packet_count == 0) {
if (!wtap_dump_close(pdh, &err)) {
fprintf(stderr, "editcap: Error writing to %s: %s\n",
filename, wtap_strerror(err));
exit(2);
}
g_free(filename);
filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
g_assert(filename);
if (verbose)
fprintf(stderr, "Continuing writing in file %s\n", filename);
pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
FALSE /* compressed */, shb_hdr, idb_inf, &err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
filename, wtap_strerror(err));
exit(2);
}
}
}
if (check_startstop)
ts_okay = check_timestamp(wth);
if (ts_okay && ((!selected(count) && !keep_em)
|| (selected(count) && keep_em))) {
if (verbose && !dup_detect && !dup_detect_by_time)
fprintf(stderr, "Packet: %u\n", count);
/* We simply write it, perhaps after truncating it; we could
* do other things, like modify it. */
while ((rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1) {
if (rec_type == REC_TYPE_PACKET) {
read_count++;
phdr = wtap_phdr(wth);
buf = wtap_buf_ptr(wth);
if (snaplen != 0) {
if (phdr->caplen > snaplen) {
snap_phdr = *phdr;
snap_phdr.caplen = snaplen;
phdr = &snap_phdr;
if (nstime_is_unset(&block_start)) { /* should only be the first packet */
block_start.secs = phdr->ts.secs;
block_start.nsecs = phdr->ts.nsecs;
if (split_packet_count > 0 || secs_per_block > 0) {
if (!fileset_extract_prefix_suffix(argv[optind+1], &fprefix, &fsuffix))
exit(2);
filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
} else {
filename = g_strdup(argv[optind+1]);
}
if (adjlen && phdr->len > snaplen) {
snap_phdr = *phdr;
snap_phdr.len = snaplen;
phdr = &snap_phdr;
/* If we don't have an application name add Editcap */
if (shb_hdr->shb_user_appl == NULL) {
shb_hdr->shb_user_appl = "Editcap " VERSION;
}
pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
FALSE /* compressed */, shb_hdr, idb_inf, &err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
filename, wtap_strerror(err));
exit(2);
}
}
/* CHOP */
snap_phdr = *phdr;
handle_chopping(chop, &snap_phdr, phdr, &buf, adjlen);
phdr = &snap_phdr;
g_assert(filename);
/* Do we adjust timestamps to ensure strict chronological
* order? */
if (do_strict_time_adjustment) {
if (previous_time.secs || previous_time.nsecs) {
if (!strict_time_adj.is_negative) {
nstime_t current;
nstime_t delta;
if (secs_per_block > 0) {
while ((phdr->ts.secs - block_start.secs > secs_per_block)
|| (phdr->ts.secs - block_start.secs == secs_per_block
&& phdr->ts.nsecs >= block_start.nsecs )) { /* time for the next file */
current.secs = phdr->ts.secs;
current.nsecs = phdr->ts.nsecs;
if (!wtap_dump_close(pdh, &err)) {
fprintf(stderr, "editcap: Error writing to %s: %s\n",
filename, wtap_strerror(err));
exit(2);
}
block_start.secs = block_start.secs + secs_per_block; /* reset for next interval */
g_free(filename);
filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
g_assert(filename);
nstime_delta(&delta, &current, &previous_time);
if (verbose)
fprintf(stderr, "Continuing writing in file %s\n", filename);
if (delta.secs < 0 || delta.nsecs < 0) {
pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
FALSE /* compressed */, shb_hdr, idb_inf, &err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
filename, wtap_strerror(err));
exit(2);
}
}
}
if (split_packet_count > 0) {
/* time for the next file? */
if (written_count > 0 && written_count % split_packet_count == 0) {
if (!wtap_dump_close(pdh, &err)) {
fprintf(stderr, "editcap: Error writing to %s: %s\n",
filename, wtap_strerror(err));
exit(2);
}
g_free(filename);
filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
g_assert(filename);
if (verbose)
fprintf(stderr, "Continuing writing in file %s\n", filename);
pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
FALSE /* compressed */, shb_hdr, idb_inf, &err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
filename, wtap_strerror(err));
exit(2);
}
}
}
if (check_startstop)
ts_okay = check_timestamp(wth);
if (ts_okay && ((!selected(count) && !keep_em)
|| (selected(count) && keep_em))) {
if (verbose && !dup_detect && !dup_detect_by_time)
fprintf(stderr, "Packet: %u\n", count);
/* We simply write it, perhaps after truncating it; we could
* do other things, like modify it. */
phdr = wtap_phdr(wth);
if (snaplen != 0) {
if (phdr->caplen > snaplen) {
snap_phdr = *phdr;
snap_phdr.caplen = snaplen;
phdr = &snap_phdr;
}
if (adjlen && phdr->len > snaplen) {
snap_phdr = *phdr;
snap_phdr.len = snaplen;
phdr = &snap_phdr;
}
}
/* CHOP */
snap_phdr = *phdr;
handle_chopping(chop, &snap_phdr, phdr, &buf, adjlen);
phdr = &snap_phdr;
/* Do we adjust timestamps to ensure strict chronological
* order? */
if (do_strict_time_adjustment) {
if (previous_time.secs || previous_time.nsecs) {
if (!strict_time_adj.is_negative) {
nstime_t current;
nstime_t delta;
current.secs = phdr->ts.secs;
current.nsecs = phdr->ts.nsecs;
nstime_delta(&delta, &current, &previous_time);
if (delta.secs < 0 || delta.nsecs < 0) {
/*
* A negative delta indicates that the current packet
* has an absolute timestamp less than the previous packet
* that it is being compared to. This is NOT a normal
* situation since trace files usually have packets in
* chronological order (oldest to newest).
*/
/* fprintf(stderr, "++out of order, need to adjust this packet!\n"); */
snap_phdr = *phdr;
snap_phdr.ts.secs = previous_time.secs + strict_time_adj.tv.tv_sec;
snap_phdr.ts.nsecs = previous_time.nsecs;
if (snap_phdr.ts.nsecs + strict_time_adj.tv.tv_usec * 1000 > ONE_MILLION * 1000) {
/* carry */
snap_phdr.ts.secs++;
snap_phdr.ts.nsecs += (strict_time_adj.tv.tv_usec - ONE_MILLION) * 1000;
} else {
snap_phdr.ts.nsecs += strict_time_adj.tv.tv_usec * 1000;
}
phdr = &snap_phdr;
}
} else {
/*
* A negative delta indicates that the current packet
* has an absolute timestamp less than the previous packet
* that it is being compared to. This is NOT a normal
* situation since trace files usually have packets in
* chronological order (oldest to newest).
* A negative strict time adjustment is requested.
* Unconditionally set each timestamp to previous
* packet's timestamp plus delta.
*/
/* fprintf(stderr, "++out of order, need to adjust this packet!\n"); */
snap_phdr = *phdr;
snap_phdr.ts.secs = previous_time.secs + strict_time_adj.tv.tv_sec;
snap_phdr.ts.nsecs = previous_time.nsecs;
@ -1352,207 +1371,190 @@ main(int argc, char *argv[])
}
phdr = &snap_phdr;
}
} else {
/*
* A negative strict time adjustment is requested.
* Unconditionally set each timestamp to previous
* packet's timestamp plus delta.
*/
snap_phdr = *phdr;
snap_phdr.ts.secs = previous_time.secs + strict_time_adj.tv.tv_sec;
snap_phdr.ts.nsecs = previous_time.nsecs;
if (snap_phdr.ts.nsecs + strict_time_adj.tv.tv_usec * 1000 > ONE_MILLION * 1000) {
}
previous_time.secs = phdr->ts.secs;
previous_time.nsecs = phdr->ts.nsecs;
}
/* assume that if the frame's tv_sec is 0, then
* the timestamp isn't supported */
if (phdr->ts.secs > 0 && time_adj.tv.tv_sec != 0) {
snap_phdr = *phdr;
if (time_adj.is_negative)
snap_phdr.ts.secs -= time_adj.tv.tv_sec;
else
snap_phdr.ts.secs += time_adj.tv.tv_sec;
phdr = &snap_phdr;
}
/* assume that if the frame's tv_sec is 0, then
* the timestamp isn't supported */
if (phdr->ts.secs > 0 && time_adj.tv.tv_usec != 0) {
snap_phdr = *phdr;
if (time_adj.is_negative) { /* subtract */
if (snap_phdr.ts.nsecs/1000 < time_adj.tv.tv_usec) { /* borrow */
snap_phdr.ts.secs--;
snap_phdr.ts.nsecs += ONE_MILLION * 1000;
}
snap_phdr.ts.nsecs -= time_adj.tv.tv_usec * 1000;
} else { /* add */
if (snap_phdr.ts.nsecs + time_adj.tv.tv_usec * 1000 > ONE_MILLION * 1000) {
/* carry */
snap_phdr.ts.secs++;
snap_phdr.ts.nsecs += (strict_time_adj.tv.tv_usec - ONE_MILLION) * 1000;
snap_phdr.ts.nsecs += (time_adj.tv.tv_usec - ONE_MILLION) * 1000;
} else {
snap_phdr.ts.nsecs += strict_time_adj.tv.tv_usec * 1000;
snap_phdr.ts.nsecs += time_adj.tv.tv_usec * 1000;
}
phdr = &snap_phdr;
}
phdr = &snap_phdr;
}
previous_time.secs = phdr->ts.secs;
previous_time.nsecs = phdr->ts.nsecs;
}
/* assume that if the frame's tv_sec is 0, then
* the timestamp isn't supported */
if (phdr->ts.secs > 0 && time_adj.tv.tv_sec != 0) {
snap_phdr = *phdr;
if (time_adj.is_negative)
snap_phdr.ts.secs -= time_adj.tv.tv_sec;
else
snap_phdr.ts.secs += time_adj.tv.tv_sec;
phdr = &snap_phdr;
}
/* assume that if the frame's tv_sec is 0, then
* the timestamp isn't supported */
if (phdr->ts.secs > 0 && time_adj.tv.tv_usec != 0) {
snap_phdr = *phdr;
if (time_adj.is_negative) { /* subtract */
if (snap_phdr.ts.nsecs/1000 < time_adj.tv.tv_usec) { /* borrow */
snap_phdr.ts.secs--;
snap_phdr.ts.nsecs += ONE_MILLION * 1000;
}
snap_phdr.ts.nsecs -= time_adj.tv.tv_usec * 1000;
} else { /* add */
if (snap_phdr.ts.nsecs + time_adj.tv.tv_usec * 1000 > ONE_MILLION * 1000) {
/* carry */
snap_phdr.ts.secs++;
snap_phdr.ts.nsecs += (time_adj.tv.tv_usec - ONE_MILLION) * 1000;
/* suppress duplicates by packet window */
if (dup_detect) {
if (is_duplicate(buf, phdr->caplen)) {
if (verbose) {
fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
count, phdr->caplen);
for (i = 0; i < 16; i++)
fprintf(stderr, "%02x",
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
fprintf(stderr, "\n");
}
duplicate_count++;
count++;
continue;
} else {
snap_phdr.ts.nsecs += time_adj.tv.tv_usec * 1000;
}
}
phdr = &snap_phdr;
}
/* suppress duplicates by packet window */
if (dup_detect) {
if (is_duplicate(buf, phdr->caplen)) {
if (verbose) {
fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
count, phdr->caplen);
for (i = 0; i < 16; i++)
fprintf(stderr, "%02x",
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
fprintf(stderr, "\n");
}
duplicate_count++;
count++;
continue;
} else {
if (verbose) {
fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
count, phdr->caplen);
for (i = 0; i < 16; i++)
fprintf(stderr, "%02x",
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
fprintf(stderr, "\n");
}
}
}
/* suppress duplicates by time window */
if (dup_detect_by_time) {
nstime_t current;
current.secs = phdr->ts.secs;
current.nsecs = phdr->ts.nsecs;
if (is_duplicate_rel_time(buf, phdr->caplen, &current)) {
if (verbose) {
fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
count, phdr->caplen);
for (i = 0; i < 16; i++)
fprintf(stderr, "%02x",
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
fprintf(stderr, "\n");
}
duplicate_count++;
count++;
continue;
} else {
if (verbose) {
fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
count, phdr->caplen);
for (i = 0; i < 16; i++)
fprintf(stderr, "%02x",
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
fprintf(stderr, "\n");
}
}
}
/* Random error mutation */
if (err_prob > 0.0) {
int real_data_start = 0;
/* Protect non-protocol data */
if (wtap_file_type_subtype(wth) == WTAP_FILE_TYPE_SUBTYPE_CATAPULT_DCT2000)
real_data_start = find_dct2000_real_data(buf);
for (i = real_data_start; i < (int) phdr->caplen; i++) {
if (rand() <= err_prob * RAND_MAX) {
err_type = rand() / (RAND_MAX / ERR_WT_TOTAL + 1);
if (err_type < ERR_WT_BIT) {
buf[i] ^= 1 << (rand() / (RAND_MAX / 8 + 1));
err_type = ERR_WT_TOTAL;
} else {
err_type -= ERR_WT_BYTE;
}
if (err_type < ERR_WT_BYTE) {
buf[i] = rand() / (RAND_MAX / 255 + 1);
err_type = ERR_WT_TOTAL;
} else {
err_type -= ERR_WT_BYTE;
}
if (err_type < ERR_WT_ALNUM) {
buf[i] = ALNUM_CHARS[rand() / (RAND_MAX / ALNUM_LEN + 1)];
err_type = ERR_WT_TOTAL;
} else {
err_type -= ERR_WT_ALNUM;
}
if (err_type < ERR_WT_FMT) {
if ((unsigned int)i < phdr->caplen - 2)
g_strlcpy((char*) &buf[i], "%s", 2);
err_type = ERR_WT_TOTAL;
} else {
err_type -= ERR_WT_FMT;
}
if (err_type < ERR_WT_AA) {
for (j = i; j < (int) phdr->caplen; j++)
buf[j] = 0xAA;
i = phdr->caplen;
if (verbose) {
fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
count, phdr->caplen);
for (i = 0; i < 16; i++)
fprintf(stderr, "%02x",
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
fprintf(stderr, "\n");
}
}
}
}
if (!wtap_dump(pdh, phdr, buf, &err)) {
switch (err) {
case WTAP_ERR_UNSUPPORTED_ENCAP:
/*
* This is a problem with the particular frame we're
* writing and the file type and subtype we're
* writing; note that, and report the frame number
* and file type/subtype.
*/
fprintf(stderr,
"editcap: Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file\n.",
read_count, argv[optind],
wtap_file_type_subtype_string(out_file_type_subtype));
break;
/* suppress duplicates by time window */
if (dup_detect_by_time) {
nstime_t current;
case WTAP_ERR_PACKET_TOO_LARGE:
/*
* This is a problem with the particular frame we're
* writing and the file type and subtype we're
* writing; note that, and report the frame number
* and file type/subtype.
*/
fprintf(stderr,
"editcap: Frame %u of \"%s\" is too large for a \"%s\" file\n.",
read_count, argv[optind],
wtap_file_type_subtype_string(out_file_type_subtype));
break;
current.secs = phdr->ts.secs;
current.nsecs = phdr->ts.nsecs;
default:
fprintf(stderr, "editcap: Error writing to %s: %s\n",
filename, wtap_strerror(err));
break;
if (is_duplicate_rel_time(buf, phdr->caplen, &current)) {
if (verbose) {
fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
count, phdr->caplen);
for (i = 0; i < 16; i++)
fprintf(stderr, "%02x",
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
fprintf(stderr, "\n");
}
duplicate_count++;
count++;
continue;
} else {
if (verbose) {
fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
count, phdr->caplen);
for (i = 0; i < 16; i++)
fprintf(stderr, "%02x",
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
fprintf(stderr, "\n");
}
}
}
exit(2);
/* Random error mutation */
if (err_prob > 0.0) {
int real_data_start = 0;
/* Protect non-protocol data */
if (wtap_file_type_subtype(wth) == WTAP_FILE_TYPE_SUBTYPE_CATAPULT_DCT2000)
real_data_start = find_dct2000_real_data(buf);
for (i = real_data_start; i < (int) phdr->caplen; i++) {
if (rand() <= err_prob * RAND_MAX) {
err_type = rand() / (RAND_MAX / ERR_WT_TOTAL + 1);
if (err_type < ERR_WT_BIT) {
buf[i] ^= 1 << (rand() / (RAND_MAX / 8 + 1));
err_type = ERR_WT_TOTAL;
} else {
err_type -= ERR_WT_BYTE;
}
if (err_type < ERR_WT_BYTE) {
buf[i] = rand() / (RAND_MAX / 255 + 1);
err_type = ERR_WT_TOTAL;
} else {
err_type -= ERR_WT_BYTE;
}
if (err_type < ERR_WT_ALNUM) {
buf[i] = ALNUM_CHARS[rand() / (RAND_MAX / ALNUM_LEN + 1)];
err_type = ERR_WT_TOTAL;
} else {
err_type -= ERR_WT_ALNUM;
}
if (err_type < ERR_WT_FMT) {
if ((unsigned int)i < phdr->caplen - 2)
g_strlcpy((char*) &buf[i], "%s", 2);
err_type = ERR_WT_TOTAL;
} else {
err_type -= ERR_WT_FMT;
}
if (err_type < ERR_WT_AA) {
for (j = i; j < (int) phdr->caplen; j++)
buf[j] = 0xAA;
i = phdr->caplen;
}
}
}
}
if (!wtap_dump(pdh, phdr, buf, &err)) {
switch (err) {
case WTAP_ERR_UNSUPPORTED_ENCAP:
/*
* This is a problem with the particular frame we're
* writing and the file type and subtype we're
* writing; note that, and report the frame number
* and file type/subtype.
*/
fprintf(stderr,
"editcap: Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file\n.",
read_count, argv[optind],
wtap_file_type_subtype_string(out_file_type_subtype));
break;
case WTAP_ERR_PACKET_TOO_LARGE:
/*
* This is a problem with the particular frame we're
* writing and the file type and subtype we're
* writing; note that, and report the frame number
* and file type/subtype.
*/
fprintf(stderr,
"editcap: Frame %u of \"%s\" is too large for a \"%s\" file\n.",
read_count, argv[optind],
wtap_file_type_subtype_string(out_file_type_subtype));
break;
default:
fprintf(stderr, "editcap: Error writing to %s: %s\n",
filename, wtap_strerror(err));
break;
}
exit(2);
}
written_count++;
}
written_count++;
count++;
}
count++;
}
g_free(fprefix);

87
file.c
View File

@ -575,6 +575,7 @@ cf_read(capture_file *cf, gboolean reloading)
{
int err;
gchar *err_info;
int rec_type;
gchar *name_ptr;
progdlg_t *progbar = NULL;
gboolean stop_flag;
@ -651,7 +652,7 @@ cf_read(capture_file *cf, gboolean reloading)
}else
progbar_quantum = 0;
while ((wtap_read(cf->wth, &err, &err_info, &data_offset))) {
while ((rec_type = wtap_read(cf->wth, &err, &err_info, &data_offset)) != -1) {
if (size >= 0) {
count++;
file_pos = wtap_read_so_far(cf->wth);
@ -701,7 +702,9 @@ cf_read(capture_file *cf, gboolean reloading)
hours even on fast machines) just to see that it was the wrong file. */
break;
}
read_packet(cf, dfcode, &edt, cinfo, data_offset);
if (rec_type == REC_TYPE_PACKET)
read_packet(cf, dfcode, &edt, cinfo, data_offset);
}
}
CATCH(OutOfMemoryError) {
@ -837,6 +840,7 @@ cf_read(capture_file *cf, gboolean reloading)
cf_read_status_t
cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
{
int rec_type;
gchar *err_info;
volatile int newly_displayed_packets = 0;
dfilter_t *dfcode;
@ -875,7 +879,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
while (to_read != 0) {
wtap_cleareof(cf->wth);
if (!wtap_read(cf->wth, err, &err_info, &data_offset)) {
if ((rec_type = wtap_read(cf->wth, err, &err_info, &data_offset)) == -1) {
break;
}
if (cf->state == FILE_READ_ABORTED) {
@ -884,8 +888,10 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
aren't any packets left to read) exit. */
break;
}
if (read_packet(cf, dfcode, &edt, (column_info *) cinfo, data_offset) != -1) {
newly_displayed_packets++;
if (rec_type == REC_TYPE_PACKET) {
if (read_packet(cf, dfcode, &edt, (column_info *) cinfo, data_offset) != -1) {
newly_displayed_packets++;
}
}
to_read--;
}
@ -959,6 +965,7 @@ cf_fake_continue_tail(capture_file *cf) {
cf_read_status_t
cf_finish_tail(capture_file *cf, int *err)
{
int rec_type;
gchar *err_info;
gint64 data_offset;
dfilter_t *dfcode;
@ -992,14 +999,15 @@ cf_finish_tail(capture_file *cf, int *err)
epan_dissect_init(&edt, cf->epan, create_proto_tree, FALSE);
while ((wtap_read(cf->wth, err, &err_info, &data_offset))) {
while ((rec_type = wtap_read(cf->wth, err, &err_info, &data_offset)) != -1) {
if (cf->state == FILE_READ_ABORTED) {
/* Well, the user decided to abort the read. Break out of the
loop, and let the code below (which is called even if there
aren't any packets left to read) exit. */
break;
}
read_packet(cf, dfcode, &edt, cinfo, data_offset);
if (rec_type == REC_TYPE_PACKET)
read_packet(cf, dfcode, &edt, cinfo, data_offset);
}
/* Cleanup and release all dfilter resources */
@ -1753,10 +1761,11 @@ cf_redissect_packets(capture_file *cf)
}
}
gboolean
int
cf_read_frame_r(capture_file *cf, const frame_data *fdata,
struct wtap_pkthdr *phdr, Buffer *buf)
{
int rec_type;
int err;
gchar *err_info;
gchar *display_basename;
@ -1768,17 +1777,19 @@ cf_read_frame_r(capture_file *cf, const frame_data *fdata,
if (!frame) {
simple_error_message_box("fdata->file_off == -1, but can't find modified frame!");
return FALSE;
return -1;
}
*phdr = frame->phdr;
buffer_assure_space(buf, frame->phdr.caplen);
memcpy(buffer_start_ptr(buf), frame->pd, frame->phdr.caplen);
return TRUE;
/* XXX - what if this isn't a packet? */
return REC_TYPE_PACKET;
}
#endif
if (!wtap_seek_read(cf->wth, fdata->file_off, phdr, buf, &err, &err_info)) {
rec_type = wtap_seek_read(cf->wth, fdata->file_off, phdr, buf, &err, &err_info);
if (rec_type == -1) {
display_basename = g_filename_display_basename(cf->filename);
switch (err) {
@ -1801,12 +1812,12 @@ cf_read_frame_r(capture_file *cf, const frame_data *fdata,
break;
}
g_free(display_basename);
return FALSE;
return -1;
}
return TRUE;
return rec_type;
}
gboolean
int
cf_read_frame(capture_file *cf, frame_data *fdata)
{
return cf_read_frame_r(cf, fdata, &cf->phdr, &cf->buf);
@ -2005,7 +2016,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
/* Frame dependencies from the previous dissection/filtering are no longer valid. */
fdata->flags.dependent_of_displayed = 0;
if (!cf_read_frame(cf, fdata))
if (cf_read_frame(cf, fdata) == -1)
break; /* error reading the frame */
/* If the previous frame is displayed, and we haven't yet seen the
@ -2332,7 +2343,7 @@ process_specified_packets(capture_file *cf, packet_range_t *range,
}
/* Get the packet */
if (!cf_read_frame_r(cf, fdata, &phdr, &buf)) {
if (cf_read_frame_r(cf, fdata, &phdr, &buf) == -1) {
/* Attempt to get the packet failed. */
ret = PSP_FAILED;
break;
@ -3109,7 +3120,7 @@ match_protocol_tree(capture_file *cf, frame_data *fdata, void *criterion)
epan_dissect_t edt;
/* Load the frame's data. */
if (!cf_read_frame(cf, fdata)) {
if (cf_read_frame(cf, fdata) == -1) {
/* Attempt to get the packet failed. */
return MR_ERROR;
}
@ -3213,7 +3224,7 @@ match_summary_line(capture_file *cf, frame_data *fdata, void *criterion)
size_t c_match = 0;
/* Load the frame's data. */
if (!cf_read_frame(cf, fdata)) {
if (cf_read_frame(cf, fdata) == -1) {
/* Attempt to get the packet failed. */
return MR_ERROR;
}
@ -3311,7 +3322,7 @@ match_narrow_and_wide(capture_file *cf, frame_data *fdata, void *criterion)
size_t c_match = 0;
/* Load the frame's data. */
if (!cf_read_frame(cf, fdata)) {
if (cf_read_frame(cf, fdata) == -1) {
/* Attempt to get the packet failed. */
return MR_ERROR;
}
@ -3359,7 +3370,7 @@ match_narrow(capture_file *cf, frame_data *fdata, void *criterion)
size_t c_match = 0;
/* Load the frame's data. */
if (!cf_read_frame(cf, fdata)) {
if (cf_read_frame(cf, fdata) == -1) {
/* Attempt to get the packet failed. */
return MR_ERROR;
}
@ -3406,7 +3417,7 @@ match_wide(capture_file *cf, frame_data *fdata, void *criterion)
size_t c_match = 0;
/* Load the frame's data. */
if (!cf_read_frame(cf, fdata)) {
if (cf_read_frame(cf, fdata) == -1) {
/* Attempt to get the packet failed. */
return MR_ERROR;
}
@ -3452,7 +3463,7 @@ match_binary(capture_file *cf, frame_data *fdata, void *criterion)
size_t c_match = 0;
/* Load the frame's data. */
if (!cf_read_frame(cf, fdata)) {
if (cf_read_frame(cf, fdata) == -1) {
/* Attempt to get the packet failed. */
return MR_ERROR;
}
@ -3522,7 +3533,7 @@ match_dfilter(capture_file *cf, frame_data *fdata, void *criterion)
match_result result;
/* Load the frame's data. */
if (!cf_read_frame(cf, fdata)) {
if (cf_read_frame(cf, fdata) == -1) {
/* Attempt to get the packet failed. */
return MR_ERROR;
}
@ -3848,7 +3859,7 @@ cf_select_packet(capture_file *cf, int row)
}
/* Get the data in that frame. */
if (!cf_read_frame (cf, fdata)) {
if (cf_read_frame (cf, fdata) == -1) {
return;
}
@ -4028,7 +4039,7 @@ cf_get_comment(capture_file *cf, const frame_data *fd)
memset(&phdr, 0, sizeof(struct wtap_pkthdr));
buffer_init(&buf, 1500);
if (!cf_read_frame_r(cf, fd, &phdr, &buf))
if (cf_read_frame_r(cf, fd, &phdr, &buf) == -1)
{ /* XXX, what we can do here? */ }
buffer_free(&buf);
@ -4322,6 +4333,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
{
const struct wtap_pkthdr *phdr;
gchar *err_info;
int rec_type;
gchar *name_ptr;
gint64 data_offset;
gint64 file_pos;
@ -4408,10 +4420,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
framenum = 0;
phdr = wtap_phdr(cf->wth);
while ((wtap_read(cf->wth, err, &err_info, &data_offset))) {
framenum++;
fdata = frame_data_sequence_find(cf->frames, framenum);
fdata->file_off = data_offset;
while ((rec_type = wtap_read(cf->wth, err, &err_info, &data_offset)) != -1) {
if (size >= 0) {
count++;
file_pos = wtap_read_so_far(cf->wth);
@ -4455,13 +4464,19 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
break;
}
/* Add this packet's link-layer encapsulation type to cf->linktypes, if
it's not already there.
XXX - yes, this is O(N), so if every packet had a different
link-layer encapsulation type, it'd be O(N^2) to read the file, but
there are probably going to be a small number of encapsulation types
in a file. */
cf_add_encapsulation_type(cf, phdr->pkt_encap);
if (rec_type == REC_TYPE_PACKET) {
framenum++;
fdata = frame_data_sequence_find(cf->frames, framenum);
fdata->file_off = data_offset;
/* Add this packet's link-layer encapsulation type to cf->linktypes, if
it's not already there.
XXX - yes, this is O(N), so if every packet had a different
link-layer encapsulation type, it'd be O(N^2) to read the file, but
there are probably going to be a small number of encapsulation types
in a file. */
cf_add_encapsulation_type(cf, phdr->pkt_encap);
}
}
/* Free the display name */

31
file.h
View File

@ -137,29 +137,30 @@ void cf_reload(capture_file *cf);
cf_read_status_t cf_read(capture_file *cf, gboolean from_save);
/**
* Read the pseudo-header and raw data for a packet. It will pop
* up an alert box if there's an error.
* Read a record from a capture file. It will pop up an alert box
* if there's an error.
*
* @param cf the capture file from which to read the packet
* @param fdata the frame_data structure for the packet in question
* @param cf the capture file from which to read the record
* @param fdata the frame_data structure for the record in question
* @param phdr pointer to a wtap_pkthdr structure to contain the
* packet's pseudo-header and other metadata
* @param buf a Buffer into which to read the packet's raw data
* @return TRUE if the read succeeded, FALSE if there was an error
* packet's pseudo-header and other metadata, if the record is a
* packet
* @param buf a Buffer into which to read the record's data
* @return record type if the read succeeded, -1 if there was an error
*/
gboolean cf_read_frame_r(capture_file *cf, const frame_data *fdata,
struct wtap_pkthdr *phdr, Buffer *buf);
int cf_read_frame_r(capture_file *cf, const frame_data *fdata,
struct wtap_pkthdr *phdr, Buffer *buf);
/**
* Read the pseudo-header and raw data for a packet into a
* capture_file structure's pseudo_header and buf members.
* Read a record from a capture file into a capture_file structure's
* pseudo_header and buf members.
* It will pop up an alert box if there's an error.
*
* @param cf the capture file from which to read the packet
* @param fdata the frame_data structure for the packet in question
* @return TRUE if the read succeeded, FALSE if there was an error
* @param cf the capture file from which to read the record
* @param fdata the frame_data structure for the record in question
* @return record type if the read succeeded, -1 if there was an error
*/
gboolean cf_read_frame(capture_file *cf, frame_data *fdata);
int cf_read_frame(capture_file *cf, frame_data *fdata);
/**
* Read packets from the "end" of a capture file.

View File

@ -57,7 +57,7 @@ frame_read(struct tvb_frame *frame_tvb, struct wtap_pkthdr *phdr, Buffer *buf)
/* XXX, what if phdr->caplen isn't equal to
* frame_tvb->tvb.length + frame_tvb->offset?
*/
if (!wtap_seek_read(frame_tvb->wth, frame_tvb->file_off, phdr, buf, &err, &err_info)) {
if (wtap_seek_read(frame_tvb->wth, frame_tvb->file_off, phdr, buf, &err, &err_info) == -1) {
switch (err) {
case WTAP_ERR_UNSUPPORTED_ENCAP:
case WTAP_ERR_BAD_FILE:

View File

@ -147,7 +147,7 @@ process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps)
/* Load the frame from the capture file */
buffer_init(&buf, 1500);
if (!cf_read_frame_r(&cfile, frame, &phdr, &buf))
if (cf_read_frame_r(&cfile, frame, &phdr, &buf) == -1)
return FALSE; /* failure */
/* Dissect the frame tree not visible */

View File

@ -103,7 +103,7 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh, Buffer *buf,
/* Re-read the first frame from the stored location */
if (!wtap_seek_read(wth, frame->offset, &phdr, buf, &err, &err_info)) {
if (wtap_seek_read(wth, frame->offset, &phdr, buf, &err, &err_info) == -1) {
if (err != 0) {
/* Print a message noting that the read failed somewhere along the line. */
fprintf(stderr,
@ -176,6 +176,7 @@ int main(int argc, char *argv[])
{
wtap *wth = NULL;
wtap_dumper *pdh = NULL;
int rec_type;
Buffer buf;
int err;
gchar *err_info;
@ -261,22 +262,24 @@ int main(int argc, char *argv[])
frames = g_ptr_array_new();
/* Read each frame from infile */
while (wtap_read(wth, &err, &err_info, &data_offset)) {
FrameRecord_t *newFrameRecord;
while ((rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1) {
if (rec_type == REC_TYPE_PACKET) {
FrameRecord_t *newFrameRecord;
phdr = wtap_phdr(wth);
phdr = wtap_phdr(wth);
newFrameRecord = g_slice_new(FrameRecord_t);
newFrameRecord->num = frames->len + 1;
newFrameRecord->offset = data_offset;
newFrameRecord->time = phdr->ts;
newFrameRecord = g_slice_new(FrameRecord_t);
newFrameRecord->num = frames->len + 1;
newFrameRecord->offset = data_offset;
newFrameRecord->time = phdr->ts;
if (prevFrame && frames_compare(&newFrameRecord, &prevFrame) < 0) {
wrong_order_count++;
if (prevFrame && frames_compare(&newFrameRecord, &prevFrame) < 0) {
wrong_order_count++;
}
g_ptr_array_add(frames, newFrameRecord);
prevFrame = newFrameRecord;
}
g_ptr_array_add(frames, newFrameRecord);
prevFrame = newFrameRecord;
}
if (err != 0) {
/* Print a message noting that the read failed somewhere along the line. */

View File

@ -1857,7 +1857,7 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
for (framenum = 1; err == 0 && framenum <= cf->count; framenum++) {
fdata = frame_data_sequence_find(cf->frames, framenum);
#if 0
if (wtap_seek_read(cf->wth, fdata->file_off,
if (local_wtap_seek_read(cf->wth, fdata->file_off,
&buf, fdata->cap_len, &err, &err_info)) {
process_packet_second_pass(cf, edt, fdata, &cf->phdr, &buf, tap_flags);
}

243
tshark.c
View File

@ -2651,11 +2651,11 @@ capture_input_new_file(capture_session *cap_session, gchar *new_file)
}
/* capture child tells us we have new packets to read */
/* capture child tells us we have new records to read */
void
capture_input_new_packets(capture_session *cap_session, int to_read)
capture_input_new_records(capture_session *cap_session, int to_read)
{
gboolean ret;
int rec_type;
int err;
gchar *err_info;
gint64 data_offset;
@ -2696,20 +2696,21 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
while (to_read-- && cf->wth) {
wtap_cleareof(cf->wth);
ret = wtap_read(cf->wth, &err, &err_info, &data_offset);
if (ret == FALSE) {
rec_type = wtap_read(cf->wth, &err, &err_info, &data_offset);
if (rec_type == -1) {
/* read from file failed, tell the capture child to stop */
sync_pipe_stop(cap_session);
wtap_close(cf->wth);
cf->wth = NULL;
} else {
ret = process_packet(cf, edt, data_offset, wtap_phdr(cf->wth),
if (rec_type == REC_TYPE_PACKET) {
if (process_packet(cf, edt, data_offset, wtap_phdr(cf->wth),
wtap_buf_ptr(cf->wth),
tap_flags);
}
if (ret != FALSE) {
/* packet successfully read and gone through the "Read Filter" */
packet_count++;
tap_flags)) {
/* packet successfully read and gone through the "Read Filter" */
packet_count++;
}
}
}
}
@ -3062,9 +3063,11 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
int snapshot_length;
wtap_dumper *pdh;
guint32 framenum;
int rec_type;
int err;
gchar *err_info = NULL;
gint64 data_offset;
gboolean packet_count_reached = FALSE;
char *save_file_string = NULL;
gboolean filtering_tap_listeners;
guint tap_flags;
@ -3191,17 +3194,19 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
edt = epan_dissect_new(cf->epan, create_proto_tree, FALSE);
}
while (wtap_read(cf->wth, &err, &err_info, &data_offset)) {
if (process_packet_first_pass(cf, edt, data_offset, wtap_phdr(cf->wth),
wtap_buf_ptr(cf->wth))) {
/* Stop reading if we have the maximum number of packets;
* When the -c option has not been used, max_packet_count
* starts at 0, which practically means, never stop reading.
* (unless we roll over max_packet_count ?)
*/
if ( (--max_packet_count == 0) || (max_byte_count != 0 && data_offset >= max_byte_count)) {
err = 0; /* This is not an error */
break;
while ((rec_type = wtap_read(cf->wth, &err, &err_info, &data_offset)) != -1) {
if (rec_type == REC_TYPE_PACKET) {
if (process_packet_first_pass(cf, edt, data_offset, wtap_phdr(cf->wth),
wtap_buf_ptr(cf->wth))) {
/* Stop reading if we have the maximum number of packets;
* When the -c option has not been used, max_packet_count
* starts at 0, which practically means, never stop reading.
* (unless we roll over max_packet_count ?)
*/
if ( (--max_packet_count == 0) || (max_byte_count != 0 && data_offset >= max_byte_count)) {
err = 0; /* This is not an error */
break;
}
}
}
}
@ -3240,55 +3245,57 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
for (framenum = 1; err == 0 && framenum <= cf->count; framenum++) {
fdata = frame_data_sequence_find(cf->frames, framenum);
if (wtap_seek_read(cf->wth, fdata->file_off, &phdr, &buf, &err,
&err_info)) {
if (process_packet_second_pass(cf, edt, fdata, &phdr, &buf,
tap_flags)) {
/* Either there's no read filtering or this packet passed the
filter, so, if we're writing to a capture file, write
this packet out. */
if (pdh != NULL) {
if (!wtap_dump(pdh, &phdr, buffer_start_ptr(&buf), &err)) {
/* Error writing to a capture file */
switch (err) {
if ((rec_type = wtap_seek_read(cf->wth, fdata->file_off, &phdr, &buf, &err,
&err_info)) == -1) {
if (rec_type == REC_TYPE_PACKET) {
if (process_packet_second_pass(cf, edt, fdata, &phdr, &buf,
tap_flags)) {
/* Either there's no read filtering or this packet passed the
filter, so, if we're writing to a capture file, write
this packet out. */
if (pdh != NULL) {
if (!wtap_dump(pdh, &phdr, buffer_start_ptr(&buf), &err)) {
/* Error writing to a capture file */
switch (err) {
case WTAP_ERR_UNSUPPORTED_ENCAP:
/*
* This is a problem with the particular frame we're writing
* and the file type and subtype we're writing; note that,
* and report the frame number and file type/subtype.
*
* XXX - framenum is not necessarily the frame number in
* the input file if there was a read filter.
*/
fprintf(stderr,
"Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file.\n",
framenum, cf->filename,
wtap_file_type_subtype_short_string(out_file_type));
break;
case WTAP_ERR_UNSUPPORTED_ENCAP:
/*
* This is a problem with the particular frame we're writing
* and the file type and subtype we're writing; note that,
* and report the frame number and file type/subtype.
*
* XXX - framenum is not necessarily the frame number in
* the input file if there was a read filter.
*/
fprintf(stderr,
"Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file.\n",
framenum, cf->filename,
wtap_file_type_subtype_short_string(out_file_type));
break;
case WTAP_ERR_PACKET_TOO_LARGE:
/*
* This is a problem with the particular frame we're writing
* and the file type and subtype we're writing; note that,
* and report the frame number and file type/subtype.
*
* XXX - framenum is not necessarily the frame number in
* the input file if there was a read filter.
*/
fprintf(stderr,
"Frame %u of \"%s\" is too large for a \"%s\" file.\n",
framenum, cf->filename,
wtap_file_type_subtype_short_string(out_file_type));
break;
case WTAP_ERR_PACKET_TOO_LARGE:
/*
* This is a problem with the particular frame we're writing
* and the file type and subtype we're writing; note that,
* and report the frame number and file type/subtype.
*
* XXX - framenum is not necessarily the frame number in
* the input file if there was a read filter.
*/
fprintf(stderr,
"Frame %u of \"%s\" is too large for a \"%s\" file.\n",
framenum, cf->filename,
wtap_file_type_subtype_short_string(out_file_type));
break;
default:
show_capture_file_io_error(save_file, err, FALSE);
break;
default:
show_capture_file_io_error(save_file, err, FALSE);
break;
}
wtap_dump_close(pdh, &err);
g_free(shb_hdr);
exit(2);
}
wtap_dump_close(pdh, &err);
g_free(shb_hdr);
exit(2);
}
}
}
@ -3321,60 +3328,72 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
edt = epan_dissect_new(cf->epan, create_proto_tree, print_packet_info && print_details);
}
while (wtap_read(cf->wth, &err, &err_info, &data_offset)) {
framenum++;
while ((rec_type = wtap_read(cf->wth, &err, &err_info, &data_offset)) != -1) {
if (rec_type == REC_TYPE_PACKET) {
framenum++;
if (process_packet(cf, edt, data_offset, wtap_phdr(cf->wth),
wtap_buf_ptr(cf->wth),
tap_flags)) {
/* Either there's no read filtering or this packet passed the
filter, so, if we're writing to a capture file, write
this packet out. */
if (pdh != NULL) {
if (!wtap_dump(pdh, wtap_phdr(cf->wth), wtap_buf_ptr(cf->wth), &err)) {
/* Error writing to a capture file */
switch (err) {
if (process_packet(cf, edt, data_offset, wtap_phdr(cf->wth),
wtap_buf_ptr(cf->wth),
tap_flags)) {
/* Either there's no read filtering or this packet passed the
filter, so, if we're writing to a capture file, write
this packet out. */
if (pdh != NULL) {
if (!wtap_dump(pdh, wtap_phdr(cf->wth), wtap_buf_ptr(cf->wth), &err)) {
/* Error writing to a capture file */
switch (err) {
case WTAP_ERR_UNSUPPORTED_ENCAP:
/*
* This is a problem with the particular frame we're writing
* and the file type and subtype we're writing; note that,
* and report the frame number and file type/subtype.
*/
fprintf(stderr,
"Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file.\n",
framenum, cf->filename,
wtap_file_type_subtype_short_string(out_file_type));
break;
case WTAP_ERR_UNSUPPORTED_ENCAP:
/*
* This is a problem with the particular frame we're writing
* and the file type and subtype we're writing; note that,
* and report the frame number and file type/subtype.
*/
fprintf(stderr,
"Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file.\n",
framenum, cf->filename,
wtap_file_type_subtype_short_string(out_file_type));
break;
case WTAP_ERR_PACKET_TOO_LARGE:
/*
* This is a problem with the particular frame we're writing
* and the file type and subtype we're writing; note that,
* and report the frame number and file type/subtype.
*/
fprintf(stderr,
"Frame %u of \"%s\" is too large for a \"%s\" file.\n",
framenum, cf->filename,
wtap_file_type_subtype_short_string(out_file_type));
break;
case WTAP_ERR_PACKET_TOO_LARGE:
/*
* This is a problem with the particular frame we're writing
* and the file type and subtype we're writing; note that,
* and report the frame number and file type/subtype.
*/
fprintf(stderr,
"Frame %u of \"%s\" is too large for a \"%s\" file.\n",
framenum, cf->filename,
wtap_file_type_subtype_short_string(out_file_type));
break;
default:
show_capture_file_io_error(save_file, err, FALSE);
break;
default:
show_capture_file_io_error(save_file, err, FALSE);
break;
}
wtap_dump_close(pdh, &err);
g_free(shb_hdr);
exit(2);
}
wtap_dump_close(pdh, &err);
g_free(shb_hdr);
exit(2);
}
}
/* If we're supposed to stop after max_packet_count packets,
* count this packet.
* When the -c option has not been used, max_packet_count
* starts at 0.
*/
if (max_packet_count != 0) {
max_packet_count--;
if (max_packet_count == 0)
packet_count_reached = TRUE;
}
}
/* Stop reading if we have the maximum number of packets;
* When the -c option has not been used, max_packet_count
* starts at 0, which practically means, never stop reading.
* (unless we roll over max_packet_count ?)
/* Stop reading if we have the maximum number of packets or the
* maximum file size.
*/
if ( (--max_packet_count == 0) || (max_byte_count != 0 && data_offset >= max_byte_count)) {
if ( packet_count_reached || (max_byte_count != 0 && data_offset >= max_byte_count)) {
err = 0; /* This is not an error */
break;
}

View File

@ -173,6 +173,7 @@ preview_set_filename(GtkWidget *prev, const gchar *cf_name)
static void
preview_do(GtkWidget *prev, wtap *wth)
{
int rec_type;
GtkWidget *label;
unsigned int elapsed_time;
time_t time_preview;
@ -183,6 +184,7 @@ preview_do(GtkWidget *prev, wtap *wth)
double start_time = 0; /* seconds, with nsec resolution */
double stop_time = 0; /* seconds, with nsec resolution */
double cur_time;
unsigned int records = 0;
unsigned int packets = 0;
gboolean is_breaked = FALSE;
gchar string_buff[PREVIEW_STR_MAX];
@ -192,22 +194,25 @@ preview_do(GtkWidget *prev, wtap *wth)
time(&time_preview);
while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) {
phdr = wtap_phdr(wth);
cur_time = nstime_to_sec(&phdr->ts);
if (packets == 0) {
start_time = cur_time;
stop_time = cur_time;
}
if (cur_time < start_time) {
start_time = cur_time;
}
if (cur_time > stop_time) {
stop_time = cur_time;
}
while ( (rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1 ) {
if (rec_type == REC_TYPE_PACKET) {
phdr = wtap_phdr(wth);
cur_time = nstime_to_sec(&phdr->ts);
if (packets == 0) {
start_time = cur_time;
stop_time = cur_time;
}
if (cur_time < start_time) {
start_time = cur_time;
}
if (cur_time > stop_time) {
stop_time = cur_time;
}
packets++;
if (packets%1000 == 0) {
packets++;
}
records++;
if (records%1000 == 0) {
/* do we have a timeout? */
time(&time_current);
if (time_current-time_preview >= (time_t) prefs.gui_fileopen_preview) {

View File

@ -3711,7 +3711,7 @@ void iax2_analysis_cb(GtkAction *action _U_, gpointer user_data _U_)
return; /* if we exit here it's an error */
/* dissect the current frame */
if (!cf_read_frame(cf, fdata))
if (cf_read_frame(cf, fdata) == -1)
return; /* error reading the frame */
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
epan_dissect_prime_dfilter(&edt, sfcode);

View File

@ -543,7 +543,7 @@ get_ip_address_list_from_packet_list_row(gpointer data)
if (fdata != NULL) {
epan_dissect_t edt;
if (!cf_read_frame (&cfile, fdata))
if (cf_read_frame (&cfile, fdata) == -1)
return NULL; /* error reading the frame */
epan_dissect_init(&edt, cfile.epan, FALSE, FALSE);
@ -584,7 +584,7 @@ get_filter_from_packet_list_row_and_column(gpointer data)
if (fdata != NULL) {
epan_dissect_t edt;
if (!cf_read_frame(&cfile, fdata))
if (cf_read_frame(&cfile, fdata) == -1)
return NULL; /* error reading the frame */
/* proto tree, visible. We need a proto tree if there's custom columns */
epan_dissect_init(&edt, cfile.epan, have_custom_cols(&cfile.cinfo), FALSE);

View File

@ -1117,7 +1117,7 @@ packet_list_dissect_and_cache_record(PacketList *packet_list, PacketListRecord *
cinfo = NULL;
buffer_init(&buf, 1500);
if (!cf_read_frame_r(&cfile, fdata, &phdr, &buf)) {
if (cf_read_frame_r(&cfile, fdata, &phdr, &buf) == -1) {
/*
* Error reading the frame.
*

View File

@ -961,7 +961,7 @@ void new_packet_window(GtkWidget *w _U_, gboolean reference, gboolean editable _
}
/* With the new packetlists "lazy columns" it's necessary to reread the frame */
if (!cf_read_frame(&cfile, fd)) {
if (cf_read_frame(&cfile, fd) == -1) {
/* error reading the frame */
return;
}

View File

@ -903,7 +903,7 @@ static rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf, struct segment
}
/* dissect the current frame */
if (!cf_read_frame(cf, fdata)) {
if (cf_read_frame(cf, fdata) == -1) {
return NULL; /* error reading the frame */
}

View File

@ -3946,7 +3946,7 @@ rtp_analysis_cb(GtkAction *action _U_, gpointer user_data _U_)
return; /* if we exit here it's an error */
/* dissect the current frame */
if (!cf_read_frame(cf, fdata))
if (cf_read_frame(cf, fdata) == -1)
return; /* error reading the frame */
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
epan_dissect_prime_dfilter(&edt, sfcode);

View File

@ -975,7 +975,7 @@ sctp_analyse_cb(struct sctp_analyse *u_data, gboolean ext)
return; /* if we exit here it's an error */
/* dissect the current frame */
if (!cf_read_frame(cf, fdata))
if (cf_read_frame(cf, fdata) == -1)
return; /* error reading the frame */
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);

View File

@ -736,11 +736,13 @@ void CaptureFileDialog::preview(const QString & path)
wtap *wth;
int err = 0;
gchar *err_info;
int rec_type;
gint64 data_offset;
const struct wtap_pkthdr *phdr;
double start_time = 0; /* seconds, with nsec resolution */
double stop_time = 0; /* seconds, with nsec resolution */
double cur_time;
unsigned int records = 0;
unsigned int packets = 0;
bool timed_out = FALSE;
time_t time_preview;
@ -792,22 +794,25 @@ void CaptureFileDialog::preview(const QString & path)
preview_size_.setText(QString(tr("%1 bytes")).arg(wtap_file_size(wth, &err)));
time(&time_preview);
while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) {
phdr = wtap_phdr(wth);
cur_time = nstime_to_sec(&phdr->ts);
if(packets == 0) {
start_time = cur_time;
stop_time = cur_time;
}
if (cur_time < start_time) {
start_time = cur_time;
}
if (cur_time > stop_time){
stop_time = cur_time;
}
while ( (rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1 ) {
if (rec_type == REC_TYPE_PACKET) {
phdr = wtap_phdr(wth);
cur_time = nstime_to_sec(&phdr->ts);
if(packets == 0) {
start_time = cur_time;
stop_time = cur_time;
}
if (cur_time < start_time) {
start_time = cur_time;
}
if (cur_time > stop_time){
stop_time = cur_time;
}
packets++;
if(packets%1000 == 0) {
packets++;
}
records++;
if(records%1000 == 0) {
/* do we have a timeout? */
time(&time_current);
if(time_current-time_preview >= (time_t) prefs.gui_fileopen_preview) {

View File

@ -655,7 +655,7 @@ QString &PacketList::getFilterFromRowAndColumn()
if (fdata != NULL) {
epan_dissect_t edt;
if (!cf_read_frame(cap_file_, fdata))
if (cf_read_frame(cap_file_, fdata) == -1)
return filter; /* error reading the frame */
/* proto tree, visible. We need a proto tree if there's custom columns */
epan_dissect_init(&edt, cap_file_->epan, have_custom_cols(&cap_file_->cinfo), FALSE);

View File

@ -221,7 +221,7 @@ QVariant PacketListModel::data(const QModelIndex &index, int role) const
memset(&phdr, 0, sizeof(struct wtap_pkthdr));
buffer_init(&buf, 1500);
if (!cap_file_ || !cf_read_frame_r(cap_file_, fdata, &phdr, &buf)) {
if (!cap_file_ || cf_read_frame_r(cap_file_, fdata, &phdr, &buf) == -1) {
/*
* Error reading the frame.
*

View File

@ -305,7 +305,7 @@ select_tcpip_session(capture_file *cf, struct segment *hdrs)
}
/* dissect the current frame */
if (!cf_read_frame(cf, fdata))
if (cf_read_frame(cf, fdata) == -1)
return NULL; /* error reading the frame */

View File

@ -1119,8 +1119,10 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
int err = 0;
gchar *err_info;
TCHAR string_buff[PREVIEW_STR_MAX];
int rec_type;
gint64 data_offset;
guint packet = 0;
guint records = 0;
guint packets = 0;
gint64 filesize;
time_t ti_time;
struct tm *ti_tm;
@ -1186,21 +1188,24 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
SetWindowText(cur_ctrl, string_buff);
time(&time_preview);
while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) {
phdr = wtap_phdr(wth);
cur_time = nstime_to_sec( (const nstime_t *) &phdr->ts );
if(packet == 0) {
start_time = cur_time;
stop_time = cur_time;
while ( (rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1 ) {
if (rec_type == REC_TYPE_PACKET) {
phdr = wtap_phdr(wth);
cur_time = nstime_to_sec( (const nstime_t *) &phdr->ts );
if(packets == 0) {
start_time = cur_time;
stop_time = cur_time;
}
if (cur_time < start_time) {
start_time = cur_time;
}
if (cur_time > stop_time){
stop_time = cur_time;
}
packets++;
}
if (cur_time < start_time) {
start_time = cur_time;
}
if (cur_time > stop_time){
stop_time = cur_time;
}
packet++;
if(packet%100 == 0) {
records++;
if(records%100 == 0) {
time(&time_current);
if(time_current-time_preview >= (time_t) prefs.gui_fileopen_preview) {
is_breaked = TRUE;
@ -1210,7 +1215,7 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
}
if(err != 0) {
StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("error after reading %u packets"), packet);
StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("error after reading %u packets"), packets);
cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_PACKETS);
SetWindowText(cur_ctrl, string_buff);
wtap_close(wth);
@ -1219,9 +1224,9 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
/* Packets */
if(is_breaked) {
StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("more than %u packets (preview timeout)"), packet);
StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("more than %u packets (preview timeout)"), packets);
} else {
StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%u"), packet);
StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%u"), packets);
}
cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_PACKETS);
SetWindowText(cur_ctrl, string_buff);

View File

@ -99,9 +99,9 @@ typedef struct
#define CST_5VW_CAPTURES_RECORD (CST_5VW_SECTION_CAPTURES << 28) /* 0x80000000 */
#define CST_5VW_SYSTEM_RECORD 0x00000000U
static gboolean _5views_read(wtap *wth, int *err, gchar **err_info,
static int _5views_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean _5views_seek_read(wtap *wth, gint64 seek_off,
static int _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 gboolean
static int
_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 FALSE;
return -1;
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 FALSE;
return -1;
} while (1);
if (wth->phdr.caplen > WTAP_MAX_PACKET_SIZE) {
@ -231,11 +231,13 @@ _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 FALSE;
return -1;
}
return wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
wth->phdr.caplen, err, err_info);
if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
wth->phdr.caplen, err, err_info))
return -1;
return REC_TYPE_PACKET;
}
static gboolean
@ -245,7 +247,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 FALSE;
return -1;
/*
* Read the header.
@ -254,14 +256,16 @@ _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 FALSE;
return -1;
}
/*
* Read the packet data.
*/
return wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen,
err, err_info);
if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen,
err, err_info))
return -1;
return REC_TYPE_PACKET;
}
/* Read the header of the next packet. Return TRUE on success, FALSE

View File

@ -112,9 +112,9 @@ typedef struct {
time_t start;
} aethra_t;
static gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
static int aethra_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean aethra_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
static int aethra_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
struct aethrarec_hdr hdr;
@ -196,7 +196,7 @@ static gboolean 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 FALSE;
return -1;
/*
* XXX - if this is big, we might waste memory by
@ -205,7 +205,7 @@ static gboolean 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 FALSE; /* Read error */
return -1; /* Read error */
}
#if 0
packet++;
@ -270,32 +270,32 @@ packet, hdr.rec_type, wth->phdr.caplen, hdr.flags);
}
found:
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean
static int
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 FALSE;
return -1;
if (!aethra_read_rec_header(wth, wth->random_fh, &hdr, phdr, err,
err_info)) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
return -1;
}
/*
* Read the packet data.
*/
if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err, err_info))
return FALSE; /* failed */
return -1; /* failed */
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean

View File

@ -74,9 +74,9 @@ static const ascend_magic_string ascend_magic[] = {
{ ASCEND_PFX_ETHER, "ETHER" },
};
static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
static int ascend_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
static int 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 FALSE;
return -1;
offset = ascend_seek(wth, err, err_info);
if (offset == -1)
return FALSE;
return -1;
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 FALSE;
return -1;
}
*data_offset = offset;
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
static int 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 FALSE;
return -1;
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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}

View File

@ -38,14 +38,14 @@
#define BER_UNI_TAG_SEQ 16 /* SEQUENCE, SEQUENCE OF */
#define BER_UNI_TAG_SET 17 /* SET, SET OF */
static gboolean ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
Buffer *buf, int *err, gchar **err_info)
static int 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 FALSE;
return -1;
if (file_size > WTAP_MAX_PACKET_SIZE) {
/*
@ -55,7 +55,7 @@ static gboolean 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 FALSE;
return -1;
}
packet_size = (int)file_size;
@ -67,10 +67,12 @@ static gboolean ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
phdr->ts.secs = 0;
phdr->ts.nsecs = 0;
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
return -1;
return REC_TYPE_PACKET;
}
static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
static int ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
gint64 offset;
@ -80,24 +82,24 @@ static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
/* there is only ever one packet */
if (offset != 0)
return FALSE;
return -1;
*data_offset = offset;
return ber_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
}
static gboolean ber_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr _U_,
Buffer *buf, int *err, gchar **err_info)
static int 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 FALSE;
return -1;
}
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
return -1;
return ber_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
}

View File

@ -73,11 +73,11 @@ struct btsnooprec_hdr {
static const gint64 KUnixTimeBase = G_GINT64_CONSTANT(0x00dcddb30f2f8000); /* offset from symbian - unix time */
static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
static int btsnoop_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
static int btsnoop_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
static int 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 gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
static int btsnoop_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
@ -169,16 +169,16 @@ static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
err, err_info);
}
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
static int 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 FALSE;
return -1;
return btsnoop_read_record(wth, wth->random_fh, phdr, buf, err, err_info);
}
static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
static int 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 gboolean 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 FALSE;
return -1;
}
packet_size = g_ntohl(hdr.incl_len);
@ -210,7 +210,7 @@ static gboolean 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 FALSE;
return -1;
}
ts = GINT64_FROM_BE(hdr.ts_usec);
@ -248,7 +248,9 @@ static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
/* Read packet data. */
return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info);
if (!wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info))
return -1;
return REC_TYPE_PACKET;
}
/* Returns 0 if we could write the specified encapsulation type,

View File

@ -256,7 +256,7 @@ create_pseudo_hdr(guint8 *buf, guint8 dat_trans_type, guint16 dat_len)
}
static gboolean
static int
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 FALSE;
return -1;
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 FALSE;
return -1;
}
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 FALSE;
return -1;
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 TRUE;
return REC_TYPE_PACKET;
}
static gboolean
static int
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 gboolean
static int
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 FALSE;
return -1;
return camins_read_packet(wth->random_fh, pkthdr, buf, err, err_info);
}

View File

@ -103,12 +103,12 @@ static const gchar catapult_dct2000_magic[] = "Session Transcript";
/************************************************************/
/* Functions called from wiretap core */
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 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 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 TRUE and details if found */
/* - return REC_TYPE_PACKET and details if found */
/**************************************************/
static gboolean
static int
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 FALSE; /* error */
return -1; /* 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 TRUE;
return REC_TYPE_PACKET;
}
}
/* No packet details to return... */
return FALSE;
return -1;
}
/**************************************************/
/* Read & seek function. */
/**************************************************/
static gboolean
static int
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 FALSE;
return -1;
}
/* Re-read whole line (this really should succeed) */
if (!read_new_line(wth->random_fh, &offset, &length, linebuff,
sizeof linebuff, err, err_info)) {
return FALSE;
return -1;
}
/* 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 TRUE;
return REC_TYPE_PACKET;
}
/* 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 FALSE;
return -1;
}

View File

@ -78,11 +78,11 @@ typedef struct commview_header {
#define MEDIUM_WIFI 1
#define MEDIUM_TOKEN_RING 2
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 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_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 FALSE;
return -1;
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 FALSE;
return -1;
}
tm.tm_year = cv_hdr.year - 1900;
@ -181,10 +181,12 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
phdr->ts.secs = mktime(&tm);
phdr->ts.nsecs = cv_hdr.usecs * 1000;
return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info);
if (!wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info))
return -1;
return REC_TYPE_PACKET;
}
static gboolean
static int
commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
@ -193,12 +195,12 @@ commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
err_info);
}
static gboolean
static int
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 FALSE;
return -1;
return commview_read_packet(wth->random_fh, phdr, buf, err, err_info);
}

View File

@ -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 gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
static int cosine_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean cosine_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr,
static int 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 gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
static int cosine_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
gint64 offset;
@ -296,13 +296,13 @@ static gboolean 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 FALSE;
return -1;
*data_offset = offset;
/* Parse the header */
pkt_len = parse_cosine_rec_hdr(&wth->phdr, line, err, err_info);
if (pkt_len == -1)
return FALSE;
return -1;
/* Convert the ASCII hex dump to binary data */
return parse_cosine_hex_dump(wth->fh, &wth->phdr, pkt_len,
@ -310,7 +310,7 @@ static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
}
/* Used to read packets in random-access fashion */
static gboolean
static int
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 TRUE on success,
FALSE if any error is encountered. */
static gboolean
/* Converts ASCII hex dump to binary data. Returns REC_TYPE_PACKET on success,
-1 if any error is encountered. */
static int
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
caplen += n;
}
phdr->caplen = caplen;
return TRUE;
return REC_TYPE_PACKET;
}

View File

@ -44,9 +44,9 @@ typedef struct {
gboolean byteswapped;
} csids_t;
static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
static int csids_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean csids_seek_read(wtap *wth, gint64 seek_off,
static int 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,19 +144,21 @@ int csids_open(wtap *wth, int *err, gchar **err_info)
}
/* Find the next packet and parse it; called from wtap_read(). */
static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
static int 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);
return csids_read_packet( wth->fh, csids, &wth->phdr, wth->frame_buffer,
err, err_info );
if (!csids_read_packet( wth->fh, csids, &wth->phdr, wth->frame_buffer,
err, err_info ))
return -1;
return REC_TYPE_PACKET;
}
/* Used to read packets in random-access fashion */
static gboolean
static int
csids_seek_read(wtap *wth,
gint64 seek_off,
struct wtap_pkthdr *phdr,
@ -167,14 +169,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 FALSE;
return -1;
if( !csids_read_packet( wth->random_fh, csids, phdr, buf, err, err_info ) ) {
if( *err == 0 )
*err = WTAP_ERR_SHORT_READ;
return FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean

View File

@ -77,16 +77,16 @@ static const char daintree_magic_text[] =
#define COMMENT_LINE daintree_magic_text[0]
static gboolean daintree_sna_read(wtap *wth, int *err, gchar **err_info,
static int daintree_sna_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean daintree_sna_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean daintree_sna_process_hex_data(struct wtap_pkthdr *phdr,
static int 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 gboolean
static int
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 FALSE; /* all done */
return -1; /* 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 FALSE;
return -1;
/* 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 gboolean
static int
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 FALSE;
return -1;
/* 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 FALSE; /* all done */
return -1; /* 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 FALSE;
return -1;
/* 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 gboolean
static int
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
phdr->caplen = bytes;
buffer_assure_space(buf, bytes);
memcpy(buffer_start_ptr(buf), readData, bytes);
return TRUE;
return REC_TYPE_PACKET;
}

View File

@ -84,11 +84,11 @@ static const char dbs_etherwatch_rec_magic[] =
*/
#define DBS_ETHERWATCH_MAX_PACKET_LEN 16384
static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
static int dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
static gboolean parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh,
static int 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 gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
gint64 offset;
@ -204,7 +204,7 @@ static gboolean 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 FALSE;
return -1;
*data_offset = offset;
/* Parse the packet */
@ -213,12 +213,12 @@ static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
}
/* Used to read packets in random-access fashion */
static gboolean
static int
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 FALSE;
return -1;
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 gboolean
static int
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 FALSE;
return -1;
}
/* 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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
/* 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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
/* 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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
/* 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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
}
return TRUE;
return REC_TYPE_PACKET;
}
/* Parse a hex dump line */

View File

@ -73,9 +73,9 @@ static const char dct3trace_magic_end[] = "</dump>";
#define MAX_PACKET_LEN 23
static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
static int dct3trace_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
static int 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 gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
{
/* Return on end of file </dump> */
*err = 0;
return FALSE;
return -1;
}
else if( memcmp(dct3trace_magic_record_end, line, strlen(dct3trace_magic_record_end)) == 0 )
{
@ -222,14 +222,14 @@ static gboolean 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 TRUE;
return REC_TYPE_PACKET;
}
else
{
/* If not got any data return error */
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("dct3trace: record without data");
return FALSE;
return -1;
}
}
else if( memcmp(dct3trace_magic_record_start, line, strlen(dct3trace_magic_record_start)) == 0 )
@ -282,7 +282,7 @@ static gboolean 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 FALSE;
return -1;
}
}
}
@ -322,7 +322,7 @@ static gboolean 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 FALSE;
return -1;
}
len += data_len;
@ -336,17 +336,17 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
{
*err = WTAP_ERR_SHORT_READ;
}
return FALSE;
return -1;
baddata:
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("dct3trace: record missing mandatory attributes");
return FALSE;
return -1;
}
/* Find the next packet and parse it; called from wtap_read(). */
static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
static int dct3trace_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
@ -357,12 +357,12 @@ static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
/* Used to read packets in random-access fashion */
static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off,
static int 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 FALSE;
return -1;
}
return dct3trace_get_packet(wth->random_fh, phdr, buf, err, err_info);

View File

@ -64,11 +64,11 @@ static int erf_read_header(FILE_T fh,
gchar **err_info,
guint32 *bytes_read,
guint32 *packet_size);
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 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 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 gboolean erf_read(wtap *wth, int *err, gchar **err_info,
static int erf_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
erf_header_t erf_header;
@ -292,36 +292,38 @@ static gboolean 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 FALSE;
return -1;
}
if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer, packet_size,
err, err_info))
return FALSE;
return -1;
} while ( erf_header.type == ERF_TYPE_PAD );
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean erf_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr, Buffer *buf,
int *err, gchar **err_info)
static int 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 FALSE;
return -1;
do {
if (!erf_read_header(wth->random_fh, phdr, &erf_header,
err, err_info, NULL, &packet_size))
return FALSE;
return -1;
} while ( erf_header.type == ERF_TYPE_PAD );
return wtap_read_packet_bytes(wth->random_fh, buf, packet_size,
err, err_info);
if (!wtap_read_packet_bytes(wth->random_fh, buf, packet_size,
err, err_info))
return -1;
return REC_TYPE_PACKET;
}
static int erf_read_header(FILE_T fh,

View File

@ -90,9 +90,9 @@ static const unsigned char eyesdn_hdr_magic[] =
*/
#define EYESDN_MAX_PACKET_LEN 16384
static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
static int eyesdn_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean eyesdn_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
static int eyesdn_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
gint64 offset;
@ -157,7 +157,7 @@ static gboolean 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 FALSE;
return -1;
*data_offset = offset;
/* Parse the record */
@ -166,18 +166,18 @@ static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
}
/* Used to read packets in random-access fashion */
static gboolean
static int
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 FALSE;
return -1;
return read_eyesdn_rec(wth->random_fh, phdr, buf, err, err_info);
}
/* Parses a record. */
static gboolean
static int
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 FALSE;
return -1;
}
/* 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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
if (file_seek(fh, cur_off, SEEK_SET, err) == -1)
return FALSE;
return -1;
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;;
}

View File

@ -34,7 +34,7 @@ struct dump_hdr {
#define DUMP_HDR_SIZE (sizeof(struct dump_hdr))
static gboolean hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr,
static int 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 gboolean 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 FALSE;
return -1;
}
packet_size = GUINT16_FROM_LE(dh.len);
@ -57,7 +57,7 @@ static gboolean 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 FALSE;
return -1;
}
phdr->presence_flags = WTAP_HAS_TS;
@ -68,10 +68,12 @@ static gboolean hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr,
phdr->pseudo_header.p2p.sent = (dh.in ? FALSE : TRUE);
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
return -1;
return REC_TYPE_PACKET;
}
static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info,
static int hcidump_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
@ -80,11 +82,11 @@ static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info,
err, err_info);
}
static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off,
static int 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 FALSE;
return -1;
return hcidump_process_packet(wth->random_fh, phdr, buf, err, err_info);
}

View File

@ -33,11 +33,11 @@ typedef struct {
gboolean byte_swapped;
} i4btrace_t;
static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
static int i4btrace_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off,
static int i4btrace_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
static int i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
static gboolean i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
Buffer *buf, int *err, gchar **err_info);
/*
@ -110,21 +110,23 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info)
}
/* Read the next packet */
static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
static int i4btrace_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
return i4b_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer,
err, err_info);
if (!i4b_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer,
err, err_info))
return -1;
return REC_TYPE_PACKET;
}
static gboolean
static int
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 FALSE;
return -1;
if (!i4b_read_rec(wth, wth->random_fh, phdr, buf, err, err_info)) {
/* Read error or EOF */
@ -132,12 +134,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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
static int
static gboolean
i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
int *err, gchar **err_info)
{

View File

@ -85,10 +85,10 @@
#define RECORDS_FOR_IPFIX_CHECK 20
static gboolean
static int
ipfix_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean
static int
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 gboolean
static int
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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
/* classic wtap: seek to file position and read packet */
static gboolean
static int
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 FALSE; /* Seek error */
return -1; /* 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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}

View File

@ -214,7 +214,7 @@ iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
}
/* Read the next packet */
static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
static int 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 gboolean 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 FALSE;
return -1;
}
/* If the per-file encapsulation isn't known, set it to this
@ -239,22 +239,22 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
wth->file_encap = WTAP_ENCAP_PER_PACKET;
}
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
static int 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 FALSE;
return -1;
/* 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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
/***********************************************************
@ -409,7 +409,7 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
}
/* Read the next packet */
static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
static int 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 gboolean 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 FALSE;
return -1;
}
/* If the per-file encapsulation isn't known, set it to this
@ -434,22 +434,22 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
wth->file_encap = WTAP_ENCAP_PER_PACKET;
}
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
static int 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 FALSE;
return -1;
/* 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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
static int

View File

@ -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 gboolean iseries_parse_packet (wtap * wth, FILE_T fh,
struct wtap_pkthdr *phdr,
Buffer * buf, 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 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 gboolean
static int
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 gboolean
static int
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 FALSE;
return -1;
/*
* Parse the packet and extract the various fields
@ -554,7 +554,7 @@ done:
}
/* Parses a packet. */
static gboolean
static int
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 FALSE;
return -1;
}
/* 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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
continue;
}
@ -769,7 +769,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
if (ascii_offset == -1)
{
/* Bad line. */
return FALSE;
return -1;
}
continue;
}
@ -792,7 +792,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
if (ascii_offset == -1)
{
/* Bad line. */
return FALSE;
return -1;
}
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 TRUE;
return REC_TYPE_PACKET;
errxit:
g_free (ascii_buf);
return FALSE;
return -1;
}
/*

View File

@ -623,7 +623,7 @@ process_packet_data(struct wtap_pkthdr *phdr, Buffer *target, guint8 *buffer,
phdr->pseudo_header.k12.stuff = k12;
}
static gboolean k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) {
static int 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 gboolean k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
if (len < 0) {
/* read error */
return FALSE;
return -1;
} else if (len == 0) {
/* EOF */
*err = 0;
return FALSE;
return -1;
} 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 FALSE;
return -1;
}
buffer = k12->seq_read_buff;
@ -681,11 +681,11 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
process_packet_data(&wth->phdr, wth->frame_buffer, buffer, len, k12);
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) {
static int 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 gboolean k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *ph
if ( file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
K12_DBG(5,("k12_seek_read: SEEK ERROR"));
return FALSE;
return -1;
}
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 FALSE;
return -1;
} 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 FALSE;
return -1;
}
buffer = k12->rand_read_buff;
@ -714,7 +714,7 @@ static gboolean k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *ph
K12_DBG(5,("k12_seek_read: DONE OK"));
return TRUE;
return REC_TYPE_PACKET;
}

View File

@ -244,7 +244,7 @@ k12text_reset(FILE_T fh)
ii=0;
}
static gboolean
static int
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
*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 TRUE;
return REC_TYPE_PACKET;
}
static gboolean
static int
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
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 TRUE;
return REC_TYPE_PACKET;
}
int

View File

@ -270,9 +270,9 @@ typedef struct {
time_t start;
} lanalyzer_t;
static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
static int lanalyzer_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
static int 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,30 +560,32 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
}
/* Read the next packet */
static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
static int lanalyzer_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
/* Read the record */
return lanalyzer_read_trace_record(wth, wth->fh, &wth->phdr,
wth->frame_buffer, err, err_info);
if (!lanalyzer_read_trace_record(wth, wth->fh, &wth->phdr,
wth->frame_buffer, err, err_info))
return -1;
return REC_TYPE_PACKET;
}
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
static int 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 FALSE;
return -1;
/* 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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
/*---------------------------------------------------

View File

@ -63,9 +63,9 @@ typedef enum {
} libpcap_try_t;
static libpcap_try_t libpcap_try(wtap *wth, int *err);
static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
static int libpcap_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean libpcap_seek_read(wtap *wth, gint64 seek_off,
static int 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,13 +590,15 @@ static libpcap_try_t libpcap_try(wtap *wth, int *err)
}
/* Read the next packet */
static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
static int libpcap_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
return libpcap_read_packet(wth, wth->fh, &wth->phdr,
wth->frame_buffer, err, err_info);
if (!libpcap_read_packet(wth, wth->fh, &wth->phdr,
wth->frame_buffer, err, err_info))
return -1;
return REC_TYPE_PACKET;
}
static gboolean
@ -604,15 +606,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 FALSE;
return -1;
if (!libpcap_read_packet(wth, wth->random_fh, phdr, buf, err,
err_info)) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean

View File

@ -214,29 +214,31 @@ static gboolean logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh,
return TRUE;
}
static gboolean logcat_read(wtap *wth, int *err, gchar **err_info,
static int logcat_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
return logcat_read_packet((struct logcat_phdr *) wth->priv, wth->fh,
&wth->phdr, wth->frame_buffer, err, err_info);
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;
}
static gboolean logcat_seek_read(wtap *wth, gint64 seek_off,
static int 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 FALSE;
return -1;
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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
int logcat_open(wtap *wth, int *err, gchar **err_info _U_)

View File

@ -94,7 +94,7 @@ static const mime_files_t magic_files[] = {
*/
#define MAX_FILE_SIZE (16*1024*1024)
static gboolean
static int
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 FALSE;
return -1;
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 FALSE;
return -1;
}
packet_size = (int)file_size;
@ -124,10 +124,12 @@ mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
phdr->ts.secs = 0;
phdr->ts.nsecs = 0;
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
return -1;
return REC_TYPE_PACKET;
}
static gboolean
static int
mime_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
gint64 offset;
@ -138,24 +140,24 @@ mime_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
/* there is only ever one packet */
if (offset != 0)
return FALSE;
return -1;
*data_offset = offset;
return mime_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
}
static gboolean
static int
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 FALSE;
return -1;
}
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
return -1;
return mime_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
}

View File

@ -102,7 +102,7 @@ mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, gint64 offset,
return TRUE;
}
static gboolean
static int
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 FALSE;
return -1;
}
/* 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 FALSE;
return -1;
}
}
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean
static int
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
int

View File

@ -220,30 +220,32 @@ mpeg_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
return TRUE;
}
static gboolean
static int
mpeg_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
return mpeg_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer,
FALSE, err, err_info);
if (!mpeg_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer,
FALSE, err, err_info))
return -1;
return REC_TYPE_PACKET;
}
static gboolean
static int
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 FALSE;
return -1;
if (!mpeg_read_packet(wth, wth->random_fh, phdr, buf, TRUE, err,
err_info)) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
struct _mpeg_magic {

View File

@ -175,9 +175,9 @@ static const int netmon_encap[] = {
#define NETMON_NET_DNS_CACHE 0xFFFE
#define NETMON_NET_NETMON_FILTER 0xFFFF
static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
static int netmon_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean netmon_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
static int 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 FALSE;
return -1;
}
/* 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 FALSE;
return -1;
}
netmon->current_frame++;
@ -715,11 +715,11 @@ again:
if (!netmon_process_rec_header(wth, wth->fh, &wth->phdr,
err, err_info))
return FALSE;
return -1;
if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
wth->phdr.caplen, err, err_info))
return FALSE; /* Read error */
return -1; /* Read error */
/*
* For version 2.1 and later, there's additional information
@ -735,33 +735,33 @@ again:
break;
case FAILURE:
return FALSE;
return -1;
}
netmon_set_pseudo_header_info(wth->phdr.pkt_encap, &wth->phdr,
wth->frame_buffer);
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean
static int
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 FALSE;
return -1;
if (!netmon_process_rec_header(wth, wth->random_fh, phdr,
err, err_info))
return FALSE;
return -1;
/*
* Read the packet data.
*/
if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err,
err_info))
return FALSE;
return -1;
/*
* 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 FALSE;
return -1;
case SUCCESS:
break;
case FAILURE:
return FALSE;
return -1;
}
netmon_set_pseudo_header_info(phdr->pkt_encap, phdr, buf);
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean

View File

@ -613,24 +613,24 @@ typedef struct {
} nstrace_t;
static guint32 nspm_signature_version(wtap*, gchar*, gint32);
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 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 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 gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
static int 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 gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *
nstrace->nstrace_buf_offset = nstrace_buf_offset + (phdr)->len;\
nstrace->nstrace_buflen = nstrace_buflen;\
nstrace->nsg_creltime = nsg_creltime;\
return TRUE;
return REC_TYPE_PACKET;
#define GENERATE_CASE_PART(phdr,type,acttype) \
case NSPR_PDPKTRACEPARTTX_V##type:\
@ -988,7 +988,7 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *
nstrace->nstrace_buf_offset = nstrace_buf_offset + (phdr)->caplen;\
nstrace->nsg_creltime = nsg_creltime;\
nstrace->nstrace_buflen = nstrace_buflen;\
return TRUE;\
return REC_TYPE_PACKET;\
switch (pletoh16(&(( nspr_header_v10_t*)&nstrace_buf[nstrace_buf_offset])->ph_RecordType))
{
@ -1030,7 +1030,7 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *
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 FALSE;
return -1;
}
#define TIMEDEFV20(fp,type) \
@ -1112,10 +1112,10 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *
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 TRUE;\
return REC_TYPE_PACKET;\
}while(0)
static gboolean nstrace_read_v20(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)
{
nstrace_t *nstrace = (nstrace_t *)wth->priv;
guint64 nsg_creltime = nstrace->nsg_creltime;
@ -1219,7 +1219,7 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *
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 FALSE;
return -1;
}
#undef PACKET_DESCRIBE
@ -1248,7 +1248,7 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *
nstrace->xxx_offset += nstrace_buflen;\
bytes_read = file_read(nstrace_buf, NSPR_PAGESIZE_TRACE, wth->fh);\
if (bytes_read != NSPR_PAGESIZE_TRACE) {\
return FALSE;\
return -1;\
} else {\
nstrace_buf_offset = 0;\
}\
@ -1263,10 +1263,10 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *
nstrace->nstrace_buf_offset = nstrace_buf_offset;\
nstrace->nstrace_buflen = nstrace_buflen = ((gint32)NSPR_PAGESIZE_TRACE);\
nstrace->nsg_creltime = nsg_creltime;\
return TRUE;\
return REC_TYPE_PACKET;\
} while(0)
static gboolean nstrace_read_v30(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)
{
nstrace_t *nstrace = (nstrace_t *)wth->priv;
guint64 nsg_creltime = nstrace->nsg_creltime;
@ -1324,12 +1324,12 @@ static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *
nstrace_buflen = NSPR_PAGESIZE_TRACE;
} while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen));
return FALSE;
return -1;
}
#undef PACKET_DESCRIBE
static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
static int 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 gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
*err = 0;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
return -1;
/*
** Read the record header.
@ -1353,7 +1353,7 @@ static gboolean 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 FALSE;
return -1;
}
/*
@ -1374,7 +1374,7 @@ static gboolean 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 FALSE;
return -1;
}
}
@ -1408,7 +1408,7 @@ static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
#undef GENERATE_CASE_FULL
#undef GENERATE_CASE_PART
return TRUE;
return REC_TYPE_PACKET;
}
#define PACKET_DESCRIBE(phdr,FPTIMEDEF,SIZEDEF,ver,enumprefix,type,structname,TYPE)\
@ -1417,10 +1417,10 @@ static gboolean 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 TRUE;\
return REC_TYPE_PACKET;\
}while(0)
static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
static int 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 gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
*err = 0;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
return -1;
/*
** Read the first 2 bytes of the record header.
@ -1443,7 +1443,7 @@ static gboolean 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 FALSE;
return -1;
}
hdrlen = 2;
@ -1456,7 +1456,7 @@ static gboolean 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 FALSE;
return -1;
}
hdrlen = 3;
}
@ -1479,7 +1479,7 @@ static gboolean 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 FALSE;
return -1;
}
}
@ -1532,11 +1532,11 @@ static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
#undef GENERATE_CASE_PART
#undef GENERATE_CASE_PART_V25
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
static int 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 gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
*err = 0;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
return -1;
/*
** Read the first 2 bytes of the record header.
*/
@ -1558,7 +1558,7 @@ static gboolean 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 FALSE;
return -1;
}
hdrlen = 2;
@ -1571,7 +1571,7 @@ static gboolean 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 FALSE;
return -1;
}
hdrlen = 3;
}
@ -1594,7 +1594,7 @@ static gboolean 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 FALSE;
return -1;
}
}
@ -1612,7 +1612,7 @@ static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
GENERATE_CASE_V30(phdr,30, 300);
}
return TRUE;
return REC_TYPE_PACKET;
}

View File

@ -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 gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
static int netscreen_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean netscreen_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
static int netscreen_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
gint64 offset;
@ -203,19 +203,19 @@ static gboolean 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 FALSE;
return -1;
/* 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 FALSE;
return -1;
/* 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 FALSE;
return -1;
/*
* If the per-file encapsulation isn't known, set it to this
@ -233,11 +233,11 @@ static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
}
*data_offset = offset;
return TRUE;
return REC_TYPE_PACKET;
}
/* Used to read packets in random-access fashion */
static gboolean
static int
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
pkt_len = parse_netscreen_rec_hdr(phdr, line, cap_int, &cap_dir,
cap_dst, err, err_info);
if (pkt_len == -1)
return FALSE;
return -1;
if (!parse_netscreen_hex_dump(wth->random_fh, pkt_len, cap_int,
cap_dst, phdr, buf, err, err_info))
return FALSE;
return TRUE;
return -1;
return REC_TYPE_PACKET;
}
/* Parses a packet record header. There are a few possible formats:

View File

@ -175,9 +175,9 @@ typedef struct {
gboolean is_hpux_11;
} nettl_t;
static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
static int nettl_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean nettl_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
static int nettl_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
/* Read record header. */
@ -295,7 +295,7 @@ static gboolean 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 FALSE;
return -1;
}
/*
@ -313,15 +313,15 @@ static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
wth->file_encap = WTAP_ENCAP_PER_PACKET;
}
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean
static int
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 FALSE;
return -1;
/* 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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean

View File

@ -94,9 +94,9 @@ static void init_gmt_to_localtime_offset(void)
}
}
static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
static int observer_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean observer_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean observer_read(wtap *wth, int *err, gchar **err_info,
static int observer_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
int header_bytes_consumed;
@ -273,7 +273,7 @@ static gboolean 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 FALSE; /* EOF or error */
return -1; /* EOF or error */
if (packet_header.packet_type == PACKET_TYPE_DATA_PACKET)
break;
@ -281,32 +281,32 @@ static gboolean 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 FALSE; /* EOF or error */
return -1; /* EOF or error */
}
}
if (!process_packet_header(wth, &packet_header, &wth->phdr, err, err_info))
return FALSE;
return -1;
/* 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 FALSE;
return -1;
}
/* 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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
/* Reads a packet at an offset. */
static gboolean observer_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean 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 FALSE;
return -1;
/* process the packet header, including TLVs */
offset = read_packet_header(wth->random_fh, pseudo_header, &packet_header, err,
err_info);
if (offset <= 0)
return FALSE; /* EOF or error */
return -1; /* EOF or error */
if (!process_packet_header(wth, &packet_header, phdr, err, err_info))
return FALSE;
return -1;
/* 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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
static int

View File

@ -402,9 +402,9 @@ typedef struct {
guint isdn_type; /* 1 = E1 PRI, 2 = T1 PRI, 3 = BRI */
} netxray_t;
static gboolean netxray_read(wtap *wth, int *err, gchar **err_info,
static int netxray_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean netxray_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean
static int
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 FALSE;
return -1;
}
/* Read and process record header. */
@ -1021,7 +1021,7 @@ reread:
/*
* Error of some sort; give up.
*/
return FALSE;
return -1;
}
/* We're at EOF. Wrap?
@ -1046,7 +1046,7 @@ reread:
*/
if (netxray->start_offset < netxray->end_offset) {
*err = WTAP_ERR_SHORT_READ;
return FALSE;
return -1;
}
if (!netxray->wrapped) {
@ -1054,12 +1054,12 @@ reread:
netxray->wrapped = TRUE;
if (file_seek(wth->fh, CAPTUREFILE_HEADER_SIZE,
SEEK_SET, err) == -1)
return FALSE;
return -1;
goto reread;
}
/* We've already wrapped - don't wrap again. */
return FALSE;
return -1;
}
/*
@ -1067,13 +1067,13 @@ reread:
*/
if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
wth->phdr.caplen, err, err_info))
return FALSE;
return -1;
/*
* If there's extra stuff at the end of the record, skip it.
*/
if (file_seek(wth->fh, padding, SEEK_CUR, err) == -1)
return FALSE;
return -1;
/*
* 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 TRUE;
return REC_TYPE_PACKET;
}
static gboolean
static int
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 FALSE;
return -1;
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 FALSE;
return -1;
}
/*
@ -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 FALSE;
return -1;
/*
* 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 TRUE;
return REC_TYPE_PACKET;
}
static int

View File

@ -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 gboolean ngsniffer_read(wtap *wth, int *err, gchar **err_info,
static int ngsniffer_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean ngsniffer_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean
static int
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 FALSE;
return -1;
}
/*
@ -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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
case REC_EOF:
/*
* End of file. Return an EOF indication.
*/
*err = 0; /* EOF, not error */
return FALSE;
return -1;
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 FALSE;
return -1;
}
break;
}
}
}
static gboolean
static int
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 FALSE;
return -1;
ret = ngsniffer_process_record(wth, TRUE, NULL, phdr, buf, err, err_info);
if (ret < 0) {
/* Read error or short read */
return FALSE;
return -1;
}
/*
@ -1152,10 +1152,10 @@ ngsniffer_seek_read(wtap *wth, gint64 seek_off,
* "Can't happen".
*/
g_assert_not_reached();
return FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
/*

View File

@ -44,11 +44,11 @@ typedef struct packetlogger_header {
guint64 ts;
} packetlogger_header_t;
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 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_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,29 +93,31 @@ int packetlogger_open(wtap *wth, int *err, gchar **err_info)
return 1; /* Our kind of file */
}
static gboolean
static int
packetlogger_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
return packetlogger_read_packet(wth->fh, &wth->phdr,
wth->frame_buffer, err, err_info);
if (!packetlogger_read_packet(wth->fh, &wth->phdr,
wth->frame_buffer, err, err_info))
return -1;
return REC_TYPE_PACKET;
}
static gboolean
static int
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 FALSE;
return -1;
if(!packetlogger_read_packet(wth->random_fh, phdr, buf, err, err_info)) {
if(*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean

View File

@ -2257,7 +2257,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
/* classic wtap: read packet */
static gboolean
static int
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 FALSE;
return -1;
}
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 FALSE;
return -1;
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 TRUE;
return REC_TYPE_PACKET;
}
/* classic wtap: seek to file position and read packet */
static gboolean
static int
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 FALSE; /* Seek error */
return -1; /* 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 FALSE;
return -1;
}
/* 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 TRUE;
return REC_TYPE_PACKET;
}

View File

@ -358,7 +358,7 @@ int peekclassic_open(wtap *wth, int *err, gchar **err_info)
return 1;
}
static gboolean peekclassic_read_v7(wtap *wth, int *err, gchar **err_info,
static int peekclassic_read_v7(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
int sliceLength;
@ -369,38 +369,38 @@ static gboolean 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 FALSE;
return -1;
/* 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 FALSE;
return -1;
}
/* 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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean peekclassic_seek_read_v7(wtap *wth, gint64 seek_off,
static int 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 FALSE;
return -1;
/* 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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
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 gboolean peekclassic_read_v56(wtap *wth, int *err, gchar **err_info,
static int peekclassic_read_v56(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
@ -501,29 +501,29 @@ static gboolean 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 FALSE;
return -1;
/*
* XXX - is the captured packet data padded to a multiple
* of 2 bytes?
*/
return TRUE;
return REC_TYPE_PACKET;
}
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 FALSE;
return -1;
/* 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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,

View File

@ -123,9 +123,9 @@ typedef struct {
gboolean has_fcs;
} peektagged_t;
static gboolean peektagged_read(wtap *wth, int *err, gchar **err_info,
static int peektagged_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean peektagged_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean peektagged_read(wtap *wth, int *err, gchar **err_info,
static int peektagged_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
int skip_len;
@ -644,29 +644,29 @@ static gboolean 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 FALSE;
return -1;
if (skip_len != 0) {
/* Skip extra junk at the end of the packet data. */
if (!file_skip(wth->fh, skip_len, err))
return FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean
static int
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 FALSE;
return -1;
/* 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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}

View File

@ -95,9 +95,9 @@ typedef enum {
DIRECTION_RECV
} direction_enum;
static gboolean pppdump_read(wtap *wth, int *err, gchar **err_info,
static int pppdump_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean pppdump_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean
static int
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 FALSE;
return -1;
}
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 FALSE;
return -1;
}
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 TRUE;
return REC_TYPE_PACKET;
}
/* Returns number of bytes copied for record, -1 if failure.
@ -715,7 +715,7 @@ done:
/* Used to read packets in random-access fashion */
static gboolean
static int
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 FALSE;
return -1;
}
if (file_seek(wth->random_fh, pid->offset, SEEK_SET, err) == -1)
return FALSE;
return -1;
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 FALSE;
return -1;
num_bytes_to_skip = 0;
} while (direction != pid->dir);
pppdump_set_phdr(phdr, num_bytes, pid->dir);
return TRUE;
return REC_TYPE_PACKET;
}
static void

View File

@ -84,9 +84,9 @@ struct radcomrec_hdr {
char xxw[9]; /* unknown */
};
static gboolean radcom_read(wtap *wth, int *err, gchar **err_info,
static int radcom_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean radcom_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean radcom_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
static int radcom_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
int bytes_read;
char fcs[2];
@ -264,7 +264,7 @@ static gboolean 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 FALSE;
return -1;
}
if (wth->file_encap == WTAP_ENCAP_LAPB) {
@ -278,20 +278,20 @@ static gboolean 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 FALSE;
return -1;
}
}
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean
static int
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 FALSE;
return -1;
/* 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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean

View File

@ -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 gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
static int snoop_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean snoop_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
static int snoop_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
int padbytes;
@ -460,7 +460,7 @@ static gboolean 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 FALSE;
return -1;
/*
* Skip over the padding (don't "fseek()", as the standard
@ -482,27 +482,27 @@ static gboolean 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 FALSE;
return -1;
}
padbytes -= bytes_read;
}
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean
static int
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 FALSE;
return -1;
if (snoop_read_packet(wth, wth->random_fh, phdr, buf, err, err_info) == -1) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
static int

View File

@ -48,8 +48,8 @@ static gboolean is_valid_id(guint16 version_id)
return TRUE;
}
static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
Buffer *buf, int *err, gchar **err_info)
static int 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 gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *p
if (!is_valid_id(pntoh16(&stanag_pkt_hdr[0]))) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup("Bad version number");
return FALSE;
return -1;
}
/* The next 4 bytes are the packet length */
@ -133,16 +133,19 @@ static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *p
/* wind back to the start of the packet ... */
if (file_seek(fh, - offset, SEEK_CUR, err) == -1)
goto fail;
return -1;
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
return -1;
return REC_TYPE_PACKET;
fail:
*err = file_error(wth->fh, err_info);
return FALSE;
return -1;
}
static gboolean stanag4607_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
static int stanag4607_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
gint64 offset;
@ -155,12 +158,12 @@ static gboolean stanag4607_read(wtap *wth, int *err, gchar **err_info, gint64 *d
return stanag4607_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
}
static gboolean stanag4607_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr,
Buffer *buf, int *err, gchar **err_info)
static int 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 FALSE;
return -1;
return stanag4607_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
}

View File

@ -30,14 +30,14 @@
#include "buffer.h"
#include "tnef.h"
static gboolean tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
Buffer *buf, int *err, gchar **err_info)
static int 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 FALSE;
return -1;
if (file_size > WTAP_MAX_PACKET_SIZE) {
/*
@ -47,7 +47,7 @@ static gboolean 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 FALSE;
return -1;
}
packet_size = (int)file_size;
@ -59,10 +59,12 @@ static gboolean tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
phdr->ts.secs = 0;
phdr->ts.nsecs = 0;
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
return -1;
return REC_TYPE_PACKET;
}
static gboolean tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
static int tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
gint64 offset;
@ -72,25 +74,25 @@ static gboolean tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_of
/* there is only ever one packet */
if (offset)
return FALSE;
return -1;
*data_offset = offset;
return tnef_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
}
static gboolean tnef_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr,
Buffer *buf, int *err, gchar **err_info)
static int 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 FALSE;
return -1;
}
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
return -1;
return tnef_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
}

View File

@ -105,9 +105,9 @@ static const char toshiba_rec_magic[] = { '[', 'N', 'o', '.' };
*/
#define TOSHIBA_MAX_PACKET_LEN 16384
static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info,
static int toshiba_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean toshiba_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean toshiba_read(wtap *wth, int *err, gchar **err_info,
static int toshiba_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
gint64 offset;
@ -222,29 +222,31 @@ static gboolean 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 FALSE;
return -1;
*data_offset = offset;
/* Parse the packet */
return parse_toshiba_packet(wth->fh, &wth->phdr, wth->frame_buffer,
err, err_info);
if (!parse_toshiba_packet(wth->fh, &wth->phdr, wth->frame_buffer,
err, err_info))
return -1;
return REC_TYPE_PACKET;
}
/* Used to read packets in random-access fashion */
static gboolean
static int
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 FALSE;
return -1;
if (!parse_toshiba_packet(wth->random_fh, phdr, buf, err, err_info)) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
/* Parses a packet. */

View File

@ -158,9 +158,9 @@ struct visual_write_info
/* Local functions to handle file reads and writes */
static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
static int visual_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean visual_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean visual_read(wtap *wth, int *err, gchar **err_info,
static int visual_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
struct visual_read_info *visual = (struct visual_read_info *)wth->priv;
@ -292,31 +292,33 @@ static gboolean 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 FALSE;
return -1;
}
visual->current_pkt++;
*data_offset = file_tell(wth->fh);
return visual_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer,
err, err_info);
if (!visual_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer,
err, err_info))
return -1;
return REC_TYPE_PACKET;
}
/* Read packet header and data for random access. */
static gboolean visual_seek_read(wtap *wth, gint64 seek_off,
static int 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 FALSE;
return -1;
/* 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 FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
static gboolean

View File

@ -139,9 +139,9 @@ to handle them.
#define VMS_HEADER_LINES_TO_CHECK 200
#define VMS_LINE_LENGTH 240
static gboolean vms_read(wtap *wth, int *err, gchar **err_info,
static int vms_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean vms_seek_read(wtap *wth, gint64 seek_off,
static int 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 gboolean vms_read(wtap *wth, int *err, gchar **err_info,
static int vms_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
gint64 offset = 0;
@ -268,12 +268,14 @@ static gboolean vms_read(wtap *wth, int *err, gchar **err_info,
#endif
if (offset < 1) {
*err = file_error(wth->fh, err_info);
return FALSE;
return -1;
}
*data_offset = offset;
/* Parse the packet */
return parse_vms_packet(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
if (!parse_vms_packet(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info))
return -1;
return REC_TYPE_PACKET;
}
/* Used to read packets in random-access fashion */
@ -282,14 +284,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 FALSE;
return -1;
if (!parse_vms_packet(wth->random_fh, phdr, buf, err, err_info)) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return FALSE;
return -1;
}
return TRUE;
return REC_TYPE_PACKET;
}
/* isdumpline assumes that dump lines start with some non-alphanumerics

View File

@ -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 gboolean vwr_read(wtap *, int *, gchar **, gint64 *);
static gboolean vwr_seek_read(wtap *, gint64, struct wtap_pkthdr *phdr,
static int vwr_read(wtap *, int *, gchar **, gint64 *);
static int 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 gboolean vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
static int 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 FALSE; /* Read error or EOF */
return -1; /* Read error or EOF */
/*
* We're past the header; return the offset of the header, not of
@ -589,7 +589,7 @@ static gboolean vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
/* 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 FALSE;
return -1;
/* 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 gboolean vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
wth->file_encap = WTAP_ENCAP_PER_PACKET;
}
return TRUE;
return REC_TYPE_PACKET;
}
/* read a random record in the middle of a file; the start of the record is @ seek_off */
static gboolean vwr_seek_read(wtap *wth, gint64 seek_off,
static int 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,14 +615,17 @@ static gboolean 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 FALSE;
return -1;
/* read in the record header */
if (!vwr_read_rec_header(vwr, wth->random_fh, &rec_size, &IS_TX, err, err_info))
return FALSE; /* Read error or EOF */
return -1; /* Read error or EOF */
return vwr_process_rec_data(wth->random_fh, rec_size, phdr, buf,
vwr, IS_TX, err, err_info);
if (!vwr_process_rec_data(wth->random_fh, rec_size, phdr, buf,
vwr, IS_TX, err, err_info))
return -1;
return REC_TYPE_PACKET;
}
/* Scan down in the input capture file to find the next frame header. */

View File

@ -40,10 +40,10 @@
WS_DLL_PUBLIC
int wtap_fstat(wtap *wth, ws_statb64 *statb, int *err);
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 **);
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 **);
/**
* Struct holding data of the currently read file.
*/

View File

@ -975,9 +975,11 @@ void wtap_set_cb_new_ipv6(wtap *wth, wtap_new_ipv6_callback_t add_new_ipv6) {
wth->add_new_ipv6 = add_new_ipv6;
}
gboolean
int
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
@ -988,7 +990,8 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
*/
wth->phdr.pkt_encap = wth->file_encap;
if (!wth->subtype_read(wth, err, err_info, data_offset)) {
rectype = wth->subtype_read(wth, err, err_info, data_offset);
if (rectype == -1) {
/*
* If we didn't get an error indication, we read
* the last packet. See if there's any deferred
@ -1000,7 +1003,7 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
*/
if (*err == 0)
*err = file_error(wth->fh, err_info);
return FALSE; /* failure */
return rectype; /* failure */
}
/*
@ -1018,7 +1021,7 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
*/
g_assert(wth->phdr.pkt_encap != WTAP_ENCAP_PER_PACKET);
return TRUE; /* success */
return rectype;
}
/*
@ -1071,12 +1074,15 @@ wtap_buf_ptr(wtap *wth)
return buffer_start_ptr(wth->frame_buffer);
}
gboolean
int
wtap_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
{
if (!wth->subtype_seek_read(wth, seek_off, phdr, buf, err, err_info))
return FALSE;
int rectype;
rectype = wth->subtype_seek_read(wth, seek_off, phdr, buf, err, err_info);
if (rectype == -1)
return rectype;
/*
* It makes no sense for the captured data length to be bigger
@ -1093,5 +1099,5 @@ wtap_seek_read(wtap *wth, gint64 seek_off,
*/
g_assert(wth->phdr.pkt_encap != WTAP_ENCAP_PER_PACKET);
return TRUE;
return rectype;
}

View File

@ -1349,15 +1349,24 @@ 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);
/** 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. */
/*
* 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. */
WS_DLL_PUBLIC
gboolean wtap_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
int wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset);
WS_DLL_PUBLIC
gboolean wtap_seek_read (wtap *wth, gint64 seek_off,
int 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 ***/