wslua: Update the ByteArray and Tvb docs.
Add content from https://wiki.wireshark.org/LuaAPI/ByteArray and https://wiki.wireshark.org/LuaAPI/Tvb. Update as needed. Remove an extraneous trailing semicolon. Change-Id: I857b748821c21413ecb563c150525575fc9b947a Reviewed-on: https://code.wireshark.org/review/36635 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
ed3fe162bd
commit
da04d89f1e
|
@ -644,7 +644,7 @@ extern int wslua_reg_attributes(lua_State *L, const wslua_attribute_table *t, gb
|
||||||
#define WSLUA_REG_GLOBAL_STRING(L,n,v) { lua_pushstring(L,v); lua_setglobal(L,n); }
|
#define WSLUA_REG_GLOBAL_STRING(L,n,v) { lua_pushstring(L,v); lua_setglobal(L,n); }
|
||||||
#define WSLUA_REG_GLOBAL_NUMBER(L,n,v) { lua_pushnumber(L,v); lua_setglobal(L,n); }
|
#define WSLUA_REG_GLOBAL_NUMBER(L,n,v) { lua_pushnumber(L,v); lua_setglobal(L,n); }
|
||||||
|
|
||||||
#define WSLUA_RETURN(i) return (i);
|
#define WSLUA_RETURN(i) return (i)
|
||||||
|
|
||||||
#define WSLUA_API extern
|
#define WSLUA_API extern
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,22 @@
|
||||||
WSLUA_CLASS_DEFINE(ByteArray,FAIL_ON_NULL("ByteArray"));
|
WSLUA_CLASS_DEFINE(ByteArray,FAIL_ON_NULL("ByteArray"));
|
||||||
|
|
||||||
WSLUA_CONSTRUCTOR ByteArray_new(lua_State* L) {
|
WSLUA_CONSTRUCTOR ByteArray_new(lua_State* L) {
|
||||||
/* Creates a `ByteArray` object.
|
/*
|
||||||
|
Creates a new <<lua_class_ByteArray,`ByteArray`>> object.
|
||||||
|
|
||||||
Starting in version 1.11.3, if the second argument is a boolean `true`,
|
Starting in version 1.11.3, if the second argument is a boolean `true`,
|
||||||
then the first argyument is treated as a raw Lua string of bytes to use,
|
then the first argument is treated as a raw Lua string of bytes to use,
|
||||||
instead of a hexadecimal string.
|
instead of a hexadecimal string.
|
||||||
*/
|
|
||||||
|
===== Example
|
||||||
|
|
||||||
|
[source,lua]
|
||||||
|
----
|
||||||
|
local empty = ByteArray.new()
|
||||||
|
local b1 = ByteArray.new("a1 b2 c3 d4")
|
||||||
|
local b2 = ByteArray.new("112233")
|
||||||
|
----
|
||||||
|
*/
|
||||||
#define WSLUA_OPTARG_ByteArray_new_HEXBYTES 1 /* A string consisting of hexadecimal bytes like "00 B1 A2" or "1a2b3c4d". */
|
#define WSLUA_OPTARG_ByteArray_new_HEXBYTES 1 /* A string consisting of hexadecimal bytes like "00 B1 A2" or "1a2b3c4d". */
|
||||||
#define WSLUA_OPTARG_ByteArray_new_SEPARATOR 2 /* A string separator between hex bytes/words (default=" "),
|
#define WSLUA_OPTARG_ByteArray_new_SEPARATOR 2 /* A string separator between hex bytes/words (default=" "),
|
||||||
or if the boolean value `true` is used, then the first argument
|
or if the boolean value `true` is used, then the first argument
|
||||||
|
@ -79,7 +89,7 @@ static int ByteArray__gc(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METAMETHOD ByteArray__concat(lua_State* L) {
|
WSLUA_METAMETHOD ByteArray__concat(lua_State* L) {
|
||||||
/* Concatenate two `ByteArrays`. */
|
/* Concatenate two <<lua_class_ByteArray,`ByteArray`>>s. */
|
||||||
#define WSLUA_ARG_ByteArray__cat_FIRST 1 /* First array. */
|
#define WSLUA_ARG_ByteArray__cat_FIRST 1 /* First array. */
|
||||||
#define WSLUA_ARG_ByteArray__cat_SECOND 2 /* Second array. */
|
#define WSLUA_ARG_ByteArray__cat_SECOND 2 /* Second array. */
|
||||||
|
|
||||||
|
@ -92,7 +102,7 @@ WSLUA_METAMETHOD ByteArray__concat(lua_State* L) {
|
||||||
g_byte_array_append(ba,ba2->data,ba2->len);
|
g_byte_array_append(ba,ba2->data,ba2->len);
|
||||||
|
|
||||||
pushByteArray(L,ba);
|
pushByteArray(L,ba);
|
||||||
WSLUA_RETURN(1); /* The new composite `ByteArray`. */
|
WSLUA_RETURN(1); /* The new composite <<lua_class_ByteArray,`ByteArray`>>. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METAMETHOD ByteArray__eq(lua_State* L) {
|
WSLUA_METAMETHOD ByteArray__eq(lua_State* L) {
|
||||||
|
@ -117,8 +127,8 @@ WSLUA_METAMETHOD ByteArray__eq(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD ByteArray_prepend(lua_State* L) {
|
WSLUA_METHOD ByteArray_prepend(lua_State* L) {
|
||||||
/* Prepend a `ByteArray` to this `ByteArray`. */
|
/* Prepend a <<lua_class_ByteArray,`ByteArray`>> to this <<lua_class_ByteArray,`ByteArray`>>. */
|
||||||
#define WSLUA_ARG_ByteArray_prepend_PREPENDED 2 /* `ByteArray` to be prepended. */
|
#define WSLUA_ARG_ByteArray_prepend_PREPENDED 2 /* <<lua_class_ByteArray,`ByteArray`>> to be prepended. */
|
||||||
ByteArray ba = checkByteArray(L,1);
|
ByteArray ba = checkByteArray(L,1);
|
||||||
ByteArray ba2 = checkByteArray(L,WSLUA_ARG_ByteArray_prepend_PREPENDED);
|
ByteArray ba2 = checkByteArray(L,WSLUA_ARG_ByteArray_prepend_PREPENDED);
|
||||||
|
|
||||||
|
@ -128,8 +138,8 @@ WSLUA_METHOD ByteArray_prepend(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD ByteArray_append(lua_State* L) {
|
WSLUA_METHOD ByteArray_append(lua_State* L) {
|
||||||
/* Append a `ByteArray` to this `ByteArray`. */
|
/* Append a <<lua_class_ByteArray,`ByteArray`>> to this <<lua_class_ByteArray,`ByteArray`>>. */
|
||||||
#define WSLUA_ARG_ByteArray_append_APPENDED 2 /* `ByteArray` to be appended. */
|
#define WSLUA_ARG_ByteArray_append_APPENDED 2 /* <<lua_class_ByteArray,`ByteArray`>> to be appended. */
|
||||||
ByteArray ba = checkByteArray(L,1);
|
ByteArray ba = checkByteArray(L,1);
|
||||||
ByteArray ba2 = checkByteArray(L,WSLUA_ARG_ByteArray_append_APPENDED);
|
ByteArray ba2 = checkByteArray(L,WSLUA_ARG_ByteArray_append_APPENDED);
|
||||||
|
|
||||||
|
@ -139,7 +149,7 @@ WSLUA_METHOD ByteArray_append(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD ByteArray_set_size(lua_State* L) {
|
WSLUA_METHOD ByteArray_set_size(lua_State* L) {
|
||||||
/* Sets the size of a `ByteArray`, either truncating it or filling it with zeros. */
|
/* Sets the size of a <<lua_class_ByteArray,`ByteArray`>>, either truncating it or filling it with zeros. */
|
||||||
#define WSLUA_ARG_ByteArray_set_size_SIZE 2 /* New size of the array. */
|
#define WSLUA_ARG_ByteArray_set_size_SIZE 2 /* New size of the array. */
|
||||||
|
|
||||||
ByteArray ba = checkByteArray(L,1);
|
ByteArray ba = checkByteArray(L,1);
|
||||||
|
@ -162,7 +172,7 @@ WSLUA_METHOD ByteArray_set_size(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD ByteArray_set_index(lua_State* L) {
|
WSLUA_METHOD ByteArray_set_index(lua_State* L) {
|
||||||
/* Sets the value of an index of a `ByteArray`. */
|
/* Sets the value of an index of a <<lua_class_ByteArray,`ByteArray`>>. */
|
||||||
#define WSLUA_ARG_ByteArray_set_index_INDEX 2 /* The position of the byte to be set. */
|
#define WSLUA_ARG_ByteArray_set_index_INDEX 2 /* The position of the byte to be set. */
|
||||||
#define WSLUA_ARG_ByteArray_set_index_VALUE 3 /* The char value to set [0-255]. */
|
#define WSLUA_ARG_ByteArray_set_index_VALUE 3 /* The char value to set [0-255]. */
|
||||||
ByteArray ba = checkByteArray(L,1);
|
ByteArray ba = checkByteArray(L,1);
|
||||||
|
@ -191,7 +201,7 @@ WSLUA_METHOD ByteArray_set_index(lua_State* L) {
|
||||||
|
|
||||||
|
|
||||||
WSLUA_METHOD ByteArray_get_index(lua_State* L) {
|
WSLUA_METHOD ByteArray_get_index(lua_State* L) {
|
||||||
/* Get the value of a byte in a `ByteArray`. */
|
/* Get the value of a byte in a <<lua_class_ByteArray,`ByteArray`>>. */
|
||||||
#define WSLUA_ARG_ByteArray_get_index_INDEX 2 /* The position of the byte to get. */
|
#define WSLUA_ARG_ByteArray_get_index_INDEX 2 /* The position of the byte to get. */
|
||||||
ByteArray ba = checkByteArray(L,1);
|
ByteArray ba = checkByteArray(L,1);
|
||||||
int idx = (int)luaL_checkinteger(L,WSLUA_ARG_ByteArray_get_index_INDEX);
|
int idx = (int)luaL_checkinteger(L,WSLUA_ARG_ByteArray_get_index_INDEX);
|
||||||
|
@ -211,16 +221,16 @@ WSLUA_METHOD ByteArray_get_index(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD ByteArray_len(lua_State* L) {
|
WSLUA_METHOD ByteArray_len(lua_State* L) {
|
||||||
/* Obtain the length of a `ByteArray`. */
|
/* Obtain the length of a <<lua_class_ByteArray,`ByteArray`>>. */
|
||||||
ByteArray ba = checkByteArray(L,1);
|
ByteArray ba = checkByteArray(L,1);
|
||||||
|
|
||||||
lua_pushnumber(L,(lua_Number)ba->len);
|
lua_pushnumber(L,(lua_Number)ba->len);
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* The length of the `ByteArray`. */
|
WSLUA_RETURN(1); /* The length of the <<lua_class_ByteArray,`ByteArray`>>. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD ByteArray_subset(lua_State* L) {
|
WSLUA_METHOD ByteArray_subset(lua_State* L) {
|
||||||
/* Obtain a segment of a `ByteArray`, as a new `ByteArray`. */
|
/* Obtain a segment of a <<lua_class_ByteArray,`ByteArray`>>, as a new <<lua_class_ByteArray,`ByteArray`>>. */
|
||||||
#define WSLUA_ARG_ByteArray_set_index_OFFSET 2 /* The position of the first byte (0=first). */
|
#define WSLUA_ARG_ByteArray_set_index_OFFSET 2 /* The position of the first byte (0=first). */
|
||||||
#define WSLUA_ARG_ByteArray_set_index_LENGTH 3 /* The length of the segment. */
|
#define WSLUA_ARG_ByteArray_set_index_LENGTH 3 /* The length of the segment. */
|
||||||
ByteArray ba = checkByteArray(L,1);
|
ByteArray ba = checkByteArray(L,1);
|
||||||
|
@ -238,11 +248,11 @@ WSLUA_METHOD ByteArray_subset(lua_State* L) {
|
||||||
|
|
||||||
pushByteArray(L,sub);
|
pushByteArray(L,sub);
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* A `ByteArray` containing the requested segment. */
|
WSLUA_RETURN(1); /* A <<lua_class_ByteArray,`ByteArray`>> containing the requested segment. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD ByteArray_base64_decode(lua_State* L) {
|
WSLUA_METHOD ByteArray_base64_decode(lua_State* L) {
|
||||||
/* Obtain a Base64 decoded `ByteArray`.
|
/* Obtain a Base64 decoded <<lua_class_ByteArray,`ByteArray`>>.
|
||||||
|
|
||||||
@since 1.11.3
|
@since 1.11.3
|
||||||
*/
|
*/
|
||||||
|
@ -263,11 +273,11 @@ WSLUA_METHOD ByteArray_base64_decode(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pushByteArray(L,ba2);
|
pushByteArray(L,ba2);
|
||||||
WSLUA_RETURN(1); /* The created `ByteArray`. */
|
WSLUA_RETURN(1); /* The created <<lua_class_ByteArray,`ByteArray`>>. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD ByteArray_raw(lua_State* L) {
|
WSLUA_METHOD ByteArray_raw(lua_State* L) {
|
||||||
/* Obtain a Lua string of the binary bytes in a `ByteArray`.
|
/* Obtain a Lua string of the binary bytes in a <<lua_class_ByteArray,`ByteArray`>>.
|
||||||
|
|
||||||
@since 1.11.3
|
@since 1.11.3
|
||||||
*/
|
*/
|
||||||
|
@ -293,7 +303,7 @@ WSLUA_METHOD ByteArray_raw(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD ByteArray_tohex(lua_State* L) {
|
WSLUA_METHOD ByteArray_tohex(lua_State* L) {
|
||||||
/* Obtain a Lua string of the bytes in a `ByteArray` as hex-ascii, with given separator
|
/* Obtain a Lua string of the bytes in a <<lua_class_ByteArray,`ByteArray`>> as hex-ascii, with given separator
|
||||||
|
|
||||||
@since 1.11.3
|
@since 1.11.3
|
||||||
*/
|
*/
|
||||||
|
@ -310,11 +320,11 @@ WSLUA_METHOD ByteArray_tohex(lua_State* L) {
|
||||||
|
|
||||||
wslua_bin2hex(L, ba->data, ba->len, lowercase, sep);
|
wslua_bin2hex(L, ba->data, ba->len, lowercase, sep);
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* A hex-ascii string representation of the `ByteArray`. */
|
WSLUA_RETURN(1); /* A hex-ascii string representation of the <<lua_class_ByteArray,`ByteArray`>>. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METAMETHOD ByteArray__tostring(lua_State* L) {
|
WSLUA_METAMETHOD ByteArray__tostring(lua_State* L) {
|
||||||
/* Obtain a Lua string containing the bytes in a `ByteArray` so that it can be used in
|
/* Obtain a Lua string containing the bytes in a <<lua_class_ByteArray,`ByteArray`>> so that it can be used in
|
||||||
display filters (e.g. "01FE456789AB"). */
|
display filters (e.g. "01FE456789AB"). */
|
||||||
ByteArray ba = checkByteArray(L,1);
|
ByteArray ba = checkByteArray(L,1);
|
||||||
|
|
||||||
|
@ -322,12 +332,29 @@ WSLUA_METAMETHOD ByteArray__tostring(lua_State* L) {
|
||||||
|
|
||||||
wslua_bin2hex(L, ba->data, ba->len, FALSE, NULL);
|
wslua_bin2hex(L, ba->data, ba->len, FALSE, NULL);
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* A hex-ascii string representation of the `ByteArray`. */
|
WSLUA_RETURN(1); /* A hex-ascii string representation of the <<lua_class_ByteArray,`ByteArray`>>. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD ByteArray_tvb (lua_State *L) {
|
WSLUA_METHOD ByteArray_tvb (lua_State *L) {
|
||||||
/* Creates a new `Tvb` from a `ByteArray` (it gets added to the current frame too). */
|
/*
|
||||||
#define WSLUA_ARG_ByteArray_tvb_NAME 2 /* The name to be given to the new data-source. */
|
Creates a new <<lua_class_Tvb,`Tvb`>> from a <<lua_class_ByteArray,`ByteArray`>>.
|
||||||
|
The <<lua_class_Tvb,`Tvb`>> will be added to the current frame.
|
||||||
|
|
||||||
|
===== Example
|
||||||
|
|
||||||
|
[source,lua]
|
||||||
|
----
|
||||||
|
function proto_foo.dissector(buf, pinfo, tree)
|
||||||
|
-- Create a new tab named "My Tvb" and add some data to it
|
||||||
|
local b = ByteArray.new("11223344")
|
||||||
|
local tvb = ByteArray.tvb(b, "My Tvb")
|
||||||
|
|
||||||
|
-- Create a tree item that, when clicked, automatically shows the tab we just created
|
||||||
|
tree:add( tvb(1,2), "Foo" )
|
||||||
|
end
|
||||||
|
----
|
||||||
|
*/
|
||||||
|
#define WSLUA_ARG_ByteArray_tvb_NAME 2 /* The name to be given to the new data source. */
|
||||||
ByteArray ba = checkByteArray(L,1);
|
ByteArray ba = checkByteArray(L,1);
|
||||||
const gchar* name = luaL_optstring(L,WSLUA_ARG_ByteArray_tvb_NAME,"Unnamed") ;
|
const gchar* name = luaL_optstring(L,WSLUA_ARG_ByteArray_tvb_NAME,"Unnamed") ;
|
||||||
guint8* data;
|
guint8* data;
|
||||||
|
@ -348,7 +375,7 @@ WSLUA_METHOD ByteArray_tvb (lua_State *L) {
|
||||||
|
|
||||||
add_new_data_source(lua_pinfo, tvb->ws_tvb, name);
|
add_new_data_source(lua_pinfo, tvb->ws_tvb, name);
|
||||||
push_wsluaTvb(L,tvb);
|
push_wsluaTvb(L,tvb);
|
||||||
WSLUA_RETURN(1); /* The created `Tvb`. */
|
WSLUA_RETURN(1); /* The created <<lua_class_Tvb,`Tvb`>>. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,16 +48,16 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
WSLUA_CLASS_DEFINE(Tvb,FAIL_ON_NULL_OR_EXPIRED("Tvb"));
|
WSLUA_CLASS_DEFINE(Tvb,FAIL_ON_NULL_OR_EXPIRED("Tvb"));
|
||||||
/* A `Tvb` represents the packet's buffer. It is passed as an argument to listeners and dissectors,
|
/* A <<lua_class_Tvb,`Tvb`>> represents the packet's buffer. It is passed as an argument to listeners and dissectors,
|
||||||
and can be used to extract information (via `TvbRange`) from the packet's data.
|
and can be used to extract information (via <<lua_class_TvbRange,`TvbRange`>>) from the packet's data.
|
||||||
|
|
||||||
To create a `TvbRange` the `Tvb` must be called with offset and length as optional arguments;
|
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:len()`.
|
||||||
|
|
||||||
[WARNING]
|
[WARNING]
|
||||||
====
|
====
|
||||||
Tvbs are usable only by the current listener or dissector call and are destroyed
|
Tvbs are usable only by the current listener or dissector call and are destroyed
|
||||||
as soon as the listener/dissector returns, so references to them are unusable once the function
|
as soon as the listener or dissector returns, so references to them are unusable once the function
|
||||||
has returned.
|
has returned.
|
||||||
====
|
====
|
||||||
*/
|
*/
|
||||||
|
@ -106,8 +106,10 @@ Tvb* push_Tvb(lua_State* L, tvbuff_t* ws_tvb) {
|
||||||
|
|
||||||
|
|
||||||
WSLUA_METAMETHOD Tvb__tostring(lua_State* L) {
|
WSLUA_METAMETHOD Tvb__tostring(lua_State* L) {
|
||||||
/* Convert the bytes of a `Tvb` into a string, to be used for debugging purposes, as '...'
|
/*
|
||||||
will be appended if the string is too long. */
|
Convert the bytes of a <<lua_class_Tvb,`Tvb`>> into a string.
|
||||||
|
This is primarily useful for debugging purposes since the string will be truncated if it is too long.
|
||||||
|
*/
|
||||||
Tvb tvb = checkTvb(L,1);
|
Tvb tvb = checkTvb(L,1);
|
||||||
int len = tvb_captured_length(tvb->ws_tvb);
|
int len = tvb_captured_length(tvb->ws_tvb);
|
||||||
char* str = tvb_bytes_to_str(NULL,tvb->ws_tvb,0,len);
|
char* str = tvb_bytes_to_str(NULL,tvb->ws_tvb,0,len);
|
||||||
|
@ -130,39 +132,39 @@ static int Tvb__gc(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD Tvb_reported_len(lua_State* L) {
|
WSLUA_METHOD Tvb_reported_len(lua_State* L) {
|
||||||
/* Obtain the reported (not captured) length of a `Tvb`. */
|
/* Obtain the reported (not captured) length of a <<lua_class_Tvb,`Tvb`>>. */
|
||||||
Tvb tvb = checkTvb(L,1);
|
Tvb tvb = checkTvb(L,1);
|
||||||
|
|
||||||
lua_pushnumber(L,tvb_reported_length(tvb->ws_tvb));
|
lua_pushnumber(L,tvb_reported_length(tvb->ws_tvb));
|
||||||
WSLUA_RETURN(1); /* The reported length of the `Tvb`. */
|
WSLUA_RETURN(1); /* The reported length of the <<lua_class_Tvb,`Tvb`>>. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD Tvb_len(lua_State* L) {
|
WSLUA_METHOD Tvb_len(lua_State* L) {
|
||||||
/* Obtain the actual (captured) length of a `Tvb`. */
|
/* Obtain the actual (captured) length of a <<lua_class_Tvb,`Tvb`>>. */
|
||||||
Tvb tvb = checkTvb(L,1);
|
Tvb tvb = checkTvb(L,1);
|
||||||
|
|
||||||
lua_pushnumber(L,tvb_captured_length(tvb->ws_tvb));
|
lua_pushnumber(L,tvb_captured_length(tvb->ws_tvb));
|
||||||
WSLUA_RETURN(1); /* The captured length of the `Tvb`. */
|
WSLUA_RETURN(1); /* The captured length of the <<lua_class_Tvb,`Tvb`>>. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD Tvb_reported_length_remaining(lua_State* L) {
|
WSLUA_METHOD Tvb_reported_length_remaining(lua_State* L) {
|
||||||
/* Obtain the reported (not captured) length of packet data to end of a `Tvb` or -1 if the
|
/* Obtain the reported (not captured) length of packet data to end of a <<lua_class_Tvb,`Tvb`>> or -1 if the
|
||||||
offset is beyond the end of the `Tvb`. */
|
offset is beyond the end of the <<lua_class_Tvb,`Tvb`>>. */
|
||||||
#define Tvb_reported_length_remaining_OFFSET 2 /* offset */
|
#define Tvb_reported_length_remaining_OFFSET 2 /* offset */
|
||||||
Tvb tvb = checkTvb(L,1);
|
Tvb tvb = checkTvb(L,1);
|
||||||
int offset = (int) luaL_optinteger(L, Tvb_reported_length_remaining_OFFSET, 0);
|
int offset = (int) luaL_optinteger(L, Tvb_reported_length_remaining_OFFSET, 0);
|
||||||
|
|
||||||
lua_pushnumber(L,tvb_reported_length_remaining(tvb->ws_tvb, offset));
|
lua_pushnumber(L,tvb_reported_length_remaining(tvb->ws_tvb, offset));
|
||||||
WSLUA_RETURN(1); /* The captured length of the `Tvb`. */
|
WSLUA_RETURN(1); /* The captured length of the <<lua_class_Tvb,`Tvb`>>. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD Tvb_bytes(lua_State* L) {
|
WSLUA_METHOD Tvb_bytes(lua_State* L) {
|
||||||
/* Obtain a `ByteArray` from a `Tvb`.
|
/* Obtain a <<lua_class_ByteArray,`ByteArray`>> from a <<lua_class_Tvb,`Tvb`>>.
|
||||||
|
|
||||||
@since 1.99.8
|
@since 1.99.8
|
||||||
*/
|
*/
|
||||||
#define WSLUA_OPTARG_Tvb_bytes_OFFSET 2 /* The offset (in octets) from the beginning of the `Tvb`. Defaults to 0. */
|
#define WSLUA_OPTARG_Tvb_bytes_OFFSET 2 /* The offset (in octets) from the beginning of the <<lua_class_Tvb,`Tvb`>>. Defaults to 0. */
|
||||||
#define WSLUA_OPTARG_Tvb_bytes_LENGTH 3 /* The length (in octets) of the range. Defaults to until the end of the `Tvb`. */
|
#define WSLUA_OPTARG_Tvb_bytes_LENGTH 3 /* The length (in octets) of the range. Defaults to until the end of the <<lua_class_Tvb,`Tvb`>>. */
|
||||||
Tvb tvb = checkTvb(L,1);
|
Tvb tvb = checkTvb(L,1);
|
||||||
GByteArray* ba;
|
GByteArray* ba;
|
||||||
int offset = luaL_optint(L, WSLUA_OPTARG_Tvb_bytes_OFFSET, 0);
|
int offset = luaL_optint(L, WSLUA_OPTARG_Tvb_bytes_OFFSET, 0);
|
||||||
|
@ -188,15 +190,15 @@ WSLUA_METHOD Tvb_bytes(lua_State* L) {
|
||||||
g_byte_array_append(ba, tvb_get_ptr(tvb->ws_tvb, offset, len), len);
|
g_byte_array_append(ba, tvb_get_ptr(tvb->ws_tvb, offset, len), len);
|
||||||
pushByteArray(L,ba);
|
pushByteArray(L,ba);
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* The `ByteArray` object or nil. */
|
WSLUA_RETURN(1); /* The <<lua_class_ByteArray,`ByteArray`>> object or nil. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD Tvb_offset(lua_State* L) {
|
WSLUA_METHOD Tvb_offset(lua_State* L) {
|
||||||
/* Returns the raw offset (from the beginning of the source `Tvb`) of a sub `Tvb`. */
|
/* Returns the raw offset (from the beginning of the source <<lua_class_Tvb,`Tvb`>>) of a sub <<lua_class_Tvb,`Tvb`>>. */
|
||||||
Tvb tvb = checkTvb(L,1);
|
Tvb tvb = checkTvb(L,1);
|
||||||
|
|
||||||
lua_pushnumber(L,tvb_raw_offset(tvb->ws_tvb));
|
lua_pushnumber(L,tvb_raw_offset(tvb->ws_tvb));
|
||||||
WSLUA_RETURN(1); /* The raw offset of the `Tvb`. */
|
WSLUA_RETURN(1); /* The raw offset of the <<lua_class_Tvb,`Tvb`>>. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -209,9 +211,9 @@ WSLUA_METAMETHOD Tvb__call(lua_State* L) {
|
||||||
|
|
||||||
|
|
||||||
WSLUA_METHOD Tvb_range(lua_State* L) {
|
WSLUA_METHOD Tvb_range(lua_State* L) {
|
||||||
/* Creates a `TvbRange` from this `Tvb`. */
|
/* Creates a <<lua_class_TvbRange,`TvbRange`>> from this <<lua_class_Tvb,`Tvb`>>. */
|
||||||
#define WSLUA_OPTARG_Tvb_range_OFFSET 2 /* The offset (in octets) from the beginning of the `Tvb`. Defaults to 0. */
|
#define WSLUA_OPTARG_Tvb_range_OFFSET 2 /* The offset (in octets) from the beginning of the <<lua_class_Tvb,`Tvb`>>. Defaults to 0. */
|
||||||
#define WSLUA_OPTARG_Tvb_range_LENGTH 3 /* The length (in octets) of the range. Defaults to until the end of the `Tvb`. */
|
#define WSLUA_OPTARG_Tvb_range_LENGTH 3 /* The length (in octets) of the range. Defaults to -1, which specifies the remaining bytes in the <<lua_class_Tvb,`Tvb`>>. */
|
||||||
|
|
||||||
Tvb tvb = checkTvb(L,1);
|
Tvb tvb = checkTvb(L,1);
|
||||||
int offset = (int) luaL_optinteger(L,WSLUA_OPTARG_Tvb_range_OFFSET,0);
|
int offset = (int) luaL_optinteger(L,WSLUA_OPTARG_Tvb_range_OFFSET,0);
|
||||||
|
@ -225,12 +227,12 @@ WSLUA_METHOD Tvb_range(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD Tvb_raw(lua_State* L) {
|
WSLUA_METHOD Tvb_raw(lua_State* L) {
|
||||||
/* Obtain a Lua string of the binary bytes in a `Tvb`.
|
/* Obtain a Lua string of the binary bytes in a <<lua_class_Tvb,`Tvb`>>.
|
||||||
|
|
||||||
@since 1.11.3
|
@since 1.11.3
|
||||||
*/
|
*/
|
||||||
#define WSLUA_OPTARG_Tvb_raw_OFFSET 2 /* The position of the first byte (default=0/first). */
|
#define WSLUA_OPTARG_Tvb_raw_OFFSET 2 /* The position of the first byte. Default is 0, or the first byte. */
|
||||||
#define WSLUA_OPTARG_Tvb_raw_LENGTH 3 /* The length of the segment to get (default=all). */
|
#define WSLUA_OPTARG_Tvb_raw_LENGTH 3 /* The length of the segment to get. Default is -1, or the remaining bytes in the <<lua_class_Tvb,`Tvb`>>. */
|
||||||
Tvb tvb = checkTvb(L,1);
|
Tvb tvb = checkTvb(L,1);
|
||||||
int offset = (int) luaL_optinteger(L,WSLUA_OPTARG_Tvb_raw_OFFSET,0);
|
int offset = (int) luaL_optinteger(L,WSLUA_OPTARG_Tvb_raw_OFFSET,0);
|
||||||
int len = (int) luaL_optinteger(L,WSLUA_OPTARG_Tvb_raw_LENGTH,-1);
|
int len = (int) luaL_optinteger(L,WSLUA_OPTARG_Tvb_raw_LENGTH,-1);
|
||||||
|
@ -259,11 +261,11 @@ WSLUA_METHOD Tvb_raw(lua_State* L) {
|
||||||
|
|
||||||
lua_pushlstring(L, tvb_get_ptr(tvb->ws_tvb, offset, len), len);
|
lua_pushlstring(L, tvb_get_ptr(tvb->ws_tvb, offset, len), len);
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* A Lua string of the binary bytes in the `Tvb`. */
|
WSLUA_RETURN(1); /* A Lua string of the binary bytes in the <<lua_class_Tvb,`Tvb`>>. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METAMETHOD Tvb__eq(lua_State* L) {
|
WSLUA_METAMETHOD Tvb__eq(lua_State* L) {
|
||||||
/* Checks whether the two `Tvb` contents are equal.
|
/* Checks whether contents of two <<lua_class_Tvb,`Tvb`>>s are equal.
|
||||||
|
|
||||||
@since 1.99.8
|
@since 1.99.8
|
||||||
*/
|
*/
|
||||||
|
@ -322,13 +324,12 @@ int Tvb_register(lua_State* L) {
|
||||||
|
|
||||||
|
|
||||||
WSLUA_CLASS_DEFINE(TvbRange,FAIL_ON_NULL("TvbRange"));
|
WSLUA_CLASS_DEFINE(TvbRange,FAIL_ON_NULL("TvbRange"));
|
||||||
/*
|
/*
|
||||||
A `TvbRange` represents a usable range of a `Tvb` and is used to extract data from the `Tvb` that generated it.
|
A <<lua_class_TvbRange,`TvbRange`>> represents a usable range of a <<lua_class_Tvb,`Tvb`>> and is used to extract data from the <<lua_class_Tvb,`Tvb`>> that generated it.
|
||||||
|
|
||||||
`TvbRange`s are created by calling a `Tvb` (e.g. 'tvb(offset,length)'). If the `TvbRange` span is outside the
|
|
||||||
`Tvb`'s range the creation will cause a runtime error.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
<<lua_class_TvbRange,`TvbRange`>>s are created by calling a <<lua_class_Tvb,`Tvb`>> (e.g. 'tvb(offset,length)').
|
||||||
|
If the <<lua_class_TvbRange,`TvbRange`>> span is outside the <<lua_class_Tvb,`Tvb`>>'s range the creation will cause a runtime error.
|
||||||
|
*/
|
||||||
|
|
||||||
static void free_TvbRange(TvbRange tvbr) {
|
static void free_TvbRange(TvbRange tvbr) {
|
||||||
if (!(tvbr && tvbr->tvb)) return;
|
if (!(tvbr && tvbr->tvb)) return;
|
||||||
|
@ -383,7 +384,7 @@ gboolean push_TvbRange(lua_State* L, tvbuff_t* ws_tvb, int offset, int len) {
|
||||||
|
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_tvb(lua_State *L) {
|
WSLUA_METHOD TvbRange_tvb(lua_State *L) {
|
||||||
/* Creates a (sub)`Tvb` from a `TvbRange`. */
|
/* Creates a new <<lua_class_Tvb,`Tvb`>> from a <<lua_class_TvbRange,`TvbRange`>>. */
|
||||||
|
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
Tvb tvb;
|
Tvb tvb;
|
||||||
|
@ -411,7 +412,7 @@ WSLUA_METHOD TvbRange_tvb(lua_State *L) {
|
||||||
* get a Blefuscuoan unsigned integer from a tvb
|
* get a Blefuscuoan unsigned integer from a tvb
|
||||||
*/
|
*/
|
||||||
WSLUA_METHOD TvbRange_uint(lua_State* L) {
|
WSLUA_METHOD TvbRange_uint(lua_State* L) {
|
||||||
/* Get a Big Endian (network order) unsigned integer from a `TvbRange`.
|
/* Get a Big Endian (network order) unsigned integer from a <<lua_class_TvbRange,`TvbRange`>>.
|
||||||
The range must be 1-4 octets long. */
|
The range must be 1-4 octets long. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
if (!(tvbr && tvbr->tvb)) return 0;
|
if (!(tvbr && tvbr->tvb)) return 0;
|
||||||
|
@ -443,7 +444,7 @@ WSLUA_METHOD TvbRange_uint(lua_State* L) {
|
||||||
* get a Lilliputian unsigned integer from a tvb
|
* get a Lilliputian unsigned integer from a tvb
|
||||||
*/
|
*/
|
||||||
WSLUA_METHOD TvbRange_le_uint(lua_State* L) {
|
WSLUA_METHOD TvbRange_le_uint(lua_State* L) {
|
||||||
/* Get a Little Endian unsigned integer from a `TvbRange`.
|
/* Get a Little Endian unsigned integer from a <<lua_class_TvbRange,`TvbRange`>>.
|
||||||
The range must be 1-4 octets long. */
|
The range must be 1-4 octets long. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
if (!(tvbr && tvbr->tvb)) return 0;
|
if (!(tvbr && tvbr->tvb)) return 0;
|
||||||
|
@ -476,7 +477,7 @@ WSLUA_METHOD TvbRange_le_uint(lua_State* L) {
|
||||||
* get a Blefuscuoan unsigned 64 bit integer from a tvb
|
* get a Blefuscuoan unsigned 64 bit integer from a tvb
|
||||||
*/
|
*/
|
||||||
WSLUA_METHOD TvbRange_uint64(lua_State* L) {
|
WSLUA_METHOD TvbRange_uint64(lua_State* L) {
|
||||||
/* Get a Big Endian (network order) unsigned 64 bit integer from a `TvbRange`, as a `UInt64` object.
|
/* Get a Big Endian (network order) unsigned 64 bit integer from a <<lua_class_TvbRange,`TvbRange`>>, as a <<lua_class_UInt64,`UInt64`>> object.
|
||||||
The range must be 1-8 octets long. */
|
The range must be 1-8 octets long. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
if (!(tvbr && tvbr->tvb)) return 0;
|
if (!(tvbr && tvbr->tvb)) return 0;
|
||||||
|
@ -509,7 +510,7 @@ WSLUA_METHOD TvbRange_uint64(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
case 8:
|
case 8:
|
||||||
pushUInt64(L,tvb_get_ntoh64(tvbr->tvb->ws_tvb,tvbr->offset));
|
pushUInt64(L,tvb_get_ntoh64(tvbr->tvb->ws_tvb,tvbr->offset));
|
||||||
WSLUA_RETURN(1); /* The `UInt64` object. */
|
WSLUA_RETURN(1); /* The <<lua_class_UInt64,`UInt64`>> object. */
|
||||||
default:
|
default:
|
||||||
luaL_error(L,"TvbRange:uint64() does not handle %d byte integers",tvbr->len);
|
luaL_error(L,"TvbRange:uint64() does not handle %d byte integers",tvbr->len);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -520,7 +521,7 @@ WSLUA_METHOD TvbRange_uint64(lua_State* L) {
|
||||||
* get a Lilliputian unsigned 64 bit integer from a tvb
|
* get a Lilliputian unsigned 64 bit integer from a tvb
|
||||||
*/
|
*/
|
||||||
WSLUA_METHOD TvbRange_le_uint64(lua_State* L) {
|
WSLUA_METHOD TvbRange_le_uint64(lua_State* L) {
|
||||||
/* Get a Little Endian unsigned 64 bit integer from a `TvbRange`, as a `UInt64` object.
|
/* Get a Little Endian unsigned 64 bit integer from a <<lua_class_TvbRange,`TvbRange`>>, as a <<lua_class_UInt64,`UInt64`>> object.
|
||||||
The range must be 1-8 octets long. */
|
The range must be 1-8 octets long. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
if (!(tvbr && tvbr->tvb)) return 0;
|
if (!(tvbr && tvbr->tvb)) return 0;
|
||||||
|
@ -553,7 +554,7 @@ WSLUA_METHOD TvbRange_le_uint64(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
case 8:
|
case 8:
|
||||||
pushUInt64(L,tvb_get_letoh64(tvbr->tvb->ws_tvb,tvbr->offset));
|
pushUInt64(L,tvb_get_letoh64(tvbr->tvb->ws_tvb,tvbr->offset));
|
||||||
WSLUA_RETURN(1); /* The `UInt64` object. */
|
WSLUA_RETURN(1); /* The <<lua_class_UInt64,`UInt64`>> object. */
|
||||||
default:
|
default:
|
||||||
luaL_error(L,"TvbRange:le_uint64() does not handle %d byte integers",tvbr->len);
|
luaL_error(L,"TvbRange:le_uint64() does not handle %d byte integers",tvbr->len);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -564,7 +565,7 @@ WSLUA_METHOD TvbRange_le_uint64(lua_State* L) {
|
||||||
* get a Blefuscuoan signed integer from a tvb
|
* get a Blefuscuoan signed integer from a tvb
|
||||||
*/
|
*/
|
||||||
WSLUA_METHOD TvbRange_int(lua_State* L) {
|
WSLUA_METHOD TvbRange_int(lua_State* L) {
|
||||||
/* Get a Big Endian (network order) signed integer from a `TvbRange`.
|
/* Get a Big Endian (network order) signed integer from a <<lua_class_TvbRange,`TvbRange`>>.
|
||||||
The range must be 1-4 octets long. */
|
The range must be 1-4 octets long. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
if (!(tvbr && tvbr->tvb)) return 0;
|
if (!(tvbr && tvbr->tvb)) return 0;
|
||||||
|
@ -585,7 +586,7 @@ WSLUA_METHOD TvbRange_int(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
case 4:
|
case 4:
|
||||||
lua_pushnumber(L,tvb_get_ntohil(tvbr->tvb->ws_tvb,tvbr->offset));
|
lua_pushnumber(L,tvb_get_ntohil(tvbr->tvb->ws_tvb,tvbr->offset));
|
||||||
WSLUA_RETURN(1); /* The signed integer value */
|
WSLUA_RETURN(1); /* The signed integer value. */
|
||||||
/*
|
/*
|
||||||
* XXX:
|
* XXX:
|
||||||
* lua uses double so we have 52 bits to play with
|
* lua uses double so we have 52 bits to play with
|
||||||
|
@ -603,7 +604,7 @@ WSLUA_METHOD TvbRange_int(lua_State* L) {
|
||||||
* get a Lilliputian signed integer from a tvb
|
* get a Lilliputian signed integer from a tvb
|
||||||
*/
|
*/
|
||||||
WSLUA_METHOD TvbRange_le_int(lua_State* L) {
|
WSLUA_METHOD TvbRange_le_int(lua_State* L) {
|
||||||
/* Get a Little Endian signed integer from a `TvbRange`.
|
/* Get a Little Endian signed integer from a <<lua_class_TvbRange,`TvbRange`>>.
|
||||||
The range must be 1-4 octets long. */
|
The range must be 1-4 octets long. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
if (!(tvbr && tvbr->tvb)) return 0;
|
if (!(tvbr && tvbr->tvb)) return 0;
|
||||||
|
@ -635,7 +636,7 @@ WSLUA_METHOD TvbRange_le_int(lua_State* L) {
|
||||||
* get a Blefuscuoan signed 64 bit integer from a tvb
|
* get a Blefuscuoan signed 64 bit integer from a tvb
|
||||||
*/
|
*/
|
||||||
WSLUA_METHOD TvbRange_int64(lua_State* L) {
|
WSLUA_METHOD TvbRange_int64(lua_State* L) {
|
||||||
/* Get a Big Endian (network order) signed 64 bit integer from a `TvbRange`, as an `Int64` object.
|
/* Get a Big Endian (network order) signed 64 bit integer from a <<lua_class_TvbRange,`TvbRange`>>, as an <<lua_class_Int64,`Int64`>> object.
|
||||||
The range must be 1-8 octets long. */
|
The range must be 1-8 octets long. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
if (!(tvbr && tvbr->tvb)) return 0;
|
if (!(tvbr && tvbr->tvb)) return 0;
|
||||||
|
@ -668,7 +669,7 @@ WSLUA_METHOD TvbRange_int64(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
case 8:
|
case 8:
|
||||||
pushInt64(L,tvb_get_ntohi64(tvbr->tvb->ws_tvb,tvbr->offset));
|
pushInt64(L,tvb_get_ntohi64(tvbr->tvb->ws_tvb,tvbr->offset));
|
||||||
WSLUA_RETURN(1); /* The `Int64` object. */
|
WSLUA_RETURN(1); /* The <<lua_class_Int64,`Int64`>> object. */
|
||||||
default:
|
default:
|
||||||
luaL_error(L,"TvbRange:int64() does not handle %d byte integers",tvbr->len);
|
luaL_error(L,"TvbRange:int64() does not handle %d byte integers",tvbr->len);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -679,7 +680,7 @@ WSLUA_METHOD TvbRange_int64(lua_State* L) {
|
||||||
* get a Lilliputian signed 64 bit integer from a tvb
|
* get a Lilliputian signed 64 bit integer from a tvb
|
||||||
*/
|
*/
|
||||||
WSLUA_METHOD TvbRange_le_int64(lua_State* L) {
|
WSLUA_METHOD TvbRange_le_int64(lua_State* L) {
|
||||||
/* Get a Little Endian signed 64 bit integer from a `TvbRange`, as an `Int64` object.
|
/* Get a Little Endian signed 64 bit integer from a <<lua_class_TvbRange,`TvbRange`>>, as an <<lua_class_Int64,`Int64`>> object.
|
||||||
The range must be 1-8 octets long. */
|
The range must be 1-8 octets long. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
if (!(tvbr && tvbr->tvb)) return 0;
|
if (!(tvbr && tvbr->tvb)) return 0;
|
||||||
|
@ -712,7 +713,7 @@ WSLUA_METHOD TvbRange_le_int64(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
case 8:
|
case 8:
|
||||||
pushInt64(L,tvb_get_letohi64(tvbr->tvb->ws_tvb,tvbr->offset));
|
pushInt64(L,tvb_get_letohi64(tvbr->tvb->ws_tvb,tvbr->offset));
|
||||||
WSLUA_RETURN(1); /* The `Int64` object. */
|
WSLUA_RETURN(1); /* The <<lua_class_Int64,`Int64`>> object. */
|
||||||
default:
|
default:
|
||||||
luaL_error(L,"TvbRange:le_int64() does not handle %d byte integers",tvbr->len);
|
luaL_error(L,"TvbRange:le_int64() does not handle %d byte integers",tvbr->len);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -723,7 +724,7 @@ WSLUA_METHOD TvbRange_le_int64(lua_State* L) {
|
||||||
* get a Blefuscuoan float
|
* get a Blefuscuoan float
|
||||||
*/
|
*/
|
||||||
WSLUA_METHOD TvbRange_float(lua_State* L) {
|
WSLUA_METHOD TvbRange_float(lua_State* L) {
|
||||||
/* Get a Big Endian (network order) floating point number from a `TvbRange`.
|
/* Get a Big Endian (network order) floating point number from a <<lua_class_TvbRange,`TvbRange`>>.
|
||||||
The range must be 4 or 8 octets long. */
|
The range must be 4 or 8 octets long. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
if (!(tvbr && tvbr->tvb)) return 0;
|
if (!(tvbr && tvbr->tvb)) return 0;
|
||||||
|
@ -749,7 +750,7 @@ WSLUA_METHOD TvbRange_float(lua_State* L) {
|
||||||
* get a Lilliputian float
|
* get a Lilliputian float
|
||||||
*/
|
*/
|
||||||
WSLUA_METHOD TvbRange_le_float(lua_State* L) {
|
WSLUA_METHOD TvbRange_le_float(lua_State* L) {
|
||||||
/* Get a Little Endian floating point number from a `TvbRange`.
|
/* Get a Little Endian floating point number from a <<lua_class_TvbRange,`TvbRange`>>.
|
||||||
The range must be 4 or 8 octets long. */
|
The range must be 4 or 8 octets long. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
if (!(tvbr && tvbr->tvb)) return 0;
|
if (!(tvbr && tvbr->tvb)) return 0;
|
||||||
|
@ -768,7 +769,7 @@ WSLUA_METHOD TvbRange_le_float(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_ipv4(lua_State* L) {
|
WSLUA_METHOD TvbRange_ipv4(lua_State* L) {
|
||||||
/* Get an IPv4 Address from a `TvbRange`, as an `Address` object. */
|
/* Get an IPv4 Address from a <<lua_class_TvbRange,`TvbRange`>>, as an <<lua_class_Address,`Address`>> object. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
Address addr;
|
Address addr;
|
||||||
|
|
||||||
|
@ -787,11 +788,11 @@ WSLUA_METHOD TvbRange_ipv4(lua_State* L) {
|
||||||
alloc_address_tvb(NULL,addr,AT_IPv4,sizeof(guint32),tvbr->tvb->ws_tvb,tvbr->offset);
|
alloc_address_tvb(NULL,addr,AT_IPv4,sizeof(guint32),tvbr->tvb->ws_tvb,tvbr->offset);
|
||||||
pushAddress(L,addr);
|
pushAddress(L,addr);
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* The IPv4 `Address` object. */
|
WSLUA_RETURN(1); /* The IPv4 <<lua_class_Address,`Address`>> object. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_le_ipv4(lua_State* L) {
|
WSLUA_METHOD TvbRange_le_ipv4(lua_State* L) {
|
||||||
/* Get an Little Endian IPv4 Address from a `TvbRange`, as an `Address` object. */
|
/* Get an Little Endian IPv4 Address from a <<lua_class_TvbRange,`TvbRange`>>, as an <<lua_class_Address,`Address`>> object. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
Address addr;
|
Address addr;
|
||||||
guint32 ip_addr;
|
guint32 ip_addr;
|
||||||
|
@ -812,11 +813,11 @@ WSLUA_METHOD TvbRange_le_ipv4(lua_State* L) {
|
||||||
alloc_address_wmem(NULL, addr, AT_IPv4, sizeof(ip_addr), &ip_addr);
|
alloc_address_wmem(NULL, addr, AT_IPv4, sizeof(ip_addr), &ip_addr);
|
||||||
pushAddress(L,addr);
|
pushAddress(L,addr);
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* The IPv4 `Address` object. */
|
WSLUA_RETURN(1); /* The IPv4 <<lua_class_Address,`Address`>> object. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_ipv6(lua_State* L) {
|
WSLUA_METHOD TvbRange_ipv6(lua_State* L) {
|
||||||
/* Get an IPv6 Address from a `TvbRange`, as an `Address` object. */
|
/* Get an IPv6 Address from a <<lua_class_TvbRange,`TvbRange`>>, as an <<lua_class_Address,`Address`>> object. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
Address addr;
|
Address addr;
|
||||||
|
|
||||||
|
@ -835,11 +836,11 @@ WSLUA_METHOD TvbRange_ipv6(lua_State* L) {
|
||||||
alloc_address_tvb(NULL,addr,AT_IPv6,16,tvbr->tvb->ws_tvb,tvbr->offset);
|
alloc_address_tvb(NULL,addr,AT_IPv6,16,tvbr->tvb->ws_tvb,tvbr->offset);
|
||||||
pushAddress(L,addr);
|
pushAddress(L,addr);
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* The IPv6 `Address` object. */
|
WSLUA_RETURN(1); /* The IPv6 <<lua_class_Address,`Address`>> object. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_ether(lua_State* L) {
|
WSLUA_METHOD TvbRange_ether(lua_State* L) {
|
||||||
/* Get an Ethernet Address from a `TvbRange`, as an `Address` object. */
|
/* Get an Ethernet Address from a <<lua_class_TvbRange,`TvbRange`>>, as an <<lua_class_Address,`Address`>> object. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
Address addr;
|
Address addr;
|
||||||
|
|
||||||
|
@ -858,11 +859,11 @@ WSLUA_METHOD TvbRange_ether(lua_State* L) {
|
||||||
alloc_address_tvb(NULL,addr,AT_ETHER,6,tvbr->tvb->ws_tvb,tvbr->offset);
|
alloc_address_tvb(NULL,addr,AT_ETHER,6,tvbr->tvb->ws_tvb,tvbr->offset);
|
||||||
pushAddress(L,addr);
|
pushAddress(L,addr);
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* The Ethernet `Address` object. */
|
WSLUA_RETURN(1); /* The Ethernet <<lua_class_Address,`Address`>> object. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_nstime(lua_State* L) {
|
WSLUA_METHOD TvbRange_nstime(lua_State* L) {
|
||||||
/* Obtain a time_t structure from a `TvbRange`, as an `NSTime` object. */
|
/* Obtain a time_t structure from a <<lua_class_TvbRange,`TvbRange`>>, as an <<lua_class_NSTime,`NSTime`>> object. */
|
||||||
#define WSLUA_OPTARG_TvbRange_nstime_ENCODING 2 /* An optional ENC_* encoding value to use */
|
#define WSLUA_OPTARG_TvbRange_nstime_ENCODING 2 /* An optional ENC_* encoding value to use */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
NSTime nstime;
|
NSTime nstime;
|
||||||
|
@ -912,11 +913,11 @@ WSLUA_METHOD TvbRange_nstime(lua_State* L) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_RETURN(2); /* The `NSTime` object and number of bytes used, or nil on failure. */
|
WSLUA_RETURN(2); /* The <<lua_class_NSTime,`NSTime`>> object and number of bytes used, or nil on failure. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_le_nstime(lua_State* L) {
|
WSLUA_METHOD TvbRange_le_nstime(lua_State* L) {
|
||||||
/* Obtain a nstime from a `TvbRange`, as an `NSTime` object. */
|
/* Obtain a nstime from a <<lua_class_TvbRange,`TvbRange`>>, as an <<lua_class_NSTime,`NSTime`>> object. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
NSTime nstime;
|
NSTime nstime;
|
||||||
|
|
||||||
|
@ -942,11 +943,11 @@ WSLUA_METHOD TvbRange_le_nstime(lua_State* L) {
|
||||||
|
|
||||||
pushNSTime(L, nstime);
|
pushNSTime(L, nstime);
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* The `NSTime` object. */
|
WSLUA_RETURN(1); /* The <<lua_class_NSTime,`NSTime`>> object. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_string(lua_State* L) {
|
WSLUA_METHOD TvbRange_string(lua_State* L) {
|
||||||
/* Obtain a string from a `TvbRange`. */
|
/* Obtain a string from a <<lua_class_TvbRange,`TvbRange`>>. */
|
||||||
#define WSLUA_OPTARG_TvbRange_string_ENCODING 2 /* The encoding to use. Defaults to ENC_ASCII. */
|
#define WSLUA_OPTARG_TvbRange_string_ENCODING 2 /* The encoding to use. Defaults to ENC_ASCII. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
guint encoding = (guint)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_string_ENCODING, ENC_ASCII|ENC_NA);
|
guint encoding = (guint)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_string_ENCODING, ENC_ASCII|ENC_NA);
|
||||||
|
@ -959,11 +960,11 @@ WSLUA_METHOD TvbRange_string(lua_State* L) {
|
||||||
|
|
||||||
lua_pushlstring(L, (gchar*)tvb_get_string_enc(wmem_packet_scope(),tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len,encoding), tvbr->len);
|
lua_pushlstring(L, (gchar*)tvb_get_string_enc(wmem_packet_scope(),tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len,encoding), tvbr->len);
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* The string */
|
WSLUA_RETURN(1); /* A string containing all bytes in the <<lua_class_TvbRange,`TvbRange`>> including all zeroes (e.g., "a\000bc\000"). */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int TvbRange_ustring_any(lua_State* L, gboolean little_endian) {
|
static int TvbRange_ustring_any(lua_State* L, gboolean little_endian) {
|
||||||
/* Obtain a UTF-16 encoded string from a `TvbRange`. */
|
/* Obtain a UTF-16 encoded string from a <<lua_class_TvbRange,`TvbRange`>>. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
gchar * str;
|
gchar * str;
|
||||||
|
|
||||||
|
@ -980,17 +981,17 @@ static int TvbRange_ustring_any(lua_State* L, gboolean little_endian) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_ustring(lua_State* L) {
|
WSLUA_METHOD TvbRange_ustring(lua_State* L) {
|
||||||
/* Obtain a Big Endian (network order) UTF-16 encoded string from a `TvbRange`. */
|
/* Obtain a Big Endian (network order) UTF-16 encoded string from a <<lua_class_TvbRange,`TvbRange`>>. */
|
||||||
WSLUA_RETURN(TvbRange_ustring_any(L, FALSE)); /* The string. */
|
WSLUA_RETURN(TvbRange_ustring_any(L, FALSE)); /* A string containing all bytes in the <<lua_class_TvbRange,`TvbRange`>> including all zeroes (e.g., "a\000bc\000"). */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_le_ustring(lua_State* L) {
|
WSLUA_METHOD TvbRange_le_ustring(lua_State* L) {
|
||||||
/* Obtain a Little Endian UTF-16 encoded string from a `TvbRange`. */
|
/* Obtain a Little Endian UTF-16 encoded string from a <<lua_class_TvbRange,`TvbRange`>>. */
|
||||||
WSLUA_RETURN(TvbRange_ustring_any(L, TRUE)); /* The string. */
|
WSLUA_RETURN(TvbRange_ustring_any(L, TRUE)); /* A string containing all bytes in the <<lua_class_TvbRange,`TvbRange`>> including all zeroes (e.g., "a\000bc\000"). */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_stringz(lua_State* L) {
|
WSLUA_METHOD TvbRange_stringz(lua_State* L) {
|
||||||
/* Obtain a zero terminated string from a `TvbRange`. */
|
/* Obtain a zero terminated string from a <<lua_class_TvbRange,`TvbRange`>>. */
|
||||||
#define WSLUA_OPTARG_TvbRange_stringz_ENCODING 2 /* The encoding to use. Defaults to ENC_ASCII. */
|
#define WSLUA_OPTARG_TvbRange_stringz_ENCODING 2 /* The encoding to use. Defaults to ENC_ASCII. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
guint encoding = (guint)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_stringz_ENCODING, ENC_ASCII|ENC_NA);
|
guint encoding = (guint)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_stringz_ENCODING, ENC_ASCII|ENC_NA);
|
||||||
|
@ -1029,15 +1030,16 @@ WSLUA_METHOD TvbRange_stringz(lua_State* L) {
|
||||||
|
|
||||||
lua_pushstring(L, (gchar*)tvb_get_stringz_enc(wmem_packet_scope(),tvbr->tvb->ws_tvb,tvbr->offset,NULL,encoding));
|
lua_pushstring(L, (gchar*)tvb_get_stringz_enc(wmem_packet_scope(),tvbr->tvb->ws_tvb,tvbr->offset,NULL,encoding));
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* The zero terminated string. */
|
WSLUA_RETURN(1); /* The string containing all bytes in the <<lua_class_TvbRange,`TvbRange`>> up to the first terminating zero. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_strsize(lua_State* L) {
|
WSLUA_METHOD TvbRange_strsize(lua_State* L) {
|
||||||
/* Find the size of a zero terminated string from a `TvbRange`.
|
/*
|
||||||
The size of the string includes the terminating zero.
|
Find the size of a zero terminated string from a <<lua_class_TvbRange,`TvbRange`>>.
|
||||||
|
The size of the string includes the terminating zero.
|
||||||
|
|
||||||
@since 1.11.3
|
@since 1.11.3
|
||||||
*/
|
*/
|
||||||
#define WSLUA_OPTARG_TvbRange_strsize_ENCODING 2 /* The encoding to use. Defaults to ENC_ASCII. */
|
#define WSLUA_OPTARG_TvbRange_strsize_ENCODING 2 /* The encoding to use. Defaults to ENC_ASCII. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
guint encoding = (guint)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_strsize_ENCODING, ENC_ASCII|ENC_NA);
|
guint encoding = (guint)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_strsize_ENCODING, ENC_ASCII|ENC_NA);
|
||||||
|
@ -1112,7 +1114,7 @@ static int TvbRange_ustringz_any(lua_State* L, gboolean little_endian) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_ustringz(lua_State* L) {
|
WSLUA_METHOD TvbRange_ustringz(lua_State* L) {
|
||||||
/* Obtain a Big Endian (network order) UTF-16 encoded zero terminated string from a `TvbRange`. */
|
/* Obtain a Big Endian (network order) UTF-16 encoded zero terminated string from a <<lua_class_TvbRange,`TvbRange`>>. */
|
||||||
WSLUA_RETURN(TvbRange_ustringz_any(L, FALSE)); /* Two return values: the zero terminated string, and the length. */
|
WSLUA_RETURN(TvbRange_ustringz_any(L, FALSE)); /* Two return values: the zero terminated string, and the length. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1122,11 +1124,11 @@ WSLUA_METHOD TvbRange_le_ustringz(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_bytes(lua_State* L) {
|
WSLUA_METHOD TvbRange_bytes(lua_State* L) {
|
||||||
/* Obtain a `ByteArray` from a `TvbRange`.
|
/* Obtain a <<lua_class_ByteArray,`ByteArray`>> from a <<lua_class_TvbRange,`TvbRange`>>.
|
||||||
|
|
||||||
Starting in 1.11.4, this function also takes an optional `encoding` argument,
|
Starting in 1.11.4, this function also takes an optional `encoding` argument,
|
||||||
which can be set to `ENC_STR_HEX` to decode a hex-string from the `TvbRange`
|
which can be set to `ENC_STR_HEX` to decode a hex-string from the <<lua_class_TvbRange,`TvbRange`>>
|
||||||
into the returned `ByteArray`. The `encoding` can be bitwise-or'ed with one
|
into the returned <<lua_class_ByteArray,`ByteArray`>>. The `encoding` can be bitwise-or'ed with one
|
||||||
or more separator encodings, such as `ENC_SEP_COLON`, to allow separators
|
or more separator encodings, such as `ENC_SEP_COLON`, to allow separators
|
||||||
to occur between each pair of hex characters.
|
to occur between each pair of hex characters.
|
||||||
|
|
||||||
|
@ -1179,13 +1181,13 @@ WSLUA_METHOD TvbRange_bytes(lua_State* L) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_RETURN(2); /* The `ByteArray` object or nil, and number of bytes consumed or nil. */
|
WSLUA_RETURN(2); /* The <<lua_class_ByteArray,`ByteArray`>> object or nil, and number of bytes consumed or nil. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_bitfield(lua_State* L) {
|
WSLUA_METHOD TvbRange_bitfield(lua_State* L) {
|
||||||
/* Get a bitfield from a `TvbRange`. */
|
/* Get a bitfield from a <<lua_class_TvbRange,`TvbRange`>>. */
|
||||||
#define WSLUA_OPTARG_TvbRange_bitfield_POSITION 2 /* The bit offset from the beginning of the `TvbRange`. Defaults to 0. */
|
#define WSLUA_OPTARG_TvbRange_bitfield_POSITION 2 /* The bit offset (link:https://en.wikipedia.org/wiki/Bit_numbering#MSB_0_bit_numbering[MSB 0 bit numbering]) from the beginning of the <<lua_class_TvbRange,`TvbRange`>>. Defaults to 0. */
|
||||||
#define WSLUA_OPTARG_TvbRange_bitfield_LENGTH 3 /* The length (in bits) of the field. Defaults to 1. */
|
#define WSLUA_OPTARG_TvbRange_bitfield_LENGTH 3 /* The length in bits of the field. Defaults to 1. */
|
||||||
|
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
int pos = (int)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_bitfield_POSITION,0);
|
int pos = (int)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_bitfield_POSITION,0);
|
||||||
|
@ -1221,9 +1223,9 @@ WSLUA_METHOD TvbRange_bitfield(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_range(lua_State* L) {
|
WSLUA_METHOD TvbRange_range(lua_State* L) {
|
||||||
/* Creates a sub-`TvbRange` from this `TvbRange`. */
|
/* Creates a sub-<<lua_class_TvbRange,`TvbRange`>> from this <<lua_class_TvbRange,`TvbRange`>>. */
|
||||||
#define WSLUA_OPTARG_TvbRange_range_OFFSET 2 /* The offset (in octets) from the beginning of the `TvbRange`. Defaults to 0. */
|
#define WSLUA_OPTARG_TvbRange_range_OFFSET 2 /* The offset (in octets) from the beginning of the <<lua_class_TvbRange,`TvbRange`>>. Defaults to 0. */
|
||||||
#define WSLUA_OPTARG_TvbRange_range_LENGTH 3 /* The length (in octets) of the range. Defaults to until the end of the `TvbRange`. */
|
#define WSLUA_OPTARG_TvbRange_range_LENGTH 3 /* The length (in octets) of the range. Defaults to until the end of the <<lua_class_TvbRange,`TvbRange`>>. */
|
||||||
|
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
int offset = (int)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_range_OFFSET,0);
|
int offset = (int)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_range_OFFSET,0);
|
||||||
|
@ -1244,14 +1246,14 @@ WSLUA_METHOD TvbRange_range(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (push_TvbRange(L,tvbr->tvb->ws_tvb,tvbr->offset+offset,len)) {
|
if (push_TvbRange(L,tvbr->tvb->ws_tvb,tvbr->offset+offset,len)) {
|
||||||
WSLUA_RETURN(1); /* The TvbRange */
|
WSLUA_RETURN(1); /* The <<lua_class_TvbRange,`TvbRange`>>. */
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_uncompress(lua_State* L) {
|
WSLUA_METHOD TvbRange_uncompress(lua_State* L) {
|
||||||
/* Obtain an uncompressed TvbRange from a TvbRange */
|
/* Obtain an uncompressed <<lua_class_TvbRange,`TvbRange`>> from a <<lua_class_TvbRange,`TvbRange`>> */
|
||||||
#define WSLUA_ARG_TvbRange_uncompress_NAME 2 /* The name to be given to the new data-source. */
|
#define WSLUA_ARG_TvbRange_uncompress_NAME 2 /* The name to be given to the new data-source. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
#ifdef HAVE_ZLIB
|
#ifdef HAVE_ZLIB
|
||||||
|
@ -1271,7 +1273,7 @@ WSLUA_METHOD TvbRange_uncompress(lua_State* L) {
|
||||||
if (uncompr_tvb) {
|
if (uncompr_tvb) {
|
||||||
add_new_data_source (lua_pinfo, uncompr_tvb, name);
|
add_new_data_source (lua_pinfo, uncompr_tvb, name);
|
||||||
if (push_TvbRange(L,uncompr_tvb,0,tvb_captured_length(uncompr_tvb))) {
|
if (push_TvbRange(L,uncompr_tvb,0,tvb_captured_length(uncompr_tvb))) {
|
||||||
WSLUA_RETURN(1); /* The TvbRange */
|
WSLUA_RETURN(1); /* The <<lua_class_TvbRange,`TvbRange`>>. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -1292,7 +1294,7 @@ static int TvbRange__gc(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_len(lua_State* L) {
|
WSLUA_METHOD TvbRange_len(lua_State* L) {
|
||||||
/* Obtain the length of a `TvbRange`. */
|
/* Obtain the length of a <<lua_class_TvbRange,`TvbRange`>>. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
|
|
||||||
if (!(tvbr && tvbr->tvb)) return 0;
|
if (!(tvbr && tvbr->tvb)) return 0;
|
||||||
|
@ -1305,7 +1307,7 @@ WSLUA_METHOD TvbRange_len(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_offset(lua_State* L) {
|
WSLUA_METHOD TvbRange_offset(lua_State* L) {
|
||||||
/* Obtain the offset in a `TvbRange`. */
|
/* Obtain the offset in a <<lua_class_TvbRange,`TvbRange`>>. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
|
|
||||||
if (!(tvbr && tvbr->tvb)) return 0;
|
if (!(tvbr && tvbr->tvb)) return 0;
|
||||||
|
@ -1318,12 +1320,12 @@ WSLUA_METHOD TvbRange_offset(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHOD TvbRange_raw(lua_State* L) {
|
WSLUA_METHOD TvbRange_raw(lua_State* L) {
|
||||||
/* Obtain a Lua string of the binary bytes in a `TvbRange`.
|
/* Obtain a Lua string of the binary bytes in a <<lua_class_TvbRange,`TvbRange`>>.
|
||||||
|
|
||||||
@since 1.11.3
|
@since 1.11.3
|
||||||
*/
|
*/
|
||||||
#define WSLUA_OPTARG_TvbRange_raw_OFFSET 2 /* The position of the first byte (default=0/first). */
|
#define WSLUA_OPTARG_TvbRange_raw_OFFSET 2 /* The position of the first byte. Default is 0, or first byte. */
|
||||||
#define WSLUA_OPTARG_TvbRange_raw_LENGTH 3 /* The length of the segment to get (default=all). */
|
#define WSLUA_OPTARG_TvbRange_raw_LENGTH 3 /* The length of the segment to get. Default is -1, Default is -1, or the remaining bytes. */
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
int offset = (int)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_raw_OFFSET,0);
|
int offset = (int)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_raw_OFFSET,0);
|
||||||
int len = (int)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_raw_LENGTH,-1);
|
int len = (int)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_raw_LENGTH,-1);
|
||||||
|
@ -1352,11 +1354,11 @@ WSLUA_METHOD TvbRange_raw(lua_State* L) {
|
||||||
|
|
||||||
lua_pushlstring(L, tvb_get_ptr(tvbr->tvb->ws_tvb, offset, len), len);
|
lua_pushlstring(L, tvb_get_ptr(tvbr->tvb->ws_tvb, offset, len), len);
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* A Lua string of the binary bytes in the `TvbRange`. */
|
WSLUA_RETURN(1); /* A Lua string of the binary bytes in the <<lua_class_TvbRange,`TvbRange`>>. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METAMETHOD TvbRange__eq(lua_State* L) {
|
WSLUA_METAMETHOD TvbRange__eq(lua_State* L) {
|
||||||
/* Checks whether the two `TvbRange` contents are equal.
|
/* Checks whether the contents of two <<lua_class_TvbRange,`TvbRange`>>s are equal.
|
||||||
|
|
||||||
@since 1.99.8
|
@since 1.99.8
|
||||||
*/
|
*/
|
||||||
|
@ -1387,9 +1389,10 @@ WSLUA_METAMETHOD TvbRange__eq(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METAMETHOD TvbRange__tostring(lua_State* L) {
|
WSLUA_METAMETHOD TvbRange__tostring(lua_State* L) {
|
||||||
/* Converts the `TvbRange` into a string. Since the string gets truncated,
|
/*
|
||||||
you should use this only for debugging purposes
|
Converts the <<lua_class_TvbRange,`TvbRange`>> into a string.
|
||||||
or if what you want is to have a truncated string in the format 67:89:AB:... */
|
The string can be truncated, so this is primarily useful for debugging or in cases where truncation is preferred, e.g. "67:89:AB:...".
|
||||||
|
*/
|
||||||
TvbRange tvbr = checkTvbRange(L,1);
|
TvbRange tvbr = checkTvbRange(L,1);
|
||||||
char* str = NULL;
|
char* str = NULL;
|
||||||
|
|
||||||
|
@ -1407,7 +1410,7 @@ WSLUA_METAMETHOD TvbRange__tostring(lua_State* L) {
|
||||||
wmem_free(NULL, str);
|
wmem_free(NULL, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* A Lua hex string of the first 24 binary bytes in the `TvbRange`. */
|
WSLUA_RETURN(1); /* A Lua hex string of the <<lua_class_TvbRange,`TvbRange`>> truncated to 24 bytes. */
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_METHODS TvbRange_methods[] = {
|
WSLUA_METHODS TvbRange_methods[] = {
|
||||||
|
|
Loading…
Reference in New Issue