Wireshark mailing list archives
Re: C equivalent of LUA proto.init
From: Pascal Quantin <pascal.quantin () gmail com>
Date: Fri, 26 Aug 2016 18:26:38 +0200
Hi Paul, 2016-08-26 18:01 GMT+02:00 Paul Offord <Paul.Offord () advance7 com>:
Hi All, I’m slowly porting the TRANSUM post-dissector from LUA to C. My LUA dissector has a transum.init() function that is called each time a new trace file is opened. Is there an equivalent mechanism in the C dissector functions.
Have a look at this function allowing you to register a callback: /** * Allow protocols to register "init" routines, which are called before * we make a pass through a capture file and dissect all its packets * (e.g., when we read in a new capture file, or run a "filter packets" * or "colorize packets" pass over the current capture file or when the * preferences are changed). */ WS_DLL_PUBLIC void register_init_routine(void (*func)(void)); If you need to cleanup memory (for example) when closing a file, you can register another callback with: /** * Allows protocols to register "cleanup" routines which are called * after closing a capture file (or when preferences are changed, in * that case these routines are called before the init routines are * executed). It can be used to release resources that are allocated in * register_init_routine. */ WS_DLL_PUBLIC void register_cleanup_routine(void (*func)(void)); Pascal.
___________________________________________________________________________ Sent via: Wireshark-dev mailing list <wireshark-dev () wireshark org> Archives: https://www.wireshark.org/lists/wireshark-dev Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev mailto:wireshark-dev-request () wireshark org?subject=unsubscribe
Current thread:
- C equivalent of LUA proto.init Paul Offord (Aug 26)
- Re: C equivalent of LUA proto.init Pascal Quantin (Aug 26)
- Re: C equivalent of LUA proto.init Paul Offord (Aug 26)
- Re: C equivalent of LUA proto.init Pascal Quantin (Aug 26)