Creates a new ByteArray
object.
Starting in version 1.11.3, if the second argument is a boolean true
,
then the first argument is treated as a raw Lua string of bytes to use,
instead of a hexadecimal string.
local empty = ByteArray.new() local b1 = ByteArray.new("a1 b2 c3 d4") local b2 = ByteArray.new("112233")
true
is used, then the first argument
is treated as raw binary data
The new ByteArray object.
Concatenate two ByteArray
s.
The new composite ByteArray
.
Sets the size of a ByteArray
, either truncating it or filling it with zeros.
Sets the value of an index of a ByteArray
.
Get the value of a byte in a ByteArray
.
The value [0-255] of the byte.
Read a little endian encoded signed integer in a ByteArray
beginning at given offset with given length.
Since: 4.2.0
ByteArray
.
The value of the little endian encoded signed integer beginning at given offset with given length.
Read a little endian encoded 64 bit signed integer in a ByteArray
beginning at given offset with given length.
Since: 4.2.0
ByteArray
.
The value of the little endian encoded 64 bit signed integer as a Int64
object beginning at given offset with given length.
Read a little endian encoded unsigned integer in a ByteArray
beginning at given offset with given length.
Since: 4.2.0
ByteArray
.
The value of the little endian encoded unsigned integer beginning at given offset with given length.
Read a little endian encoded 64 bit unsigned integer in a ByteArray
beginning at given offset with given length.
Since: 4.2.0
ByteArray
.
The value of the little endian encoded 64 bit unsigned integer as a UInt64
object beginning at given offset with given length.
Read a big endian encoded signed integer in a ByteArray
beginning at given offset with given length.
Since: 4.2.0
ByteArray
.
The value of the big endian encoded 32 bit signed integer beginning at given offset with given length.
Read a big endian encoded 64 bit signed integer in a ByteArray
beginning at given offset with given length.
Since: 4.2.0
ByteArray
.
The value of the big endian encoded 64 bit signed integer as a Int64
object beginning at given offset and given length.
Read a big endian encoded unsigned integer in a ByteArray
beginning at given offset with given length.
Since: 4.2.0
ByteArray
.
The value of the big endian encoded 32 bit unsigned integer beginning at given offset with given length.
Read a big endian encoded 64 bit unsigned integer in a ByteArray
beginning at given offset with given length.
Since: 4.2.0
ByteArray
.
The value of the big endian encoded 64 bit unsigned integer as a UInt64
object beginning at given offset with given length.
Obtain a segment of a ByteArray
, as a new ByteArray
.
A ByteArray
containing the requested segment.
Obtain a Lua string of the binary bytes in a ByteArray
.
A Lua string of the binary bytes in the ByteArray.
Obtain a Lua string of the bytes in a ByteArray
as hex-ascii, with given separator.
A hex-ascii string representation of the ByteArray
.
Obtain a Lua string containing the bytes in a ByteArray
so that it can be used in
display filters (e.g. "01FE456789AB").
A hex-ascii string representation of the ByteArray
.
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
The created Tvb
.
A 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.
To create a TvbRange
the Tvb
must be called with offset and length as optional arguments;
the offset defaults to 0 and the length to tvb:captured_len()
.
Warning | |
---|---|
Tvbs are usable only by the current listener or dissector call and are destroyed as soon as the listener or dissector returns, so references to them are unusable once the function has returned. |
Convert the bytes of a Tvb
into a string.
This is primarily useful for debugging purposes since the string will be truncated if it is too long.
The string.
Obtain the reported length (length on the network) of a Tvb
.
The reported length of the Tvb
.
Obtain the captured length (amount saved in the capture process) of a Tvb
.
The captured length of the Tvb
.
Obtain the captured length (amount saved in the capture process) of a Tvb
.
Same as captured_len; kept only for backwards compatibility
The captured length of the Tvb
.
Obtain the reported (not captured) length of packet data to end of a Tvb
or 0 if the
offset is beyond the end of the Tvb
.
Tvb
. Defaults to 0.
The remaining reported length of the Tvb
.
Obtain a ByteArray
from a Tvb
.
Tvb
. Defaults to 0.
Tvb
.
The ByteArray
object or nil.
Returns the raw offset (from the beginning of the source Tvb
) of a sub Tvb
.
The raw offset of the Tvb
.
Creates a TvbRange
from this Tvb
.
Tvb
. Defaults to 0.
Tvb
.
The TvbRange
Obtain a Lua string of the binary bytes in a Tvb
.
Tvb
.
A Lua string of the binary bytes in the Tvb
.
Checks whether contents of two Tvb
s are equal.
A TvbRange
represents a usable range of a Tvb
and is used to extract data from the Tvb
that generated it.
TvbRange
s are created by calling a Tvb
(e.g. 'tvb(offset,length)').
A length of -1, which is the default, means to use the bytes up to the end of the Tvb
.
If the TvbRange
span is outside the Tvb
's range the creation will cause a runtime error.
Get a Big Endian (network order) unsigned integer from a TvbRange
.
The range must be 1-4 octets long.
The unsigned integer value.
Get a Little Endian unsigned integer from a TvbRange
.
The range must be 1-4 octets long.
The unsigned integer value
Get a Big Endian (network order) unsigned 64 bit integer from a TvbRange
, as a UInt64
object.
The range must be 1-8 octets long.
The UInt64
object.
Get a Little Endian unsigned 64 bit integer from a TvbRange
, as a UInt64
object.
The range must be 1-8 octets long.
The UInt64
object.
Get a Big Endian (network order) signed integer from a TvbRange
.
The range must be 1-4 octets long.
The signed integer value.
Get a Little Endian signed integer from a TvbRange
.
The range must be 1-4 octets long.
The signed integer value.
Get a Big Endian (network order) signed 64 bit integer from a TvbRange
, as an Int64
object.
The range must be 1-8 octets long.
The Int64
object.
Get a Little Endian signed 64 bit integer from a TvbRange
, as an Int64
object.
The range must be 1-8 octets long.
The Int64
object.
Get a Big Endian (network order) floating point number from a TvbRange
.
The range must be 4 or 8 octets long.
The floating point value.
Get a Little Endian floating point number from a TvbRange
.
The range must be 4 or 8 octets long.
The floating point value.
Get an Little Endian IPv4 Address from a TvbRange
, as an Address
object.
The IPv4 Address
object.
Get an Ethernet Address from a TvbRange
, as an Address
object.
The Ethernet Address
object.
Obtain a time_t structure from a TvbRange
, as an NSTime
object.
The NSTime
object and number of bytes used, or nil on failure.
Obtain a nstime from a TvbRange
, as an NSTime
object.
The NSTime
object.
Obtain a string from a TvbRange
.
A string containing all bytes in the TvbRange
including all zeroes (e.g., "a\000bc\000").
Obtain a Big Endian (network order) UTF-16 encoded string from a TvbRange
.
A string containing all bytes in the TvbRange
including all zeroes (e.g., "a\000bc\000").
Obtain a Little Endian UTF-16 encoded string from a TvbRange
.
A string containing all bytes in the TvbRange
including all zeroes (e.g., "a\000bc\000").
Obtain a zero terminated string from a TvbRange
.
The string containing all bytes in the TvbRange
up to the first terminating zero.
Find the size of a zero terminated string from a TvbRange
.
The size of the string includes the terminating zero.
Length of the zero terminated string.
Obtain a Big Endian (network order) UTF-16 encoded zero terminated string from a TvbRange
.
Two return values: the zero terminated string, and the length.
Obtain a Little Endian UTF-16 encoded zero terminated string from a TvbRange
Two return values: the zero terminated string, and the length.
Obtain a ByteArray
from a TvbRange
.
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
into the returned ByteArray
. The encoding
can be bitwise-or’ed with one
or more separator encodings, such as ENC_SEP_COLON
, to allow separators
to occur between each pair of hex characters.
The return value also now returns the number of bytes used as a second return value.
On failure or error, nil is returned for both return values.
Note | |
---|---|
The encoding type of the hex string should also be set, for example
|
The ByteArray
object or nil, and number of bytes consumed or nil.
Get a bitfield from a TvbRange
.
TvbRange
. Defaults to 0.
The bitfield value
Creates a sub-TvbRange
from this TvbRange
.
TvbRange
. Defaults to 0.
TvbRange
.
The TvbRange
.
Given a TvbRange
containing zlib compressed data, decompresses the data and returns a new TvbRange
containing the uncompressed data.
Since: 4.3.0
The TvbRange
.
Given a TvbRange
containing zlib compressed data, decompresses the data and returns a new TvbRange
containing the uncompressed data. Deprecated; use tvbrange:uncompress_zlib() instead.
Given a TvbRange
containing Brotli compressed data, decompresses the data and returns a new TvbRange
containing the uncompressed data.
Since: 4.3.0
The TvbRange
.
Given a TvbRange
containing data compressed using the Huffman encoding in HTTP/2 HPACK and HTTP/3 QPACK, decompresses the data and returns a new TvbRange
containing the uncompressed data.
Since: 4.3.0
The TvbRange
.
Given a TvbRange
containing Microsoft Plain LZ77 compressed data, decompresses the data and returns a new TvbRange
containing the uncompressed data.
Since: 4.3.0
The TvbRange
.
Given a TvbRange
containing Microsoft LZ77+Huffman compressed data, decompresses the data and returns a new TvbRange
containing the uncompressed data.
Since: 4.3.0
The TvbRange
.
Given a TvbRange
containing Microsoft LZNT1 compressed data, decompresses the data and returns a new TvbRange
containing the uncompressed data.
Since: 4.3.0
The TvbRange
.
Given a TvbRange
containing Snappy compressed data, decompresses the data and returns a new TvbRange
containing the uncompressed data.
Since: 4.3.0
The TvbRange
.
Given a TvbRange
containing Zstandard compressed data, decompresses the data and returns a new TvbRange
containing the uncompressed data.
Since: 4.3.0
The TvbRange
.
Given a TvbRange
containing Base64 encoded data, return a new TvbRange
containing the decoded data.
Since: 4.3.0
The TvbRange
.
Given a TvbRange
containing base64url encoded data, return a new TvbRange
containing the decoded data.
Since: 4.3.0
The TvbRange
.
Obtain the length of a TvbRange
.
Obtain the offset in a TvbRange
.
Obtain a Lua string of the binary bytes in a TvbRange
.
A Lua string of the binary bytes in the TvbRange
.
Checks whether the contents of two TvbRange
s are equal.