diff options
author | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-07-21 18:38:03 +0000 |
---|---|---|
committer | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-07-21 18:38:03 +0000 |
commit | 28e9dcc4a9261a61b16dfd9a2051205289beb926 (patch) | |
tree | 69465d340a5472a87467c43de32fd9f6a3035b1a /epan | |
parent | 9e7b6f1a69c516579ffd4618f89e20559d738666 (diff) |
Some work on multi file dissection
- make init_dissection/cleanup_dissection private for libwireshark
- implement epan_new(), epan_free()
- pass epan_t to epan_dissect*
svn path=/trunk/; revision=50761
Diffstat (limited to 'epan')
-rw-r--r-- | epan/epan.c | 28 | ||||
-rw-r--r-- | epan/epan.h | 11 | ||||
-rw-r--r-- | epan/epan_dissect.h | 1 | ||||
-rw-r--r-- | epan/packet.h | 4 |
4 files changed, 32 insertions, 12 deletions
diff --git a/epan/epan.c b/epan/epan.c index 023d580436..6382f79703 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -40,6 +40,7 @@ #include "epan_dissect.h" #include "wsutil/report_err.h" +#include "epan-int.h" #include "conversation.h" #include "circuit.h" #include "except.h" @@ -134,6 +135,26 @@ epan_cleanup(void) wmem_cleanup(); } +epan_t * +epan_new(void) +{ + epan_t *session = g_slice_new(epan_t); + + /* XXX, it should take session as param */ + init_dissection(); + + return session; +} + +void +epan_free(epan_t *session) +{ + /* XXX, it should take session as param */ + cleanup_dissection(); + + g_slice_free(epan_t, session); +} + void epan_conversation_init(void) { @@ -159,10 +180,11 @@ epan_circuit_cleanup(void) } epan_dissect_t* -epan_dissect_init(epan_dissect_t *edt, const gboolean create_proto_tree, const gboolean proto_tree_visible) +epan_dissect_init(epan_dissect_t *edt, epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible) { g_assert(edt); + edt->session = session; edt->pi.pool = wmem_allocator_new(WMEM_ALLOCATOR_SIMPLE); if (create_proto_tree) { @@ -179,13 +201,13 @@ epan_dissect_init(epan_dissect_t *edt, const gboolean create_proto_tree, const g } epan_dissect_t* -epan_dissect_new(const gboolean create_proto_tree, const gboolean proto_tree_visible) +epan_dissect_new(epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible) { epan_dissect_t *edt; edt = g_new0(epan_dissect_t, 1); - return epan_dissect_init(edt, create_proto_tree, proto_tree_visible); + return epan_dissect_init(edt, session, create_proto_tree, proto_tree_visible); } void diff --git a/epan/epan.h b/epan/epan.h index 6882947c17..263a80f353 100644 --- a/epan/epan.h +++ b/epan/epan.h @@ -125,14 +125,11 @@ void epan_circuit_cleanup(void); * some protocols cannot be decoded without knowledge of previous packets. * This inter-packet "state" is stored in the epan_t. */ -/* XXX - NOTE: epan_t, epan_new and epan_free are currently unused! */ typedef struct epan_session epan_t; -epan_t* -epan_new(void); +WS_DLL_PUBLIC epan_t *epan_new(void); -void -epan_free(epan_t*); +WS_DLL_PUBLIC void epan_free(epan_t *session); WS_DLL_PUBLIC const gchar* epan_get_version(void); @@ -140,14 +137,14 @@ epan_get_version(void); /** initialize an existing single packet dissection */ WS_DLL_PUBLIC epan_dissect_t* -epan_dissect_init(epan_dissect_t *edt, const gboolean create_proto_tree, const gboolean proto_tree_visible); +epan_dissect_init(epan_dissect_t *edt, epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible); /** get a new single packet dissection * should be freed using epan_dissect_free() after packet dissection completed */ WS_DLL_PUBLIC epan_dissect_t* -epan_dissect_new(const gboolean create_proto_tree, const gboolean proto_tree_visible); +epan_dissect_new(epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible); /** Indicate whether we should fake protocols or not */ WS_DLL_PUBLIC diff --git a/epan/epan_dissect.h b/epan/epan_dissect.h index ff48107a5d..98e4a0b8e9 100644 --- a/epan/epan_dissect.h +++ b/epan/epan_dissect.h @@ -39,6 +39,7 @@ extern "C" { * to addresses in your byte array. */ struct _epan_dissect_t { + struct epan_session *session; tvbuff_t *tvb; proto_tree *tree; packet_info pi; diff --git a/epan/packet.h b/epan/packet.h index 2d1e231a75..107eab3a5d 100644 --- a/epan/packet.h +++ b/epan/packet.h @@ -382,10 +382,10 @@ WS_DLL_PUBLIC void set_actual_length(tvbuff_t *tvb, const guint specified_len); WS_DLL_PUBLIC void register_init_routine(void (*func)(void)); /* Initialize all data structures used for dissection. */ -WS_DLL_PUBLIC void init_dissection(void); +void init_dissection(void); /* Free data structures allocated for dissection. */ -WS_DLL_PUBLIC void cleanup_dissection(void); +void cleanup_dissection(void); /* Allow protocols to register a "cleanup" routine to be * run after the initial sequential run through the packets. |