Hi, Would anyone know if it's possible to get or set a preference of an existing protocol from Lua ? thanks asked 27 Jun '11, 10:22 izopizo showing 5 of 9 show 4 more comments |
2 Answers:
The fast answer is no. AFAIK, setting prefs of non-Lua protocols on-the-fly from Wireshark's Lua API is not possible. As a hack, Lua can "stage" a pref setting by writing to the Lua can read a pref that was set from the GUI as soon as the user changes it because updates are written to Your best bet is to submit an enhancement request for the Lua API (and vote!). answered 29 Jun '11, 23:48 helloworld |
Check this out: http://sharkfest.wireshark.org/sharkfest.09/DT06_Bjorlykke_Lua%20Scripting%20in%20Wireshark.pdf Page 33 is about Prefs.. answered 28 Jun '11, 02:06 Hiftu |
By "existing protocol", do you mean a protocol that was not registered from Lua (e.g., "ip")?
Yes, For example wireshark preferences file contains following attribute ip.defragment: TRUE Is there a way I can get or set this preference ?
I'm aware of the ability to get/set preferences if I define my own protocol in lua but I'm looking for a way of doing the same thing for protocols like IP/TCP/UDP or any other not registered from Lua.
There's not even a documented, supported way of doing that from C, much less from Lua.
Why do you want to know the settings of some other protocol's preferences? By doing so, you're making an assumption about what its preferences are, and that can change over time.
Looks simple from C. I know you need Lua, but since Guy mentioned it, I thought I'd list it in case someone cares:
read_prefs()
orread_prefs_file()
prefs_set_pref()
orset_pref()
Since all prefs are read from and written to a file, it is possible from Lua to read/set a preference of a protocol that wasn't originally registered from Lua. It's kind of a pain though...
But then there are command-line overrides (the
-o
flag) that aren't written to file, so Lua can't know about those...Exactly. Those routines were not intended to be used by dissectors; they're intended to be used by programs when starting up or, in the case of read_prefs_file(), by the code that maintains the "recents" file. They may or may not do what you want when used elsewhere, and they may or may not continue to exist with the current interface or even continue to exist at all.
Thanks for all your responses. What I was hoping to do was to change preferences on the fly. For example MTP3 protocol can come in different version ITU/ANSI I wanted to implement autodetection in LUA and change preferences on the fly accordingly
Thanks again
"Autodetection" in what sense? Are you, in effect, trying to enhance the MTP3 dissector in a Lua add-on, so that, rather than requiring the user to determine whether the MTP3 traffic is ITU or ANSI, the Lua script will look at the traffic, attempt to determine whether it's ITU or ANSI, and then change the preference accordingly?