wslua: add support for ft_none dissector tables

The C code introduced ft_none dissector tables some time ago. They have
no indicator to select the next protocol, only Decode As is supported
for them.

Allow lua code to create ft_none dissector tables as well. The patch
is trying to make as few changes as possible to DissectorTable_new().

Change-Id: Ie3ff58f092e6922ab7878d202c7484a64b2430a3
Reviewed-on: https://code.wireshark.org/review/33588
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Martin Kaiser 2019-06-12 09:53:08 -07:00 committed by Anders Broman
parent 24138a0a74
commit bf8bc8e007

View file

@ -19,6 +19,7 @@
#include "wslua.h"
#include <epan/decode_as.h>
#include <epan/exceptions.h>
#include <epan/show_exception.h>
@ -179,6 +180,8 @@ WSLUA_CONSTRUCTOR DissectorTable_new (lua_State *L) {
case FT_STRING:
base = BASE_NONE;
/* fallthrough */
case FT_NONE:
/* fallthrough */
case FT_UINT8:
case FT_UINT16:
case FT_UINT24:
@ -190,7 +193,9 @@ WSLUA_CONSTRUCTOR DissectorTable_new (lua_State *L) {
ui_name = g_strdup(ui_name);
/* XXX - can't determine dependencies of Lua protocols if they don't provide protocol name */
dt->table = register_dissector_table(name, ui_name, -1, type, base);
dt->table = (type == FT_NONE) ?
register_decode_as_next_proto(-1, name, ui_name, NULL) :
register_dissector_table(name, ui_name, -1, type, base);
dt->name = name;
dt->ui_name = ui_name;
dt->created = TRUE;
@ -205,7 +210,7 @@ WSLUA_CONSTRUCTOR DissectorTable_new (lua_State *L) {
}
WSLUA_RETURN(1); /* The newly created DissectorTable. */
default:
WSLUA_OPTARG_ERROR(DissectorTable_new,TYPE,"must be ftypes.UINT{8,16,24,32} or ftypes.STRING");
WSLUA_OPTARG_ERROR(DissectorTable_new,TYPE,"must be ftypes.UINT{8,16,24,32}, ftypes.STRING or ftypes.NONE");
break;
}
return 0;