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/cosine.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/cosine.c')
-rw-r--r-- | wiretap/cosine.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/wiretap/cosine.c b/wiretap/cosine.c index d937018796..18b2065287 100644 --- a/wiretap/cosine.c +++ b/wiretap/cosine.c @@ -166,13 +166,13 @@ static gboolean empty_line(const gchar *line); static gint64 cosine_seek_next_packet(wtap *wth, int *err, gchar **err_info, char *hdr); static gboolean cosine_check_file_type(wtap *wth, int *err, gchar **err_info); -static 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; } |