-
/* tvbparse.h
*
* an API for text tvb parsers
struct _tvbparse_wanted_t {
int id;
- tvbparse_condition_t condition;
+ tvbparse_condition_t condition;
union {
- const gchar* str;
- struct _tvbparse_wanted_t** handle;
- struct {
- union {
- gint64 i;
- guint64 u;
- gdouble f;
- } value;
- gboolean (*comp)(void*,const void*);
- void* (*extract)(tvbuff_t*,guint);
- } number;
- enum ftenum ftenum;
- struct {
- until_mode_t mode;
- const tvbparse_wanted_t* subelem;
- } until;
- struct {
- GHashTable* table;
- struct _tvbparse_wanted_t* key;
- struct _tvbparse_wanted_t* other;
- } hash;
- GPtrArray* elems;
- const tvbparse_wanted_t* subelem;
- void* p;
- } control;
+ const gchar* str;
+ struct _tvbparse_wanted_t** handle;
+ struct {
+ union {
+ gint64 i;
+ guint64 u;
+ gdouble f;
+ } value;
+ gboolean (*comp)(void*,const void*);
+ void* (*extract)(tvbuff_t*,guint);
+ } number;
+ enum ftenum ftenum;
+ struct {
+ until_mode_t mode;
+ const tvbparse_wanted_t* subelem;
+ } until;
+ struct {
+ GHashTable* table;
+ struct _tvbparse_wanted_t* key;
+ struct _tvbparse_wanted_t* other;
+ } hash;
+ GPtrArray* elems;
+ const tvbparse_wanted_t* subelem;
+ void* p;
+ } control;
int len;
tvbparse_action_t before;
tvbparse_action_t after;
-
};
/* an instance of a per packet parser */
struct _tvbparse_t {
tvbuff_t* tvb;
int offset;
- int end_offset;
+ int end_offset;
void* data;
const tvbparse_wanted_t* ignore;
};
/*
* hashed
*/
-
tvbparse_wanted_t* tvbparse_hashed(const int id,
- const void* data,
- tvbparse_action_t before_cb,
- tvbparse_action_t after_cb,
- tvbparse_wanted_t* key,
- tvbparse_wanted_t* other,
- ...);
+ const void* data,
+ tvbparse_action_t before_cb,
+ tvbparse_action_t after_cb,
+ tvbparse_wanted_t* key,
+ tvbparse_wanted_t* other,
+ ...);
void tvbparse_hashed_add(tvbparse_wanted_t* w, ...);
tvbparse_action_t before_cb,
tvbparse_action_t after_cb,
...);
+
/*
* some
*
/* initialize the parser (at every packet)
-* tvb: what are we parsing?
-* offset: from where
-* len: for how many bytes
-* private_data: will be passed to the action callbacks
-* ignore: a wanted token type to be ignored (the associated cb WILL be called when it matches)
-*/
+ * tvb: what are we parsing?
+ * offset: from where
+ * len: for how many bytes
+ * private_data: will be passed to the action callbacks
+ * ignore: a wanted token type to be ignored (the associated cb WILL be called when it matches)
+ */
tvbparse_t* tvbparse_init(tvbuff_t* tvb,
const int offset,
int len,
* The parser will be left in its original state and no callbacks will be called.
*/
gboolean tvbparse_peek(tvbparse_t* tt,
- const tvbparse_wanted_t* wanted);
+ const tvbparse_wanted_t* wanted);
/*
* This will look for the wanted token at the current offset or after any given
* current offset.
* This function is slow.
*/
-
tvbparse_elem_t* tvbparse_find(tvbparse_t* tt,
const tvbparse_wanted_t* wanted);