diff options
author | Hadriel Kaplan <hadriel@128technology.com> | 2014-12-25 10:17:11 -0500 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2014-12-28 21:26:34 +0000 |
commit | 016769d7e2462c2238364d73c1dde1c4457fa486 (patch) | |
tree | e0eea46046a51ddd60986badf78fcb63346770dc /epan/wslua | |
parent | 5e16157de57a87ddd5879f937ebf287144179309 (diff) |
Expose dissector_add_for_decode_as() to Lua
Allow Lua scripts to add their Protocol's dissector for "Decode as...".
Bug: 10696
Change-Id: Ic270cc85eff62ccfc29d8e5fcbb48247cfcd14bd
Reviewed-on: https://code.wireshark.org/review/6050
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/wslua')
-rw-r--r-- | epan/wslua/wslua_proto.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/epan/wslua/wslua_proto.c b/epan/wslua/wslua_proto.c index 8e974a46e6..069ab373ff 100644 --- a/epan/wslua/wslua_proto.c +++ b/epan/wslua/wslua_proto.c @@ -2585,6 +2585,29 @@ WSLUA_METHOD DissectorTable_get_dissector (lua_State *L) { } } +WSLUA_METHOD DissectorTable_add_for_decode_as (lua_State *L) { + /* + Add the given `Proto` to the "Decode as..." list for this DissectorTable. + The passed-in `Proto` object's `dissector()` function is used for dissecting. + + @since 1.99.1 + */ +#define WSLUA_ARG_DissectorTable_add_for_decode_as_PROTO 2 /* The `Proto` to add. */ + DissectorTable dt = checkDissectorTable(L,1); + Proto proto = checkProto(L, WSLUA_ARG_DissectorTable_add_for_decode_as_PROTO); + dissector_handle_t handle = NULL; + + if (! proto->handle) { + proto->handle = new_register_dissector(proto->loname, dissect_lua, proto->hfid); + } + + handle = proto->handle; + + dissector_add_for_decode_as(dt->name, handle); + + return 0; +} + /* XXX It would be nice to iterate and print which dissectors it has */ WSLUA_METAMETHOD DissectorTable__tostring(lua_State* L) { /* Gets some debug information about the DissectorTable. */ @@ -2638,6 +2661,7 @@ WSLUA_METHODS DissectorTable_methods[] = { WSLUA_CLASS_FNREG(DissectorTable,remove_all), WSLUA_CLASS_FNREG(DissectorTable,try), WSLUA_CLASS_FNREG(DissectorTable,get_dissector), + WSLUA_CLASS_FNREG(DissectorTable,add_for_decode_as), { NULL, NULL } }; |