diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-05-22 20:01:31 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-05-23 03:02:32 +0000 |
commit | c0c480d08c175eed4524ea9e73ec86298f468cf4 (patch) | |
tree | 1234cd09094dcc8447e3fb2b13671f12aba5ae69 /wiretap/k12.c | |
parent | 6287efb9c05482531ea675bb5a3d23b03b5715ab (diff) |
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>
Diffstat (limited to 'wiretap/k12.c')
-rw-r--r-- | wiretap/k12.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/wiretap/k12.c b/wiretap/k12.c index cd1bbe6104..013c19e6f6 100644 --- a/wiretap/k12.c +++ b/wiretap/k12.c @@ -623,7 +623,7 @@ process_packet_data(struct wtap_pkthdr *phdr, Buffer *target, guint8 *buffer, phdr->pseudo_header.k12.stuff = k12; } -static 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; } |