'''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():
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)
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)
}
}
-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;
}
/*
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_)