diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-03-30 18:44:01 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-04-03 22:21:29 +0000 |
commit | 59816ef00c6dd09532d80b393ba03f8194aba236 (patch) | |
tree | f5e84c67ebe0e69542db94d56db70fa476c0db6c /wiretap/ascend-int.h | |
parent | e42a43bc58a36848316adae19981878a5f430c46 (diff) |
Make the Flex scanners and YACC parser in libraries reentrant.
master-branch libpcap now generates a reentrant Flex scanner and
Bison/Berkeley YACC parser for capture filter expressions, so it
requires versions of Flex and Bison/Berkeley YACC that support that.
We might as well do the same. For libwiretap, it means we could
actually have multiple K12 text or Ascend/Lucent text files open at the
same time. For libwireshark, it might not be as useful, as we only read
configuration files at startup (which should only happen once, in one
thread) or on demand (in which case, if we ever support multiple threads
running libwireshark, we'd need a mutex to ensure that only one file
reads it), but it's still the right thing to do.
We also require a version of Flex that can write out a header file, so
we change the runlex script to generate the header file ourselves. This
means we require a version of Flex new enough to support --header-file.
Clean up some other stuff encountered in the process.
Change-Id: Id23078c6acea549a52fc687779bb55d715b55c16
Reviewed-on: https://code.wireshark.org/review/14719
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/ascend-int.h')
-rw-r--r-- | wiretap/ascend-int.h | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/wiretap/ascend-int.h b/wiretap/ascend-int.h index 049bf8599d..0d8e70b6d6 100644 --- a/wiretap/ascend-int.h +++ b/wiretap/ascend-int.h @@ -27,31 +27,34 @@ #include <glib.h> #include "ws_symbol_export.h" -extern const gchar *ascend_parse_error; - -/* - * Pointer to the pseudo-header for the current packet. - */ -extern struct ascend_phdr *pseudo_header; - typedef struct { time_t inittime; gboolean adjusted; gint64 next_packet_seek_start; } ascend_t; -/* Here we provide interfaces to make our scanner act and look like lex */ -int ascendlex(void); - -void init_parse_ascend(void); -void ascend_init_lexer(FILE_T fh); -gboolean check_ascend(FILE_T fh, struct wtap_pkthdr *phdr); -typedef enum { - PARSED_RECORD, - PARSED_NONRECORD, - PARSE_FAILED -} parse_t; -parse_t parse_ascend(ascend_t *ascend, FILE_T fh, struct wtap_pkthdr *phdr, - Buffer *buf, guint length); +typedef struct { + FILE_T fh; + const gchar *ascend_parse_error; + int *err; + gchar **err_info; + struct ascend_phdr *pseudo_header; + guint8 *pkt_data; + + gboolean saw_timestamp; + guint32 timestamp; + + unsigned int bcur; + gint64 first_hexbyte; + guint32 wirelen; + guint32 caplen; + time_t secs; + guint32 usecs; +} ascend_state_t; +#define YY_EXTRA_TYPE ascend_state_t * + +extern int +run_ascend_parser(FILE_T fh, struct wtap_pkthdr *phdr, guint8 *pd, + ascend_state_t *parser_state, int *err, gchar **err_info); #endif /* ! __ASCEND_INT_H__ */ |