(Trivial): indentation & whitespace cleanup.
svn path=/trunk/; revision=32366
This commit is contained in:
parent
6812b68eb1
commit
0d372283b3
|
@ -54,12 +54,12 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <epan/packet.h>
|
#include <epan/packet.h>
|
||||||
#include <epan/addr_resolv.h>
|
#include <epan/addr_resolv.h>
|
||||||
|
|
||||||
|
|
||||||
#include "packet-rtps.h"
|
#include "packet-rtps.h"
|
||||||
|
|
|
@ -54,13 +54,13 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <epan/packet.h>
|
#include <epan/packet.h>
|
||||||
#include <epan/addr_resolv.h>
|
#include <epan/addr_resolv.h>
|
||||||
#include <epan/prefs.h>
|
#include <epan/prefs.h>
|
||||||
|
|
||||||
|
|
||||||
#include "packet-rtps2.h"
|
#include "packet-rtps2.h"
|
||||||
|
|
813
epan/tvbparse.c
813
epan/tvbparse.c
File diff suppressed because it is too large
Load Diff
|
@ -15,12 +15,12 @@
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
@ -29,11 +29,11 @@
|
||||||
/*
|
/*
|
||||||
The intention behind this is to ease the writing of dissectors that have to
|
The intention behind this is to ease the writing of dissectors that have to
|
||||||
parse text without the need of writing into buffers.
|
parse text without the need of writing into buffers.
|
||||||
|
|
||||||
It was originally written to avoid using lex and yacc for the xml dissector.
|
It was originally written to avoid using lex and yacc for the xml dissector.
|
||||||
|
|
||||||
the parser is able to look for wanted elements these can be:
|
the parser is able to look for wanted elements these can be:
|
||||||
|
|
||||||
simple tokens:
|
simple tokens:
|
||||||
- a char out of a string of needles
|
- a char out of a string of needles
|
||||||
- a char not belonging to a string of needles
|
- a char not belonging to a string of needles
|
||||||
|
@ -42,24 +42,24 @@
|
||||||
- a string
|
- a string
|
||||||
- a caseless string
|
- a caseless string
|
||||||
- all the characters up to a certain wanted element (included or excluded)
|
- all the characters up to a certain wanted element (included or excluded)
|
||||||
|
|
||||||
composed elements:
|
composed elements:
|
||||||
- one of a given group of wanted elements
|
- one of a given group of wanted elements
|
||||||
- a sequence of wanted elements
|
- a sequence of wanted elements
|
||||||
- some (at least one) instances of a wanted element
|
- some (at least one) instances of a wanted element
|
||||||
|
|
||||||
Once a wanted element is successfully extracted, by either tvbparse_get or
|
Once a wanted element is successfully extracted, by either tvbparse_get or
|
||||||
tvbparse_find, the parser will invoke a given callback
|
tvbparse_find, the parser will invoke a given callback
|
||||||
before and another one after every of its component's subelement's callbacks
|
before and another one after every of its component's subelement's callbacks
|
||||||
are being called.
|
are being called.
|
||||||
|
|
||||||
If tvbparse_get or tvbparse_find fail to extract the wanted element the
|
If tvbparse_get or tvbparse_find fail to extract the wanted element the
|
||||||
subelements callbacks are not going to be invoked.
|
subelements callbacks are not going to be invoked.
|
||||||
|
|
||||||
The wanted elements are instantiated once by the proto_register_xxx function.
|
The wanted elements are instantiated once by the proto_register_xxx function.
|
||||||
|
|
||||||
The parser is instantiated for every packet and it mantains its state.
|
The parser is instantiated for every packet and it mantains its state.
|
||||||
|
|
||||||
The element's data is destroyed before the next packet is dissected.
|
The element's data is destroyed before the next packet is dissected.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ typedef void (*tvbparse_action_t)(void* tvbparse_data, const void* wanted_data,
|
||||||
|
|
||||||
typedef int (*tvbparse_condition_t)
|
typedef int (*tvbparse_condition_t)
|
||||||
(tvbparse_t*, const int,
|
(tvbparse_t*, const int,
|
||||||
const tvbparse_wanted_t*,
|
const tvbparse_wanted_t*,
|
||||||
tvbparse_elem_t**);
|
tvbparse_elem_t**);
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ typedef enum {
|
||||||
struct _tvbparse_wanted_t {
|
struct _tvbparse_wanted_t {
|
||||||
int id;
|
int id;
|
||||||
tvbparse_condition_t condition;
|
tvbparse_condition_t condition;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
const gchar* str;
|
const gchar* str;
|
||||||
struct _tvbparse_wanted_t** handle;
|
struct _tvbparse_wanted_t** handle;
|
||||||
|
@ -113,7 +113,7 @@ struct _tvbparse_wanted_t {
|
||||||
gint64 i;
|
gint64 i;
|
||||||
guint64 u;
|
guint64 u;
|
||||||
gdouble f;
|
gdouble f;
|
||||||
} value;
|
} value;
|
||||||
gboolean (*comp)(void*,const void*);
|
gboolean (*comp)(void*,const void*);
|
||||||
void* (*extract)(tvbuff_t*,guint);
|
void* (*extract)(tvbuff_t*,guint);
|
||||||
} number;
|
} number;
|
||||||
|
@ -131,17 +131,17 @@ struct _tvbparse_wanted_t {
|
||||||
const tvbparse_wanted_t* subelem;
|
const tvbparse_wanted_t* subelem;
|
||||||
void* p;
|
void* p;
|
||||||
} control;
|
} control;
|
||||||
|
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
guint min;
|
guint min;
|
||||||
guint max;
|
guint max;
|
||||||
|
|
||||||
const void* data;
|
const void* data;
|
||||||
|
|
||||||
tvbparse_action_t before;
|
tvbparse_action_t before;
|
||||||
tvbparse_action_t after;
|
tvbparse_action_t after;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* an instance of a per packet parser */
|
/* an instance of a per packet parser */
|
||||||
|
@ -157,18 +157,18 @@ struct _tvbparse_t {
|
||||||
/* a matching token returned by either tvbparser_get or tvb_parser_find */
|
/* a matching token returned by either tvbparser_get or tvb_parser_find */
|
||||||
struct _tvbparse_elem_t {
|
struct _tvbparse_elem_t {
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
tvbuff_t* tvb;
|
tvbuff_t* tvb;
|
||||||
int offset;
|
int offset;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
void* data;
|
void* data;
|
||||||
|
|
||||||
struct _tvbparse_elem_t* sub;
|
struct _tvbparse_elem_t* sub;
|
||||||
|
|
||||||
struct _tvbparse_elem_t* next;
|
struct _tvbparse_elem_t* next;
|
||||||
struct _tvbparse_elem_t* last;
|
struct _tvbparse_elem_t* last;
|
||||||
|
|
||||||
const tvbparse_wanted_t* wanted;
|
const tvbparse_wanted_t* wanted;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ tvbparse_wanted_t* tvbparse_not_char(const int id,
|
||||||
*
|
*
|
||||||
* When looked for it returns a simple element one or more characters long if
|
* When looked for it returns a simple element one or more characters long if
|
||||||
* one or more char(s) starting from the current offset match one of the needles.
|
* one or more char(s) starting from the current offset match one of the needles.
|
||||||
* An element will be returned if at least min_len chars are given (1 if it's 0)
|
* An element will be returned if at least min_len chars are given (1 if it's 0)
|
||||||
* It will get at most max_len chars or as much as it can if max_len is 0.
|
* It will get at most max_len chars or as much as it can if max_len is 0.
|
||||||
*/
|
*/
|
||||||
tvbparse_wanted_t* tvbparse_chars(const int id,
|
tvbparse_wanted_t* tvbparse_chars(const int id,
|
||||||
|
@ -232,7 +232,7 @@ tvbparse_wanted_t* tvbparse_chars(const int id,
|
||||||
* When looked for it returns a simple element one or more characters long if
|
* When looked for it returns a simple element one or more characters long if
|
||||||
* one or more char(s) starting from the current offset do not match one of the
|
* one or more char(s) starting from the current offset do not match one of the
|
||||||
* needles.
|
* needles.
|
||||||
* An element will be returned if at least min_len chars are given (1 if it's 0)
|
* An element will be returned if at least min_len chars are given (1 if it's 0)
|
||||||
* It will get at most max_len chars or as much as it can if max_len is 0.
|
* It will get at most max_len chars or as much as it can if max_len is 0.
|
||||||
*/
|
*/
|
||||||
tvbparse_wanted_t* tvbparse_not_chars(const int id,
|
tvbparse_wanted_t* tvbparse_not_chars(const int id,
|
||||||
|
@ -247,7 +247,7 @@ tvbparse_wanted_t* tvbparse_not_chars(const int id,
|
||||||
* a string element
|
* a string element
|
||||||
*
|
*
|
||||||
* When looked for it returns a simple element if we have the given string at
|
* When looked for it returns a simple element if we have the given string at
|
||||||
* the current offset
|
* the current offset
|
||||||
*/
|
*/
|
||||||
tvbparse_wanted_t* tvbparse_string(const int id,
|
tvbparse_wanted_t* tvbparse_string(const int id,
|
||||||
const gchar* string,
|
const gchar* string,
|
||||||
|
@ -259,7 +259,7 @@ tvbparse_wanted_t* tvbparse_string(const int id,
|
||||||
* casestring
|
* casestring
|
||||||
*
|
*
|
||||||
* When looked for it returns a simple element if we have a matching string at
|
* When looked for it returns a simple element if we have a matching string at
|
||||||
* the current offset
|
* the current offset
|
||||||
*/
|
*/
|
||||||
tvbparse_wanted_t* tvbparse_casestring(const int id,
|
tvbparse_wanted_t* tvbparse_casestring(const int id,
|
||||||
const gchar* str,
|
const gchar* str,
|
||||||
|
@ -270,18 +270,18 @@ tvbparse_wanted_t* tvbparse_casestring(const int id,
|
||||||
/*
|
/*
|
||||||
* until
|
* until
|
||||||
*
|
*
|
||||||
* When looked for it returns a simple element containing all the characters
|
* When looked for it returns a simple element containing all the characters
|
||||||
* found until the first match of the ending element if the ending element is
|
* found until the first match of the ending element if the ending element is
|
||||||
* found.
|
* found.
|
||||||
*
|
*
|
||||||
* When looking for until elements it calls tvbparse_find so it can be very slow.
|
* When looking for until elements it calls tvbparse_find so it can be very slow.
|
||||||
*
|
*
|
||||||
* It won't have a subelement, the ending's callbacks won't get called.
|
* It won't have a subelement, the ending's callbacks won't get called.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* op_mode values determine how the terminating element and the current offset
|
* op_mode values determine how the terminating element and the current offset
|
||||||
* of the parser are handled
|
* of the parser are handled
|
||||||
*/
|
*/
|
||||||
tvbparse_wanted_t* tvbparse_until(const int id,
|
tvbparse_wanted_t* tvbparse_until(const int id,
|
||||||
const void* private_data,
|
const void* private_data,
|
||||||
|
@ -305,12 +305,12 @@ tvbparse_wanted_t* tvbparse_set_oneof(const int id,
|
||||||
tvbparse_action_t after_cb,
|
tvbparse_action_t after_cb,
|
||||||
...);
|
...);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* hashed
|
* hashed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
tvbparse_wanted_t* tvbparse_hashed(const int id,
|
tvbparse_wanted_t* tvbparse_hashed(const int id,
|
||||||
const void* data,
|
const void* data,
|
||||||
tvbparse_action_t before_cb,
|
tvbparse_action_t before_cb,
|
||||||
tvbparse_action_t after_cb,
|
tvbparse_action_t after_cb,
|
||||||
tvbparse_wanted_t* key,
|
tvbparse_wanted_t* key,
|
||||||
|
@ -354,7 +354,7 @@ tvbparse_wanted_t* tvbparse_some(const int id,
|
||||||
tvbparse_some(id, 1, G_MAXINT, private_data, before_cb, after_cb, wanted)
|
tvbparse_some(id, 1, G_MAXINT, private_data, before_cb, after_cb, wanted)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* handle
|
* handle
|
||||||
*
|
*
|
||||||
* this is a pointer to a pointer to a wanted element (that might have not
|
* this is a pointer to a pointer to a wanted element (that might have not
|
||||||
|
@ -422,10 +422,10 @@ void tvbparse_shrink_token_cb(void* tvbparse_data,
|
||||||
|
|
||||||
|
|
||||||
/* initialize the parser (at every packet)
|
/* initialize the parser (at every packet)
|
||||||
* tvb: what are we parsing?
|
* tvb: what are we parsing?
|
||||||
* offset: from where
|
* offset: from where
|
||||||
* len: for how many bytes
|
* len: for how many bytes
|
||||||
* private_data: will be passed to the action callbacks
|
* 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)
|
* ignore: a wanted token type to be ignored (the associated cb WILL be called when it matches)
|
||||||
*/
|
*/
|
||||||
tvbparse_t* tvbparse_init(tvbuff_t* tvb,
|
tvbparse_t* tvbparse_init(tvbuff_t* tvb,
|
||||||
|
@ -446,7 +446,7 @@ guint tvbparse_len_left(tvbparse_t* tt);
|
||||||
* This will look for the wanted token at the current offset or after any given
|
* This will look for the wanted token at the current offset or after any given
|
||||||
* number of ignored tokens returning FALSE if there's no match or TRUE if there
|
* number of ignored tokens returning FALSE if there's no match or TRUE if there
|
||||||
* is a match.
|
* is a match.
|
||||||
* The parser will be left in its original state and no callbacks will be called.
|
* The parser will be left in its original state and no callbacks will be called.
|
||||||
*/
|
*/
|
||||||
gboolean tvbparse_peek(tvbparse_t* tt,
|
gboolean tvbparse_peek(tvbparse_t* tt,
|
||||||
const tvbparse_wanted_t* wanted);
|
const tvbparse_wanted_t* wanted);
|
||||||
|
@ -455,7 +455,7 @@ gboolean tvbparse_peek(tvbparse_t* tt,
|
||||||
* This will look for the wanted token at the current offset or after any given
|
* This will look for the wanted token at the current offset or after any given
|
||||||
* number of ignored tokens returning NULL if there's no match.
|
* number of ignored tokens returning NULL if there's no match.
|
||||||
* if there is a match it will set the offset of the current parser after
|
* if there is a match it will set the offset of the current parser after
|
||||||
* the end of the token
|
* the end of the token
|
||||||
*/
|
*/
|
||||||
tvbparse_elem_t* tvbparse_get(tvbparse_t* tt,
|
tvbparse_elem_t* tvbparse_get(tvbparse_t* tt,
|
||||||
const tvbparse_wanted_t* wanted);
|
const tvbparse_wanted_t* wanted);
|
||||||
|
|
Loading…
Reference in New Issue