aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wspython
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2011-10-24 16:37:07 +0000
committerAnders Broman <anders.broman@ericsson.com>2011-10-24 16:37:07 +0000
commitaf46b3f92973d11e4714ba13432e6258f186a071 (patch)
tree63e3e29da9164aff7f6dad9c586bd0e854bd2e03 /epan/wspython
parenta203843c86d9b5454fc39fd073e8c0655b75cd9f (diff)
From Eliot:
Change to python support functions. Avoid passing C dissector callback via python to create_dissector_handle. This caused problems at least on 64 bit linux. Get all dissector args in one call. Simplifies common usage. https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6448 svn path=/trunk/; revision=39535
Diffstat (limited to 'epan/wspython')
-rwxr-xr-xepan/wspython/wspy_dissector.py20
-rw-r--r--epan/wspython/wspy_register.c28
2 files changed, 13 insertions, 35 deletions
diff --git a/epan/wspython/wspy_dissector.py b/epan/wspython/wspy_dissector.py
index 6dfb11a887..7769603423 100755
--- a/epan/wspython/wspy_dissector.py
+++ b/epan/wspython/wspy_dissector.py
@@ -263,11 +263,13 @@ class Dissector(object):
'''private method executed right before dissect in order to retrieve some
internal information and enabling the possibility to add the base tree of
this protocol dissection to the tree without any user intervention'''
- self.__tvb = self.__wsl.py_tvbuff()
- self.__pinfo = self.__wsl.py_pinfo()
- self.__tree = self.__wsl.py_tree()
- #self.__wsl.print_current_proto(py_object(pinfo))
+ self.__tvb = ct.c_void_p()
+ self.__pinfo = ct.c_void_p()
+ self.__tree = ct.c_void_p()
+ self.__wsl.py_dissector_args(ct.byref(self.__tvb), ct.byref(self.__pinfo), ct.byref(self.__tree))
+ # print self.__tvb, self.__pinfo, self.__tree
+ #self.__wsl.print_current_proto(ct.py_object(pinfo))
subt = self.subtrees
try:
if not subt.has_user_defined_protocol_tree():
@@ -283,13 +285,6 @@ class Dissector(object):
implementing the dissector of a specific protocol.'''
return [ (None, 0, None) ]
- def create_dissector_handle(self, protocol=None):
- '''create_dissector_handle : see proto.h'''
- gdissector = self.__wsl.py_generic_dissector()
- if not protocol:
- protocol = self.__protocol
- return self.__wsl.create_dissector_handle(gdissector, protocol)
-
def find_dissector(self, protocol):
'''find_dissector : see proto.h'''
return self.__wsl.find_dissector(protocol)
@@ -307,8 +302,7 @@ class Dissector(object):
continue
if not handle:
if not private_handle:
- handle = \
- self.create_dissector_handle(self.__protocol)
+ handle = self.__wsl.py_create_dissector_handle(self.__protocol)
else:
handle = private_handle
self.__wsl.dissector_add_uint(type, protocol_id, handle)
diff --git a/epan/wspython/wspy_register.c b/epan/wspython/wspy_register.c
index 97bde1b2f3..60e6e22d17 100644
--- a/epan/wspython/wspy_register.c
+++ b/epan/wspython/wspy_register.c
@@ -173,19 +173,11 @@ void register_all_py_protocols_func(void)
}
}
-tvbuff_t *py_tvbuff(void)
+void py_dissector_args(tvbuff_t ** tvb, packet_info ** pinfo, proto_tree ** tree)
{
- return g_tvb;
-}
-
-packet_info * py_pinfo(void)
-{
- return g_pinfo;
-}
-
-proto_tree * py_tree(void)
-{
- return g_tree;
+ *tvb = g_tvb;
+ *pinfo = g_pinfo;
+ *tree = g_tree;
}
/*
@@ -214,17 +206,9 @@ void py_dissect(tvbuff_t * tvb, packet_info * pinfo,
PyObject_CallMethod(py_dissector, "pre_dissect", NULL);
}
-/*
- * Return the pointer to the generic python dissector
- *
- * One could think that it could be a PyCObject but it is a
- * workaround because ctypes is used and it complains later -not
- * knowing how to conver the parameter - in the Python code when
- * calling back a C function with a PyCObject as parameter
- */
-dissector_t py_generic_dissector(void)
+dissector_handle_t py_create_dissector_handle(const int proto)
{
- return &py_dissect;
+ return create_dissector_handle(&py_dissect, proto);
}
static void register_all_py_handoffs_foreach(gpointer key _U_, gpointer value, gpointer user_data _U_)