aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2010-02-25 20:45:59 +0000
committerGuy Harris <guy@alum.mit.edu>2010-02-25 20:45:59 +0000
commit207a75388a534a38e23d4f5c1068037cd5f26b91 (patch)
tree1d07967fc0421f7a790f46063312ff62dcb42b59
parentdef01f5c66c04817289e006fc8fee9046e09a954 (diff)
Have parse_ascend() return:
PARSED_RECORD if we got a packet; PARSED_NONRECORD if the parser succeeded but didn't see a packet; PARSE_FAILED if the parser failed. Treat anything other than PARSED_RECORD as a failure, for now; I'm not sure why we were treating "parser succeeded but didn't see a packet" as success, as that was causing us to recognize some non-Ascend-output text files as Ascend files and to return "records" with bogus caplen and len values. svn path=/trunk/; revision=32009
-rw-r--r--wiretap/ascend-int.h7
-rw-r--r--wiretap/ascend.y15
-rw-r--r--wiretap/ascendtext.c9
3 files changed, 21 insertions, 10 deletions
diff --git a/wiretap/ascend-int.h b/wiretap/ascend-int.h
index 812b84d774..f4a3509c8a 100644
--- a/wiretap/ascend-int.h
+++ b/wiretap/ascend-int.h
@@ -48,7 +48,12 @@ int ascendlex(void);
void init_parse_ascend(void);
void ascend_init_lexer(FILE_T fh);
-int parse_ascend(FILE_T fh, guint8 *pd, struct ascend_phdr *phdr,
+typedef enum {
+ PARSED_RECORD,
+ PARSED_NONRECORD,
+ PARSE_FAILED
+} parse_t;
+parse_t parse_ascend(FILE_T fh, guint8 *pd, struct ascend_phdr *phdr,
ascend_pkthdr *hdr, gint64 *start_of_data);
#endif /* ! __ASCEND_INT_H__ */
diff --git a/wiretap/ascend.y b/wiretap/ascend.y
index 6b23c504db..089eccab8d 100644
--- a/wiretap/ascend.y
+++ b/wiretap/ascend.y
@@ -442,9 +442,12 @@ init_parse_ascend()
start_time = 0; /* we haven't see a date/time yet */
}
-/* Parse the capture file. Return the offset of the next packet, or zero
- if there is none. */
-int
+/* Parse the capture file.
+ Returns:
+ PARSED_RECORD if we got a packet
+ PARSED_NONRECORD if the parser succeeded but didn't see a packet
+ PARSE_FAILED if the parser failed. */
+parse_t
parse_ascend(FILE_T fh, guint8 *pd, struct ascend_phdr *phdr,
ascend_pkthdr *hdr, gint64 *start_of_data)
{
@@ -507,14 +510,14 @@ parse_ascend(FILE_T fh, guint8 *pd, struct ascend_phdr *phdr,
header->len = wirelen;
}
- return 1;
+ return PARSED_RECORD;
}
/* Didn't see any data. Still, perhaps the parser was happy. */
if (retval)
- return 0;
+ return PARSE_FAILED;
else
- return 1;
+ return PARSED_NONRECORD;
}
void
diff --git a/wiretap/ascendtext.c b/wiretap/ascendtext.c
index f8597ae245..e019f94532 100644
--- a/wiretap/ascendtext.c
+++ b/wiretap/ascendtext.c
@@ -190,7 +190,8 @@ int ascend_open(wtap *wth, int *err, gchar **err_info _U_)
/* Do a trial parse of the first packet just found to see if we might really have an Ascend file */
init_parse_ascend();
- if (! parse_ascend(wth->fh, buf, &wth->pseudo_header.ascend, &header, &dummy_seek_start)) {
+ if (parse_ascend(wth->fh, buf, &wth->pseudo_header.ascend, &header,
+ &dummy_seek_start) != PARSED_RECORD) {
return 0;
}
@@ -279,7 +280,8 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
offset = ascend_seek(wth, err);
if (offset == -1)
return FALSE;
- if (! parse_ascend(wth->fh, buf, &wth->pseudo_header.ascend, &header, &(wth->capture.ascend->next_packet_seek_start))) {
+ if (parse_ascend(wth->fh, buf, &wth->pseudo_header.ascend, &header,
+ &(wth->capture.ascend->next_packet_seek_start)) != PARSED_RECORD) {
*err = WTAP_ERR_BAD_RECORD;
*err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
return FALSE;
@@ -327,7 +329,8 @@ static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
- if (! parse_ascend(wth->random_fh, pd, &pseudo_head->ascend, NULL, &(wth->capture.ascend->next_packet_seek_start))) {
+ if (parse_ascend(wth->random_fh, pd, &pseudo_head->ascend, NULL,
+ &(wth->capture.ascend->next_packet_seek_start)) != PARSED_RECORD) {
*err = WTAP_ERR_BAD_RECORD;
*err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
return FALSE;