diff options
Diffstat (limited to 'epan')
-rw-r--r-- | epan/wslua/init_wslua.c | 16 | ||||
-rw-r--r-- | epan/wslua/wslua.h | 4 |
2 files changed, 12 insertions, 8 deletions
diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c index 025e0547f2..2e8021c281 100644 --- a/epan/wslua/init_wslua.c +++ b/epan/wslua/init_wslua.c @@ -91,14 +91,14 @@ int dissect_lua(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) { /* if the Lua dissector reported the consumed bytes, pass it to our caller */ if (lua_isnumber(L, -1)) { - /* we got the consumed bytes ot the missing bytes as a negative number */ + /* we got the consumed bytes of the missing bytes as a negative number */ if ((consumed_bytes = (int) lua_tonumber(L, -1)) < 0) pinfo->desegment_len = 0 - consumed_bytes; - lua_pop(L, 1); - } else if (lua_isnil(L, -1)) { - /* got nil value, indicating that we need more bytes, but we - * don't know the exact number */ - pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT; + /* Lua dissectors may return DESEGMENT_ONE_MORE_SEGMENT indicating that + * it needs need more bytes, but the exact number of needed bytes is not known */ + if (consumed_bytes == DESEGMENT_ONE_MORE_SEGMENT) + pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT; + lua_pop(L, 1); } } @@ -276,6 +276,10 @@ int wslua_init(lua_State* LS) { /* set running_superuser variable to it's propper value */ WSLUA_REG_GLOBAL_BOOL(L,"running_superuser",started_with_special_privs()); + + /* special constant used by PDU reassembly handling */ + /* see dissect_lua() for notes */ + WSLUA_REG_GLOBAL_NUMBER(L,"DESEGMENT_ONE_MORE_SEGMENT",DESEGMENT_ONE_MORE_SEGMENT); /* load system's init.lua */ filename = get_datafile_path("init.lua"); diff --git a/epan/wslua/wslua.h b/epan/wslua/wslua.h index 797cdbc427..7403d03c06 100644 --- a/epan/wslua/wslua.h +++ b/epan/wslua/wslua.h @@ -329,8 +329,8 @@ typedef int dummy##C #define WSLUA_OPTARG_ERROR(name,attr,error) { luaL_argerror(L,WSLUA_OPTARG_##name##_ ##attr, #name ": " error); return 0; } #define WSLUA_REG_GLOBAL_BOOL(L,n,v) { lua_pushstring(L,n); lua_pushboolean(L,v); lua_settable(L, LUA_GLOBALSINDEX); } -#define WSLUA_REG_GLOBAL_STRING(n,v) { lua_pushstring(L,n); lua_pushstring(L,v); lua_settable(L, LUA_GLOBALSINDEX); } -#define WSLUA_REG_GLOBAL_NUMBER(n,v) { lua_pushstring(L,n); lua_pushnumber(L,v); lua_settable(L, LUA_GLOBALSINDEX); } +#define WSLUA_REG_GLOBAL_STRING(L,n,v) { lua_pushstring(L,n); lua_pushstring(L,v); lua_settable(L, LUA_GLOBALSINDEX); } +#define WSLUA_REG_GLOBAL_NUMBER(L,n,v) { lua_pushstring(L,n); lua_pushnumber(L,v); lua_settable(L, LUA_GLOBALSINDEX); } #define WSLUA_RETURN(i) return (i); |