diff options
-rw-r--r-- | epan/wslua/wslua_tvb.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/epan/wslua/wslua_tvb.c b/epan/wslua/wslua_tvb.c index 8d01ddc66e..3e5c817ecb 100644 --- a/epan/wslua/wslua_tvb.c +++ b/epan/wslua/wslua_tvb.c @@ -52,7 +52,7 @@ WSLUA_CLASS_DEFINE(Tvb,FAIL_ON_NULL_OR_EXPIRED("Tvb")); and can be used to extract information (via <<lua_class_TvbRange,`TvbRange`>>) from the packet's data. To create a <<lua_class_TvbRange,`TvbRange`>> the <<lua_class_Tvb,`Tvb`>> must be called with offset and length as optional arguments; - the offset defaults to 0 and the length to `tvb:len()`. + the offset defaults to 0 and the length to `tvb:captured_len()`. [WARNING] ==== @@ -132,15 +132,24 @@ static int Tvb__gc(lua_State* L) { } WSLUA_METHOD Tvb_reported_len(lua_State* L) { - /* Obtain the reported (not captured) length of a <<lua_class_Tvb,`Tvb`>>. */ + /* Obtain the reported length (length on the network) of a <<lua_class_Tvb,`Tvb`>>. */ Tvb tvb = checkTvb(L,1); lua_pushnumber(L,tvb_reported_length(tvb->ws_tvb)); WSLUA_RETURN(1); /* The reported length of the <<lua_class_Tvb,`Tvb`>>. */ } +WSLUA_METHOD Tvb_captured_len(lua_State* L) { + /* Obtain the captured length (amount saved in the capture process) of a <<lua_class_Tvb,`Tvb`>>. */ + Tvb tvb = checkTvb(L,1); + + lua_pushnumber(L,tvb_captured_length(tvb->ws_tvb)); + WSLUA_RETURN(1); /* The captured length of the <<lua_class_Tvb,`Tvb`>>. */ +} + WSLUA_METHOD Tvb_len(lua_State* L) { - /* Obtain the actual (captured) length of a <<lua_class_Tvb,`Tvb`>>. */ + /* Obtain the captured length (amount saved in the capture process) of a <<lua_class_Tvb,`Tvb`>>. + Same as captured_len; kept only for backwards compatibility */ Tvb tvb = checkTvb(L,1); lua_pushnumber(L,tvb_captured_length(tvb->ws_tvb)); @@ -299,10 +308,11 @@ WSLUA_METAMETHOD Tvb__eq(lua_State* L) { WSLUA_METHODS Tvb_methods[] = { WSLUA_CLASS_FNREG(Tvb,bytes), WSLUA_CLASS_FNREG(Tvb,range), - WSLUA_CLASS_FNREG(Tvb,len), WSLUA_CLASS_FNREG(Tvb,offset), WSLUA_CLASS_FNREG(Tvb,reported_len), WSLUA_CLASS_FNREG(Tvb,reported_length_remaining), + WSLUA_CLASS_FNREG(Tvb,captured_len), + WSLUA_CLASS_FNREG(Tvb,len), WSLUA_CLASS_FNREG(Tvb,raw), { NULL, NULL } }; |