aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2011-08-11 00:49:43 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2011-08-11 00:49:43 +0000
commitfa4d32113c6f5f30ba1a4633681ccd03ef07b82b (patch)
tree6400c7fd40d0e2934d210e3874275dc6f0fe8147 /epan/wslua
parenta56ba849330154bf32126fd5151f2927898afc8a (diff)
From Alexander Stein via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6175 :
The attached patch adds the method reported_length_remaining to tvb. svn path=/trunk/; revision=38464
Diffstat (limited to 'epan/wslua')
-rw-r--r--epan/wslua/wslua_tvb.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/epan/wslua/wslua_tvb.c b/epan/wslua/wslua_tvb.c
index 89deb5b412..6697ed0211 100644
--- a/epan/wslua/wslua_tvb.c
+++ b/epan/wslua/wslua_tvb.c
@@ -478,6 +478,22 @@ WSLUA_METHOD Tvb_len(lua_State* L) {
WSLUA_RETURN(1); /* The length of the Tvb. */
}
+WSLUA_METHOD Tvb_reported_length_remaining(lua_State* L) {
+ /* Obtain the reported length of packet data to end of a TVB */
+#define Tvb_reported_length_remaining_OFFSET 2 /* offset */
+ Tvb tvb = checkTvb(L,1);
+ int offset = luaL_optint(L, Tvb_reported_length_remaining_OFFSET, 0);
+
+ if (!tvb) return 0;
+ if (tvb->expired) {
+ luaL_error(L,"expired tvb");
+ return 0;
+ }
+
+ lua_pushnumber(L,tvb_reported_length_remaining(tvb->ws_tvb, offset));
+ WSLUA_RETURN(1); /* The length of the Tvb. */
+}
+
WSLUA_METHOD Tvb_offset(lua_State* L) {
/* Returns the raw offset (from the beginning of the source Tvb) of a sub Tvb. */
Tvb tvb = checkTvb(L,1);
@@ -578,6 +594,7 @@ static const luaL_reg Tvb_methods[] = {
{"len", Tvb_len},
{"offset", Tvb_offset},
{"reported_len", Tvb_reported_len},
+ {"reported_length_remaining", Tvb_reported_length_remaining},
{ NULL, NULL }
};