diff options
author | Martin Kaiser <wireshark@kaiser.cx> | 2019-06-14 13:29:35 -0700 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2019-06-16 02:39:18 +0000 |
commit | bfad6f03d64992794978c7deca9484f962620912 (patch) | |
tree | b71a10f6099c2155baef908088141c6eab0eab71 /epan/wslua | |
parent | 6d539de542cb72b225f361f7ee8021fc772f5338 (diff) |
wslua: add a Proto parameter to DissectorTable.new()
Add an optional paramter of type Proto to DissectorTable.new().
If the caller provides a Proto, we can get the protocol id and
use it when we register the dissector table.
Change-Id: I3ab0819c41fa97288ec962d8d495b63d4750ce4b
Reviewed-on: https://code.wireshark.org/review/33608
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/wslua')
-rw-r--r-- | epan/wslua/wslua_dissector.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/epan/wslua/wslua_dissector.c b/epan/wslua/wslua_dissector.c index 4a6b383dce..cce72331e5 100644 --- a/epan/wslua/wslua_dissector.c +++ b/epan/wslua/wslua_dissector.c @@ -171,11 +171,14 @@ WSLUA_CONSTRUCTOR DissectorTable_new (lua_State *L) { #define WSLUA_OPTARG_DissectorTable_new_BASE 4 /* Either `base.NONE`, `base.DEC`, `base.HEX`, `base.OCT`, `base.DEC_HEX` or `base.HEX_DEC` (defaults to `base.DEC`). */ +#define WSLUA_OPTARG_DissectorTable_new_PROTO 5 /* The protocol that uses this dissector table + (a Proto object). */ const gchar* name = (const gchar*)luaL_checkstring(L,WSLUA_ARG_DissectorTable_new_TABLENAME); const gchar* ui_name = (const gchar*)luaL_optstring(L,WSLUA_OPTARG_DissectorTable_new_UINAME,name); enum ftenum type = (enum ftenum)luaL_optinteger(L,WSLUA_OPTARG_DissectorTable_new_TYPE,FT_UINT32); unsigned base = (unsigned)luaL_optinteger(L,WSLUA_OPTARG_DissectorTable_new_BASE,BASE_DEC); DissectorTable dt; + int proto_id = -1; switch(type) { case FT_STRING: @@ -202,11 +205,14 @@ WSLUA_CONSTRUCTOR DissectorTable_new (lua_State *L) { dt = (DissectorTable)g_malloc(sizeof(struct _wslua_distbl_t)); - /* XXX - can't determine dependencies of Lua protocols - if they don't provide protocol name */ + if (isProto(L, WSLUA_OPTARG_DissectorTable_new_PROTO)) { + Proto proto = checkProto(L, WSLUA_OPTARG_DissectorTable_new_PROTO); + proto_id = proto_get_id_by_short_name(proto->name); + } + dt->table = (type == FT_NONE) ? - register_decode_as_next_proto(-1, name, ui_name, NULL) : - register_dissector_table(name, ui_name, -1, type, base); + register_decode_as_next_proto(proto_id, name, ui_name, NULL) : + register_dissector_table(name, ui_name, proto_id, type, base); dt->name = g_strdup(name); dt->ui_name = g_strdup(ui_name); dt->created = TRUE; |