aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2014-03-23 11:01:12 -0400
committerAnders Broman <a.broman58@gmail.com>2014-03-25 05:30:11 +0000
commitde441241ef16262fa8ba1c5fbd77509a1ee86c67 (patch)
treedd71bffb6e8728958fb3dee0e9da6ea5e05a2397
parente4756ccacf47234a766ab5e10d17bd9c5203061d (diff)
Enhance Lua API doc generator and add more API info
This enhances the Lua API doc generator Perl script to handle meta-information in description comments, such as bold, italics, raw code, version info, etc. The supported markup and codes are documented in make-wsluarm.pl. It's not beautiful Perl code (I don't know Perl), and I'd rather do it using Lua, but I think keeping it Perl makes more sense in the long run. Change-Id: I477b3ebe770075dcea9ec52708e2d6fb5758d2f4 Reviewed-on: https://code.wireshark.org/review/802 Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rwxr-xr-xdocbook/make-wsluarm.pl549
-rw-r--r--docbook/wsluarm.xml227
-rw-r--r--epan/wslua/wslua_dumper.c36
-rw-r--r--epan/wslua/wslua_field.c47
-rw-r--r--epan/wslua/wslua_file.c336
-rw-r--r--epan/wslua/wslua_gui.c101
-rw-r--r--epan/wslua/wslua_int64.c494
-rw-r--r--epan/wslua/wslua_internals.c108
-rw-r--r--epan/wslua/wslua_listener.c51
-rw-r--r--epan/wslua/wslua_pinfo.c158
-rw-r--r--epan/wslua/wslua_proto.c703
-rw-r--r--epan/wslua/wslua_struct.c76
-rw-r--r--epan/wslua/wslua_tree.c42
-rw-r--r--epan/wslua/wslua_tvb.c245
-rw-r--r--epan/wslua/wslua_util.c159
15 files changed, 2046 insertions, 1286 deletions
diff --git a/docbook/make-wsluarm.pl b/docbook/make-wsluarm.pl
index c4a06d21ff..d550c1b254 100755
--- a/docbook/make-wsluarm.pl
+++ b/docbook/make-wsluarm.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
-# make-doc.pl
+# make-wsluarm.pl
# WSLUA's Reference Manual Generator
#
# (c) 2006, Luis E. Garcia Onatnon <luis@ontanon.org>
@@ -26,6 +26,31 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# (-: I don't even think writing this in Lua :-)
+# ...well I wished you had!
+#
+# changed by Hadriel Kaplan to do the following:
+# - generates pretty XML output, to make debugging it easier
+# - allows modules (i.e., WSLUA_MODULE) to have detailed descriptions
+# - two (or more) line breaks in comments result in separate paragraphs
+# - all '&' are converted into their entity names, except inside urls
+# - all '<', and '>' are converted into their entity names everywhere
+# - any word(s) wrapped in one star, e.g., *foo bar*, become italics
+# - any word(s) wrapped in two stars, e.g., **foo bar**, become commands (is there a 'bold'?)
+# - any word(s) wrapped in backticks, e.g., `foo bar`, become commands (is there something better?)
+# - any word(s) wrapped in two backticks, e.g., ``foo bar``, become one backtick
+# - any "[[url]]" becomes an XML ulink with the url as both the url and text
+# - any "[[url|text]]" becomes an XML ulink with the url as the url and text as text
+# - any indent with a single leading star '*' followed by space is a bulleted list item
+# reducing indent or having an extra linebreak stops the list
+# - any indent with a leading digits-dot followed by space, i.e. "1. ", is a numbered list item
+# reducing indent or having an extra linebreak stops the list
+# - supports meta-tagged info inside comment descriptions as follows:
+# * a line starting with "@note" or "Note:" becomes an XML note line
+# * a line starting with "@warning" or "Warning:" becomes an XML warning line
+# * a line starting with "@version" or "@since" becomes a "Since:" line
+# * a line starting with "@code" and ending with "@endcode" becomes an
+# XML programlisting block, with no indenting/parsing within the block
+# The above '@' commands are based on Doxygen commands
use strict;
#use V2P;
@@ -38,21 +63,288 @@ sub gorolla {
# a gorilla stays to a chimp like gorolla stays to chomp
# but this one returns the shrugged string.
my $s = shift;
+ # remove leading newlines and spaces at beginning
$s =~ s/^([\n]|\s)*//ms;
- $s =~ s/([\n]|\s)*$//ms;
- # as far as I can tell, these will only convert the *first* '<'/'>' they find in a line, but
- # not subsequent ones in that line (because the flag isn't 'msg'?) -hadriel
- $s =~ s/\</&lt;/ms;
- $s =~ s/\>/&gt;/ms;
- # this is a horrible horrible hack, but it works
- # basically we undo the replacements just made above, if it's a '</para>' or '<para>' case
- # so that comments can include them for prettier output. Really this API generator thing needs
- # to be rewritten, but I don't understand perl well enough to do it properly -hadriel
- $s =~ s/&lt;\/para&gt;/<\/para>/ms;
- $s =~ s/&lt;para&gt;/<para>/ms;
+ # remove trailing newlines and spaces at end
+ $s =~ s/([\n]|\s)*$//s;
+ # escape HTML entities everywhere
+ $s =~ s/&/&amp;/msg; # do this one first so we don't clobber later ones
+ $s =~ s/\</&lt;/msg;
+ $s =~ s/\>/&gt;/msg;
+
+ # bold and italics - but don't change a star followed by space (it's a list item)
+ $s =~ s/(\*\*)([^*]+?)(\*\*)/<command>$2<\/command>/g; # bold=command??
+ $s =~ s/(\*)([^\s][^*]*?)(\*)/<emphasis>$2<\/emphasis>/g; # italics
+
+ # one backtick is quote/command
+ $s =~ s/([^`]|^)(`)([^`]+?)(`)/$1<command>$3<\/command>/g; # quote=command??
+ # two backticks are one
+ $s =~ s/(``)([^`]+?)(``)/`$2`/g; # quote=command??
+
+ # handle '[[url]]'
+ $s =~ s/(\[\[)([^\]\|]+?)(\]\])/<ulink url="$2">$2<\/ulink>/g;
+ # handle '[[url|pretty]]'
+ $s =~ s/(\[\[)(([^\]\|]+?)\|\s*([^\]]+?))(\]\])/<ulink url="$3">$4<\/ulink>/g;
+ # unescape gorolla'd ampersands in url
+ while ($s =~ /<ulink url="[^"]*&amp;/) {
+ $s =~ s/(<ulink url="[^"]*)(&amp;)/$1\&/;
+ }
+
$s;
}
+# break up descriptions based on newlines and keywords
+# builds an array of paragraphs and returns the array ref
+# each entry in the array is a single line for XML, but not a
+# whole paragraph - there are "<para>"/"</para>" entries in the
+# array to make them paragraphs - this way the XML itself is
+# also pretty, while the resulting output is of course valid
+# first arg is the array to build into; second arg is an array
+# of lines to parse - this way it can be called from multiple
+# other functions with slightly different needs
+# this function assumes gorolla was called previously
+sub parse_desc_common {
+ my @r; # a temp array we fill, then copy into @ret below
+ my @ret = @{ $_[0] };
+ my @lines = @{ $_[1] };
+
+ # the following will unfortunately create empty paragraphs too
+ # (ie, <para> followed by </para>), so we do this stuff to a temp @r
+ # array and then copy the non-empty ones into the passed-in array @ret
+ if ($#lines >= 0) {
+ # capitalize the first letter of the first line
+ $lines[0] = ucfirst($lines[0]);
+ # for each double newline, break into separate para's
+ $r[++$#r] = "<para>\n";
+ for (my $idx=0; $idx <= $#lines; $idx++) {
+
+ $lines[$idx] =~ s/^(\s*)//; # remove leading whitespace
+ # save number of spaces in case we need to know later
+ my $indent = length($1);
+
+ # if we find @code then treat it as a blob
+ if ($lines[$idx] =~ /^\@code\b/) {
+ my $line = $lines[$idx];
+ $line =~ s/\@code/<programlisting language="lua">/;
+ # if this line didn't have ending token, keep eating paragraphs
+ while (!($line =~ /\@endcode\b/) && $idx <= $#lines) {
+ # also insert back the line separator we ate in earlier split()
+ $line .= $lines[++$idx] . "\n";
+ }
+ # fix ending token, and also remove trailing whitespace before it
+ $line =~ s/[\s\n]*\@endcode/<\/programlisting>/;
+ $r[++$#r] = $line . "\n";
+ } elsif ($lines[$idx] =~ /^\s*$/) {
+ # line is either empty or just whitespace, and we're not in a @code block
+ # so it's the end of a previous paragraph, beginning of new one
+ $r[++$#r] = "</para>\n";
+ $r[++$#r] = "<para>\n";
+ } else {
+ # we have a regular line, not in a @code block
+ # XML-ify it
+ my $line = $lines[$idx];
+
+ # if line starts with "Note:" or "@note", make it an XML <note>
+ if ($line =~ /^[nN]ote:|^\@note /) {
+ $r[++$#r] = "</para>\n";
+ $r[++$#r] = "<note>\n";
+ $r[++$#r] = "\t<para>\n";
+ $line =~ s/^([nN]ote:\s*|\@note\s*)//;
+ $r[++$#r] = "\t\t" . $line . "\n";
+ # keep eating until we find a blank line or end
+ while (!($lines[++$idx] =~ /^\s*$/) && $idx <= $#lines) {
+ $lines[$idx] =~ s/^(\s*)//; # remove leading whitespace
+ $r[++$#r] = "\t\t" . $lines[$idx]. "\n";
+ }
+ $r[++$#r] = "\t</para>\n";
+ $r[++$#r] = "</note>\n";
+ $r[++$#r] = "<para>\n";
+
+ # if line starts with "Warning:"" or @warning", make it an XML <warning>
+ } elsif ($line =~ /^[wW]arning:|^\@warning /) {
+ $r[++$#r] = "</para>\n";
+ $r[++$#r] = "<warning>\n";
+ $r[++$#r] = "\t<para>\n";
+ $line =~ s/^(wW]arning:\s*|\@warning\s*)//;
+ # keep eating until we find a blank line or end
+ $r[++$#r] = "\t\t" . $line . "\n";
+ while (!($lines[++$idx] =~ /^\s*$/) && $idx <= $#lines) {
+ $lines[$idx] =~ s/^(\s*)//; # remove leading whitespace
+ $r[++$#r] = "\t\t" . $lines[$idx] . "\n";
+ }
+ $r[++$#r] = "\t</para>\n";
+ $r[++$#r] = "</warning>\n";
+ $r[++$#r] = "<para>\n";
+
+ # if line starts with "@version" or "@since", make it a "Since:"
+ } elsif ($line =~ /^\@version |^\@since /) {
+ $r[++$#r] = "</para>\n";
+ $r[++$#r] = "<para>\n";
+ $line =~ s/^\@version\s+|^\@since\s+/Since: /;
+ $r[++$#r] = "\t" . $line . "\n";
+ $r[++$#r] = "</para>\n";
+ $r[++$#r] = "<para>\n";
+
+ # if line starts with single "*" and space, make it an XML <itemizedlist>
+ } elsif ($line =~ /^\*\s/) {
+ $r[++$#r] = "</para>\n";
+ $r[++$#r] = "<itemizedlist>\n";
+ $r[++$#r] = "\t<listitem>\n";
+ $r[++$#r] = "\t\t<para>\n";
+ $line =~ s/^\*\s*//; # remove the star and whitespace
+ $r[++$#r] = "\t\t\t" . $line . "\n";
+ # keep eating until we find a blank line or end
+ while (!($lines[++$idx] =~ /^\s*$/) && $idx <= $#lines) {
+ $lines[$idx] =~ s/^(\s*)//; # count and remove leading whitespace
+ # if this is less indented than before, break out
+ last if length($1) < $indent;
+ if ($lines[$idx] =~ /^\*\s/) {
+ # another star, new list item
+ $r[++$#r] = "\t\t</para>\n";
+ $r[++$#r] = "\t</listitem>\n";
+ $r[++$#r] = "\t<listitem>\n";
+ $r[++$#r] = "\t\t<para>\n";
+ $lines[$idx] =~ s/^\*\s*//; # remove star and whitespace
+ }
+ $r[++$#r] = "\t\t\t" . $lines[$idx] . "\n";
+ }
+ $r[++$#r] = "\t\t</para>\n";
+ $r[++$#r] = "\t</listitem>\n";
+ $r[++$#r] = "</itemizedlist>\n";
+ $r[++$#r] = "<para>\n";
+
+ # if line starts with "1." and space, make it an XML <orderedlist>
+ } elsif ($line =~ /^1\.\s/) {
+ $r[++$#r] = "</para>\n";
+ $r[++$#r] = "<orderedlist>\n";
+ $r[++$#r] = "\t<listitem>\n";
+ $r[++$#r] = "\t\t<para>\n";
+ $line =~ s/^1\.\s*//; # remove the 1. and whitespace
+ $r[++$#r] = "\t\t\t" . $line . "\n";
+ # keep eating until we find a blank line or end
+ while (!($lines[++$idx] =~ /^\s*$/) && $idx <= $#lines) {
+ $lines[$idx] =~ s/^(\s*)//; # count and remove leading whitespace
+ # if this is less indented than before, break out
+ last if length($1) < $indent;
+ if ($lines[$idx] =~ /^[0-9]+\.\s/) {
+ # another number, new list item
+ $r[++$#r] = "\t\t</para>\n";
+ $r[++$#r] = "\t</listitem>\n";
+ $r[++$#r] = "\t<listitem>\n";
+ $r[++$#r] = "\t\t<para>\n";
+ $lines[$idx] =~ s/^[0-9]+\.\s*//; # remove star and whitespace
+ }
+ $r[++$#r] = "\t\t\t" . $lines[$idx] . "\n";
+ }
+ $r[++$#r] = "\t\t</para>\n";
+ $r[++$#r] = "\t</listitem>\n";
+ $r[++$#r] = "</orderedlist>\n";
+ $r[++$#r] = "<para>\n";
+
+ # just a normal line, add it to array
+ } else {
+ $r[++$#r] = "\t" . $line . "\n";
+ }
+ }
+ }
+ $r[++$#r] = "</para>\n";
+
+ # now go through @r, and copy into @ret but skip empty
+ # paragraphs (ie, <para> followed by </para>)
+ # I could have used splice(), but I think this is easier (and faster?)
+ # this isn't strictly necessary since the XML tool seems
+ # to ignore empty paragraphs, but in case it ever changes...
+ for (my $idx=0; $idx <= $#r; $idx++) {
+ if ($r[$idx] =~ /^<para>\n$/ && $r[$idx+1] =~ /^<\/para>\n$/) {
+ $idx++; # for-loop will increment $idx and skip the other one
+ } else {
+ $ret[++$#ret] = $r[$idx];
+ }
+ }
+ }
+
+ return \@ret;
+}
+
+# for "normal" description cases - class, function, etc.
+# but not for modules nor function arguments
+sub parse_desc {
+ my $s = gorolla(shift);
+ # break description into separate sections
+ my @r = (); # the array we return
+
+ # split each line into an array
+ my @lines = split(/\n/, $s);
+
+ return parse_desc_common(\@r, \@lines);
+}
+
+# modules have a "title" and an optional description
+sub parse_module_desc {
+ my $s = gorolla(shift);
+ # break description into separate sections
+ my @r = (); # the array we return
+
+ my @lines = split(/\n/, $s);
+ my $line = shift @lines;
+
+ $r[++$#r] = "<title>$line</title>\n";
+
+ return parse_desc_common(\@r, \@lines);
+}
+
+# function argument descriptions are in a <listitem>
+sub parse_function_arg_desc {
+ my $s = gorolla(shift);
+ # break description into separate sections
+ my @r = ( "<listitem>\n" ); # the array we return
+
+ my @lines = split(/\n/, $s);
+ @r = @{ parse_desc_common(\@r, \@lines) };
+
+ $r[++$#r] = "</listitem>\n";
+
+ return \@r;
+}
+
+# attributes have a "mode" and an optional description
+sub parse_attrib_desc {
+ my $s = gorolla(shift);
+ # break description into separate sections
+ my @r = (); # the array we return
+
+ my $mode = shift;
+ if ($mode) {
+ $mode =~ s/RO/ Retrieve only./;
+ $mode =~ s/WO/ Assign only./;
+ $mode =~ s/RW|WR/ Retrieve or assign./;
+ $r[++$#r] = "<para>Mode: $mode</para>\n";
+ } else {
+ die "Attribute does not have a RO/WO/RW mode: '$s'\n";
+ }
+
+ # split each line into an array
+ my @lines = split(/\n/, $s);
+
+ return parse_desc_common(\@r, \@lines);
+}
+
+# prints the parse_* arrays into the XML file with pretty indenting
+# first arg is the description array, second is indent level
+sub print_desc {
+ my $desc_ref = $_[0];
+
+ my $indent = $_[1];
+ if (!$indent) {
+ $indent = 2;
+ }
+ my $tabs = "\t" x $indent;
+
+ for my $line ( @{ $desc_ref } ) {
+ printf D "%s%s", $tabs, $line;
+ }
+}
+
my %module = ();
my %modules = ();
my $class;
@@ -61,40 +353,57 @@ my $function;
my @functions;
my $docbook_template = {
- module_header => "<section id='lua_module_%s'>\n",
- module_desc => "\t<title>%s</title>\n",
- module_footer => "</section>\n",
- class_header => "\t<section id='lua_class_%s'><title>%s</title>\n",
- class_desc => "\t\t<para>%s</para>\n",
- class_footer => "\t</section> <!-- class_footer: %s -->\n",
-# class_constructors_header => "\t\t<section id='lua_class_constructors_%s'>\n\t\t\t<title>%s Constructors</title>\n",
-# class_constructors_footer => "\t\t</section> <!-- class_constructors_footer -->\n",
-# class_methods_header => "\t\t<section id='lua_class_methods_%s'>\n\t\t\t<title>%s Methods</title>\n",
-# class_methods_footer => "\t\t</section> <!-- class_methods_footer: %s -->\n",
- class_attr_header => "\t\t<section id='lua_class_attrib_%s'>\n\t\t\t<title>%s</title>\n",
- class_attr_footer => "\t\t</section> <!-- class_attr_footer: %s -->\n",
- class_attr_descr => "\t\t\t<para>%s%s</para>\n",
- function_header => "\t\t\t<section id='lua_fn_%s'>\n\t\t\t\t<title>%s</title>\n",
- function_descr => "\t\t\t\t<para>%s</para>\n",
- function_footer => "\t\t\t</section> <!-- function_footer: %s -->\n",
- function_args_header => "\t\t\t\t\t<section><title>Arguments</title>\t\t\t\t<variablelist>\n",
- function_args_footer => "\t\t\t\t</variablelist></section>\n",
- function_arg_header => "\t\t\t\t<varlistentry><term>%s</term>\n",
- function_arg_descr => "\t\t\t\t\t<listitem><para>%s</para></listitem>\n",
- function_arg_footer => "\t\t\t\t</varlistentry> <!-- function_arg_footer: %s -->\n",
- function_argerror_header => "", #"\t\t\t\t\t<section><title>Errors</title>\n\t\t\t\t\t\t<itemizedlist>\n",
- function_argerror => "", #"\t\t\t\t\t\t\t<listitem><para>%s</para></listitem>\n",
- function_argerror_footer => "", #"\t\t\t\t\t\t</itemizedlist></section> <!-- function_argerror_footer: %s -->\n",
- function_returns_header => "\t\t\t\t<section><title>Returns</title>\n",
- function_returns_footer => "\t\t\t\t</section> <!-- function_returns_footer: %s -->\n",
- function_returns => "\t\t\t\t\t<para>%s</para>\n",
- function_errors_header => "\t\t\t\t<section><title>Errors</title><itemizedlist>\n",
- function_errors => "\t\t\t\t\t\t<listitem><para>%s</para></listitem>\n",
- function_errors_footer => "\t\t\t\t\t</itemizedlist></section> <!-- function_error_footer: %s -->\n",
- non_method_functions_header => "\t\t<section id='non_method_functions_%s'><title>Non Method Functions</title>\n",
- non_method_functions_footer => "\t\t</section> <!-- Non method -->\n",
+ module_header => "<section id='lua_module_%s'>\n",
+ # module_desc => "\t<title>%s</title>\n",
+ class_header => "\t<section id='lua_class_%s'>\n" .
+ "\t\t<title>%s</title>\n",
+ #class_desc => "\t\t<para>%s</para>\n",
+ class_attr_header => "\t\t<section id='lua_class_attrib_%s'>\n" .
+ "\t\t\t<title>%s</title>\n",
+ #class_attr_descr => "\t\t\t<para>%s%s</para>\n",
+ class_attr_footer => "\t\t</section> <!-- class_attr_footer: %s -->\n",
+ function_header => "\t\t<section id='lua_fn_%s'>\n" .
+ "\t\t\t<title>%s</title>\n",
+ #function_descr => "\t\t\t<para>%s</para>\n",
+ function_args_header => "\t\t\t<section>\n" .
+ "\t\t\t\t<title>Arguments</title>\n" .
+ "\t\t\t\t<variablelist>\n",
+ function_arg_header => "\t\t\t\t\t<varlistentry>\n" .
+ "\t\t\t\t\t\t<term>%s</term>\n",
+ #function_arg_descr => "\t\t\t\t\t\t<listitem>\n" .
+ # "\t\t\t\t\t\t\t<para>%s</para>\n" .
+ # "\t\t\t\t\t\t</listitem>\n",
+ function_arg_footer => "\t\t\t\t\t</varlistentry> <!-- function_arg_footer: %s -->\n",
+ function_args_footer => "\t\t\t\t</variablelist>\n" .
+ "\t\t\t</section> <!-- end of function_args -->\n",
+ function_argerror_header => "", #"\t\t\t\t\t<section><title>Errors</title>\n\t\t\t\t\t\t<itemizedlist>\n",
+ function_argerror => "", #"\t\t\t\t\t\t\t<listitem><para>%s</para></listitem>\n",
+ function_argerror_footer => "", #"\t\t\t\t\t\t</itemizedlist></section> <!-- function_argerror_footer: %s -->\n",
+ function_returns_header => "\t\t\t<section>\n" .
+ "\t\t\t\t<title>Returns</title>\n",
+ function_returns => "\t\t\t\t<para>%s</para>\n",
+ function_returns_footer => "\t\t\t</section> <!-- function_returns_footer: %s -->\n",
+ function_errors_header => "\t\t\t<section>\n" .
+ "\t\t\t\t<title>Errors</title>\n" .
+ "\t\t\t\t<itemizedlist>\n",
+ function_errors => "\t\t\t\t\t<listitem>\n" .
+ "\t\t\t\t\t\t<para>%s</para>\n" .
+ "\t\t\t\t\t</listitem>\n",
+ function_errors_footer => "\t\t\t\t</itemizedlist>\n" .
+ "\t\t\t</section> <!-- function_errors_footer: %s -->\n",
+ function_footer => "\t\t</section> <!-- function_footer: %s -->\n",
+ class_footer => "\t</section> <!-- class_footer: %s -->\n",
+ global_functions_header => "\t<section id='global_functions_%s'>\n" .
+ "\t\t<title>Global Functions</title>\n",
+ global_functions_footer => "\t</section> <!-- Global function -->\n",
+ module_footer => "</section> <!-- end of module -->\n",
};
+# class_constructors_header => "\t\t<section id='lua_class_constructors_%s'>\n\t\t\t<title>%s Constructors</title>\n",
+# class_constructors_footer => "\t\t</section> <!-- class_constructors_footer -->\n",
+# class_methods_header => "\t\t<section id='lua_class_methods_%s'>\n\t\t\t<title>%s Methods</title>\n",
+# class_methods_footer => "\t\t</section> <!-- class_methods_footer: %s -->\n",
+
my $template_ref = $docbook_template;
my $out_extension = "xml";
@@ -105,15 +414,16 @@ my $out_extension = "xml";
my $QUOTED_RE = "\042\050\133^\042\135*\051\042";
my $TRAILING_COMMENT_RE = '((\s*|[\n\r]*)/\*(.*?)\*/)?';
+my $IN_COMMENT_RE = '[\s\r\n]*((.*?)\*/)?';
my @control =
(
# This will be scanned in order trying to match the re if it matches
-# the body will be executed immediatelly after.
-[ 'WSLUA_MODULE\s*([A-Z][a-zA-Z0-9]+)([^\*]*)',
+# the body will be executed immediately after.
+[ 'WSLUA_MODULE\s*([A-Z][a-zA-Z0-9]+)' . $IN_COMMENT_RE,
sub {
$module{name} = $1;
- $module{descr} = $2
+ $module{descr} = parse_module_desc($3);
} ],
[ 'WSLUA_CLASS_DEFINE(?:_BASE)?\050\s*([A-Z][a-zA-Z0-9]+).*?\051;' . $TRAILING_COMMENT_RE,
@@ -121,7 +431,7 @@ sub {
deb ">c=$1=$2=$3=$4=$5=$6=$7=\n";
$class = {
name => $1,
- descr=> gorolla($4),
+ descr=> parse_desc($4),
constructors => [],
methods => [],
attributes => []
@@ -137,7 +447,7 @@ sub {
arglist => [],
args => {},
name => $1,
- descr => gorolla($4),
+ descr => parse_desc($4),
type => 'standalone'
};
push @functions, $function;
@@ -151,7 +461,7 @@ sub {
arglist => [],
args => {},
name => "$1.$2",
- descr => gorolla($5),
+ descr => parse_desc($5),
type => 'constructor'
};
push @{${$class}{constructors}}, $function;
@@ -165,7 +475,7 @@ sub {
arglist => [],
args => {},
name => "$1.$2",
- descr => gorolla($3),
+ descr => parse_desc($3),
type => 'constructor'
};
push @{${$class}{constructors}}, $function;
@@ -182,7 +492,7 @@ sub {
arglist => [],
args => {},
name => $name,
- descr => gorolla($5),
+ descr => parse_desc($5),
type => 'method'
};
push @{${$class}{methods}}, $function;
@@ -200,7 +510,7 @@ sub {
arglist => [],
args => {},
name => $name,
- descr => gorolla($5),
+ descr => parse_desc($5),
type => 'metamethod'
};
push @{${$class}{methods}}, $function;
@@ -211,7 +521,7 @@ sub {
deb ">a=$1=$2=$3=$4=$5=$6=$7=\n";
my $name = $1 eq 'OPT' ? "[$3]" : $3;
push @{${$function}{arglist}} , $name;
- ${${$function}{args}}{$name} = {descr=>$6,}
+ ${${$function}{args}}{$name} = {descr=>parse_function_arg_desc($6),}
} ],
[ '\057\052\s*WSLUA_(OPT)?ARG_([A-Za-z0-9_]+)_([A-Z0-9]+)\s*(.*?)\052\057',
@@ -219,7 +529,7 @@ sub {
deb ">a=$1=$2=$3=$4=$5=$6=$7=\n";
my $name = $1 eq 'OPT' ? "[$3]" : $3;
push @{${$function}{arglist}} , $name;
- ${${$function}{args}}{$name} = {descr=>$4,}
+ ${${$function}{args}}{$name} = {descr=>parse_function_arg_desc($4),}
} ],
[ '#define WSLUA_(OPT)?ARG_([A-Za-z0-9]+)_([a-z_]+)_([A-Z0-9]+)\s+\d+' . $TRAILING_COMMENT_RE,
@@ -227,7 +537,7 @@ sub {
deb ">ca=$1=$2=$3=$4=$5=$6=$7=\n";
my $name = $1 eq 'OPT' ? "[$4]" : $4;
push @{${$function}{arglist}} , $name;
- ${${$function}{args}}{$name} = {descr=>$7,optional => $1 eq '' ? 1 : 0 }
+ ${${$function}{args}}{$name} = {descr=>parse_function_arg_desc($7),optional => $1 eq '' ? 1 : 0 }
} ],
[ '/\052\s+WSLUA_ATTRIBUTE\s+([A-Za-z0-9]+)_([a-z_]+)\s+([A-Z]*)\s*(.*?)\052/',
@@ -236,24 +546,14 @@ sub {
my $name = "$1";
$name =~ tr/A-Z/a-z/;
$name .= ".$2";
- push @{${$class}{attributes}}, { name => $name, descr => gorolla($4), mode=>$3 };
-} ],
-
-# the following never gets used (WSLUA_ATTR_GET is defunct)
-[ 'WSLUA_ATTR_GET\s+([A-Za-z]+)_([a-z_]+).*?' . $TRAILING_COMMENT_RE,
-sub {
- deb ">at=$1=$2=$3=$4=$5=$6=$7=\n";
- my $name = "$1";
- $name =~ tr/A-Z/a-z/;
- $name .= ".$2";
- push @{${$class}{attributes}}, { name => $name, descr => gorolla($4), mode=>$3 };
+ push @{${$class}{attributes}}, { name => $name, descr => parse_attrib_desc($4, $3) };
} ],
[ '/\052\s+WSLUA_MOREARGS\s+([A-Za-z_]+)\s+(.*?)\052/',
sub {
deb ">ma=$1=$2=$3=$4=$5=$6=$7=\n";
push @{${$function}{arglist}} , "...";
- ${${$function}{args}}{"..."} = {descr=>gorolla($2)}
+ ${${$function}{args}}{"..."} = {descr=>parse_function_arg_desc($2)}
} ],
[ 'WSLUA_(FINAL_)?RETURN\050\s*.*?\s*\051\s*;' . $TRAILING_COMMENT_RE,
@@ -333,51 +633,48 @@ while ( $file = shift) {
$modules{$module{name}} = $docfile;
+ print "Generating source XML for: $module{name}\n";
+
printf D ${$template_ref}{module_header}, $module{name}, $module{name};
- if ( exists ${$template_ref}{module_desc} ) {
- printf D ${$template_ref}{module_desc}, $module{descr}, $module{descr};
+
+ if ($module{descr} && @{$module{descr}} >= 0) {
+ print_desc($module{descr}, 1);
+ } else {
+ die "did NOT print $module{name} description\n";
}
for my $cname (sort keys %classes) {
my $cl = $classes{$cname};
printf D ${$template_ref}{class_header}, $cname, $cname;
- if ( ${$cl}{descr} ) {
- printf D ${$template_ref}{class_desc} , ${$cl}{descr};
+ if (${$cl}{descr} && @{${$cl}{descr}} >= 0) {
+ print_desc(${$cl}{descr}, 2);
+ } else {
+ die "did NOT print $cname description\n";
}
if ( $#{${$cl}{constructors}} >= 0) {
-# printf D ${$template_ref}{class_constructors_header}, $cname, $cname;
-
for my $c (@{${$cl}{constructors}}) {
- function_descr($c);
+ function_descr($c,3);
}
-
-# printf D ${$template_ref}{class_constructors_footer}, $cname, $cname;
}
if ( $#{${$cl}{methods}} >= 0) {
-# printf D ${$template_ref}{class_methods_header}, $cname, $cname;
-
for my $m (@{${$cl}{methods}}) {
- function_descr($m);
+ function_descr($m, 3);
}
-
-# printf D ${$template_ref}{class_methods_footer}, $cname, $cname;
}
if ( $#{${$cl}{attributes}} >= 0) {
for my $a (@{${$cl}{attributes}}) {
my $a_id = ${$a}{name};
$a_id =~ s/[^a-zA-Z0-9]/_/g;
- my $mode = ${$a}{mode};
- if ($mode) {
- $mode =~ s/RO/ (read-only)/;
- $mode =~ s/WO/ (write-only)/;
- $mode =~ s/RW|WR/ (read\/write)/;
- }
printf D ${$template_ref}{class_attr_header}, $a_id, ${$a}{name};
- printf D ${$template_ref}{class_attr_descr}, ${$a}{descr}, $mode if ${$a}{mode};
+ if (${$a}{descr} && @{${$a}{descr}} >= 0) {
+ print_desc(${$a}{descr}, 3);
+ } else {
+ die "did not print $a_id description\n";
+ }
printf D ${$template_ref}{class_attr_footer}, ${$a}{name}, ${$a}{name};
}
@@ -390,13 +687,13 @@ while ( $file = shift) {
}
if ($#functions >= 0) {
- printf D ${$template_ref}{non_method_functions_header}, $module{name};
+ printf D ${$template_ref}{global_functions_header}, $module{name};
for my $f (@functions) {
- function_descr($f);
+ function_descr($f, 3);
}
- print D ${$template_ref}{non_method_functions_footer};
+ print D ${$template_ref}{global_functions_footer};
}
%classes = ();
@@ -410,57 +707,30 @@ while ( $file = shift) {
close D;
}
-#my $wsluarm = '';
-#open B, "< template-wsluarm.xml";
-#$wsluarm .= $_ while(<B>);
-#close B;
-#
-#my $ents = '';
-#my $txt = '';
-#
-#for my $module_name (sort keys %modules) {
-# $ents .= <<"_ENT";
-# <!ENTITY $module_name SYSTEM "wsluarm_src/$modules{$module_name}">
-#_ENT
-# $txt .= "&$module_name;\n";
-#}
-#
-#$wsluarm =~ s/<!-- WSLUA_MODULE_ENTITIES -->/$ents/;
-#$wsluarm =~ s/<!-- WSLUA_MODULE_TEXT -->/$txt/;
-#
-#open X, "> wsluarm.xml";
-#print X $wsluarm;
-#close X;
-
sub function_descr {
my $f = $_[0];
- my $label = $_[1];
+ my $indent = $_[1];
+ my $section_name = 'UNKNOWN';
- if (defined $label ) {
- $label =~ s/>/&gt;/;
- $label =~ s/</&lt;/;
- my $section_name = ${$f}{section_name};
- $section_name =~ s/[^a-zA-Z0-9]/_/g;
+ my $arglist = '';
- printf D ${$template_ref}{function_header}, $section_name, $label;
- } else {
- my $arglist = '';
+ for (@{ ${$f}{arglist} }) {
+ my $a = $_;
+ $a =~ tr/A-Z/a-z/;
+ $arglist .= "$a, ";
+ }
- for (@{ ${$f}{arglist} }) {
- my $a = $_;
- $a =~ tr/A-Z/a-z/;
- $arglist .= "$a, ";
- }
+ $arglist =~ s/, $//;
+ $section_name = "${$f}{name}($arglist)";
+ $section_name =~ s/[^a-zA-Z0-9]/_/g;
- $arglist =~ s/, $//;
- my $section_name = "${$f}{name}($arglist)";
- $section_name =~ s/[^a-zA-Z0-9]/_/g;
+ printf D ${$template_ref}{function_header}, $section_name , "${$f}{name}($arglist)";
- printf D ${$template_ref}{function_header}, $section_name , "${$f}{name}($arglist)";
+ my @desc = ${$f}{descr};
+ if ($#desc >= 0) {
+ print_desc(@desc, $indent);
}
- printf D ${$template_ref}{function_descr}, ${$f}{descr} if ${$f}{descr};
-
print D ${$template_ref}{function_args_header} if $#{${$f}{arglist}} >= 0;
for my $argname (@{${$f}{arglist}}) {
@@ -469,7 +739,10 @@ sub function_descr {
$argname =~ s/\[(.*)\]/$1 (optional)/;
printf D ${$template_ref}{function_arg_header}, $argname, $argname;
- printf D ${$template_ref}{function_arg_descr}, ${$arg}{descr} , ${$arg}{descr} if ${$arg}{descr};
+ my @desc = ${$arg}{descr};
+ if ($#desc >= 0) {
+ print_desc(@desc, $indent+2);
+ }
if ( $#{${$arg}{errors}} >= 0) {
printf D ${$template_ref}{function_argerror_header}, $argname, $argname;
@@ -497,10 +770,6 @@ sub function_descr {
printf D ${$template_ref}{function_errors_footer}, ${$f}{name};
}
- if (not defined $label ) {
- $label = '';
- }
-
- printf D ${$template_ref}{function_footer}, $label, $label;
+ printf D ${$template_ref}{function_footer}, $section_name;
}
diff --git a/docbook/wsluarm.xml b/docbook/wsluarm.xml
index 5c9253da52..fdcae10a1f 100644
--- a/docbook/wsluarm.xml
+++ b/docbook/wsluarm.xml
@@ -13,7 +13,7 @@
Both Tecgraf and Lua.org are laboratories of the Department of Computer Science.
</para>
<para>
- In Wireshark Lua can be used to write dissectors and taps.
+ In Wireshark Lua can be used to write dissectors, taps, and capture file readers and writers.
</para>
<para>
Wireshark's Lua interpreter starts by loading <command>init.lua</command> that
@@ -41,126 +41,118 @@
</section>
<section id="wslua_dissector_example">
<title>Example of Dissector written in Lua</title>
- <programlisting>
-do
- local p_multi = Proto("multi","MultiProto");
+<programlisting>local p_multi = Proto("multi","MultiProto");
- local vs_protos = {
- [2] = "mtp2",
- [3] = "mtp3",
- [4] = "alcap",
- [5] = "h248",
- [6] = "ranap",
- [7] = "rnsap",
- [8] = "nbap"
- }
+local vs_protos = {
+ [2] = "mtp2",
+ [3] = "mtp3",
+ [4] = "alcap",
+ [5] = "h248",
+ [6] = "ranap",
+ [7] = "rnsap",
+ [8] = "nbap"
+}
- local f_proto = ProtoField.uint8("multi.protocol","Protocol",base.DEC,vs_protos)
- local f_dir = ProtoField.uint8("multi.direction","Direction",base.DEC,{ [1] = "incoming", [0] = "outgoing"})
- local f_text = ProtoField.string("multi.text","Text")
+local f_proto = ProtoField.uint8("multi.protocol","Protocol",base.DEC,vs_protos)
+local f_dir = ProtoField.uint8("multi.direction","Direction",base.DEC,{ [1] = "incoming", [0] = "outgoing"})
+local f_text = ProtoField.string("multi.text","Text")
- p_multi.fields = { f_proto, f_dir, f_text }
+p_multi.fields = { f_proto, f_dir, f_text }
- local data_dis = Dissector.get("data")
+local data_dis = Dissector.get("data")
- local protos = {
- [2] = Dissector.get("mtp2"),
- [3] = Dissector.get("mtp3"),
- [4] = Dissector.get("alcap"),
- [5] = Dissector.get("h248"),
- [6] = Dissector.get("ranap"),
- [7] = Dissector.get("rnsap"),
- [8] = Dissector.get("nbap"),
- [9] = Dissector.get("rrc"),
- [10] = DissectorTable.get("sctp.ppi"):get_dissector(3), -- m3ua
- [11] = DissectorTable.get("ip.proto"):get_dissector(132), -- sctp
- }
+local protos = {
+ [2] = Dissector.get("mtp2"),
+ [3] = Dissector.get("mtp3"),
+ [4] = Dissector.get("alcap"),
+ [5] = Dissector.get("h248"),
+ [6] = Dissector.get("ranap"),
+ [7] = Dissector.get("rnsap"),
+ [8] = Dissector.get("nbap"),
+ [9] = Dissector.get("rrc"),
+ [10] = DissectorTable.get("sctp.ppi"):get_dissector(3), -- m3ua
+ [11] = DissectorTable.get("ip.proto"):get_dissector(132), -- sctp
+}
- function p_multi.dissector(buf,pkt,root)
+function p_multi.dissector(buf,pkt,root)
- local t = root:add(p_multi,buf(0,2))
- t:add(f_proto,buf(0,1))
- t:add(f_dir,buf(1,1))
+ local t = root:add(p_multi,buf(0,2))
+ t:add(f_proto,buf(0,1))
+ t:add(f_dir,buf(1,1))
- local proto_id = buf(0,1):uint()
+ local proto_id = buf(0,1):uint()
- local dissector = protos[proto_id]
-
- if dissector ~= nil then
- dissector:call(buf(2):tvb(),pkt,root)
- elseif proto_id &lt; 2 then
- t:add(f_text,buf(2))
- -- pkt.cols.info:set(buf(2,buf:len() - 3):string())
- else
- data_dis:call(buf(2):tvb(),pkt,root)
- end
+ local dissector = protos[proto_id]
+ if dissector ~= nil then
+ dissector:call(buf(2):tvb(),pkt,root)
+ elseif proto_id &lt; 2 then
+ t:add(f_text,buf(2))
+ -- pkt.cols.info:set(buf(2,buf:len() - 3):string())
+ else
+ data_dis:call(buf(2):tvb(),pkt,root)
end
- local wtap_encap_table = DissectorTable.get("wtap_encap")
- local udp_encap_table = DissectorTable.get("udp.port")
-
- wtap_encap_table:add(wtap.USER15,p_multi)
- wtap_encap_table:add(wtap.USER12,p_multi)
- udp_encap_table:add(7555,p_multi)
end
- </programlisting>
+
+local wtap_encap_table = DissectorTable.get("wtap_encap")
+local udp_encap_table = DissectorTable.get("udp.port")
+
+wtap_encap_table:add(wtap.USER15,p_multi)
+wtap_encap_table:add(wtap.USER12,p_multi)
+udp_encap_table:add(7555,p_multi)</programlisting>
</section>
<section id="wslua_tap_example">
<title>Example of Listener written in Lua</title>
- <programlisting>
--- This program will register a menu that will open a window with a count of occurrences
+ <programlisting>-- This program will register a menu that will open a window with a count of occurrences
-- of every address in the capture
-do
- local function menuable_tap()
- -- Declare the window we will use
- local tw = TextWindow.new("Address Counter")
-
- -- This will contain a hash of counters of appearances of a certain address
- local ips = {}
+local function menuable_tap()
+ -- Declare the window we will use
+ local tw = TextWindow.new("Address Counter")
- -- this is our tap
- local tap = Listener.new();
+ -- This will contain a hash of counters of appearances of a certain address
+ local ips = {}
- function remove()
- -- this way we remove the listener that otherwise will remain running indefinitely
- tap:remove();
- end
+ -- this is our tap
+ local tap = Listener.new();
- -- we tell the window to call the remove() function when closed
- tw:set_atclose(remove)
+ function remove()
+ -- this way we remove the listener that otherwise will remain running indefinitely
+ tap:remove();
+ end
- -- this function will be called once for each packet
- function tap.packet(pinfo,tvb)
- local src = ips[tostring(pinfo.src)] or 0
- local dst = ips[tostring(pinfo.dst)] or 0
+ -- we tell the window to call the remove() function when closed
+ tw:set_atclose(remove)
- ips[tostring(pinfo.src)] = src + 1
- ips[tostring(pinfo.dst)] = dst + 1
- end
+ -- this function will be called once for each packet
+ function tap.packet(pinfo,tvb)
+ local src = ips[tostring(pinfo.src)] or 0
+ local dst = ips[tostring(pinfo.dst)] or 0
- -- this function will be called once every few seconds to update our window
- function tap.draw(t)
- tw:clear()
- for ip,num in pairs(ips) do
- tw:append(ip .. "\t" .. num .. "\n");
- end
- end
+ ips[tostring(pinfo.src)] = src + 1
+ ips[tostring(pinfo.dst)] = dst + 1
+ end
- -- this function will be called whenever a reset is needed
- -- e.g. when reloading the capture file
- function tap.reset()
- tw:clear()
- ips = {}
+ -- this function will be called once every few seconds to update our window
+ function tap.draw(t)
+ tw:clear()
+ for ip,num in pairs(ips) do
+ tw:append(ip .. "\t" .. num .. "\n");
end
end
- -- using this function we register our function
- -- to be called when the user selects the Tools->Test->Packets menu
- register_menu("Test/Packets", menuable_tap, MENU_TOOLS_UNSORTED)
+ -- this function will be called whenever a reset is needed
+ -- e.g. when reloading the capture file
+ function tap.reset()
+ tw:clear()
+ ips = {}
+ end
end
- </programlisting>
+
+-- using this function we register our function
+-- to be called when the user selects the Tools->Test->Packets menu
+register_menu("Test/Packets", menuable_tap, MENU_TOOLS_UNSORTED)</programlisting>
</section>
<section id="wsluarm_modules">
<title>Wireshark's Lua API Reference Manual</title>
@@ -230,6 +222,9 @@ end
</itemizedlist>
</para>
<para>
+ Since: 1.11.3
+ </para>
+ <para>
This page is based on the full documentation for Lrexlib at
<ulink url="http://rrthomas.github.io/lrexlib/manual.html">http://rrthomas.github.io/lrexlib/manual.html</ulink>
</para>
@@ -241,6 +236,9 @@ end
<para>
GLib Regular Expressions based on PCRE.
</para>
+ <para>
+ Since: 1.11.3
+ </para>
<section id='lua_class_GRegex_notes'><title>Notes</title>
<para>
All functions that take a regular expression pattern as an argument will
@@ -295,6 +293,9 @@ end
result then can be used by the methods, e.g. match, exec, etc. Regular
expression objects are automatically garbage collected.
</para>
+ <para>
+ Since: 1.11.3
+ </para>
<section><title>Arguments</title>
<variablelist>
<varlistentry><term>pattern</term>
@@ -322,6 +323,9 @@ end
used for comparing with return codes of some functions and methods for
determining the reason of failure.
</para>
+ <para>
+ Since: 1.11.3
+ </para>
<section><title>Arguments</title>
<variablelist>
<varlistentry><term>table (optional)</term>
@@ -340,6 +344,9 @@ end
constants. If the table argument is supplied then it is used as the
output table, otherwise a new table is created.
</para>
+ <para>
+ Since: 1.11.3
+ </para>
<section><title>Arguments</title>
<variablelist>
<varlistentry><term>table (optional)</term>
@@ -358,6 +365,9 @@ end
constants. If the table argument is supplied then it is used as the
output table, otherwise a new table is created.
</para>
+ <para>
+ Since: 1.11.3
+ </para>
<section><title>Arguments</title>
<variablelist>
<varlistentry><term>table (optional)</term>
@@ -375,6 +385,9 @@ end
from offset init, subject to flags cf and ef. The pattern is compiled each time this is
called, unlike the class method 'match' function.
</para>
+ <para>
+ Since: 1.11.3
+ </para>
<section><title>Arguments</title>
<variablelist>
<varlistentry><term>subject</term>
@@ -408,6 +421,9 @@ end
from offset init, subject to flags ef. The pattern is compiled each time this is
called, unlike the class method 'find' function.
</para>
+ <para>
+ Since: 1.11.3
+ </para>
<section><title>Arguments</title>
<variablelist>
<varlistentry><term>subject</term>
@@ -441,6 +457,9 @@ end
to flags cf and ef. The function is intended for use in the generic for Lua construct.
The pattern can be a string or a GRegex object previously compiled with GRegex.new().
</para>
+ <para>
+ Since: 1.11.3
+ </para>
<section><title>Arguments</title>
<variablelist>
<varlistentry><term>subject</term>
@@ -474,6 +493,9 @@ end
to the parameters repl and max.
The pattern can be a string or a GRegex object previously compiled with GRegex.new().
</para>
+ <para>
+ Since: 1.11.3
+ </para>
<para> For details see:
<ulink url="http://rrthomas.github.io/lrexlib/manual.html#gsub">http://rrthomas.github.io/lrexlib/manual.html#gsub</ulink>
</para>
@@ -515,6 +537,9 @@ end
The sep pattern can be a string or a GRegex object previously compiled with GRegex.new().
Unlike gmatch, there will always be at least one iteration pass, even if there are no matches in the subject.
</para>
+ <para>
+ Since: 1.11.3
+ </para>
<section><title>Arguments</title>
<variablelist>
<varlistentry><term>subject</term>
@@ -543,6 +568,9 @@ end
<section id='lua_fn_GRegex_version__'>
<title>GRegex.version()</title>
<para>Returns a returns a string containing the version of the used library.</para>
+ <para>
+ Since: 1.11.3
+ </para>
<section><title>Returns</title>
<para>The version string</para>
</section> <!-- function_returns_footer: GRegex.version -->
@@ -552,6 +580,9 @@ end
<para>Searches for the first match of the regexp pattern in the string subject, starting
from offset init, subject to flags ef.
</para>
+ <para>
+ Since: 1.11.3
+ </para>
<section><title>Arguments</title>
<variablelist>
<varlistentry><term>subject</term>
@@ -578,6 +609,9 @@ end
<para>Searches for the first match of the regexp pattern in the string subject, starting
from offset init, subject to flags ef.
</para>
+ <para>
+ Since: 1.11.3
+ </para>
<section><title>Arguments</title>
<variablelist>
<varlistentry><term>subject</term>
@@ -604,6 +638,9 @@ end
<para>Searches for the first match of the compiled GRegex object in the string subject, starting
from offset init, subject to the execution match flags ef.
</para>
+ <para>
+ Since: 1.11.3
+ </para>
<section><title>Arguments</title>
<variablelist>
<varlistentry><term>subject</term>
@@ -632,6 +669,9 @@ end
<section id='lua_fn_gregex_dfa_exec_subject___init____ef__'>
<title>gregex:dfa_exec(subject, [init], [ef])</title>
<para>Matches a compiled regular expression GRegex object against a given subject string subj, using a DFA matching algorithm.</para>
+ <para>
+ Since: 1.11.3
+ </para>
<section><title>Arguments</title>
<variablelist>
<varlistentry><term>subject</term>
@@ -659,6 +699,9 @@ end
<section id='lua_fn_gregex___tostring__'>
<title>gregex:__tostring()</title>
<para>Returns a string containing debug information about the GRegex object.</para>
+ <para>
+ Since: 1.11.3
+ </para>
<section><title>Returns</title>
<para>The debug string</para>
</section> <!-- function_returns_footer: gregex:__tostring -->
diff --git a/epan/wslua/wslua_dumper.c b/epan/wslua/wslua_dumper.c
index cd759ab1b3..4340304f57 100644
--- a/epan/wslua/wslua_dumper.c
+++ b/epan/wslua/wslua_dumper.c
@@ -28,7 +28,15 @@
#include <epan/emem.h>
-/* WSLUA_MODULE Dumper Saving capture files */
+/* WSLUA_MODULE Dumper Saving capture files
+
+ The classes/functions defined in this module are for using a `Dumper` object to
+ make Wireshark save a capture file to disk. `Dumper` represents Wireshark's built-in
+ file format writers (see the `wtap_filetypes` table in `init.lua`).
+
+ To have a Lua script create its own file format writer, see the chapter titled
+ "Custom file format reading/writing".
+*/
#include "wslua.h"
#include <math.h>
@@ -76,7 +84,7 @@ WSLUA_CONSTRUCTOR PseudoHeader_none(lua_State* L) {
WSLUA_CONSTRUCTOR PseudoHeader_eth(lua_State* L) {
/*
- Creates an ethernet pseudoheader
+ Creates an ethernet pseudoheader.
*/
#define WSLUA_OPTARG_PseudoHeader_eth_FCSLEN 1 /* The fcs length */
@@ -93,7 +101,7 @@ WSLUA_CONSTRUCTOR PseudoHeader_eth(lua_State* L) {
WSLUA_CONSTRUCTOR PseudoHeader_atm(lua_State* L) {
/*
- Creates an ATM pseudoheader
+ Creates an ATM pseudoheader.
*/
#define WSLUA_OPTARG_PseudoHeader_atm_AAL 1 /* AAL number */
#define WSLUA_OPTARG_PseudoHeader_atm_VPI 2 /* VPI */
@@ -120,10 +128,10 @@ WSLUA_CONSTRUCTOR PseudoHeader_atm(lua_State* L) {
}
WSLUA_CONSTRUCTOR PseudoHeader_mtp2(lua_State* L) {
- /* Creates an MTP2 PseudoHeader */
+ /* Creates an MTP2 PseudoHeader. */
#define WSLUA_OPTARG_PseudoHeader_mtp2_SENT 1 /* True if the packet is sent, False if received. */
-#define WSLUA_OPTARG_PseudoHeader_mtp2_ANNEXA 2 /* True if annex A is used */
-#define WSLUA_OPTARG_PseudoHeader_mtp2_LINKNUM 3 /* Link Number */
+#define WSLUA_OPTARG_PseudoHeader_mtp2_ANNEXA 2 /* True if annex A is used. */
+#define WSLUA_OPTARG_PseudoHeader_mtp2_LINKNUM 3 /* Link Number. */
PseudoHeader ph = (PseudoHeader)g_malloc(sizeof(struct lua_pseudo_header));
ph->type = PHDR_MTP2;
ph->wph = (union wtap_pseudo_header *)g_malloc(sizeof(union wtap_pseudo_header));
@@ -198,11 +206,11 @@ static const char* cross_plat_fname(const char* fname) {
WSLUA_CONSTRUCTOR Dumper_new(lua_State* L) {
/*
Creates a file to write packets.
- Dumper:new_for_current() will probably be a better choice.
+ `Dumper:new_for_current()` will probably be a better choice.
*/
-#define WSLUA_ARG_Dumper_new_FILENAME 1 /* The name of the capture file to be created */
-#define WSLUA_OPTARG_Dumper_new_FILETYPE 2 /* The type of the file to be created */
-#define WSLUA_OPTARG_Dumper_new_ENCAP 3 /* The encapsulation to be used in the file to be created */
+#define WSLUA_ARG_Dumper_new_FILENAME 1 /* The name of the capture file to be created. */
+#define WSLUA_OPTARG_Dumper_new_FILETYPE 2 /* The type of the file to be created - a number entry from the `wtap_filetypes` table in `init.lua`. */
+#define WSLUA_OPTARG_Dumper_new_ENCAP 3 /* The encapsulation to be used in the file to be created - a number entry from the `wtap_encaps` table in `init.lua`. */
Dumper d;
const char* fname = luaL_checkstring(L,WSLUA_ARG_Dumper_new_FILENAME);
int filetype = luaL_optint(L,WSLUA_OPTARG_Dumper_new_FILETYPE,WTAP_FILE_TYPE_SUBTYPE_PCAP);
@@ -247,7 +255,7 @@ WSLUA_CONSTRUCTOR Dumper_new(lua_State* L) {
}
WSLUA_METHOD Dumper_close(lua_State* L) {
- /* Closes a dumper */
+ /* Closes a dumper. */
Dumper* dp = (Dumper*)luaL_checkudata(L, 1, "Dumper");
int err;
@@ -287,8 +295,8 @@ WSLUA_METHOD Dumper_dump(lua_State* L) {
Dumps an arbitrary packet.
Note: Dumper:dump_current() will fit best in most cases.
*/
-#define WSLUA_ARG_Dumper_dump_TIMESTAMP 2 /* The absolute timestamp the packet will have */
-#define WSLUA_ARG_Dumper_dump_PSEUDOHEADER 3 /* The Pseudoheader to use. */
+#define WSLUA_ARG_Dumper_dump_TIMESTAMP 2 /* The absolute timestamp the packet will have. */
+#define WSLUA_ARG_Dumper_dump_PSEUDOHEADER 3 /* The `PseudoHeader` to use. */
#define WSLUA_ARG_Dumper_dump_BYTEARRAY 4 /* the data to be saved */
Dumper d = checkDumper(L,1);
@@ -339,7 +347,7 @@ WSLUA_METHOD Dumper_dump(lua_State* L) {
WSLUA_METHOD Dumper_new_for_current(lua_State* L) {
/*
- Creates a capture file using the same encapsulation as the one of the cuurrent packet
+ Creates a capture file using the same encapsulation as the one of the current packet.
*/
#define WSLUA_OPTARG_Dumper_new_for_current_FILETYPE 2 /* The file type. Defaults to pcap. */
Dumper d;
diff --git a/epan/wslua/wslua_field.c b/epan/wslua/wslua_field.c
index 674a1d9201..0720edf591 100644
--- a/epan/wslua/wslua_field.c
+++ b/epan/wslua/wslua_field.c
@@ -37,8 +37,12 @@
/* any call to checkFieldInfo() will now error on null or expired, so no need to check again */
WSLUA_CLASS_DEFINE(FieldInfo,FAIL_ON_NULL_OR_EXPIRED("FieldInfo"),NOP);
/*
- An extracted Field
- */
+ An extracted Field from dissected packet data. A `FieldInfo` object can only be used within
+ the callback functions of dissectors, post-dissectors, heuristic-dissectors, and taps.
+
+ A `FieldInfo` can be called on either existing Wireshark fields by using either `Field.new()`
+ or `Field()` before-hand, or it can be called on new fields created by Lua from a `ProtoField`.
+ */
static GPtrArray* outstanding_FieldInfo = NULL;
@@ -46,7 +50,7 @@ static GPtrArray* outstanding_FieldInfo = NULL;
CLEAR_OUTSTANDING(FieldInfo,expired,TRUE)
-/* WSLUA_ATTRIBUTE FieldInfo_len RO The length of this field */
+/* WSLUA_ATTRIBUTE FieldInfo_len RO The length of this field. */
WSLUA_METAMETHOD FieldInfo__len(lua_State* L) {
/*
Obtain the Length of the field
@@ -57,7 +61,7 @@ WSLUA_METAMETHOD FieldInfo__len(lua_State* L) {
return 1;
}
-/* WSLUA_ATTRIBUTE FieldInfo_offset RO The offset of this field */
+/* WSLUA_ATTRIBUTE FieldInfo_offset RO The offset of this field. */
WSLUA_METAMETHOD FieldInfo__unm(lua_State* L) {
/*
Obtain the Offset of the field
@@ -68,7 +72,7 @@ WSLUA_METAMETHOD FieldInfo__unm(lua_State* L) {
return 1;
}
-/* WSLUA_ATTRIBUTE FieldInfo_value RO The value of this field */
+/* WSLUA_ATTRIBUTE FieldInfo_value RO The value of this field. */
WSLUA_METAMETHOD FieldInfo__call(lua_State* L) {
/*
Obtain the Value of the field
@@ -179,7 +183,7 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) {
/* WSLUA_ATTRIBUTE FieldInfo_label RO The string representing this field */
WSLUA_METAMETHOD FieldInfo__tostring(lua_State* L) {
- /* The string representation of the field */
+ /* The string representation of the field. */
FieldInfo fi = checkFieldInfo(L,1);
if (fi->ws_fi->value.ftype->val_to_string_repr) {
@@ -203,7 +207,7 @@ WSLUA_METAMETHOD FieldInfo__tostring(lua_State* L) {
/* WSLUA_ATTRIBUTE FieldInfo_display RO The string display of this field as seen in GUI */
static int FieldInfo_get_display(lua_State* L) {
- /* The display string of this field as seen in GUI */
+ /* The display string of this field as seen in GUI. */
FieldInfo fi = checkFieldInfo(L,1);
gchar label_str[ITEM_LABEL_LENGTH+1];
gchar *label_ptr;
@@ -229,9 +233,9 @@ static int FieldInfo_get_display(lua_State* L) {
return 1;
}
-/* WSLUA_ATTRIBUTE FieldInfo_range RO The TvbRange covering this field */
+/* WSLUA_ATTRIBUTE FieldInfo_range RO The `TvbRange` covering this field */
static int FieldInfo_get_range(lua_State* L) {
- /* The TvbRange covering this field */
+ /* The `TvbRange` covering this field. */
FieldInfo fi = checkFieldInfo(L,1);
if (push_TvbRange (L, fi->ws_fi->ds_tvb, fi->ws_fi->start, fi->ws_fi->length)) {
@@ -260,7 +264,7 @@ static int FieldInfo_get_name(lua_State* L) {
}
WSLUA_METAMETHOD FieldInfo__eq(lua_State* L) {
- /* Checks whether lhs is within rhs */
+ /* Checks whether lhs is within rhs. */
FieldInfo l = checkFieldInfo(L,1);
FieldInfo r = checkFieldInfo(L,2);
@@ -278,7 +282,7 @@ WSLUA_METAMETHOD FieldInfo__eq(lua_State* L) {
}
WSLUA_METAMETHOD FieldInfo__le(lua_State* L) {
- /* Checks whether the end byte of lhs is before the end of rhs */
+ /* Checks whether the end byte of lhs is before the end of rhs. */
FieldInfo l = checkFieldInfo(L,1);
FieldInfo r = checkFieldInfo(L,2);
@@ -294,7 +298,7 @@ WSLUA_METAMETHOD FieldInfo__le(lua_State* L) {
}
WSLUA_METAMETHOD FieldInfo__lt(lua_State* L) {
- /* Checks whether the end byte of rhs is before the beginning of rhs */
+ /* Checks whether the end byte of rhs is before the beginning of rhs. */
FieldInfo l = checkFieldInfo(L,1);
FieldInfo r = checkFieldInfo(L,2);
@@ -397,7 +401,10 @@ WSLUA_FUNCTION wslua_all_field_infos(lua_State* L) {
WSLUA_CLASS_DEFINE(Field,FAIL_ON_NULL("Field"),NOP);
/*
- A Field extractor to to obtain field values.
+ A Field extractor to to obtain field values. A `Field` object can only be created *outside* of
+ the callback functions of dissectors, post-dissectors, heuristic-dissectors, and taps.
+
+ Once created, it is used *inside* the callback functions, to generate a `FieldInfo` object.
*/
static GPtrArray* wanted_fields = NULL;
@@ -417,7 +424,7 @@ void wslua_prime_dfilter(epan_dissect_t *edt) {
}
/*
- * field extractor registartion is tricky, In order to allow
+ * field extractor registration is tricky, In order to allow
* the user to define them in the body of the script we will
* populate the Field value with a pointer of the abbrev of it
* to later replace it with the hfi.
@@ -475,7 +482,7 @@ void lua_prime_all_fields(proto_tree* tree _U_) {
WSLUA_CONSTRUCTOR Field_new(lua_State *L) {
/*
- Create a Field extractor
+ Create a Field extractor.
*/
#define WSLUA_ARG_Field_new_FIELDNAME 1 /* The filter name of the field (e.g. ip.addr) */
const gchar* name = luaL_checkstring(L,WSLUA_ARG_Field_new_FIELDNAME);
@@ -504,7 +511,11 @@ WSLUA_CONSTRUCTOR Field_new(lua_State *L) {
WSLUA_CONSTRUCTOR Field_list(lua_State *L) {
/* Gets a Lua array table of all registered field filter names.
- NOTE: this is an expensive operation, and should only be used for troubleshooting. */
+
+ NOTE: this is an expensive operation, and should only be used for troubleshooting.
+
+ @since 1.11.3
+ */
void *cookie, *cookie2;
int i = -1;
int count = 0;
@@ -531,7 +542,7 @@ WSLUA_CONSTRUCTOR Field_list(lua_State *L) {
}
WSLUA_METAMETHOD Field__call (lua_State* L) {
- /* Obtain all values (see FieldInfo) for this field. */
+ /* Obtain all values (see `FieldInfo`) for this field. */
Field f = checkField(L,1);
header_field_info* in = *f;
int items_found = 0;
@@ -566,7 +577,7 @@ WSLUA_METAMETHOD Field__call (lua_State* L) {
}
WSLUA_METAMETHOD Field__tostring(lua_State* L) {
- /* Obtain a string with the field name */
+ /* Obtain a string with the field name. */
Field f = checkField(L,1);
if (wanted_fields) {
diff --git a/epan/wslua/wslua_file.c b/epan/wslua/wslua_file.c
index 0fcc55f5e0..6149a8e043 100644
--- a/epan/wslua/wslua_file.c
+++ b/epan/wslua/wslua_file.c
@@ -38,40 +38,62 @@
#define MAX_LINE_LENGTH 65536
-/* WSLUA_MODULE File Custom file format reading/writing */
+/* WSLUA_MODULE File Custom file format reading/writing
+
+ The classes/functions defined in this section allow you to create your own
+ custom Lua-based "capture" file reader, or writer, or both.
+
+ @since 1.11.3
+ */
WSLUA_CLASS_DEFINE(File,FAIL_ON_NULL_OR_EXPIRED("File"),NOP);
/*
- A File object, passed into Lua as an argument by FileHandler callback
- functions (e.g., read_open, read, write, etc.). This behaves similarly to the
- Lua 'io' library's 'file' object, returned when calling io.open(), *except*
- in this case you cannot call file:close(), file:open(), nor file:setvbuf(),
+ A `File` object, passed into Lua as an argument by FileHandler callback
+ functions (e.g., `read_open`, `read`, `write`, etc.). This behaves similarly to the
+ Lua `io` library's `file` object, returned when calling `io.open()`, *except*
+ in this case you cannot call `file:close()`, `file:open()`, nor `file:setvbuf()`,
since Wireshark/tshark manages the opening and closing of files.
- You also cannot use the 'io' library itself on this object, i.e. you cannot
- do io.read(file, 4). Instead, use this File with the object-oriented style
- calling its methods, i.e. myfile:read(4).
+ You also cannot use the '`io`' library itself on this object, i.e. you cannot
+ do `io.read(file, 4)`. Instead, use this `File` with the object-oriented style
+ calling its methods, i.e. `myfile:read(4)`. (see later example)
- </para><para>
The purpose of this object is to hide the internal complexity of how Wireshark
handles files, and instead provide a Lua interface that is familiar, by mimicking
- the io library. The reason true/raw io files cannot be used is because Wireshark
- does many things under the hood, such as compress the file, or write to stdout,
+ the `io` library. The reason true/raw `io` files cannot be used is because Wireshark
+ does many things under the hood, such as compress the file, or write to `stdout`,
or various other things based on configuration/commands.
- </para><para>
- When a File object is passed in through reading-based callback functions, such as
- read_open(), read(), and read_close(), then the File object's write() and flush()
+ When a `File` object is passed in through reading-based callback functions, such as
+ `read_open()`, `read()`, and `read_close()`, then the File object's `write()` and `flush()`
functions are not usable and will raise an error if used.
- </para><para>
- When a File object is passed in through writing-based callback functions, such as
- write_open(), write(), and write_close(), then the File object's read() and lines()
+ When a `File` object is passed in through writing-based callback functions, such as
+ `write_open()`, `write()`, and `write_close()`, then the File object's `read()` and `lines()`
functions are not usable and will raise an error if used.
- </para><para>
- Note: a File object should never be stored/saved beyond the scope of the callback function
+ Note: a `File` object should never be stored/saved beyond the scope of the callback function
it is passed in to.
+
+ For example:
+ @code
+ function myfilehandler.read_open(file, capture)
+ local position = file:seek()
+
+ -- read 24 bytes
+ local line = file:read(24)
+
+ -- do stuff
+
+ -- it's not our file type, seek back (unnecessary but just to show it...)
+ file:seek("set",position)
+
+ -- return false because it's not our file type
+ return false
+ end
+ @endcode
+
+ @since 1.11.3
*/
@@ -182,7 +204,7 @@ static int File_read_line(lua_State *L, FILE_T ft) {
return 1;
}
-/* This internal function reads X number of btyes form the file, same as io.read(num) in Lua.
+/* This internal function reads X number of bytes from the file, same as `io.read(num)` in Lua.
* Since we have to use file_wrappers.c, and an intermediate buffer, we read it in chunks
* of 1024 bytes at a time. (or less if called with a smaller number) To do that, we use
* Lua's buffer manager to push it into Lua as those chunks, while ending up with one long
@@ -248,7 +270,7 @@ static int pushresult (lua_State *L, int i, const char *filename) {
}
WSLUA_METHOD File_read(lua_State* L) {
- /* Reads from the File, similar to Lua's file:read(). See Lua 5.x ref manual for file:read(). */
+ /* Reads from the File, similar to Lua's `file:read()`. See Lua 5.x ref manual for `file:read()`. */
File f = shiftFile(L,1);
int nargs = lua_gettop(L);
int success;
@@ -316,7 +338,7 @@ WSLUA_METHOD File_read(lua_State* L) {
}
WSLUA_METHOD File_seek(lua_State* L) {
- /* Seeks in the File, similar to Lua's file:seek(). See Lua 5.x ref manual for file:seek(). */
+ /* Seeks in the File, similar to Lua's `file:seek()`. See Lua 5.x ref manual for `file:seek()`. */
static const int mode[] = { SEEK_SET, SEEK_CUR, SEEK_END };
static const char *const modenames[] = {"set", "cur", "end", NULL};
File f = checkFile(L,1);
@@ -375,7 +397,7 @@ static int File_lines_iterator(lua_State* L) {
}
WSLUA_METHOD File_lines(lua_State* L) {
- /* Lua iterator function for retrieving ascii File lines, similar to Lua's file:lines(). See Lua 5.x ref manual for file:lines(). */
+ /* Lua iterator function for retrieving ASCII File lines, similar to Lua's `file:lines()`. See Lua 5.x ref manual for `file:lines()`. */
File f = checkFile(L,1);
FILE_T ft = NULL;
@@ -453,8 +475,9 @@ static int File__gc(lua_State* L _U_) {
}
/* WSLUA_ATTRIBUTE File_compressed RO Whether the File is compressed or not.
- See 'wtap_encaps' in init.lua for available types. Set to 'wtap_encaps.PER_PACKET' if packets can
- have different types, then later set 'FrameInfo.encap' for each packet during read()/seek_read(). */
+
+ See `wtap_encaps` in init.lua for available types. Set to `wtap_encaps.PER_PACKET` if packets can
+ have different types, then later set `FrameInfo.encap` for each packet during read()/seek_read(). */
static int File_get_compressed(lua_State* L) {
File f = checkFile(L,1);
@@ -662,16 +685,17 @@ static void remove_wdh_priv(lua_State* L, wtap_dumper *wdh) {
WSLUA_CLASS_DEFINE(CaptureInfo,FAIL_ON_NULL_MEMBER_OR_EXPIRED("CaptureInfo",wth),NOP);
/*
- A CaptureInfo object, passed into Lua as an argument by FileHandler callback
- function read_open(), read(), seek_read(), seq_read_close(), and read_close().
+ A `CaptureInfo` object, passed into Lua as an argument by `FileHandler` callback
+ function `read_open()`, `read()`, `seek_read()`, `seq_read_close()`, and `read_close()`.
This object represents capture file data and meta-data (data about the
capture file) being read into Wireshark/Tshark.
- </para><para>
This object's fields can be written-to by Lua during the read-based function callbacks.
- In other words, when the Lua plugin's FileHandler read_open() function is invoked, a
- CaptureInfo object will be passed in as one of the arguments, and its fields
+ In other words, when the Lua plugin's `FileHandler.read_open()` function is invoked, a
+ `CaptureInfo` object will be passed in as one of the arguments, and its fields
should be written to by your Lua code to tell Wireshark about the capture.
+
+ @since 1.11.3
*/
static CaptureInfo* push_CaptureInfo(lua_State* L, wtap *wth, const gboolean first_time) {
@@ -714,52 +738,58 @@ static int CaptureInfo__gc(lua_State* L _U_) {
}
/* WSLUA_ATTRIBUTE CaptureInfo_encap RW The packet encapsulation type for the whole file.
- See 'wtap_encaps' in init.lua for available types. Set to 'wtap_encaps.PER_PACKET' if packets can
- have different types, then later set 'FrameInfo.encap' for each packet during read()/seek_read(). */
+
+ See `wtap_encaps` in `init.lua` for available types. Set to `wtap_encaps.PER_PACKET` if packets can
+ have different types, then later set `FrameInfo.encap` for each packet during `read()`/`seek_read()`.
+ */
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfo,encap,wth->file_encap);
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,encap,wth->file_encap,int);
/* WSLUA_ATTRIBUTE CaptureInfo_time_precision RW The precision of the packet timestamps in the file.
- See 'wtap_file_tsprec' in init.lua for available precisions. */
+
+ See `wtap_file_tsprec` in `init.lua` for available precisions.
+ */
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfo,time_precision,wth->tsprecision);
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,time_precision,wth->tsprecision,int);
/* WSLUA_ATTRIBUTE CaptureInfo_snapshot_length RW The maximum packet length that could be recorded.
- Setting it to 0 means unknown. Wireshark cannot handle anything bigger than 65535 bytes. */
+
+ Setting it to `0` means unknown. Wireshark cannot handle anything bigger than 65535 bytes.
+ */
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfo,snapshot_length,wth->snapshot_length);
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,snapshot_length,wth->snapshot_length,guint);
/* WSLUA_ATTRIBUTE CaptureInfo_comment RW A string comment for the whole capture file,
- or nil if there is no comment. */
+ or nil if there is no `comment`. */
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfo,comment,wth->shb_hdr.opt_comment);
WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(CaptureInfo,comment,wth->shb_hdr.opt_comment,TRUE);
/* WSLUA_ATTRIBUTE CaptureInfo_hardware RW A string containing the description of
- the hardware used to create the capture, or nil if there is no hardware string. */
+ the hardware used to create the capture, or nil if there is no `hardware` string. */
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfo,hardware,wth->shb_hdr.shb_hardware);
WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(CaptureInfo,hardware,wth->shb_hdr.shb_hardware,TRUE);
/* WSLUA_ATTRIBUTE CaptureInfo_os RW A string containing the name of
- the operating system used to create the capture, or nil if there is no os string. */
+ the operating system used to create the capture, or nil if there is no `os` string. */
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfo,os,wth->shb_hdr.shb_os);
WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(CaptureInfo,os,wth->shb_hdr.shb_os,TRUE);
/* WSLUA_ATTRIBUTE CaptureInfo_user_app RW A string containing the name of
- the application used to create the capture, or nil if there is no user_app string. */
+ the application used to create the capture, or nil if there is no `user_app` string. */
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfo,user_app,wth->shb_hdr.shb_user_appl);
WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(CaptureInfo,user_app,wth->shb_hdr.shb_user_appl,TRUE);
/* WSLUA_ATTRIBUTE CaptureInfo_hosts WO Sets resolved ip-to-hostname information.
- The value set must be a Lua table of two key-ed names: 'ipv4_addresses' and 'ipv6_addresses'.
+
+ The value set must be a Lua table of two key-ed names: `ipv4_addresses` and `ipv6_addresses`.
The value of each of these names are themselves array tables, of key-ed tables, such that the inner table has a key
- 'addr' set to the raw 4-byte or 16-byte IP address Lua string and a 'name' set to the resolved name.
+ `addr` set to the raw 4-byte or 16-byte IP address Lua string and a `name` set to the resolved name.
- </para><para>
- For example, if the capture file identifies one resolved IPv4 address of 1.2.3.4 to 'foo.com', then you must set
- CaptureInfo.hosts to a table of { ipv4_addresses = { { addr = '\01\02\03\04', name = 'foo.com' } } }.
+ For example, if the capture file identifies one resolved IPv4 address of 1.2.3.4 to `foo.com`, then you must set
+ `CaptureInfo.hosts` to a table of:
+ @code { ipv4_addresses = { { addr = "\01\02\03\04", name = "foo.com" } } } @endcode
- </para><para>
- Note that either the 'ipv4_addresses' or the 'ipv6_addresses' table, or both, may be empty or nil.
+ Note that either the `ipv4_addresses` or the `ipv6_addresses` table, or both, may be empty or nil.
*/
static int CaptureInfo_set_hosts(lua_State* L) {
CaptureInfo fi = checkCaptureInfo(L,1);
@@ -870,21 +900,19 @@ static int CaptureInfo_set_hosts(lua_State* L) {
/* WSLUA_ATTRIBUTE CaptureInfo_private_table RW A private Lua value unique to this file.
- </para><para>
- The private_table is a field you set/get with your own Lua table.
+ The `private_table` is a field you set/get with your own Lua table.
This is provided so that a Lua script can save per-file reading/writing
state, because multiple files can be opened and read at the same time.
- </para><para>
For example, if the user issued a reload-file command, or Lua called the
- reload() function, then the current capture file is still open while a new one
- is being opened, and thus Wireshark will invoke read_open() while the previous
- capture file has not caused read_close() to be called; and if the read_open()
- succeeds then read_close() will be called right after that for the previous
+ `reload()` function, then the current capture file is still open while a new one
+ is being opened, and thus Wireshark will invoke `read_open()` while the previous
+ capture file has not caused `read_close()` to be called; and if the `read_open()`
+ succeeds then `read_close()` will be called right after that for the previous
file, rather than the one just opened. Thus the Lua script can use this
- private_table to store a table of values specific to each file, by setting
- this private_table in the read_open() function, which it can then later get back
- inside its read(), seek_read(), and read_close() functions.
+ `private_table` to store a table of values specific to each file, by setting
+ this `private_table` in the `read_open()` function, which it can then later get back
+ inside its `read()`, `seek_read()`, and `read_close()` functions.
*/
static int CaptureInfo_get_private_table(lua_State* L) {
CaptureInfo fi = checkCaptureInfo(L,1);
@@ -923,16 +951,18 @@ int CaptureInfo_register(lua_State* L) {
WSLUA_CLASS_DEFINE(CaptureInfoConst,FAIL_ON_NULL_MEMBER_OR_EXPIRED("CaptureInfoConst",wdh),NOP);
/*
- A CaptureInfoConst object, passed into Lua as an argument to the FileHandler callback
- function write_open().
+ A `CaptureInfoConst` object, passed into Lua as an argument to the `FileHandler` callback
+ function `write_open()`.
+
This object represents capture file data and meta-data (data about the
capture file) for the current capture in Wireshark/Tshark.
- </para><para>
- This object's fields are read-from when used by write_open function callback.
- In other words, when the Lua plugin's FileHandler write_open function is invoked, a
- CaptureInfoConst object will be passed in as one of the arguments, and its fields
+ This object's fields are read-from when used by `write_open` function callback.
+ In other words, when the Lua plugin's FileHandler `write_open` function is invoked, a
+ `CaptureInfoConst` object will be passed in as one of the arguments, and its fields
should be read from by your Lua code to get data about the capture that needs to be written.
+
+ @since 1.11.3
*/
static CaptureInfoConst* push_CaptureInfoConst(lua_State* L, wtap_dumper *wdh) {
@@ -962,17 +992,18 @@ WSLUA_METAMETHOD CaptureInfoConst__tostring(lua_State* L) {
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfoConst,type,wdh->file_type_subtype);
/* WSLUA_ATTRIBUTE CaptureInfoConst_snapshot_length RO The maximum packet length that is actually recorded (vs. the original
- length of any given packet on-the-wire). A value of 0 means the snapshot length is unknown or there is no one
+ length of any given packet on-the-wire). A value of `0` means the snapshot length is unknown or there is no one
such length for the whole file. */
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfoConst,snapshot_length,wdh->snaplen);
/* WSLUA_ATTRIBUTE CaptureInfoConst_encap RO The packet encapsulation type for the whole file.
- See 'wtap_encaps' in init.lua for available types. It is set to 'wtap_encaps.PER_PACKET' if packets can
- have different types, in which case each Frame identifies its type, in 'FrameInfo.packet_encap'. */
+
+ See `wtap_encaps` in init.lua for available types. It is set to `wtap_encaps.PER_PACKET` if packets can
+ have different types, in which case each Frame identifies its type, in `FrameInfo.packet_encap`. */
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfoConst,encap,wdh->encap);
/* WSLUA_ATTRIBUTE CaptureInfoConst_comment RW A comment for the whole capture file, if the
- 'wtap_presence_flags.COMMENTS' was set in the presence flags; nil if there is no comment. */
+ `wtap_presence_flags.COMMENTS` was set in the presence flags; nil if there is no comment. */
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfoConst,comment,wth->shb_hdr.opt_comment);
/* WSLUA_ATTRIBUTE CaptureInfoConst_hardware RO A string containing the description of
@@ -987,17 +1018,15 @@ WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfoConst,os,wth->shb_hdr.shb_os);
the application used to create the capture, or nil if there is no user_app string. */
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfoConst,user_app,wth->shb_hdr.shb_user_appl);
-/* WSLUA_ATTRIBUTE CaptureInfoConst_hosts RO A ip-to-hostname Lua table of two key-ed names: 'ipv4_addresses' and 'ipv6_addresses'.
+/* WSLUA_ATTRIBUTE CaptureInfoConst_hosts RO A ip-to-hostname Lua table of two key-ed names: `ipv4_addresses` and `ipv6_addresses`.
The value of each of these names are themselves array tables, of key-ed tables, such that the inner table has a key
- 'addr' set to the raw 4-byte or 16-byte IP address Lua string and a 'name' set to the resolved name.
+ `addr` set to the raw 4-byte or 16-byte IP address Lua string and a `name` set to the resolved name.
- </para><para>
- For example, if the current capture has one resolved IPv4 address of 1.2.3.4 to 'foo.com', then getting
- CaptureInfoConst.hosts will get a table of:
- { ipv4_addresses = { { addr = '\01\02\03\04', name = 'foo.com' } }, ipv6_addresses = { } }.
+ For example, if the current capture has one resolved IPv4 address of 1.2.3.4 to `foo.com`, then getting
+ `CaptureInfoConst.hosts` will get a table of:
+ @code { ipv4_addresses = { { addr = "\01\02\03\04", name = "foo.com" } }, ipv6_addresses = { } } @endcode
- </para><para>
- Note that either the 'ipv4_addresses' or the 'ipv6_addresses' table, or both, may be empty, however they will not
+ Note that either the `ipv4_addresses` or the `ipv6_addresses` table, or both, may be empty, however they will not
be nil. */
static int CaptureInfoConst_get_hosts(lua_State* L) {
CaptureInfoConst fi = checkCaptureInfoConst(L,1);
@@ -1066,18 +1095,16 @@ static int CaptureInfoConst_get_hosts(lua_State* L) {
/* WSLUA_ATTRIBUTE CaptureInfoConst_private_table RW A private Lua value unique to this file.
- </para><para>
- The private_table is a field you set/get with your own Lua table.
+ The `private_table` is a field you set/get with your own Lua table.
This is provided so that a Lua script can save per-file reading/writing
state, because multiple files can be opened and read at the same time.
- </para><para>
- For example, if two Lua scripts issue a Dumper:new_for_current() call and the
+ For example, if two Lua scripts issue a `Dumper:new_for_current()` call and the
current file happens to use your script's writer, then the Wireshark will invoke
- write_open() while the previous capture file has not had write_close() called.
- Thus the Lua script can use this private_table to store a table of values
- specific to each file, by setting this private_table in the write_open()
- function, which it can then later get back inside its write(), and write_close()
+ `write_open()` while the previous capture file has not had `write_close()` called.
+ Thus the Lua script can use this `private_table` to store a table of values
+ specific to each file, by setting this `private_table` in the write_open()
+ function, which it can then later get back inside its `write()`, and `write_close()`
functions.
*/
static int CaptureInfoConst_get_private_table(lua_State* L) {
@@ -1125,21 +1152,21 @@ int CaptureInfoConst_register(lua_State* L) {
WSLUA_CLASS_DEFINE(FrameInfo,FAIL_ON_NULL_OR_EXPIRED("FrameInfo"),NOP);
/*
A FrameInfo object, passed into Lua as an argument by FileHandler callback
- functions (e.g., read, seek_read, etc.).
+ functions (e.g., `read`, `seek_read`, etc.).
- </para><para>
- This object represents frame data and
- meta-data (data about the frame/packet) for a given read/seek_read/write's frame.
+ This object represents frame data and meta-data (data about the frame/packet)
+ for a given `read`/`seek_read`/`write`'s frame.
- </para><para>
This object's fields are written-to/set when used by read function callbacks, and
read-from/get when used by file write function callbacks. In other words, when
- the Lua plugin's FileHandler read/seek_read/etc. functions are invoked, a
+ the Lua plugin's FileHandler `read`/`seek_read`/etc. functions are invoked, a
FrameInfo object will be passed in as one of the arguments, and its fields
should be written-to/set based on the frame information read from the file;
- whereas when the Lua plugin's FileHandler write function is invoked, the
- FrameInfo object passed in should have its fields read-from/get, to write that
+ whereas when the Lua plugin's `FileHandler.write()` function is invoked, the
+ `FrameInfo` object passed in should have its fields read-from/get, to write that
frame information to the file.
+
+ @since 1.11.3
*/
static FrameInfo* push_FrameInfo(lua_State* L, struct wtap_pkthdr *phdr, Buffer* buf) {
@@ -1170,8 +1197,8 @@ WSLUA_METAMETHOD FrameInfo__tostring(lua_State* L) {
/* XXX: should this function be a method of File instead? */
WSLUA_METHOD FrameInfo_read_data(lua_State* L) {
/* Tells Wireshark to read directly from given file into frame data buffer, for length bytes. Returns true if succeeded, else false. */
-#define WSLUA_ARG_FrameInfo_read_data_FILE 2 /* The File object userdata, provided by Wireshark previously in a reading-based callback */
-#define WSLUA_ARG_FrameInfo_read_data_LENGTH 3 /* The number of bytes to read from the file at the current cursor position */
+#define WSLUA_ARG_FrameInfo_read_data_FILE 2 /* The File object userdata, provided by Wireshark previously in a reading-based callback. */
+#define WSLUA_ARG_FrameInfo_read_data_LENGTH 3 /* The number of bytes to read from the file at the current cursor position. */
FrameInfo fi = checkFrameInfo(L,1);
File fh = checkFile(L,WSLUA_ARG_FrameInfo_read_data_FILE);
guint32 len = wslua_checkguint32(L, WSLUA_ARG_FrameInfo_read_data_LENGTH);
@@ -1208,7 +1235,9 @@ static int FrameInfo__gc(lua_State* L _U_) {
}
/* WSLUA_ATTRIBUTE FrameInfo_time RW The packet timestamp as an NSTime object.
- Note: Set the 'FileHandler.time_precision' to the appropriate 'wtap_file_tsprec' value as well. */
+
+ Note: Set the `FileHandler.time_precision` to the appropriate `wtap_file_tsprec` value as well.
+ */
static int FrameInfo_set_time (lua_State* L) {
FrameInfo fi = checkFrameInfo(L,1);
NSTime nstime = checkNSTime(L,2);
@@ -1235,7 +1264,10 @@ static int FrameInfo_get_time (lua_State* L) {
return 1; /* An NSTime object of the frame's timestamp. */
}
-/* WSLUA_ATTRIBUTE FrameInfo_data RW The data buffer containing the packet. This cannot be cleared once set. */
+/* WSLUA_ATTRIBUTE FrameInfo_data RW The data buffer containing the packet.
+
+ @note This cannot be cleared once set.
+ */
static int FrameInfo_set_data (lua_State* L) {
FrameInfo fi = checkFrameInfo(L,1);
@@ -1279,28 +1311,29 @@ static int FrameInfo_get_data (lua_State* L) {
}
/* WSLUA_ATTRIBUTE FrameInfo_flags RW The presence flags of the packet frame.
- See 'wtap_presence_flags' in init.lua for bit values. */
+
+ See `wtap_presence_flags` in `init.lua` for bit values. */
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfo,flags,phdr->presence_flags);
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FrameInfo,flags,phdr->presence_flags,guint32);
/* WSLUA_ATTRIBUTE FrameInfo_captured_length RW The captured packet length,
- and thus the length of the buffer passed to the FrameInfo.data field. */
+ and thus the length of the buffer passed to the `FrameInfo.data` field. */
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfo,captured_length,phdr->caplen);
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FrameInfo,captured_length,phdr->caplen,guint32);
/* WSLUA_ATTRIBUTE FrameInfo_original_length RW The on-the-wire packet length,
- which may be longer than the captured_length. */
+ which may be longer than the `captured_length`. */
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfo,original_length,phdr->len);
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FrameInfo,original_length,phdr->len,guint32);
/* WSLUA_ATTRIBUTE FrameInfo_encap RW The packet encapsulation type for the frame/packet,
- if the file supports per-packet types. See 'wtap_encaps' in init.lua for possible
+ if the file supports per-packet types. See `wtap_encaps` in `init.lua` for possible
packet encapsulation types to use as the value for this field. */
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfo,encap,phdr->pkt_encap);
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FrameInfo,encap,phdr->pkt_encap,int);
/* WSLUA_ATTRIBUTE FrameInfo_comment RW A string comment for the packet, if the
- 'wtap_presence_flags.COMMENTS' was set in the presence flags; nil if there is no comment. */
+ `wtap_presence_flags.COMMENTS` was set in the presence flags; nil if there is no comment. */
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(FrameInfo,comment,phdr->opt_comment);
WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(FrameInfo,comment,phdr->opt_comment,TRUE);
@@ -1340,6 +1373,8 @@ WSLUA_CLASS_DEFINE(FrameInfoConst,FAIL_ON_NULL_OR_EXPIRED("FrameInfo"),NOP);
A constant FrameInfo object, passed into Lua as an argument by the FileHandler write
callback function. This has similar attributes/properties as FrameInfo, but the fields can
only be read from, not written to.
+
+ @since 1.11.3
*/
static FrameInfoConst* push_FrameInfoConst(lua_State* L, const struct wtap_pkthdr *phdr, const guint8 *pd) {
@@ -1370,7 +1405,7 @@ WSLUA_METAMETHOD FrameInfoConst__tostring(lua_State* L) {
/* XXX: should this function be a method of File instead? */
WSLUA_METHOD FrameInfoConst_write_data(lua_State* L) {
/* Tells Wireshark to write directly to given file from the frame data buffer, for length bytes. Returns true if succeeded, else false. */
-#define WSLUA_ARG_FrameInfoConst_write_data_FILE 2 /* The File object userdata, provided by Wireshark previously in a writing-based callback */
+#define WSLUA_ARG_FrameInfoConst_write_data_FILE 2 /* The File object userdata, provided by Wireshark previously in a writing-based callback. */
#define WSLUA_OPTARG_FrameInfoConst_write_data_LENGTH 3 /* The number of bytes to write to the file at the current cursor position, or all if not supplied. */
FrameInfoConst fi = checkFrameInfoConst(L,1);
File fh = checkFile(L,WSLUA_ARG_FrameInfoConst_write_data_FILE);
@@ -1431,17 +1466,18 @@ static int FrameInfoConst_get_data (lua_State* L) {
return 1;
}
-/* WSLUA_ATTRIBUTE FrameInfoConst_flags RO The presence flags of the packet frame - see 'wtap_presence_flags' in init.lua for bits. */
+/* WSLUA_ATTRIBUTE FrameInfoConst_flags RO The presence flags of the packet frame - see `wtap_presence_flags` in `init.lua` for bits. */
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,flags,phdr->presence_flags);
/* WSLUA_ATTRIBUTE FrameInfoConst_captured_length RO The captured packet length, and thus the length of the buffer in the FrameInfoConst.data field. */
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,captured_length,phdr->caplen);
-/* WSLUA_ATTRIBUTE FrameInfoConst_original_length RO The on-the-wire packet length, which may be longer than the captured_length. */
+/* WSLUA_ATTRIBUTE FrameInfoConst_original_length RO The on-the-wire packet length, which may be longer than the `captured_length`. */
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,original_length,phdr->len);
/* WSLUA_ATTRIBUTE FrameInfoConst_encap RO The packet encapsulation type, if the file supports per-packet types.
- See 'wtap_encaps' in init.lua for possible packet encapsulation types to use as the value for this field. */
+
+ See `wtap_encaps` in `init.lua` for possible packet encapsulation types to use as the value for this field. */
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,encap,phdr->pkt_encap);
/* WSLUA_ATTRIBUTE FrameInfoConst_comment RO A comment for the packet; nil if there is none. */
@@ -1480,6 +1516,8 @@ WSLUA_CLASS_DEFINE(FileHandler,NOP,NOP);
A FileHandler object, created by a call to FileHandler.new(arg1, arg2, ...).
The FileHandler object lets you create a file-format reader, or writer, or
both, by setting your own read_open/read or write_open/write functions.
+
+ @since 1.11.3
*/
static int filehandler_cb_error_handler(lua_State* L) {
@@ -2215,114 +2253,113 @@ WSLUA_FUNCTION wslua_deregister_filehandler(lua_State* L) {
/* WSLUA_ATTRIBUTE FileHandler_read_open WO The Lua function to be called when Wireshark opens a file for reading.
- </para><para>
- When later called by Wireshark, the Lua function will be given (1) a File object, and (2) a CaptureInfo object.
+ When later called by Wireshark, the Lua function will be given:
+ 1. A `File` object
+ 2. A `CaptureInfo` object
- </para><para>
- The purpose of the Lua function set to this 'read_open' field is to check if the file Wireshark is opening is of its type,
+ The purpose of the Lua function set to this `read_open` field is to check if the file Wireshark is opening is of its type,
for example by checking for magic numbers or trying to parse records in the file, etc. The more can be verified
the better, because Wireshark tries all file readers until it finds one that accepts the file, so accepting an
incorrect file prevents other file readers from reading their files.
- </para><para>
The called Lua function should return true if the file is its type (it accepts it), false if not. The Lua
- function must also set the File offset position (using file:seek()) to where it wants it to be for its first
- read() call, or back to beginning if it returns false.
+ function must also set the File offset position (using `file:seek()`) to where it wants it to be for its first
+ `read()` call.
*/
WSLUA_ATTRIBUTE_FUNC_SETTER(FileHandler,read_open);
/* WSLUA_ATTRIBUTE FileHandler_read WO The Lua function to be called when Wireshark wants to read a packet from the file.
- </para><para>
- When later called by Wireshark, the Lua function will be given (1) a File object, and (2) a FrameInfo object.
+ When later called by Wireshark, the Lua function will be given:
+ 1. A `File` object
+ 2. A `CaptureInfo` object
+ 3. A `FrameInfo` object
- </para><para>
- The purpose of the Lua function set to this 'read' field is to read the next packet from the file, and setting the parsed/read
- packet into the frame buffer using 'FrameInfo.data = foo' or 'FrameInfo:read_data()'.
+ The purpose of the Lua function set to this `read` field is to read the next packet from the file, and setting the parsed/read
+ packet into the frame buffer using `FrameInfo.data = foo` or `FrameInfo:read_data()`.
- </para><para>
The called Lua function should return the file offset/position number where the packet begins, or false if it hit an
- error. The file offset will be saved by Wireshark and passed into the set seek_read() Lua function later. */
+ error. The file offset will be saved by Wireshark and passed into the set `seek_read()` Lua function later. */
WSLUA_ATTRIBUTE_FUNC_SETTER(FileHandler,read);
/* WSLUA_ATTRIBUTE FileHandler_seek_read WO The Lua function to be called when Wireshark wants to read a packet from the file at the given offset.
- </para><para>
- When later called by Wireshark, the Lua function will be given (1) a File object, and (2) a FrameInfo object,
- and (3) the file offset number previously set by the read function call. */
+ When later called by Wireshark, the Lua function will be given:
+ 1. A `File` object
+ 2. A `CaptureInfo` object
+ 3. A `FrameInfo` object
+ 4. The file offset number previously set by the `read()` function call
+ */
WSLUA_ATTRIBUTE_FUNC_SETTER(FileHandler,seek_read);
/* WSLUA_ATTRIBUTE FileHandler_read_close WO The Lua function to be called when Wireshark wants to close the read file completely.
- </para><para>
- When later called by Wireshark, the Lua function will be given (1) a File object.
+ When later called by Wireshark, the Lua function will be given:
+ 1. A `File` object
+ 2. A `CaptureInfo` object
- </para><para>
It is not necessary to set this field to a Lua function - FileHandler can be registered without doing so - it
is available in case there is memory/state to clear in your script when the file is closed. */
WSLUA_ATTRIBUTE_FUNC_SETTER(FileHandler,read_close);
/* WSLUA_ATTRIBUTE FileHandler_seq_read_close WO The Lua function to be called when Wireshark wants to close the sequentially-read file.
- </para><para>
- When later called by Wireshark, the Lua function will be given a File object.
+ When later called by Wireshark, the Lua function will be given:
+ 1. A `File` object
+ 2. A `CaptureInfo` object
- </para><para>
It is not necessary to set this field to a Lua
function - FileHandler can be registered without doing so - it is available in case there is memory/state to clear in your script
- when the file is closed for the sequential reading portion. After this point, there will be no more calls to read(), only seek_read(). */
+ when the file is closed for the sequential reading portion. After this point, there will be no more calls to `read()`, only `seek_read()`. */
WSLUA_ATTRIBUTE_FUNC_SETTER(FileHandler,seq_read_close);
/* WSLUA_ATTRIBUTE FileHandler_can_write_encap WO The Lua function to be called when Wireshark wants to write a file,
by checking if this file writer can handle the wtap packet encapsulation(s).
- </para><para>
When later called by Wireshark, the Lua function will be given a Lua number, which matches one of the encapsulations
- in the Lua 'wtap_encaps' table. This might be the 'wtap_encap.PER_PACKET' number, meaning the capture contains multiple
+ in the Lua `wtap_encaps` table. This might be the `wtap_encap.PER_PACKET` number, meaning the capture contains multiple
encapsulation types, and the file reader should only return true if it can handle multiple encap types in one file. The
function will then be called again, once for each encap type in the file, to make sure it can write each one.
- </para><para>
If the Lua file writer can write the given type of encapsulation into a file, then it returns the boolean true, else false. */
WSLUA_ATTRIBUTE_FUNC_SETTER(FileHandler,can_write_encap);
/* WSLUA_ATTRIBUTE FileHandler_write_open WO The Lua function to be called when Wireshark opens a file for writing.
- </para><para>
- When later called by Wireshark, the Lua function will be given (1) a File object, and (2) a CaptureInfoConst object.
+ When later called by Wireshark, the Lua function will be given:
+ 1. A `File` object
+ 2. A `CaptureInfoConst` object
- </para><para>
- The purpose of the Lua function set to this 'write_open' field is similar to the read_open callback function:
+ The purpose of the Lua function set to this `write_open` field is similar to the read_open callback function:
to initialize things necessary for writing the capture to a file. For example, if the output file format has a
file header, then the file header should be written within this write_open function.
- </para><para>
The called Lua function should return true on success, or false if it hit an error.
- Also make sure to set the FileHandler.write (and potentially FileHandler.write_close) functions before
+
+ Also make sure to set the `FileHandler.write` (and potentially `FileHandler.write_close`) functions before
returning true from this function. */
WSLUA_ATTRIBUTE_FUNC_SETTER(FileHandler,write_open);
/* WSLUA_ATTRIBUTE FileHandler_write WO The Lua function to be called when Wireshark wants to write a packet to the file.
- </para><para>
- When later called by Wireshark, the Lua function will be given (1) a File object, and (2) a FrameInfoConst object
- of the current frame/packet to be written.
+ When later called by Wireshark, the Lua function will be given:
+ 1. A `File` object
+ 2. A `CaptureInfoConst` object
+ 3. A `FrameInfoConst` object of the current frame/packet to be written
- </para><para>
- The purpose of the Lua function set to this 'write' field is to write the next packet to the file.
+ The purpose of the Lua function set to this `write` field is to write the next packet to the file.
- </para><para>
- The called Lua function should return true on succcess, or false if it hit an error. */
+ The called Lua function should return true on success, or false if it hit an error. */
WSLUA_ATTRIBUTE_FUNC_SETTER(FileHandler,write);
/* WSLUA_ATTRIBUTE FileHandler_write_close WO The Lua function to be called when Wireshark wants to close the written file.
- </para><para>
- When later called by Wireshark, the Lua function will be given a File object.
+ When later called by Wireshark, the Lua function will be given:
+ 1. A `File` object
+ 2. A `CaptureInfoConst` object
- </para><para>
- It is not necessary to set this field to a Lua function - FileHandler can be registered without doing so - it is available
+ It is not necessary to set this field to a Lua function - `FileHandler` can be registered without doing so - it is available
in case there is memory/state to clear in your script when the file is closed. */
WSLUA_ATTRIBUTE_FUNC_SETTER(FileHandler,write_close);
@@ -2334,7 +2371,6 @@ WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FileHandler,type,file_type);
/* WSLUA_ATTRIBUTE FileHandler_extensions RW One or more file extensions that this file type usually uses.
- </para><para>
For readers using heuristics to determine file type, Wireshark will try the readers of the file's
extension first, before trying other readers. But ultimately Wireshark tries all file readers
for any file extension, until it finds one that accepts the file. */
@@ -2342,7 +2378,9 @@ WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(FileHandler,extensions,finfo.additional_file
WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(FileHandler,extensions,finfo.additional_file_extensions,TRUE);
/* WSLUA_ATTRIBUTE FileHandler_writing_must_seek RW true if the ability to seek is required when writing
- this file format, else false. This will be checked by Wireshark when writing out to compressed
+ this file format, else false.
+
+ This will be checked by Wireshark when writing out to compressed
file formats, because seeking is not possible with compressed files. Usually a file writer only
needs to be able to seek if it needs to go back in the file to change something, such as a block or
file length value earlier in the file. */
@@ -2355,7 +2393,7 @@ WSLUA_ATTRIBUTE_NAMED_BOOLEAN_GETTER(FileHandler,writes_name_resolution,finfo.ha
WSLUA_ATTRIBUTE_NAMED_BOOLEAN_SETTER(FileHandler,writes_name_resolution,finfo.has_name_resolution);
/* WSLUA_ATTRIBUTE FileHandler_supported_comment_types RW set to the bit-wise OR'ed number representing
- the type of comments the file writer supports writing, based on the numbers in the 'wtap_comments' table. */
+ the type of comments the file writer supports writing, based on the numbers in the `wtap_comments` table. */
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FileHandler,supported_comment_types,finfo.supported_comment_types);
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FileHandler,supported_comment_types,finfo.supported_comment_types,guint32);
diff --git a/epan/wslua/wslua_gui.c b/epan/wslua/wslua_gui.c
index 5f25afae76..b10e1e1312 100644
--- a/epan/wslua/wslua_gui.c
+++ b/epan/wslua/wslua_gui.c
@@ -74,21 +74,21 @@ static void lua_menu_callback(gpointer data) {
}
WSLUA_FUNCTION wslua_register_menu(lua_State* L) { /* Register a menu item in one of the main menus. */
-#define WSLUA_ARG_register_menu_NAME 1 /* The name of the menu item. The submenus are to be separated by '/'s. (string) */
+#define WSLUA_ARG_register_menu_NAME 1 /* The name of the menu item. The submenus are to be separated by '`/`'s. (string) */
#define WSLUA_ARG_register_menu_ACTION 2 /* The function to be called when the menu item is invoked. (function taking no arguments and returning nothing) */
#define WSLUA_OPTARG_register_menu_GROUP 3 /* The menu group into which the menu item is to be inserted. If omitted, defaults to MENU_STAT_GENERIC. One of:
- MENU_STAT_UNSORTED (Statistics),
- MENU_STAT_GENERIC (Statistics, first section),
- MENU_STAT_CONVERSATION (Statistics/Conversation List),
- MENU_STAT_ENDPOINT (Statistics/Endpoint List),
- MENU_STAT_RESPONSE (Statistics/Service Response Time),
- MENU_STAT_TELEPHONY (Telephony),
- MENU_STAT_TELEPHONY_GSM (Telephony/GSM),
- MENU_STAT_TELEPHONY_LTE (Telephony/LTE),
- MENU_STAT_TELEPHONY_SCTP (Telephony/SCTP),
- MENU_ANALYZE (Analyze),
- MENU_ANALYZE_CONVERSATION (Analyze/Conversation Filter),
- MENU_TOOLS_UNSORTED (Tools). (number) */
+ * MENU_STAT_UNSORTED (Statistics),
+ * MENU_STAT_GENERIC (Statistics, first section),
+ * MENU_STAT_CONVERSATION (Statistics/Conversation List),
+ * MENU_STAT_ENDPOINT (Statistics/Endpoint List),
+ * MENU_STAT_RESPONSE (Statistics/Service Response Time),
+ * MENU_STAT_TELEPHONY (Telephony),
+ * MENU_STAT_TELEPHONY_GSM (Telephony/GSM),
+ * MENU_STAT_TELEPHONY_LTE (Telephony/LTE),
+ * MENU_STAT_TELEPHONY_SCTP (Telephony/SCTP),
+ * MENU_ANALYZE (Analyze),
+ * MENU_ANALYZE_CONVERSATION (Analyze/Conversation Filter),
+ * MENU_TOOLS_UNSORTED (Tools). (number) */
const gchar* name = luaL_checkstring(L,WSLUA_ARG_register_menu_NAME);
struct _lua_menu_data* md;
@@ -220,8 +220,8 @@ static void text_win_close_cb(void* data) {
WSLUA_FUNCTION wslua_new_dialog(lua_State* L) { /* Pops up a new dialog */
#define WSLUA_ARG_new_dialog_TITLE 1 /* Title of the dialog's window. */
-#define WSLUA_ARG_new_dialog_ACTION 2 /* Action to be performed when OKd. */
-/* WSLUA_MOREARGS new_dialog A series of strings to be used as labels of the dialog's fields */
+#define WSLUA_ARG_new_dialog_ACTION 2 /* Action to be performed when OK'd. */
+/* WSLUA_MOREARGS new_dialog A series of strings to be used as labels of the dialog's fields. */
const gchar* title;
int top = lua_gettop(L);
@@ -293,7 +293,7 @@ WSLUA_FUNCTION wslua_new_dialog(lua_State* L) { /* Pops up a new dialog */
WSLUA_CLASS_DEFINE(ProgDlg,FAIL_ON_NULL("ProgDlg"),NOP); /* Manages a progress bar dialog. */
-WSLUA_CONSTRUCTOR ProgDlg_new(lua_State* L) { /* Creates a new TextWindow. */
+WSLUA_CONSTRUCTOR ProgDlg_new(lua_State* L) { /* Creates a new `ProgDlg` progress dialog. */
#define WSLUA_OPTARG_ProgDlg_new_TITLE 2 /* Title of the new window, defaults to "Progress". */
#define WSLUA_OPTARG_ProgDlg_new_TASK 3 /* Current task, defaults to "". */
ProgDlg pd = (ProgDlg)g_malloc(sizeof(struct _wslua_progdlg));
@@ -310,10 +310,10 @@ WSLUA_CONSTRUCTOR ProgDlg_new(lua_State* L) { /* Creates a new TextWindow. */
pushProgDlg(L,pd);
- WSLUA_RETURN(1); /* The newly created TextWindow object. */
+ WSLUA_RETURN(1); /* The newly created `ProgDlg` object. */
}
-WSLUA_METHOD ProgDlg_update(lua_State* L) { /* Appends text */
+WSLUA_METHOD ProgDlg_update(lua_State* L) { /* Appends text. */
#define WSLUA_ARG_ProgDlg_update_PROGRESS 2 /* Part done ( e.g. 0.75 ). */
#define WSLUA_OPTARG_ProgDlg_update_TASK 3 /* Current task, defaults to "". */
ProgDlg pd = checkProgDlg(L,1);
@@ -343,7 +343,7 @@ WSLUA_METHOD ProgDlg_update(lua_State* L) { /* Appends text */
return 0;
}
-WSLUA_METHOD ProgDlg_stopped(lua_State* L) { /* Checks wheher the user has pressed the stop button. */
+WSLUA_METHOD ProgDlg_stopped(lua_State* L) { /* Checks whether the user has pressed the stop button. */
ProgDlg pd = checkProgDlg(L,1);
lua_pushboolean(L,pd->stopped);
@@ -353,7 +353,7 @@ WSLUA_METHOD ProgDlg_stopped(lua_State* L) { /* Checks wheher the user has press
-WSLUA_METHOD ProgDlg_close(lua_State* L) { /* Appends text */
+WSLUA_METHOD ProgDlg_close(lua_State* L) { /* Closes the progress dialog. */
ProgDlg pd = checkProgDlg(L,1);
if (!ops->destroy_progress_window) {
@@ -425,7 +425,7 @@ WSLUA_CLASS_DEFINE(TextWindow,FAIL_ON_NULL_OR_EXPIRED("TextWindow"),NOP); /* Man
/* XXX: lua callback function and TextWindow are not garbage collected because
they stay in LUA_REGISTRYINDEX forever */
-WSLUA_CONSTRUCTOR TextWindow_new(lua_State* L) { /* Creates a new TextWindow. */
+WSLUA_CONSTRUCTOR TextWindow_new(lua_State* L) { /* Creates a new `TextWindow` text window. */
#define WSLUA_OPTARG_TextWindow_new_TITLE 1 /* Title of the new window. */
const gchar* title;
@@ -452,11 +452,11 @@ WSLUA_CONSTRUCTOR TextWindow_new(lua_State* L) { /* Creates a new TextWindow. */
pushTextWindow(L,tw);
- WSLUA_RETURN(1); /* The newly created TextWindow object. */
+ WSLUA_RETURN(1); /* The newly created `TextWindow` object. */
}
-WSLUA_METHOD TextWindow_set_atclose(lua_State* L) { /* Set the function that will be called when the window closes */
-#define WSLUA_ARG_TextWindow_at_close_ACTION 2 /* A function to be executed when the user closes the window */
+WSLUA_METHOD TextWindow_set_atclose(lua_State* L) { /* Set the function that will be called when the text window closes. */
+#define WSLUA_ARG_TextWindow_at_close_ACTION 2 /* A Lua function to be executed when the user closes the text window. */
TextWindow tw = checkTextWindow(L,1);
struct _close_cb_data* cbd;
@@ -481,7 +481,8 @@ WSLUA_METHOD TextWindow_set_atclose(lua_State* L) { /* Set the function that wil
ops->set_close_cb(tw->ws_tw,text_win_close_cb,cbd);
- WSLUA_RETURN(1); /* The TextWindow object. */
+ /* XXX: this is a bad way to do this - should copy the object on to the stack first */
+ WSLUA_RETURN(1); /* The `TextWindow` object. */
}
WSLUA_METHOD TextWindow_set(lua_State* L) { /* Sets the text. */
@@ -502,7 +503,8 @@ WSLUA_METHOD TextWindow_set(lua_State* L) { /* Sets the text. */
ops->set_text(tw->ws_tw,text);
- WSLUA_RETURN(1); /* The TextWindow object. */
+ /* XXX: this is a bad way to do this - should copy the object on to the stack first */
+ WSLUA_RETURN(1); /* The `TextWindow` object. */
}
WSLUA_METHOD TextWindow_append(lua_State* L) { /* Appends text */
@@ -522,7 +524,8 @@ WSLUA_METHOD TextWindow_append(lua_State* L) { /* Appends text */
ops->append_text(tw->ws_tw,text);
- WSLUA_RETURN(1); /* The TextWindow object. */
+ /* XXX: this is a bad way to do this - should copy the object on to the stack first */
+ WSLUA_RETURN(1); /* The `TextWindow` object. */
}
WSLUA_METHOD TextWindow_prepend(lua_State* L) { /* Prepends text */
@@ -542,7 +545,8 @@ WSLUA_METHOD TextWindow_prepend(lua_State* L) { /* Prepends text */
ops->prepend_text(tw->ws_tw,text);
- WSLUA_RETURN(1); /* The TextWindow object. */
+ /* XXX: this is a bad way to do this - should copy the object on to the stack first */
+ WSLUA_RETURN(1); /* The `TextWindow` object. */
}
WSLUA_METHOD TextWindow_clear(lua_State* L) { /* Erases all text in the window. */
@@ -555,6 +559,7 @@ WSLUA_METHOD TextWindow_clear(lua_State* L) { /* Erases all text in the window.
ops->clear_text(tw->ws_tw);
+ /* XXX: this is a bad way to do this - should copy the object on to the stack first */
WSLUA_RETURN(1); /* The TextWindow object. */
}
@@ -570,7 +575,7 @@ WSLUA_METHOD TextWindow_get_text(lua_State* L) { /* Get the text of the window *
text = ops->get_text(tw->ws_tw);
lua_pushstring(L,text);
- WSLUA_RETURN(1); /* The TextWindow's text. */
+ WSLUA_RETURN(1); /* The `TextWindow`'s text. */
}
/* Gets registered as metamethod automatically by WSLUA_REGISTER_CLASS/META */
@@ -592,8 +597,8 @@ static int TextWindow__gc(lua_State* L) {
return 0;
}
-WSLUA_METHOD TextWindow_set_editable(lua_State* L) { /* Make this window editable */
-#define WSLUA_OPTARG_TextWindow_set_editable_EDITABLE 2 /* A boolean flag, defaults to true */
+WSLUA_METHOD TextWindow_set_editable(lua_State* L) { /* Make this text window editable. */
+#define WSLUA_OPTARG_TextWindow_set_editable_EDITABLE 2 /* A boolean flag, defaults to true. */
TextWindow tw = checkTextWindow(L,1);
gboolean editable = wslua_optbool(L,WSLUA_OPTARG_TextWindow_set_editable_EDITABLE,TRUE);
@@ -605,7 +610,7 @@ WSLUA_METHOD TextWindow_set_editable(lua_State* L) { /* Make this window editabl
ops->set_editable(tw->ws_tw,editable);
- WSLUA_RETURN(1); /* The TextWindow object. */
+ WSLUA_RETURN(1); /* The `TextWindow` object. */
}
typedef struct _wslua_bt_cb_t {
@@ -642,8 +647,9 @@ static gboolean wslua_button_callback(funnel_text_window_t* ws_tw, void* data) {
}
WSLUA_METHOD TextWindow_add_button(lua_State* L) {
+ /* Adds a button to the text window. */
#define WSLUA_ARG_TextWindow_add_button_LABEL 2 /* The label of the button */
-#define WSLUA_ARG_TextWindow_add_button_FUNCTION 3 /* The function to be called when clicked */
+#define WSLUA_ARG_TextWindow_add_button_FUNCTION 3 /* The Lua function to be called when clicked */
TextWindow tw = checkTextWindow(L,1);
const gchar* label = luaL_checkstring(L,WSLUA_ARG_TextWindow_add_button_LABEL);
@@ -679,7 +685,7 @@ WSLUA_METHOD TextWindow_add_button(lua_State* L) {
ops->add_button(tw->ws_tw,fbt,label);
}
- WSLUA_RETURN(1); /* The TextWindow object. */
+ WSLUA_RETURN(1); /* The `TextWindow` object. */
}
WSLUA_METHODS TextWindow_methods[] = {
@@ -725,7 +731,7 @@ WSLUA_FUNCTION wslua_retap_packets(lua_State* L) {
}
-WSLUA_FUNCTION wslua_copy_to_clipboard(lua_State* L) { /* Copy a string into the clipboard */
+WSLUA_FUNCTION wslua_copy_to_clipboard(lua_State* L) { /* Copy a string into the clipboard. */
#define WSLUA_ARG_copy_to_clipboard_TEXT 1 /* The string to be copied into the clipboard. */
const char* copied_str = luaL_checkstring(L,WSLUA_ARG_copy_to_clipboard_TEXT);
GString* gstr;
@@ -748,7 +754,7 @@ WSLUA_FUNCTION wslua_copy_to_clipboard(lua_State* L) { /* Copy a string into the
return 0;
}
-WSLUA_FUNCTION wslua_open_capture_file(lua_State* L) { /* Open and display a capture file */
+WSLUA_FUNCTION wslua_open_capture_file(lua_State* L) { /* Open and display a capture file. */
#define WSLUA_ARG_open_capture_file_FILENAME 1 /* The name of the file to be opened. */
#define WSLUA_ARG_open_capture_file_FILTER 2 /* A filter to be applied as the file gets opened. */
@@ -781,7 +787,7 @@ WSLUA_FUNCTION wslua_open_capture_file(lua_State* L) { /* Open and display a cap
}
}
-WSLUA_FUNCTION wslua_get_filter(lua_State* L) { /* Get the main filter text */
+WSLUA_FUNCTION wslua_get_filter(lua_State* L) { /* Get the main filter text. */
const char *filter_str = NULL;
if (!ops->get_filter) {
@@ -795,7 +801,7 @@ WSLUA_FUNCTION wslua_get_filter(lua_State* L) { /* Get the main filter text */
return 1;
}
-WSLUA_FUNCTION wslua_set_filter(lua_State* L) { /* Set the main filter text */
+WSLUA_FUNCTION wslua_set_filter(lua_State* L) { /* Set the main filter text. */
#define WSLUA_ARG_set_filter_TEXT 1 /* The filter's text. */
const char* filter_str = luaL_checkstring(L,WSLUA_ARG_set_filter_TEXT);
@@ -814,9 +820,9 @@ WSLUA_FUNCTION wslua_set_filter(lua_State* L) { /* Set the main filter text */
return 0;
}
-WSLUA_FUNCTION wslua_set_color_filter_slot(lua_State* L) { /* Set packet-coloring rule for the current session */
-#define WSLUA_ARG_set_color_filter_slot_ROW 1 /* The index of the desired color in the temporary coloring rules list */
-#define WSLUA_ARG_set_color_filter_slot_TEXT 2 /* Display filter for selecting packets to be colorized */
+WSLUA_FUNCTION wslua_set_color_filter_slot(lua_State* L) { /* Set packet-coloring rule for the current session. */
+#define WSLUA_ARG_set_color_filter_slot_ROW 1 /* The index of the desired color in the temporary coloring rules list. */
+#define WSLUA_ARG_set_color_filter_slot_TEXT 2 /* Display filter for selecting packets to be colorized. */
guint8 row = luaL_checkint(L,WSLUA_ARG_set_color_filter_slot_ROW);
const gchar* filter_str = luaL_checkstring(L,WSLUA_ARG_set_color_filter_slot_TEXT);
@@ -835,7 +841,7 @@ WSLUA_FUNCTION wslua_set_color_filter_slot(lua_State* L) { /* Set packet-colorin
return 0;
}
-WSLUA_FUNCTION wslua_apply_filter(lua_State* L) { /* Apply the filter in the main filter box */
+WSLUA_FUNCTION wslua_apply_filter(lua_State* L) { /* Apply the filter in the main filter box. */
if (!ops->apply_filter) {
WSLUA_ERROR(apply_filter, "GUI not available");
return 0;
@@ -847,7 +853,7 @@ WSLUA_FUNCTION wslua_apply_filter(lua_State* L) { /* Apply the filter in the mai
}
-WSLUA_FUNCTION wslua_reload(lua_State* L) { /* Reload the current capture file */
+WSLUA_FUNCTION wslua_reload(lua_State* L) { /* Reload the current capture file. */
if (!ops->reload) {
WSLUA_ERROR(reload, "GUI not available");
@@ -860,7 +866,7 @@ WSLUA_FUNCTION wslua_reload(lua_State* L) { /* Reload the current capture file *
}
-WSLUA_FUNCTION wslua_browser_open_url(lua_State* L) { /* Open an url in a browser */
+WSLUA_FUNCTION wslua_browser_open_url(lua_State* L) { /* Open an url in a browser. */
#define WSLUA_ARG_browser_open_url_URL 1 /* The url. */
const char* url = luaL_checkstring(L,WSLUA_ARG_browser_open_url_URL);
@@ -879,8 +885,8 @@ WSLUA_FUNCTION wslua_browser_open_url(lua_State* L) { /* Open an url in a browse
return 0;
}
-WSLUA_FUNCTION wslua_browser_open_data_file(lua_State* L) { /* Open an file in a browser */
-#define WSLUA_ARG_browser_open_data_file_FILENAME 1 /* The url. */
+WSLUA_FUNCTION wslua_browser_open_data_file(lua_State* L) { /* Open a file in a browser. */
+#define WSLUA_ARG_browser_open_data_file_FILENAME 1 /* The file name. */
const char* file = luaL_checkstring(L,WSLUA_ARG_browser_open_data_file_FILENAME);
if (!ops->browser_open_data_file) {
@@ -897,6 +903,3 @@ WSLUA_FUNCTION wslua_browser_open_data_file(lua_State* L) { /* Open an file in a
return 0;
}
-
-
-
diff --git a/epan/wslua/wslua_int64.c b/epan/wslua/wslua_int64.c
index d5d5281e7c..ace9280659 100644
--- a/epan/wslua/wslua_int64.c
+++ b/epan/wslua/wslua_int64.c
@@ -41,18 +41,23 @@ either expressed or implied, of the FreeBSD Project.
#include "wslua.h"
-/* WSLUA_MODULE Int64 Handling 64-bit Integers */
+/* WSLUA_MODULE Int64 Handling 64-bit Integers
+
+ Lua uses one single number representation which can be chosen at compile time and since
+ it is often set to IEEE 754 double precision floating point, one cannot store a 64 bit integer
+ with full precision.
+
+ For details, see [[http://wiki.wireshark.org/LuaAPI/Int64]].
+ */
#define LUATYPE64_STRING_SIZE 21 /* string to hold 18446744073709551615 */
WSLUA_CLASS_DEFINE_BASE(Int64,NOP,NOP,0);
/*
- Int64 represents a 64 bit signed integer.
- Lua uses one single number representation which can be chosen at compile time and since
- it is often set to IEEE 754 double precision floating point, we cannot store a 64 bit integer
- with full precision.
- For details, see: http://wiki.wireshark.org/LuaAPI/Int64
+ `Int64` represents a 64 bit signed integer.
+
+ For details, see [[http://wiki.wireshark.org/LuaAPI/Int64]].
*/
/* A checkInt64 but that also auto-converts numbers, strings, and UINT64 to a gint64 */
@@ -77,7 +82,7 @@ static gint64 getInt64(lua_State *L, int i)
}
-/* Encodes Int64 userdata into Lua string struct with given endianess */
+/* Encodes Int64 userdata into Lua string struct with given endianness */
void Int64_pack(lua_State* L, luaL_Buffer *b, gint idx, gboolean asLittleEndian) {
gint64 value = checkInt64(L,idx);
gint8 buff[sizeof(gint64)];
@@ -100,8 +105,12 @@ void Int64_pack(lua_State* L, luaL_Buffer *b, gint idx, gboolean asLittleEndian)
}
WSLUA_METHOD Int64_encode(lua_State* L) {
- /* Encodes the Int64 number into an 8-byte Lua string, using given endianess */
-#define WSLUA_OPTARG_Int64_encode_ENDIAN 2 /* If set to true then little-endian is used, if false then big-endian; if missing/nil, native host endian */
+ /* Encodes the `Int64` number into an 8-byte Lua string, using given endianness.
+ @since 1.11.3
+ */
+#define WSLUA_OPTARG_Int64_encode_ENDIAN 2 /* If set to true then little-endian is used,
+ if false then big-endian; if missing/nil,
+ native host endian. */
luaL_Buffer b;
gboolean asLittleEndian = (G_BYTE_ORDER == G_LITTLE_ENDIAN)? TRUE : FALSE;
@@ -115,10 +124,10 @@ WSLUA_METHOD Int64_encode(lua_State* L) {
Int64_pack(L, &b, 1, asLittleEndian);
luaL_pushresult(&b);
- WSLUA_RETURN(1); /* The Lua string */
+ WSLUA_RETURN(1); /* The Lua string. */
}
-/* Decodes from string buffer struct into Int64 userdata, with given endianess */
+/* Decodes from string buffer struct into Int64 userdata, with given endianness */
int Int64_unpack(lua_State* L, const gchar *buff, gboolean asLittleEndian) {
gint64 value = 0;
gint i;
@@ -141,9 +150,13 @@ int Int64_unpack(lua_State* L, const gchar *buff, gboolean asLittleEndian) {
}
WSLUA_CONSTRUCTOR Int64_decode(lua_State* L) {
- /* Decodes an 8-byte Lua string, using given endianess, into a new Int64 object */
-#define WSLUA_ARG_Int64_decode_STRING 1 /* The Lua string containing a binary 64-bit integer */
-#define WSLUA_OPTARG_Int64_decode_ENDIAN 2 /* If set to true then little-endian is used, if false then big-endian; if missing/nil, native host endian */
+ /* Decodes an 8-byte Lua string, using given endianness, into a new `Int64` object.
+ @since 1.11.3
+ */
+#define WSLUA_ARG_Int64_decode_STRING 1 /* The Lua string containing a binary 64-bit integer. */
+#define WSLUA_OPTARG_Int64_decode_ENDIAN 2 /* If set to true then little-endian is used,
+ if false then big-endian; if missing/nil, native
+ host endian. */
gboolean asLittleEndian = (G_BYTE_ORDER == G_LITTLE_ENDIAN)? TRUE : FALSE;
size_t len = 0;
const gchar *s = luaL_checklstring(L, WSLUA_ARG_Int64_decode_STRING, &len);
@@ -159,19 +172,27 @@ WSLUA_CONSTRUCTOR Int64_decode(lua_State* L) {
lua_pushnil(L);
}
- WSLUA_RETURN(1); /* The Int64 object created, or nil on failure */
+ WSLUA_RETURN(1); /* The `Int64` object created, or nil on failure. */
}
-WSLUA_CONSTRUCTOR Int64_new(lua_State* L) { /* Creates a Int64 Object */
-#define WSLUA_OPTARG_Int64_new_VALUE 1 /* A number, UInt64, Int64, or string of ascii digits to assign the value of the new Int64 (default=0) */
-#define WSLUA_OPTARG_Int64_new_HIGHVALUE 2 /* If this is a number and the first argument was a number, then the first will be treated as a lower 32-bits, and this is the high-order 32 bit number */
+WSLUA_CONSTRUCTOR Int64_new(lua_State* L) {
+ /* Creates a `Int64` Object.
+ @since 1.11.3
+ */
+#define WSLUA_OPTARG_Int64_new_VALUE 1 /* A number, `UInt64`, `Int64`, or string of ASCII digits
+ to assign the value of the new `Int64` (default=0). */
+#define WSLUA_OPTARG_Int64_new_HIGHVALUE 2 /* If this is a number and the first argument was
+ a number, then the first will be treated as a
+ lower 32-bits, and this is the high-order 32
+ bit number. */
gint64 value = 0;
if (lua_gettop(L) >= 1) {
switch(lua_type(L, WSLUA_OPTARG_Int64_new_VALUE)) {
case LUA_TNUMBER:
value = wslua_togint64(L, WSLUA_OPTARG_Int64_new_VALUE);
- if (lua_gettop(L) == 2 && lua_type(L, WSLUA_OPTARG_Int64_new_HIGHVALUE) == LUA_TNUMBER) {
+ if (lua_gettop(L) == 2 &&
+ lua_type(L, WSLUA_OPTARG_Int64_new_HIGHVALUE) == LUA_TNUMBER) {
gint64 h = wslua_togint64(L, WSLUA_OPTARG_Int64_new_HIGHVALUE);
value &= G_GUINT64_CONSTANT(0x00000000FFFFFFFF);
h <<= 32; h &= G_GUINT64_CONSTANT(0xFFFFFFFF00000000);
@@ -190,33 +211,47 @@ WSLUA_CONSTRUCTOR Int64_new(lua_State* L) { /* Creates a Int64 Object */
pushInt64(L,value);
- WSLUA_RETURN(1); /* The new Int64 object. */
+ WSLUA_RETURN(1); /* The new `Int64` object. */
}
-WSLUA_METAMETHOD Int64__call(lua_State* L) { /* Creates a Int64 Object */
+WSLUA_METAMETHOD Int64__call(lua_State* L) {
+ /* Creates a `Int64` Object.
+ @since 1.11.3
+ */
lua_remove(L,1); /* remove the table */
- WSLUA_RETURN(Int64_new(L)); /* The new Int64 object. */
+ WSLUA_RETURN(Int64_new(L)); /* The new `Int64` object. */
}
-WSLUA_CONSTRUCTOR Int64_max(lua_State* L) { /* Gets the max possible value */
+WSLUA_CONSTRUCTOR Int64_max(lua_State* L) {
+ /* Gets the max possible value.
+ @since 1.11.3
+ */
pushInt64(L, G_MAXINT64);
- WSLUA_RETURN(1); /* The new Int64 object of the max value. */
+ WSLUA_RETURN(1); /* The new `Int64` object of the max value. */
}
-WSLUA_CONSTRUCTOR Int64_min(lua_State* L) { /* Gets the min possible value */
+WSLUA_CONSTRUCTOR Int64_min(lua_State* L) {
+ /* Gets the min possible value.
+ @since 1.11.3
+ */
pushInt64(L, G_MININT64);
- WSLUA_RETURN(1); /* The new Int64 object of the min value. */
+ WSLUA_RETURN(1); /* The new `Int64` object of the min value. */
}
WSLUA_METHOD Int64_tonumber(lua_State* L) {
- /* Returns a Lua number of the Int64 value - this may lose precision. */
+ /* Returns a Lua number of the `Int64` value - this may lose precision.
+ @since 1.11.3
+ */
lua_pushnumber(L, (lua_Number)(checkInt64(L,1)));
- WSLUA_RETURN(1); /* The Lua number */
+ WSLUA_RETURN(1); /* The Lua number. */
}
-WSLUA_CONSTRUCTOR Int64_fromhex(lua_State* L) { /* Creates an Int64 object from the given hex string */
-#define WSLUA_ARG_Int64_fromhex_HEX 1 /* The hex-ascii Lua string */
+WSLUA_CONSTRUCTOR Int64_fromhex(lua_State* L) {
+ /* Creates an `Int64` object from the given hex string.
+ @since 1.11.3
+ */
+#define WSLUA_ARG_Int64_fromhex_HEX 1 /* The hex-ascii Lua string. */
guint64 result = 0;
size_t len = 0;
const gchar *s = luaL_checklstring(L,WSLUA_ARG_Int64_fromhex_HEX,&len);
@@ -225,12 +260,15 @@ WSLUA_CONSTRUCTOR Int64_fromhex(lua_State* L) { /* Creates an Int64 object from
sscanf(s, "%" G_GINT64_MODIFIER "x", &result);
}
pushInt64(L,(gint64)result);
- WSLUA_RETURN(1); /* The new Int64 object. */
+ WSLUA_RETURN(1); /* The new `Int64` object. */
}
WSLUA_METHOD Int64_tohex(lua_State* L) {
- /* Returns a hex string of the Int64 value. */
-#define WSLUA_OPTARG_Int64_new_NUMBYTES 2 /* The number of hex-chars/nibbles to generate, negative means uppercase (default=16) */
+ /* Returns a hex string of the `Int64` value.
+ @since 1.11.3
+ */
+#define WSLUA_OPTARG_Int64_new_NUMBYTES 2 /* The number of hex-chars/nibbles to generate,
+ negative means uppercase (default=16). */
gint64 b = getInt64(L,1);
gint n = luaL_optint(L, WSLUA_OPTARG_Int64_new_NUMBYTES, 16);
const gchar *hexdigits = "0123456789abcdef";
@@ -240,11 +278,14 @@ WSLUA_METHOD Int64_tohex(lua_State* L) {
if (n > 16) n = 16;
for (i = n-1; i >= 0; --i) { buf[i] = hexdigits[b & 15]; b >>= 4; }
lua_pushlstring(L, buf, (size_t)n);
- WSLUA_RETURN(1); /* The string hex */
+ WSLUA_RETURN(1); /* The string hex. */
}
WSLUA_METHOD Int64_higher(lua_State* L) {
- /* Returns a Lua number of the higher 32-bits of the Int64 value. (negative Int64 will return a negative Lua number) */
+ /* Returns a Lua number of the higher 32-bits of the `Int64` value. (negative `Int64`
+ will return a negative Lua number).
+ @since 1.11.3
+ */
gint64 num = getInt64(L,1);
gint64 b = num;
lua_Number n = 0;
@@ -254,32 +295,36 @@ WSLUA_METHOD Int64_higher(lua_State* L) {
n = (lua_Number)(guint32)(b & G_GUINT64_CONSTANT(0x00000000FFFFFFFFF));
if (num < 0) n = -n;
lua_pushnumber(L,n);
- WSLUA_RETURN(1); /* The Lua number */
+ WSLUA_RETURN(1); /* The Lua number. */
}
WSLUA_METHOD Int64_lower(lua_State* L) {
- /* Returns a Lua number of the lower 32-bits of the Int64 value. (always positive) */
+ /* Returns a Lua number of the lower 32-bits of the `Int64` value. (always positive).
+ @since 1.11.3
+ */
gint64 b = getInt64(L,1);
if (b < 0) b = -b; /* masking/shifting negative int64 isn't working on some platforms */
lua_pushnumber(L,(guint32)(b & G_GUINT64_CONSTANT(0x00000000FFFFFFFFF)));
- WSLUA_RETURN(1); /* The Lua number */
+ WSLUA_RETURN(1); /* The Lua number. */
}
WSLUA_METAMETHOD Int64__tostring(lua_State* L) {
- /* Converts the Int64 into a string of decimal digits */
+ /* Converts the `Int64` into a string of decimal digits. */
gint64 num = getInt64(L,1);
gchar s[LUATYPE64_STRING_SIZE];
if (g_snprintf(s, LUATYPE64_STRING_SIZE, "%" G_GINT64_MODIFIER "d", num) < 0) {
return luaL_error(L, "Error writing Int64 to a string");
}
lua_pushstring(L,s);
- WSLUA_RETURN(1); /* The Lua string */
+ WSLUA_RETURN(1); /* The Lua string. */
}
WSLUA_METAMETHOD Int64__unm(lua_State* L) {
- /* Returns the negative of the Int64, in a new Int64 */
+ /* Returns the negative of the `Int64`, in a new `Int64`.
+ @since 1.11.3
+ */
pushInt64(L,-(getInt64(L,1)));
- WSLUA_RETURN(1); /* The new Int64 */
+ WSLUA_RETURN(1); /* The new `Int64`. */
}
#define WSLUA_MATH_OP_FUNC(obj,op) \
@@ -290,46 +335,59 @@ WSLUA_METAMETHOD Int64__unm(lua_State* L) {
return 1
WSLUA_METAMETHOD Int64__add(lua_State* L) {
- /* Adds two Int64 together and returns a new one (this may wrap the value) */
+ /* Adds two `Int64` together and returns a new one (this may wrap the value).
+ @since 1.11.3
+ */
WSLUA_MATH_OP_FUNC(Int64,+);
}
WSLUA_METAMETHOD Int64__sub(lua_State* L) {
- /* Subtracts two Int64 and returns a new one (this may wrap the value) */
+ /* Subtracts two `Int64` and returns a new one (this may wrap the value).
+ @since 1.11.3
+ */
WSLUA_MATH_OP_FUNC(Int64,-);
}
WSLUA_METAMETHOD Int64__mul(lua_State* L) {
- /* Multiplies two Int64 and returns a new one (this may truncate the value) */
+ /* Multiplies two `Int64` and returns a new one (this may truncate the value).
+ @since 1.11.3
+ */
WSLUA_MATH_OP_FUNC(Int64,*);
}
WSLUA_METAMETHOD Int64__div(lua_State* L) {
- /* Divides two Int64 and returns a new one (integer divide, no remainder).
- Trying to divide by zero results in a Lua error. */
+ /* Divides two `Int64` and returns a new one (integer divide, no remainder).
+ Trying to divide by zero results in a Lua error.
+ @since 1.11.3
+ */
Int64 num1 = getInt64(L,1);
Int64 num2 = getInt64(L,2);
if (num2 == 0) {
return luaL_error(L, "Trying to divide Int64 by zero");
}
pushInt64(L, num1 / num2);
- WSLUA_RETURN(1); /* The Int64 object */
+ WSLUA_RETURN(1); /* The `Int64` object. */
}
WSLUA_METAMETHOD Int64__mod(lua_State* L) {
- /* Divides two Int64 and returns a new one of the remainder.
- Trying to modulo by zero results in a Lua error. */
+ /* Divides two `Int64` and returns a new one of the remainder.
+ Trying to modulo by zero results in a Lua error.
+ @since 1.11.3
+ */
Int64 num1 = getInt64(L,1);
Int64 num2 = getInt64(L,2);
if (num2 == 0) {
return luaL_error(L, "Trying to modulo Int64 by zero");
}
pushInt64(L, num1 % num2);
- WSLUA_RETURN(1); /* The Int64 object */
+ WSLUA_RETURN(1); /* The `Int64` object. */
}
WSLUA_METAMETHOD Int64__pow(lua_State* L) {
- /* The first Int64 is taken to the power of the second Int64, returning a new one (this may truncate the value) */
+ /* The first `Int64` is taken to the power of the second `Int64`, returning a new
+ one (this may truncate the value).
+ @since 1.11.3
+ */
gint64 num1 = getInt64(L,1);
gint64 num2 = getInt64(L,2);
gint64 result;
@@ -343,7 +401,7 @@ WSLUA_METAMETHOD Int64__pow(lua_State* L) {
}
}
pushInt64(L,result);
- WSLUA_RETURN(1); /* The Int64 object */
+ WSLUA_RETURN(1); /* The `Int64` object. */
}
#define WSLUA_COMP_OP_FUNC(obj,op) \
@@ -353,24 +411,32 @@ WSLUA_METAMETHOD Int64__pow(lua_State* L) {
return 1
WSLUA_METAMETHOD Int64__eq(lua_State* L) {
- /* Returns true if both Int64 are equal */
+ /* Returns true if both `Int64` are equal.
+ @since 1.11.3
+ */
WSLUA_COMP_OP_FUNC(Int64,==);
}
WSLUA_METAMETHOD Int64__lt(lua_State* L) {
- /* Returns true if first Int64 < second */
+ /* Returns true if first `Int64` < second.
+ @since 1.11.3
+ */
WSLUA_COMP_OP_FUNC(Int64,<);
}
WSLUA_METAMETHOD Int64__le(lua_State* L) {
- /* Returns true if first Int64 <= second */
+ /* Returns true if first `Int64` <= second.
+ @since 1.11.3
+ */
WSLUA_COMP_OP_FUNC(Int64,<=);
}
WSLUA_METHOD Int64_bnot(lua_State* L) {
- /* Returns a Int64 of the bitwise 'not' operation. */
+ /* Returns a `Int64` of the bitwise 'not' operation.
+ @since 1.11.3
+ */
pushInt64(L,~(getInt64(L,1)));
- WSLUA_RETURN(1); /* The Int64 object */
+ WSLUA_RETURN(1); /* The `Int64` object. */
}
#define WSLUA_BIT_OP_FUNC(obj,op) \
@@ -383,70 +449,97 @@ WSLUA_METHOD Int64_bnot(lua_State* L) {
return 1
WSLUA_METHOD Int64_band(lua_State* L) {
- /* Returns a Int64 of the bitwise 'and' operation, with the given number/Int64/UInt64. Note that multiple arguments are allowed. */
+ /* Returns a `Int64` of the bitwise 'and' operation, with the given number/`Int64`/`UInt64`.
+ Note that multiple arguments are allowed.
+ @since 1.11.3
+ */
WSLUA_BIT_OP_FUNC(Int64,&=);
- WSLUA_RETURN(1); /* The Int64 object */
+ WSLUA_RETURN(1); /* The `Int64` object. */
}
WSLUA_METHOD Int64_bor(lua_State* L) {
- /* Returns a Int64 of the bitwise 'or' operation, with the given number/Int64/UInt64. Note that multiple arguments are allowed. */
+ /* Returns a `Int64` of the bitwise 'or' operation, with the given number/`Int64`/`UInt64`.
+ Note that multiple arguments are allowed.
+ @since 1.11.3
+ */
WSLUA_BIT_OP_FUNC(Int64,|=);
- WSLUA_RETURN(1); /* The Int64 object */
+ WSLUA_RETURN(1); /* The `Int64` object. */
}
WSLUA_METHOD Int64_bxor(lua_State* L) {
- /* Returns a Int64 of the bitwise 'xor' operation, with the given number/Int64/UInt64. Note that multiple arguments are allowed. */
+ /* Returns a `Int64` of the bitwise 'xor' operation, with the given number/`Int64`/`UInt64`.
+ Note that multiple arguments are allowed.
+ @since 1.11.3
+ */
WSLUA_BIT_OP_FUNC(Int64,^=);
- WSLUA_RETURN(1); /* The Int64 object */
+ WSLUA_RETURN(1); /* The `Int64` object. */
}
WSLUA_METHOD Int64_lshift(lua_State* L) {
- /* Returns a Int64 of the bitwise logical left-shift operation, by the given number of bits. */
-#define WSLUA_ARG_Int64_lshift_NUMBITS 2 /* The number of bits to left-shift by */
+ /* Returns a `Int64` of the bitwise logical left-shift operation, by the given
+ number of bits.
+ @since 1.11.3
+ */
+#define WSLUA_ARG_Int64_lshift_NUMBITS 2 /* The number of bits to left-shift by. */
guint64 b = (guint64) getInt64(L,1);
guint32 n = wslua_checkguint32(L,WSLUA_ARG_Int64_lshift_NUMBITS);
pushInt64(L,(gint64)(b << n));
- WSLUA_RETURN(1); /* The Int64 object */
+ WSLUA_RETURN(1); /* The `Int64` object. */
}
WSLUA_METHOD Int64_rshift(lua_State* L) {
- /* Returns a Int64 of the bitwise logical right-shift operation, by the given number of bits. */
-#define WSLUA_ARG_Int64_rshift_NUMBITS 2 /* The number of bits to right-shift by */
+ /* Returns a `Int64` of the bitwise logical right-shift operation, by the
+ given number of bits.
+ @since 1.11.3
+ */
+#define WSLUA_ARG_Int64_rshift_NUMBITS 2 /* The number of bits to right-shift by. */
guint64 b = (guint64) getInt64(L,1);
guint32 n = wslua_checkguint32(L,WSLUA_ARG_Int64_rshift_NUMBITS);
pushInt64(L,(gint64)(b >> n));
- WSLUA_RETURN(1); /* The Int64 object */
+ WSLUA_RETURN(1); /* The `Int64` object. */
}
WSLUA_METHOD Int64_arshift(lua_State* L) {
- /* Returns a Int64 of the bitwise arithmetic right-shift operation, by the given number of bits. */
-#define WSLUA_ARG_Int64_arshift_NUMBITS 2 /* The number of bits to right-shift by */
+ /* Returns a `Int64` of the bitwise arithmetic right-shift operation, by the
+ given number of bits.
+ @since 1.11.3
+ */
+#define WSLUA_ARG_Int64_arshift_NUMBITS 2 /* The number of bits to right-shift by. */
gint64 b = getInt64(L,1);
gint32 n = wslua_checkgint32(L,WSLUA_ARG_Int64_arshift_NUMBITS);
pushInt64(L,(b >> n));
- WSLUA_RETURN(1); /* The Int64 object */
+ WSLUA_RETURN(1); /* The `Int64` object. */
}
WSLUA_METHOD Int64_rol(lua_State* L) {
- /* Returns a Int64 of the bitwise left rotation operation, by the given number of bits (up to 63). */
-#define WSLUA_ARG_Int64_rol_NUMBITS 2 /* The number of bits to roll left by */
+ /* Returns a `Int64` of the bitwise left rotation operation, by the given number of
+ bits (up to 63).
+ @since 1.11.3
+ */
+#define WSLUA_ARG_Int64_rol_NUMBITS 2 /* The number of bits to roll left by. */
guint64 b = (guint64) getInt64(L,1);
guint32 n = wslua_checkguint32(L,WSLUA_ARG_Int64_rol_NUMBITS);
pushInt64(L,(gint64)((b << n) | (b >> (64-n))));
- WSLUA_RETURN(1); /* The Int64 object */
+ WSLUA_RETURN(1); /* The `Int64` object. */
}
WSLUA_METHOD Int64_ror(lua_State* L) {
- /* Returns a Int64 of the bitwise right rotation operation, by the given number of bits (up to 63). */
-#define WSLUA_ARG_Int64_ror_NUMBITS 2 /* The number of bits to roll right by */
+ /* Returns a `Int64` of the bitwise right rotation operation, by the given number of
+ bits (up to 63).
+ @since 1.11.3
+ */
+#define WSLUA_ARG_Int64_ror_NUMBITS 2 /* The number of bits to roll right by. */
guint64 b = (guint64) getInt64(L,1);
guint32 n = wslua_checkguint32(L,WSLUA_ARG_Int64_ror_NUMBITS);
pushInt64(L,(gint64)((b << (64-n)) | (b >> n)));
- WSLUA_RETURN(1); /* The Int64 object */
+ WSLUA_RETURN(1); /* The `Int64` object. */
}
WSLUA_METHOD Int64_bswap(lua_State* L) {
- /* Returns a Int64 of the bytes swapped. This can be used to convert little-endian 64 bit numbers to big-endian 64 bit numbers or vice versa. */
+ /* Returns a `Int64` of the bytes swapped. This can be used to convert little-endian
+ 64-bit numbers to big-endian 64 bit numbers or vice versa.
+ @since 1.11.3
+ */
guint64 b = (guint64) getInt64(L,1);
guint64 result = 0;
size_t i;
@@ -456,10 +549,10 @@ WSLUA_METHOD Int64_bswap(lua_State* L) {
b >>= 8;
}
pushInt64(L,(gint64)result);
- WSLUA_RETURN(1); /* The Int64 object */
+ WSLUA_RETURN(1); /* The `Int64` object. */
}
-/* Gets registered as metamethod automatically by WSLUA_REGISTER_CLASS/META */
+/* Gets registered as metamethod automatically by WSLUA_REGISTER_CLASS/META. */
static int Int64__gc(lua_State* L _U_) {
return 0;
}
@@ -513,10 +606,12 @@ LUALIB_API int Int64_register(lua_State* L) {
WSLUA_CLASS_DEFINE_BASE(UInt64,NOP,NOP,0);
- /* UInt64 represents a 64 bit unsigned integer, similar to Int64.
- For details, see: http://wiki.wireshark.org/LuaAPI/Int64 */
+/* `UInt64` represents a 64 bit unsigned integer, similar to `Int64`.
+
+ For details, see: http://wiki.wireshark.org/LuaAPI/`Int64`.
+*/
-/* A checkUInt64 but that also auto-converts numbers, strings, and Int64 to a guint64 */
+/* A checkUInt64 but that also auto-converts numbers, strings, and `Int64` to a guint64. */
static guint64 getUInt64(lua_State *L, int i)
{
gchar *end = NULL;
@@ -537,7 +632,7 @@ static guint64 getUInt64(lua_State *L, int i)
}
}
-/* Encodes UInt64 userdata into Lua string struct with given endianess */
+/* Encodes `UInt64` userdata into Lua string struct with given endianness */
void UInt64_pack(lua_State* L, luaL_Buffer *b, gint idx, gboolean asLittleEndian) {
guint64 value = checkUInt64(L,idx);
gint8 buff[sizeof(guint64)];
@@ -560,8 +655,12 @@ void UInt64_pack(lua_State* L, luaL_Buffer *b, gint idx, gboolean asLittleEndian
}
WSLUA_METHOD UInt64_encode(lua_State* L) {
- /* Encodes the UInt64 number into an 8-byte Lua binary string, using given endianess */
-#define WSLUA_OPTARG_UInt64_encode_ENDIAN 2 /* If set to true then little-endian is used, if false then big-endian; if missing/nil, native host endian */
+ /* Encodes the `UInt64` number into an 8-byte Lua binary string, using given endianness.
+ @since 1.11.3
+ */
+#define WSLUA_OPTARG_UInt64_encode_ENDIAN 2 /* If set to true then little-endian is used,
+ if false then big-endian; if missing/nil,
+ native host endian. */
luaL_Buffer b;
gboolean asLittleEndian = (G_BYTE_ORDER == G_LITTLE_ENDIAN)? TRUE : FALSE;
@@ -575,10 +674,10 @@ WSLUA_METHOD UInt64_encode(lua_State* L) {
UInt64_pack(L, &b, 1, asLittleEndian);
luaL_pushresult(&b);
- WSLUA_RETURN(1); /* The Lua binary string */
+ WSLUA_RETURN(1); /* The Lua binary string. */
}
-/* Decodes from string buffer struct into UInt64 userdata, with given endianess */
+/* Decodes from string buffer struct into `UInt64` userdata, with given endianness. */
int UInt64_unpack(lua_State* L, const gchar *buff, gboolean asLittleEndian) {
guint64 value = 0;
gint i;
@@ -601,9 +700,13 @@ int UInt64_unpack(lua_State* L, const gchar *buff, gboolean asLittleEndian) {
}
WSLUA_CONSTRUCTOR UInt64_decode(lua_State* L) {
- /* Decodes an 8-byte Lua binary string, using given endianess, into a new UInt64 object */
-#define WSLUA_ARG_UInt64_decode_STRING 1 /* The Lua string containing a binary 64-bit integer */
-#define WSLUA_OPTARG_UInt64_decode_ENDIAN 2 /* If set to true then little-endian is used, if false then big-endian; if missing/nil, native host endian */
+ /* Decodes an 8-byte Lua binary string, using given endianness, into a new `UInt64` object.
+ @since 1.11.3
+ */
+#define WSLUA_ARG_UInt64_decode_STRING 1 /* The Lua string containing a binary 64-bit integer. */
+#define WSLUA_OPTARG_UInt64_decode_ENDIAN 2 /* If set to true then little-endian is used,
+ if false then big-endian; if missing/nil,
+ native host endian. */
gboolean asLittleEndian = (G_BYTE_ORDER == G_LITTLE_ENDIAN)? TRUE : FALSE;
size_t len = 0;
const gchar *s = luaL_checklstring(L, WSLUA_ARG_UInt64_decode_STRING, &len);
@@ -619,19 +722,27 @@ WSLUA_CONSTRUCTOR UInt64_decode(lua_State* L) {
lua_pushnil(L);
}
- WSLUA_RETURN(1); /* The UInt64 object created, or nil on failure */
+ WSLUA_RETURN(1); /* The `UInt64` object created, or nil on failure. */
}
-WSLUA_CONSTRUCTOR UInt64_new(lua_State* L) { /* Creates a UInt64 Object */
-#define WSLUA_OPTARG_UInt64_new_VALUE 1 /* A number, UInt64, Int64, or string of digits to assign the value of the new UInt64 (default=0) */
-#define WSLUA_OPTARG_UInt64_new_HIGHVALUE 2 /* If this is a number and the first argument was a number, then the first will be treated as a lower 32-bits, and this is the high-order 32 bit number */
+WSLUA_CONSTRUCTOR UInt64_new(lua_State* L) {
+ /* Creates a `UInt64` Object.
+ @since 1.11.3
+ */
+#define WSLUA_OPTARG_UInt64_new_VALUE 1 /* A number, `UInt64`, `Int64`, or string of digits
+ to assign the value of the new `UInt64` (default=0). */
+#define WSLUA_OPTARG_UInt64_new_HIGHVALUE 2 /* If this is a number and the first argument was
+ a number, then the first will be treated as a
+ lower 32-bits, and this is the high-order
+ 32-bit number. */
guint64 value = 0;
if (lua_gettop(L) >= 1) {
switch(lua_type(L, WSLUA_OPTARG_UInt64_new_VALUE)) {
case LUA_TNUMBER:
value = wslua_toguint64(L, WSLUA_OPTARG_UInt64_new_VALUE);
- if (lua_gettop(L) == 2 && lua_type(L, WSLUA_OPTARG_UInt64_new_HIGHVALUE) == LUA_TNUMBER) {
+ if (lua_gettop(L) == 2 &&
+ lua_type(L, WSLUA_OPTARG_UInt64_new_HIGHVALUE) == LUA_TNUMBER) {
guint64 h = wslua_toguint64(L, WSLUA_OPTARG_UInt64_new_HIGHVALUE);
value &= G_GUINT64_CONSTANT(0x00000000FFFFFFFF);
h <<= 32; h &= G_GUINT64_CONSTANT(0xFFFFFFFF00000000);
@@ -650,43 +761,57 @@ WSLUA_CONSTRUCTOR UInt64_new(lua_State* L) { /* Creates a UInt64 Object */
pushUInt64(L,value);
- WSLUA_RETURN(1); /* The new UInt64 object. */
+ WSLUA_RETURN(1); /* The new `UInt64` object. */
}
-WSLUA_METAMETHOD UInt64__call(lua_State* L) { /* Creates a UInt64 Object */
+WSLUA_METAMETHOD UInt64__call(lua_State* L) {
+ /* Creates a `UInt64` Object.
+ @since 1.11.3
+ */
lua_remove(L,1); /* remove the table */
- WSLUA_RETURN(UInt64_new(L)); /* The new UInt64 object. */
+ WSLUA_RETURN(UInt64_new(L)); /* The new `UInt64` object. */
}
-WSLUA_CONSTRUCTOR UInt64_max(lua_State* L) { /* Gets the max possible value */
+WSLUA_CONSTRUCTOR UInt64_max(lua_State* L) {
+ /* Gets the max possible value.
+ @since 1.11.3
+ */
pushUInt64(L,G_MAXUINT64);
WSLUA_RETURN(1); /* The max value. */
}
-WSLUA_CONSTRUCTOR UInt64_min(lua_State* L) { /* Gets the min possible value (i.e., 0) */
+WSLUA_CONSTRUCTOR UInt64_min(lua_State* L) {
+ /* Gets the min possible value (i.e., 0).
+ @since 1.11.3
+ */
pushUInt64(L,0);
WSLUA_RETURN(1); /* The min value. */
}
WSLUA_METHOD UInt64_tonumber(lua_State* L) {
- /* Returns a Lua number of the UInt64 value - this may lose precision. */
+ /* Returns a Lua number of the `UInt64` value - this may lose precision.
+ @since 1.11.3
+ */
lua_pushnumber(L,(lua_Number)(checkUInt64(L,1)));
- WSLUA_RETURN(1); /* The Lua number */
+ WSLUA_RETURN(1); /* The Lua number. */
}
WSLUA_METAMETHOD UInt64__tostring(lua_State* L) {
- /* Converts the UInt64 into a string */
+ /* Converts the `UInt64` into a string. */
guint64 num = getUInt64(L,1);
gchar s[LUATYPE64_STRING_SIZE];
if (g_snprintf(s, LUATYPE64_STRING_SIZE, "%" G_GINT64_MODIFIER "u",(guint64)num) < 0) {
return luaL_error(L, "Error writing UInt64 to a string");
}
lua_pushstring(L,s);
- WSLUA_RETURN(1); /* The Lua string */
+ WSLUA_RETURN(1); /* The Lua string. */
}
-WSLUA_CONSTRUCTOR UInt64_fromhex(lua_State* L) { /* Creates a UInt64 object from the given hex string */
-#define WSLUA_ARG_UInt64_fromhex_HEX 1 /* The hex-ascii Lua string */
+WSLUA_CONSTRUCTOR UInt64_fromhex(lua_State* L) {
+ /* Creates a `UInt64` object from the given hex string.
+ @since 1.11.3
+ */
+#define WSLUA_ARG_UInt64_fromhex_HEX 1 /* The hex-ascii Lua string. */
guint64 result = 0;
size_t len = 0;
const gchar *s = luaL_checklstring(L,WSLUA_ARG_UInt64_fromhex_HEX,&len);
@@ -695,12 +820,15 @@ WSLUA_CONSTRUCTOR UInt64_fromhex(lua_State* L) { /* Creates a UInt64 object from
sscanf(s, "%" G_GINT64_MODIFIER "x", &result);
}
pushUInt64(L,result);
- WSLUA_RETURN(1); /* The new UInt64 object. */
+ WSLUA_RETURN(1); /* The new `UInt64` object. */
}
WSLUA_METHOD UInt64_tohex(lua_State* L) {
- /* Returns a hex string of the UInt64 value. */
-#define WSLUA_OPTARG_UInt64_new_NUMBYTES 2 /* The number of hex-chars/nibbles to generate, negative means uppercase (default=16) */
+ /* Returns a hex string of the `UInt64` value.
+ @since 1.11.3
+ */
+#define WSLUA_OPTARG_UInt64_new_NUMBYTES 2 /* The number of hex-chars/nibbles to generate,
+ negative means uppercase (default=16). */
guint64 b = getUInt64(L,1);
gint n = luaL_optint(L, WSLUA_OPTARG_UInt64_new_NUMBYTES, 16);
const gchar *hexdigits = "0123456789abcdef";
@@ -710,11 +838,11 @@ WSLUA_METHOD UInt64_tohex(lua_State* L) {
if (n > 16) n = 16;
for (i = n-1; i >= 0; --i) { buf[i] = hexdigits[b & 15]; b >>= 4; }
lua_pushlstring(L, buf, (size_t)n);
- WSLUA_RETURN(1); /* The string hex */
+ WSLUA_RETURN(1); /* The string hex. */
}
WSLUA_METHOD UInt64_higher(lua_State* L) {
- /* Returns a Lua number of the higher 32-bits of the UInt64 value. */
+ /* Returns a Lua number of the higher 32-bits of the `UInt64` value. */
guint64 num = getUInt64(L,1);
guint64 b = num;
lua_Number n = 0;
@@ -722,63 +850,78 @@ WSLUA_METHOD UInt64_higher(lua_State* L) {
b >>= 32;
n = (lua_Number)(guint32)(b & G_GUINT64_CONSTANT(0x00000000FFFFFFFFF));
lua_pushnumber(L,n);
- WSLUA_RETURN(1); /* The Lua number */
+ WSLUA_RETURN(1); /* The Lua number. */
}
WSLUA_METHOD UInt64_lower(lua_State* L) {
- /* Returns a Lua number of the lower 32-bits of the UInt64 value. */
+ /* Returns a Lua number of the lower 32-bits of the `UInt64` value. */
guint64 b = getUInt64(L,1);
lua_pushnumber(L,(guint32)(b & G_GUINT64_CONSTANT(0x00000000FFFFFFFFF)));
- WSLUA_RETURN(1); /* The Lua number */
+ WSLUA_RETURN(1); /* The Lua number. */
}
WSLUA_METAMETHOD UInt64__unm(lua_State* L) {
- /* Returns the UInt64, in a new UInt64, since unsigned integers can't be negated. */
+ /* Returns the `UInt64`, in a new `UInt64`, since unsigned integers can't be negated.
+ @since 1.11.3
+ */
pushUInt64(L,getUInt64(L,1));
- WSLUA_RETURN(1); /* The UInt64 object */
+ WSLUA_RETURN(1); /* The `UInt64` object. */
}
WSLUA_METAMETHOD UInt64__add(lua_State* L) {
- /* Adds two UInt64 together and returns a new one (this may wrap the value) */
+ /* Adds two `UInt64` together and returns a new one (this may wrap the value).
+ @since 1.11.3
+ */
WSLUA_MATH_OP_FUNC(UInt64,+);
}
WSLUA_METAMETHOD UInt64__sub(lua_State* L) {
- /* Subtracts two UInt64 and returns a new one (this may wrap the value) */
+ /* Subtracts two `UInt64` and returns a new one (this may wrap the value).
+ @since 1.11.3
+ */
WSLUA_MATH_OP_FUNC(UInt64,-);
}
WSLUA_METAMETHOD UInt64__mul(lua_State* L) {
- /* Multiplies two UInt64 and returns a new one (this may truncate the value) */
+ /* Multiplies two `UInt64` and returns a new one (this may truncate the value).
+ @since 1.11.3
+ */
WSLUA_MATH_OP_FUNC(UInt64,*);
}
WSLUA_METAMETHOD UInt64__div(lua_State* L) {
- /* Divides two UInt64 and returns a new one (integer divide, no remainder).
- Trying to divide by zero results in a Lua error. */
+ /* Divides two `UInt64` and returns a new one (integer divide, no remainder).
+ Trying to divide by zero results in a Lua error.
+ @since 1.11.3
+ */
UInt64 num1 = getUInt64(L,1);
UInt64 num2 = getUInt64(L,2);
if (num2 == 0) {
return luaL_error(L, "Trying to divide UInt64 by zero");
}
pushUInt64(L, num1 / num2);
- WSLUA_RETURN(1); /* The UInt64 result */
+ WSLUA_RETURN(1); /* The `UInt64` result. */
}
WSLUA_METAMETHOD UInt64__mod(lua_State* L) {
- /* Divides two UInt64 and returns a new one of the remainder.
- Trying to modulo by zero results in a Lua error. */
+ /* Divides two `UInt64` and returns a new one of the remainder.
+ Trying to modulo by zero results in a Lua error.
+ @since 1.11.3
+ */
UInt64 num1 = getUInt64(L,1);
UInt64 num2 = getUInt64(L,2);
if (num2 == 0) {
return luaL_error(L, "Trying to modulo UInt64 by zero");
}
pushUInt64(L, num1 % num2);
- WSLUA_RETURN(1); /* The UInt64 result */
+ WSLUA_RETURN(1); /* The `UInt64` result. */
}
WSLUA_METAMETHOD UInt64__pow(lua_State* L) {
- /* The first UInt64 is taken to the power of the second UInt64/number, returning a new one (this may truncate the value) */
+ /* The first `UInt64` is taken to the power of the second `UInt64`/number,
+ returning a new one (this may truncate the value).
+ @since 1.11.3
+ */
guint64 num1 = getUInt64(L,1);
guint64 num2 = getUInt64(L,2);
guint64 result;
@@ -792,95 +935,130 @@ WSLUA_METAMETHOD UInt64__pow(lua_State* L) {
}
}
pushUInt64(L,result);
- WSLUA_RETURN(1); /* The UInt64 object */
+ WSLUA_RETURN(1); /* The `UInt64` object. */
}
WSLUA_METAMETHOD UInt64__eq(lua_State* L) {
- /* Returns true if both UInt64 are equal */
+ /* Returns true if both `UInt64` are equal.
+ @since 1.11.3
+ */
WSLUA_COMP_OP_FUNC(UInt64,==);
}
WSLUA_METAMETHOD UInt64__lt(lua_State* L) {
- /* Returns true if first UInt64 < second */
+ /* Returns true if first `UInt64` < second.
+ @since 1.11.3
+ */
WSLUA_COMP_OP_FUNC(UInt64,<);
}
WSLUA_METAMETHOD UInt64__le(lua_State* L) {
- /* Returns true if first UInt64 <= second */
+ /* Returns true if first `UInt64` <= second.
+ @since 1.11.3
+ */
WSLUA_COMP_OP_FUNC(UInt64,<=);
}
WSLUA_METHOD UInt64_bnot(lua_State* L) {
- /* Returns a UInt64 of the bitwise 'not' operation. */
+ /* Returns a `UInt64` of the bitwise 'not' operation.
+ @since 1.11.3
+ */
pushUInt64(L,~(getUInt64(L,1)));
- WSLUA_RETURN(1); /* The UInt64 object */
+ WSLUA_RETURN(1); /* The `UInt64` object. */
}
WSLUA_METHOD UInt64_band(lua_State* L) {
- /* Returns a UInt64 of the bitwise 'and' operation, with the given number/Int64/UInt64. Note that multiple arguments are allowed. */
+ /* Returns a `UInt64` of the bitwise 'and' operation, with the given number/`Int64`/`UInt64`.
+ Note that multiple arguments are allowed.
+ @since 1.11.3
+ */
WSLUA_BIT_OP_FUNC(UInt64,&=);
- WSLUA_RETURN(1); /* The UInt64 object */
+ WSLUA_RETURN(1); /* The `UInt64` object. */
}
WSLUA_METHOD UInt64_bor(lua_State* L) {
- /* Returns a UInt64 of the bitwise 'or' operation, with the given number/Int64/UInt64. Note that multiple arguments are allowed. */
+ /* Returns a `UInt64` of the bitwise 'or' operation, with the given number/`Int64`/`UInt64`.
+ Note that multiple arguments are allowed.
+ @since 1.11.3
+ */
WSLUA_BIT_OP_FUNC(UInt64,|=);
- WSLUA_RETURN(1); /* The UInt64 object */
+ WSLUA_RETURN(1); /* The `UInt64` object. */
}
WSLUA_METHOD UInt64_bxor(lua_State* L) {
- /* Returns a UInt64 of the bitwise 'xor' operation, with the given number/Int64/UInt64. Note that multiple arguments are allowed. */
+ /* Returns a `UInt64` of the bitwise 'xor' operation, with the given number/`Int64`/`UInt64`.
+ Note that multiple arguments are allowed.
+ @since 1.11.3
+ */
WSLUA_BIT_OP_FUNC(UInt64,^=);
- WSLUA_RETURN(1); /* The UInt64 object */
+ WSLUA_RETURN(1); /* The `UInt64` object. */
}
WSLUA_METHOD UInt64_lshift(lua_State* L) {
- /* Returns a UInt64 of the bitwise logical left-shift operation, by the given number of bits. */
-#define WSLUA_ARG_UInt64_lshift_NUMBITS 2 /* The number of bits to left-shift by */
+ /* Returns a `UInt64` of the bitwise logical left-shift operation, by the
+ given number of bits.
+ @since 1.11.3
+ */
+#define WSLUA_ARG_UInt64_lshift_NUMBITS 2 /* The number of bits to left-shift by. */
guint64 b = getUInt64(L,1);
guint32 n = wslua_checkguint32(L,WSLUA_ARG_UInt64_lshift_NUMBITS);
pushUInt64(L,(b << n));
- WSLUA_RETURN(1); /* The UInt64 object */
+ WSLUA_RETURN(1); /* The `UInt64` object. */
}
WSLUA_METHOD UInt64_rshift(lua_State* L) {
- /* Returns a UInt64 of the bitwise logical right-shift operation, by the given number of bits. */
-#define WSLUA_ARG_UInt64_rshift_NUMBITS 2 /* The number of bits to right-shift by */
+ /* Returns a `UInt64` of the bitwise logical right-shift operation, by the
+ given number of bits.
+ @since 1.11.3
+ */
+#define WSLUA_ARG_UInt64_rshift_NUMBITS 2 /* The number of bits to right-shift by. */
guint64 b = getUInt64(L,1);
guint32 n = wslua_checkguint32(L,WSLUA_ARG_UInt64_rshift_NUMBITS);
pushUInt64(L,(b >> n));
- WSLUA_RETURN(1); /* The UInt64 object */
+ WSLUA_RETURN(1); /* The `UInt64` object. */
}
WSLUA_METHOD UInt64_arshift(lua_State* L) {
- /* Returns a UInt64 of the bitwise arithmetic right-shift operation, by the given number of bits. */
-#define WSLUA_ARG_UInt64_arshift_NUMBITS 2 /* The number of bits to right-shift by */
+ /* Returns a `UInt64` of the bitwise arithmetic right-shift operation, by the
+ given number of bits.
+ @since 1.11.3
+ */
+#define WSLUA_ARG_UInt64_arshift_NUMBITS 2 /* The number of bits to right-shift by. */
guint64 b = getUInt64(L,1);
guint32 n = wslua_checkguint32(L,WSLUA_ARG_UInt64_arshift_NUMBITS);
pushUInt64(L,(b >> n));
- WSLUA_RETURN(1); /* The UInt64 object */
+ WSLUA_RETURN(1); /* The `UInt64` object. */
}
WSLUA_METHOD UInt64_rol(lua_State* L) {
- /* Returns a UInt64 of the bitwise left rotation operation, by the given number of bits (up to 63). */
-#define WSLUA_ARG_UInt64_rol_NUMBITS 2 /* The number of bits to roll left by */
+ /* Returns a `UInt64` of the bitwise left rotation operation, by the
+ given number of bits (up to 63).
+ @since 1.11.3
+ */
+#define WSLUA_ARG_UInt64_rol_NUMBITS 2 /* The number of bits to roll left by. */
guint64 b = getUInt64(L,1);
guint32 n = wslua_checkguint32(L,WSLUA_ARG_UInt64_rol_NUMBITS);
pushUInt64(L,((b << n) | (b >> (64-n))));
- WSLUA_RETURN(1); /* The UInt64 object */
+ WSLUA_RETURN(1); /* The `UInt64` object. */
}
WSLUA_METHOD UInt64_ror(lua_State* L) {
- /* Returns a UInt64 of the bitwise right rotation operation, by the given number of bits (up to 63). */
-#define WSLUA_ARG_UInt64_ror_NUMBITS 2 /* The number of bits to roll right by */
+ /* Returns a `UInt64` of the bitwise right rotation operation, by the
+ given number of bits (up to 63).
+ @since 1.11.3
+ */
+#define WSLUA_ARG_UInt64_ror_NUMBITS 2 /* The number of bits to roll right by. */
guint64 b = getUInt64(L,1);
guint32 n = wslua_checkguint32(L,WSLUA_ARG_UInt64_ror_NUMBITS);
pushUInt64(L,((b << (64-n)) | (b >> n)));
- WSLUA_RETURN(1); /* The UInt64 object */
+ WSLUA_RETURN(1); /* The `UInt64` object. */
}
WSLUA_METHOD UInt64_bswap(lua_State* L) {
- /* Returns a UInt64 of the bytes swapped. This can be used to convert little-endian 64 bit numbers to big-endian 64 bit numbers or vice versa. */
+ /* Returns a `UInt64` of the bytes swapped. This can be used to convert little-endian
+ 64-bit numbers to big-endian 64 bit numbers or vice versa.
+ @since 1.11.3
+ */
guint64 b = getUInt64(L,1);
guint64 result = 0;
size_t i;
@@ -890,7 +1068,7 @@ WSLUA_METHOD UInt64_bswap(lua_State* L) {
b >>= 8;
}
pushUInt64(L,result);
- WSLUA_RETURN(1); /* The UInt64 object */
+ WSLUA_RETURN(1); /* The `UInt64` object. */
}
/* Gets registered as metamethod automatically by WSLUA_REGISTER_CLASS/META */
diff --git a/epan/wslua/wslua_internals.c b/epan/wslua/wslua_internals.c
index 3617b5e868..c18bdc6441 100644
--- a/epan/wslua/wslua_internals.c
+++ b/epan/wslua/wslua_internals.c
@@ -415,3 +415,111 @@ int wslua_set__index(lua_State *L) {
/* we should now be back to real metatable being on top */
return 0;
}
+
+/* Pushes a hex string of the binary data argument. */
+int wslua_bin2hex(lua_State* L, const guint8* data, const guint len, const gboolean lowercase, const gchar* sep) {
+ luaL_Buffer b;
+ guint i = 0;
+ static const char byte_to_str_upper[256][3] = {
+ "00","01","02","03","04","05","06","07","08","09","0A","0B","0C","0D","0E","0F",
+ "10","11","12","13","14","15","16","17","18","19","1A","1B","1C","1D","1E","1F",
+ "20","21","22","23","24","25","26","27","28","29","2A","2B","2C","2D","2E","2F",
+ "30","31","32","33","34","35","36","37","38","39","3A","3B","3C","3D","3E","3F",
+ "40","41","42","43","44","45","46","47","48","49","4A","4B","4C","4D","4E","4F",
+ "50","51","52","53","54","55","56","57","58","59","5A","5B","5C","5D","5E","5F",
+ "60","61","62","63","64","65","66","67","68","69","6A","6B","6C","6D","6E","6F",
+ "70","71","72","73","74","75","76","77","78","79","7A","7B","7C","7D","7E","7F",
+ "80","81","82","83","84","85","86","87","88","89","8A","8B","8C","8D","8E","8F",
+ "90","91","92","93","94","95","96","97","98","99","9A","9B","9C","9D","9E","9F",
+ "A0","A1","A2","A3","A4","A5","A6","A7","A8","A9","AA","AB","AC","AD","AE","AF",
+ "B0","B1","B2","B3","B4","B5","B6","B7","B8","B9","BA","BB","BC","BD","BE","BF",
+ "C0","C1","C2","C3","C4","C5","C6","C7","C8","C9","CA","CB","CC","CD","CE","CF",
+ "D0","D1","D2","D3","D4","D5","D6","D7","D8","D9","DA","DB","DC","DD","DE","DF",
+ "E0","E1","E2","E3","E4","E5","E6","E7","E8","E9","EA","EB","EC","ED","EE","EF",
+ "F0","F1","F2","F3","F4","F5","F6","F7","F8","F9","FA","FB","FC","FD","FE","FF"
+ };
+ static const char byte_to_str_lower[256][3] = {
+ "00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f",
+ "10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f",
+ "20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f",
+ "30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f",
+ "40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f",
+ "50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f",
+ "60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f",
+ "70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f",
+ "80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f",
+ "90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f",
+ "a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af",
+ "b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf",
+ "c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf",
+ "d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df",
+ "e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef",
+ "f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"
+ };
+ const char (*byte_to_str)[3] = byte_to_str_upper;
+ const guint last = len - 1;
+
+ if (lowercase) byte_to_str = byte_to_str_lower;
+
+ luaL_buffinit(L, &b);
+
+ for (i = 0; i < len; i++) {
+ luaL_addlstring(&b, &(*byte_to_str[data[i]]), 2);
+ if (sep && i < last) luaL_addstring(&b, sep);
+ }
+
+ luaL_pushresult(&b);
+
+ return 1;
+}
+
+/* Pushes a binary string of the hex-ascii data argument. */
+int wslua_hex2bin(lua_State* L, const char* data, const guint len, const gchar* sep) {
+ luaL_Buffer b;
+ guint i = 0;
+ guint seplen = 0;
+ char c, d;
+
+ static const char str_to_nibble[256] = {
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1,
+ -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
+ };
+
+ if (sep) seplen = (guint) strlen(sep);
+
+ luaL_buffinit(L, &b);
+
+ for (i = 0; i < len;) {
+ c = str_to_nibble[(int)data[i]];
+ if (c < 0) {
+ if (seplen && strncmp(&data[i], sep, seplen) == 0) {
+ i += seplen;
+ continue;
+ } else {
+ break;
+ }
+ }
+ d = str_to_nibble[(int)data[++i]];
+ if (d < 0) break;
+ luaL_addchar(&b, (c * 16) + d);
+ i++;
+ }
+
+ luaL_pushresult(&b);
+
+ return 1;
+}
diff --git a/epan/wslua/wslua_listener.c b/epan/wslua/wslua_listener.c
index 125613378b..5e0deb6307 100644
--- a/epan/wslua/wslua_listener.c
+++ b/epan/wslua/wslua_listener.c
@@ -36,8 +36,8 @@
WSLUA_CLASS_DEFINE(Listener,FAIL_ON_NULL("Listener"),NOP);
/*
- A Listener, is called once for every packet that matches a certain filter or has a certain tap.
- It can read the tree, the packet's Tvb eventually the tapped data but it cannot
+ A `Listener` is called once for every packet that matches a certain filter or has a certain tap.
+ It can read the tree, the packet's `Tvb` buffer as well as the tapped data, but it cannot
add elements to the tree.
*/
@@ -187,10 +187,12 @@ static void lua_tap_draw(void *tapdata) {
}
WSLUA_CONSTRUCTOR Listener_new(lua_State* L) {
- /* Creates a new Listener listener */
-#define WSLUA_OPTARG_Listener_new_TAP 1 /* The name of this tap */
-#define WSLUA_OPTARG_Listener_new_FILTER 2 /* A filter that when matches the tap.packet function gets called (use nil to be called for every packet) */
-#define WSLUA_OPTARG_Listener_new_ALLFIELDS 3 /* Whether to generate all fields. Note: this impacts performance (default=false) */
+ /* Creates a new `Listener` listener object. */
+#define WSLUA_OPTARG_Listener_new_TAP 1 /* The name of this tap. */
+#define WSLUA_OPTARG_Listener_new_FILTER 2 /* A filter that when matches the `tap.packet` function gets
+ called (use nil to be called for every packet). */
+#define WSLUA_OPTARG_Listener_new_ALLFIELDS 3 /* Whether to generate all fields. (default=false)
+ Note: this impacts performance. */
const gchar* tap_type = luaL_optstring(L,WSLUA_OPTARG_Listener_new_TAP,"frame");
const gchar* filter = luaL_optstring(L,WSLUA_OPTARG_Listener_new_FILTER,NULL);
@@ -244,8 +246,12 @@ compare_dissector_key_name(gconstpointer dissector_a, gconstpointer dissector_b)
}
WSLUA_CONSTRUCTOR Listener_list (lua_State *L) {
- /* Gets a Lua array table of all registered Listener tap names.
- NOTE: this is an expensive operation, and should only be used for troubleshooting. */
+ /* Gets a Lua array table of all registered `Listener` tap names.
+
+ Note: this is an expensive operation, and should only be used for troubleshooting.
+
+ @since 1.11.3
+ */
GList* list = get_tap_names();
GList* elist = NULL;
int i = 1;
@@ -266,7 +272,7 @@ WSLUA_CONSTRUCTOR Listener_list (lua_State *L) {
}
WSLUA_METHOD Listener_remove(lua_State* L) {
- /* Removes a tap listener */
+ /* Removes a tap `Listener`. */
Listener tap = checkListener(L,1);
if (tap->all_fields) {
@@ -280,7 +286,7 @@ WSLUA_METHOD Listener_remove(lua_State* L) {
}
WSLUA_METAMETHOD Listener__tostring(lua_State* L) {
- /* Generates a string of debug info for the tap listener */
+ /* Generates a string of debug info for the tap `Listener`. */
Listener tap = checkListener(L,1);
gchar* str;
@@ -291,24 +297,35 @@ WSLUA_METAMETHOD Listener__tostring(lua_State* L) {
}
-/* WSLUA_ATTRIBUTE Listener_packet WO A function that will be called once every packet matches the Listener listener filter.
+/* WSLUA_ATTRIBUTE Listener_packet WO A function that will be called once every packet matches the
+ `Listener` listener filter.
+
+ When later called by Wireshark, the `packet` function will be given:
+ 1. A `Pinfo` object
+ 2. A `Tvb` object
+ 3. A `tapinfo` table
- function tap.packet(pinfo,tvb,tapinfo) ... end
- Note: tapinfo is a table of info based on the Listener's type, or nil.
+ @code function tap.packet(pinfo,tvb,tapinfo) ... end @endcode
+
+ @note `tapinfo` is a table of info based on the `Listener`'s type, or nil.
*/
WSLUA_ATTRIBUTE_FUNC_SETTER(Listener,packet);
-/* WSLUA_ATTRIBUTE Listener_draw WO A function that will be called once every few seconds to redraw the gui objects;
- in tshark this funtion is called only at the very end of the capture file.
+/* WSLUA_ATTRIBUTE Listener_draw WO A function that will be called once every few seconds to redraw the GUI objects;
+ in Tshark this funtion is called only at the very end of the capture file.
+
+ When later called by Wireshark, the `draw` function will not be given any arguments.
- function tap.draw() ... end
+ @code function tap.draw() ... end @endcode
*/
WSLUA_ATTRIBUTE_FUNC_SETTER(Listener,draw);
/* WSLUA_ATTRIBUTE Listener_reset WO A function that will be called at the end of the capture run.
- function tap.reset() ... end
+ When later called by Wireshark, the `reset` function will not be given any arguments.
+
+ @code function tap.reset() ... end @endcode
*/
WSLUA_ATTRIBUTE_FUNC_SETTER(Listener,reset);
diff --git a/epan/wslua/wslua_pinfo.c b/epan/wslua/wslua_pinfo.c
index c5cbaa3802..f3a8a04599 100644
--- a/epan/wslua/wslua_pinfo.c
+++ b/epan/wslua/wslua_pinfo.c
@@ -71,12 +71,12 @@ Pinfo* push_Pinfo(lua_State* L, packet_info* ws_pinfo) {
#define PUSH_PRIVATE_TABLE(L,c) {g_ptr_array_add(outstanding_PrivateTable,c);pushPrivateTable(L,c);}
WSLUA_CLASS_DEFINE(NSTime,FAIL_ON_NULL("NSTime"),NOP);
- /* NSTime represents a nstime_t. This is an object with seconds and nano seconds. */
+ /* NSTime represents a nstime_t. This is an object with seconds and nanoseconds. */
WSLUA_CONSTRUCTOR NSTime_new(lua_State *L) {
- /* Creates a new NSTime object */
-#define WSLUA_OPTARG_NSTime_new_SECONDS 1 /* Seconds */
-#define WSLUA_OPTARG_NSTime_new_NSECONDS 2 /* Nano seconds */
+ /* Creates a new NSTime object. */
+#define WSLUA_OPTARG_NSTime_new_SECONDS 1 /* Seconds. */
+#define WSLUA_OPTARG_NSTime_new_NSECONDS 2 /* Nano seconds. */
NSTime nstime = (NSTime)g_malloc(sizeof(nstime_t));
if (!nstime) return 0;
@@ -89,9 +89,9 @@ WSLUA_CONSTRUCTOR NSTime_new(lua_State *L) {
WSLUA_RETURN(1); /* The new NSTime object. */
}
-WSLUA_METAMETHOD NSTime__call(lua_State* L) { /* Creates a NSTime object */
-#define WSLUA_OPTARG_NSTime__call_SECONDS 1 /* Seconds */
-#define WSLUA_OPTARG_NSTime__call_NSECONDS 2 /* Nano seconds */
+WSLUA_METAMETHOD NSTime__call(lua_State* L) { /* Creates a NSTime object. */
+#define WSLUA_OPTARG_NSTime__call_SECONDS 1 /* Seconds. */
+#define WSLUA_OPTARG_NSTime__call_NSECONDS 2 /* Nanoseconds. */
lua_remove(L,1); /* remove the table */
WSLUA_RETURN(NSTime_new(L)); /* The new NSTime object. */
}
@@ -103,7 +103,7 @@ WSLUA_METAMETHOD NSTime__tostring(lua_State* L) {
WSLUA_RETURN(1); /* The string representing the nstime. */
}
-WSLUA_METAMETHOD NSTime__add(lua_State* L) { /* Calculates the sum of two NSTimes */
+WSLUA_METAMETHOD NSTime__add(lua_State* L) { /* Calculates the sum of two NSTimes. */
NSTime time1 = checkNSTime(L,1);
NSTime time2 = checkNSTime(L,2);
NSTime time3 = (NSTime)g_malloc (sizeof (nstime_t));
@@ -114,7 +114,7 @@ WSLUA_METAMETHOD NSTime__add(lua_State* L) { /* Calculates the sum of two NSTime
return 1;
}
-WSLUA_METAMETHOD NSTime__sub(lua_State* L) { /* Calculates the diff of two NSTimes */
+WSLUA_METAMETHOD NSTime__sub(lua_State* L) { /* Calculates the diff of two NSTimes. */
NSTime time1 = checkNSTime(L,1);
NSTime time2 = checkNSTime(L,2);
NSTime time3 = (NSTime)g_malloc (sizeof (nstime_t));
@@ -125,7 +125,7 @@ WSLUA_METAMETHOD NSTime__sub(lua_State* L) { /* Calculates the diff of two NSTim
return 1;
}
-WSLUA_METAMETHOD NSTime__unm(lua_State* L) { /* Calculates the negative NSTime */
+WSLUA_METAMETHOD NSTime__unm(lua_State* L) { /* Calculates the negative NSTime. */
NSTime time1 = checkNSTime(L,1);
NSTime time2 = (NSTime)g_malloc (sizeof (nstime_t));
@@ -136,7 +136,7 @@ WSLUA_METAMETHOD NSTime__unm(lua_State* L) { /* Calculates the negative NSTime *
return 1;
}
-WSLUA_METAMETHOD NSTime__eq(lua_State* L) { /* Compares two NSTimes */
+WSLUA_METAMETHOD NSTime__eq(lua_State* L) { /* Compares two NSTimes. */
NSTime time1 = checkNSTime(L,1);
NSTime time2 = checkNSTime(L,2);
gboolean result = FALSE;
@@ -149,7 +149,7 @@ WSLUA_METAMETHOD NSTime__eq(lua_State* L) { /* Compares two NSTimes */
return 1;
}
-WSLUA_METAMETHOD NSTime__le(lua_State* L) { /* Compares two NSTimes */
+WSLUA_METAMETHOD NSTime__le(lua_State* L) { /* Compares two NSTimes. */
NSTime time1 = checkNSTime(L,1);
NSTime time2 = checkNSTime(L,2);
gboolean result = FALSE;
@@ -162,7 +162,7 @@ WSLUA_METAMETHOD NSTime__le(lua_State* L) { /* Compares two NSTimes */
return 1;
}
-WSLUA_METAMETHOD NSTime__lt(lua_State* L) { /* Compares two NSTimes */
+WSLUA_METAMETHOD NSTime__lt(lua_State* L) { /* Compares two NSTimes. */
NSTime time1 = checkNSTime(L,1);
NSTime time2 = checkNSTime(L,2);
gboolean result = FALSE;
@@ -176,11 +176,11 @@ WSLUA_METAMETHOD NSTime__lt(lua_State* L) { /* Compares two NSTimes */
}
-/* WSLUA_ATTRIBUTE NSTime_secs RW The NSTime seconds */
+/* WSLUA_ATTRIBUTE NSTime_secs RW The NSTime seconds. */
WSLUA_ATTRIBUTE_NUMBER_GETTER(NSTime,secs);
WSLUA_ATTRIBUTE_NUMBER_SETTER(NSTime,secs,time_t);
-/* WSLUA_ATTRIBUTE NSTime_nsecs RW The NSTime nano seconds */
+/* WSLUA_ATTRIBUTE NSTime_nsecs RW The NSTime nano seconds. */
WSLUA_ATTRIBUTE_NUMBER_GETTER(NSTime,nsecs);
WSLUA_ATTRIBUTE_NUMBER_SETTER(NSTime,nsecs,int);
@@ -227,7 +227,7 @@ int NSTime_register(lua_State* L) {
return 0;
}
-WSLUA_CLASS_DEFINE(Address,FAIL_ON_NULL("Address"),NOP); /* Represents an address */
+WSLUA_CLASS_DEFINE(Address,FAIL_ON_NULL("Address"),NOP); /* Represents an address. */
WSLUA_CONSTRUCTOR Address_ip(lua_State* L) {
/* Creates an Address Object representing an IP address. */
@@ -243,7 +243,7 @@ WSLUA_CONSTRUCTOR Address_ip(lua_State* L) {
SET_ADDRESS(addr, AT_IPv4, 4, ip_addr);
pushAddress(L,addr);
- WSLUA_RETURN(1); /* The Address object */
+ WSLUA_RETURN(1); /* The Address object. */
}
#if 0
@@ -395,7 +395,7 @@ static int Address__gc(lua_State* L) {
return 0;
}
-WSLUA_METAMETHOD Address__eq(lua_State* L) { /* Compares two Addresses */
+WSLUA_METAMETHOD Address__eq(lua_State* L) { /* Compares two Addresses. */
Address addr1 = checkAddress(L,1);
Address addr2 = checkAddress(L,2);
gboolean result = FALSE;
@@ -408,7 +408,7 @@ WSLUA_METAMETHOD Address__eq(lua_State* L) { /* Compares two Addresses */
return 1;
}
-WSLUA_METAMETHOD Address__le(lua_State* L) { /* Compares two Addresses */
+WSLUA_METAMETHOD Address__le(lua_State* L) { /* Compares two Addresses. */
Address addr1 = checkAddress(L,1);
Address addr2 = checkAddress(L,2);
gboolean result = FALSE;
@@ -421,7 +421,7 @@ WSLUA_METAMETHOD Address__le(lua_State* L) { /* Compares two Addresses */
return 1;
}
-WSLUA_METAMETHOD Address__lt(lua_State* L) { /* Compares two Addresses */
+WSLUA_METAMETHOD Address__lt(lua_State* L) { /* Compares two Addresses. */
Address addr1 = checkAddress(L,1);
Address addr2 = checkAddress(L,2);
gboolean result = FALSE;
@@ -449,7 +449,7 @@ int Address_register(lua_State *L) {
}
-WSLUA_CLASS_DEFINE(Column,FAIL_ON_NULL("Column"),NOP); /* A Column in the packet list */
+WSLUA_CLASS_DEFINE(Column,FAIL_ON_NULL("Column"),NOP); /* A Column in the packet list. */
struct col_names_t {
const gchar* name;
@@ -539,7 +539,7 @@ WSLUA_METAMETHOD Column__tostring(lua_State *L) {
lua_pushstring(L, text ? text : "(nil)");
}
- WSLUA_RETURN(1); /* The column's string text (in parenthesis if not available) */
+ WSLUA_RETURN(1); /* The column's string text (in parenthesis if not available). */
}
/* Gets registered as metamethod automatically by WSLUA_REGISTER_CLASS */
@@ -558,7 +558,7 @@ static int Column__gc(lua_State* L) {
}
WSLUA_METHOD Column_clear(lua_State *L) {
- /* Clears a Column */
+ /* Clears a Column. */
Column c = checkColumn(L,1);
if (!(c->cinfo)) return 0;
@@ -569,8 +569,8 @@ WSLUA_METHOD Column_clear(lua_State *L) {
}
WSLUA_METHOD Column_set(lua_State *L) {
- /* Sets the text of a Column */
-#define WSLUA_ARG_Column_set_TEXT 2 /* The text to which to set the Column */
+ /* Sets the text of a Column. */
+#define WSLUA_ARG_Column_set_TEXT 2 /* The text to which to set the Column. */
Column c = checkColumn(L,1);
const gchar* s = luaL_checkstring(L,WSLUA_ARG_Column_set_TEXT);
@@ -588,8 +588,8 @@ WSLUA_METHOD Column_set(lua_State *L) {
}
WSLUA_METHOD Column_append(lua_State *L) {
- /* Appends text to a Column */
-#define WSLUA_ARG_Column_append_TEXT 2 /* The text to append to the Column */
+ /* Appends text to a Column. */
+#define WSLUA_ARG_Column_append_TEXT 2 /* The text to append to the Column. */
Column c = checkColumn(L,1);
const gchar* s = luaL_checkstring(L,WSLUA_ARG_Column_append_TEXT);
@@ -607,8 +607,8 @@ WSLUA_METHOD Column_append(lua_State *L) {
}
WSLUA_METHOD Column_prepend(lua_State *L) {
- /* Prepends text to a Column */
-#define WSLUA_ARG_Column_prepend_TEXT 2 /* The text to prepend to the Column */
+ /* Prepends text to a Column. */
+#define WSLUA_ARG_Column_prepend_TEXT 2 /* The text to prepend to the Column. */
Column c = checkColumn(L,1);
const gchar* s = luaL_checkstring(L,WSLUA_ARG_Column_prepend_TEXT);
@@ -626,7 +626,10 @@ WSLUA_METHOD Column_prepend(lua_State *L) {
}
WSLUA_METHOD Column_fence(lua_State *L) {
- /* Sets Column text fence, to prevent overwriting */
+ /* Sets Column text fence, to prevent overwriting.
+
+ @since 1.10.6
+ */
Column c = checkColumn(L,1);
if (c->cinfo)
@@ -636,7 +639,10 @@ WSLUA_METHOD Column_fence(lua_State *L) {
}
WSLUA_METHOD Column_clear_fence(lua_State *L) {
- /* Clear Column text fence */
+ /* Clear Column text fence.
+
+ @since 1.11.3
+ */
Column c = checkColumn(L,1);
if (c->cinfo)
@@ -670,10 +676,6 @@ int Column_register(lua_State *L) {
}
-
-
-
-
WSLUA_CLASS_DEFINE(Columns,NOP,NOP);
/* The Columns of the packet list. */
@@ -688,9 +690,9 @@ WSLUA_METAMETHOD Columns__tostring(lua_State *L) {
* API docs to see this metamethod as a method, but oh well.
*/
WSLUA_METAMETHOD Columns__newindex(lua_State *L) {
- /* Sets the text of a specific column */
-#define WSLUA_ARG_Columns__newindex_COLUMN 2 /* The name of the column to set */
-#define WSLUA_ARG_Columns__newindex_TEXT 3 /* The text for the column */
+ /* Sets the text of a specific column. */
+#define WSLUA_ARG_Columns__newindex_COLUMN 2 /* The name of the column to set. */
+#define WSLUA_ARG_Columns__newindex_TEXT 3 /* The text for the column. */
Columns cols = checkColumns(L,1);
const struct col_names_t* cn;
const char* colname;
@@ -717,7 +719,7 @@ WSLUA_METAMETHOD Columns__newindex(lua_State *L) {
}
WSLUA_METAMETHOD Columns__index(lua_State *L) {
- /* Gets a specific Column */
+ /* Gets a specific Column. */
Columns cols = checkColumns(L,1);
const struct col_names_t* cn;
const char* colname = luaL_checkstring(L,2);
@@ -788,7 +790,7 @@ WSLUA_CLASS_DEFINE(PrivateTable,FAIL_ON_NULL_OR_EXPIRED("PrivateTable"),NOP);
/* PrivateTable represents the pinfo->private_table. */
WSLUA_METAMETHOD PrivateTable__tostring(lua_State* L) {
- /* Gets debugging type information about the private table */
+ /* Gets debugging type information about the private table. */
PrivateTable priv = toPrivateTable(L,1);
GString *key_string;
GList *keys, *key;
@@ -815,7 +817,7 @@ WSLUA_METAMETHOD PrivateTable__tostring(lua_State* L) {
}
static int PrivateTable__index(lua_State* L) {
- /* Gets the text of a specific entry */
+ /* Gets the text of a specific entry. */
PrivateTable priv = checkPrivateTable(L,1);
const gchar* name = luaL_checkstring(L,2);
const gchar* string;
@@ -832,7 +834,7 @@ static int PrivateTable__index(lua_State* L) {
}
static int PrivateTable__newindex(lua_State* L) {
- /* Sets the text of a specific entry */
+ /* Sets the text of a specific entry. */
PrivateTable priv = checkPrivateTable(L,1);
const gchar* name = luaL_checkstring(L,2);
const gchar* string = NULL;
@@ -889,7 +891,7 @@ int PrivateTable_register(lua_State* L) {
WSLUA_CLASS_DEFINE(Pinfo,FAIL_ON_NULL_OR_EXPIRED("Pinfo"),NOP);
-/* Packet information */
+/* Packet information. */
static int Pinfo__tostring(lua_State *L) { lua_pushstring(L,"a Pinfo"); return 1; }
@@ -937,104 +939,104 @@ lua_delta_nstime_to_sec(const Pinfo pinfo, const frame_data *fd, guint32 prev_nu
}
-/* WSLUA_ATTRIBUTE Pinfo_visited RO Whether this packet hass been already visited */
+/* WSLUA_ATTRIBUTE Pinfo_visited RO Whether this packet has been already visited. */
PINFO_NAMED_BOOLEAN_GETTER(visited,fd->flags.visited);
-/* WSLUA_ATTRIBUTE Pinfo_number RO The number of this packet in the current file */
+/* WSLUA_ATTRIBUTE Pinfo_number RO The number of this packet in the current file. */
PINFO_NAMED_NUMBER_GETTER(number,fd->num);
-/* WSLUA_ATTRIBUTE Pinfo_len RO The length of the frame */
+/* WSLUA_ATTRIBUTE Pinfo_len RO The length of the frame. */
PINFO_NAMED_NUMBER_GETTER(len,fd->pkt_len);
-/* WSLUA_ATTRIBUTE Pinfo_caplen RO The captured length of the frame */
+/* WSLUA_ATTRIBUTE Pinfo_caplen RO The captured length of the frame. */
PINFO_NAMED_NUMBER_GETTER(caplen,fd->cap_len);
-/* WSLUA_ATTRIBUTE Pinfo_abs_ts RO When the packet was captured */
+/* WSLUA_ATTRIBUTE Pinfo_abs_ts RO When the packet was captured. */
WSLUA_ATTRIBUTE_BLOCK_NUMBER_GETTER(Pinfo,abs_ts,lua_nstime_to_sec(&obj->ws_pinfo->fd->abs_ts));
-/* WSLUA_ATTRIBUTE Pinfo_rel_ts RO Number of seconds passed since beginning of capture */
+/* WSLUA_ATTRIBUTE Pinfo_rel_ts RO Number of seconds passed since beginning of capture. */
WSLUA_ATTRIBUTE_BLOCK_NUMBER_GETTER(Pinfo,rel_ts,lua_nstime_to_sec(&obj->ws_pinfo->rel_ts));
-/* WSLUA_ATTRIBUTE Pinfo_delta_ts RO Number of seconds passed since the last captured packet */
+/* WSLUA_ATTRIBUTE Pinfo_delta_ts RO Number of seconds passed since the last captured packet. */
WSLUA_ATTRIBUTE_BLOCK_NUMBER_GETTER(Pinfo,delta_ts,lua_delta_nstime_to_sec(obj, obj->ws_pinfo->fd, obj->ws_pinfo->fd->num - 1));
-/* WSLUA_ATTRIBUTE Pinfo_delta_dis_ts RO Number of seconds passed since the last displayed packet */
+/* WSLUA_ATTRIBUTE Pinfo_delta_dis_ts RO Number of seconds passed since the last displayed packet. */
WSLUA_ATTRIBUTE_BLOCK_NUMBER_GETTER(Pinfo,delta_dis_ts,lua_delta_nstime_to_sec(obj, obj->ws_pinfo->fd, obj->ws_pinfo->fd->prev_dis_num));
-/* WSLUA_ATTRIBUTE Pinfo_ipproto RO IP Protocol id */
+/* WSLUA_ATTRIBUTE Pinfo_ipproto RO IP Protocol id. */
PINFO_NUMBER_GETTER(ipproto);
-/* WSLUA_ATTRIBUTE Pinfo_circuit_id RW For circuit based protocols */
+/* WSLUA_ATTRIBUTE Pinfo_circuit_id RW For circuit based protocols. */
PINFO_NUMBER_GETTER(circuit_id);
PINFO_NUMBER_SETTER(circuit_id,guint32);
-/* WSLUA_ATTRIBUTE Pinfo_curr_proto RO Which Protocol are we dissecting */
+/* WSLUA_ATTRIBUTE Pinfo_curr_proto RO Which Protocol are we dissecting. */
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(Pinfo,curr_proto,ws_pinfo->current_proto);
-/* WSLUA_ATTRIBUTE Pinfo_can_desegment RW Set if this segment could be desegmented */
+/* WSLUA_ATTRIBUTE Pinfo_can_desegment RW Set if this segment could be desegmented. */
PINFO_NUMBER_GETTER(can_desegment);
PINFO_NUMBER_SETTER(can_desegment,guint16);
-/* WSLUA_ATTRIBUTE Pinfo_desegment_len RW Estimated number of additional bytes required for completing the PDU */
+/* WSLUA_ATTRIBUTE Pinfo_desegment_len RW Estimated number of additional bytes required for completing the PDU. */
PINFO_NUMBER_GETTER(desegment_len);
PINFO_NUMBER_SETTER(desegment_len,guint32);
-/* WSLUA_ATTRIBUTE Pinfo_desegment_offset RW Offset in the tvbuff at which the dissector will continue processing when next called*/
+/* WSLUA_ATTRIBUTE Pinfo_desegment_offset RW Offset in the tvbuff at which the dissector will continue processing when next called. */
PINFO_NUMBER_GETTER(desegment_offset);
PINFO_NUMBER_SETTER(desegment_offset,int);
-/* WSLUA_ATTRIBUTE Pinfo_private_data RO Access to private data */
+/* WSLUA_ATTRIBUTE Pinfo_private_data RO Access to private data. */
WSLUA_ATTRIBUTE_GET(Pinfo,private_data, {lua_pushlightuserdata(L,(void *)(obj->ws_pinfo->private_data));});
-/* WSLUA_ATTRIBUTE Pinfo_fragmented RO If the protocol is only a fragment */
+/* WSLUA_ATTRIBUTE Pinfo_fragmented RO If the protocol is only a fragment. */
PINFO_NAMED_BOOLEAN_GETTER(fragmented,fragmented);
-/* WSLUA_ATTRIBUTE Pinfo_in_error_pkt RO If we're inside an error packet */
+/* WSLUA_ATTRIBUTE Pinfo_in_error_pkt RO If we're inside an error packet. */
PINFO_NAMED_BOOLEAN_GETTER(in_error_pkt,flags.in_error_pkt);
-/* WSLUA_ATTRIBUTE Pinfo_match_uint RO Matched uint for calling subdissector from table */
+/* WSLUA_ATTRIBUTE Pinfo_match_uint RO Matched uint for calling subdissector from table. */
PINFO_NUMBER_GETTER(match_uint);
-/* WSLUA_ATTRIBUTE Pinfo_match_string RO Matched string for calling subdissector from table */
+/* WSLUA_ATTRIBUTE Pinfo_match_string RO Matched string for calling subdissector from table. */
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(Pinfo,match_string,ws_pinfo->match_string);
-/* WSLUA_ATTRIBUTE Pinfo_port_type RW Type of Port of .src_port and .dst_port */
+/* WSLUA_ATTRIBUTE Pinfo_port_type RW Type of Port of .src_port and .dst_port. */
PINFO_NAMED_NUMBER_GETTER(port_type,ptype);
-/* WSLUA_ATTRIBUTE Pinfo_src_port RW Source Port of this Packet */
+/* WSLUA_ATTRIBUTE Pinfo_src_port RW Source Port of this Packet. */
PINFO_NAMED_NUMBER_GETTER(src_port,srcport);
PINFO_NAMED_NUMBER_SETTER(src_port,srcport,guint32);
-/* WSLUA_ATTRIBUTE Pinfo_dst_port RW Source Address of this Packet */
+/* WSLUA_ATTRIBUTE Pinfo_dst_port RW Source Address of this Packet. */
PINFO_NAMED_NUMBER_GETTER(dst_port,destport);
PINFO_NAMED_NUMBER_SETTER(dst_port,destport,guint32);
-/* WSLUA_ATTRIBUTE Pinfo_dl_src RW Data Link Source Address of this Packet */
+/* WSLUA_ATTRIBUTE Pinfo_dl_src RW Data Link Source Address of this Packet. */
PINFO_ADDRESS_GETTER(dl_src);
PINFO_ADDRESS_SETTER(dl_src);
-/* WSLUA_ATTRIBUTE Pinfo_dl_dst RW Data Link Destination Address of this Packet */
+/* WSLUA_ATTRIBUTE Pinfo_dl_dst RW Data Link Destination Address of this Packet. */
PINFO_ADDRESS_GETTER(dl_dst);
PINFO_ADDRESS_SETTER(dl_dst);
-/* WSLUA_ATTRIBUTE Pinfo_net_src RW Network Layer Source Address of this Packet */
+/* WSLUA_ATTRIBUTE Pinfo_net_src RW Network Layer Source Address of this Packet. */
PINFO_ADDRESS_GETTER(net_src);
PINFO_ADDRESS_SETTER(net_src);
-/* WSLUA_ATTRIBUTE Pinfo_net_dst RW Network Layer Destination Address of this Packet */
+/* WSLUA_ATTRIBUTE Pinfo_net_dst RW Network Layer Destination Address of this Packet. */
PINFO_ADDRESS_GETTER(net_dst);
PINFO_ADDRESS_SETTER(net_dst);
-/* WSLUA_ATTRIBUTE Pinfo_src RW Source Address of this Packet */
+/* WSLUA_ATTRIBUTE Pinfo_src RW Source Address of this Packet. */
PINFO_ADDRESS_GETTER(src);
PINFO_ADDRESS_SETTER(src);
-/* WSLUA_ATTRIBUTE Pinfo_dst RW Destination Address of this Packet */
+/* WSLUA_ATTRIBUTE Pinfo_dst RW Destination Address of this Packet. */
PINFO_ADDRESS_GETTER(dst);
PINFO_ADDRESS_SETTER(dst);
-/* WSLUA_ATTRIBUTE Pinfo_match RO Port/Data we are matching */
+/* WSLUA_ATTRIBUTE Pinfo_match RO Port/Data we are matching. */
static int Pinfo_get_match(lua_State *L) {
Pinfo pinfo = checkPinfo(L,1);
@@ -1047,8 +1049,8 @@ static int Pinfo_get_match(lua_State *L) {
return 1;
}
-/* WSLUA_ATTRIBUTE Pinfo_columns RO Accesss to the packet list columns */
-/* WSLUA_ATTRIBUTE Pinfo_cols RO Accesss to the packet list columns (equivalent to pinfo.columns) */
+/* WSLUA_ATTRIBUTE Pinfo_columns RO Accesss to the packet list columns. */
+/* WSLUA_ATTRIBUTE Pinfo_cols RO Accesss to the packet list columns (equivalent to pinfo.columns). */
static int Pinfo_get_columns(lua_State *L) {
Columns cols = NULL;
Pinfo pinfo = checkPinfo(L,1);
@@ -1069,7 +1071,7 @@ static int Pinfo_get_columns(lua_State *L) {
return 1;
}
-/* WSLUA_ATTRIBUTE Pinfo_private RO Access to the private table entries */
+/* WSLUA_ATTRIBUTE Pinfo_private RO Access to the private table entries. */
static int Pinfo_get_private(lua_State *L) {
PrivateTable priv = NULL;
Pinfo pinfo = checkPinfo(L,1);
@@ -1097,7 +1099,7 @@ static int Pinfo_get_private(lua_State *L) {
return 1;
}
-/* WSLUA_ATTRIBUTE Pinfo_hi RW higher Address of this Packet */
+/* WSLUA_ATTRIBUTE Pinfo_hi RW higher Address of this Packet. */
static int Pinfo_get_hi(lua_State *L) {
Pinfo pinfo = checkPinfo(L,1);
Address addr;
@@ -1113,7 +1115,7 @@ static int Pinfo_get_hi(lua_State *L) {
return 1;
}
-/* WSLUA_ATTRIBUTE Pinfo_lo RO lower Address of this Packet */
+/* WSLUA_ATTRIBUTE Pinfo_lo RO lower Address of this Packet. */
static int Pinfo_get_lo(lua_State *L) {
Pinfo pinfo = checkPinfo(L,1);
Address addr;
@@ -1129,7 +1131,7 @@ static int Pinfo_get_lo(lua_State *L) {
return 1;
}
-/* WSLUA_ATTRIBUTE Pinfo_conversation WO sets the packet conversation to the given Proto object */
+/* WSLUA_ATTRIBUTE Pinfo_conversation WO sets the packet conversation to the given Proto object. */
static int Pinfo_set_conversation(lua_State *L) {
Pinfo pinfo = checkPinfo(L,1);
Proto proto = checkProto(L,2);
diff --git a/epan/wslua/wslua_proto.c b/epan/wslua/wslua_proto.c
index 172e049c40..6d08055df9 100644
--- a/epan/wslua/wslua_proto.c
+++ b/epan/wslua/wslua_proto.c
@@ -29,7 +29,20 @@
#include <epan/emem.h>
-/* WSLUA_MODULE Proto Functions for writing dissectors */
+/* WSLUA_MODULE Proto Functions for new protocols and dissectors
+
+ The classes and functions in this chapter allow Lua scripts to create new
+ protocols for Wireshark. `Proto` protocol objects can have `Pref` preferences,
+ `ProtoField` fields for filterable values that can be displayed in a details
+ view tree, functions for dissecting the new protocol, and so on.
+
+ The dissection function can be hooked into existing protocol tables through
+ `DissectorTables` so that the new protocol dissector function gets called by that
+ protocol, and the new dissector can itself call on other, already existing protocol
+ dissectors by retrieving and calling the `Dissector` object. A `Proto` dissector
+ can also be used as a post-dissector, at the end of every frame's dissection, or
+ as a heuristic dissector.
+*/
#include "wslua.h"
@@ -158,52 +171,58 @@ static int new_pref(lua_State* L, pref_type_t type) {
}
WSLUA_CONSTRUCTOR Pref_bool(lua_State* L) {
- /* Creates a boolean preference to be added to a Protocol's prefs table. */
-#define WSLUA_ARG_Pref_bool_LABEL 1 /* The Label (text in the right side of the preference input) for this preference */
-#define WSLUA_ARG_Pref_bool_DEFAULT 2 /* The default value for this preference */
-#define WSLUA_ARG_Pref_bool_DESCR 3 /* A description of what this preference is */
+ /* Creates a boolean preference to be added to a `Proto.prefs` Lua table. */
+#define WSLUA_ARG_Pref_bool_LABEL 1 /* The Label (text in the right side of the
+ preference input) for this preference. */
+#define WSLUA_ARG_Pref_bool_DEFAULT 2 /* The default value for this preference. */
+#define WSLUA_ARG_Pref_bool_DESCR 3 /* A description of what this preference is. */
return new_pref(L,PREF_BOOL);
}
WSLUA_CONSTRUCTOR Pref_uint(lua_State* L) {
- /* Creates an (unsigned) integer preference to be added to a Protocol's prefs table. */
-#define WSLUA_ARG_Pref_uint_LABEL 1 /* The Label (text in the right side of the preference input) for this preference */
-#define WSLUA_ARG_Pref_uint_DEFAULT 2 /* The default value for this preference */
-#define WSLUA_ARG_Pref_uint_DESCR 3 /* A description of what this preference is */
+ /* Creates an (unsigned) integer preference to be added to a `Proto.prefs` Lua table. */
+#define WSLUA_ARG_Pref_uint_LABEL 1 /* The Label (text in the right side of the
+ preference input) for this preference. */
+#define WSLUA_ARG_Pref_uint_DEFAULT 2 /* The default value for this preference. */
+#define WSLUA_ARG_Pref_uint_DESCR 3 /* A description of what this preference is. */
return new_pref(L,PREF_UINT);
}
WSLUA_CONSTRUCTOR Pref_string(lua_State* L) {
- /* Creates a string preference to be added to a Protocol's prefs table. */
-#define WSLUA_ARG_Pref_string_LABEL 1 /* The Label (text in the right side of the preference input) for this preference */
-#define WSLUA_ARG_Pref_string_DEFAULT 2 /* The default value for this preference */
-#define WSLUA_ARG_Pref_string_DESCR 3 /* A description of what this preference is */
+ /* Creates a string preference to be added to a `Proto.prefs` Lua table. */
+#define WSLUA_ARG_Pref_string_LABEL 1 /* The Label (text in the right side of the
+ preference input) for this preference. */
+#define WSLUA_ARG_Pref_string_DEFAULT 2 /* The default value for this preference. */
+#define WSLUA_ARG_Pref_string_DESCR 3 /* A description of what this preference is. */
return new_pref(L,PREF_STRING);
}
WSLUA_CONSTRUCTOR Pref_enum(lua_State* L) {
- /* Creates an enum preference to be added to a Protocol's prefs table. */
-#define WSLUA_ARG_Pref_enum_LABEL 1 /* The Label (text in the right side of the preference input) for this preference */
-#define WSLUA_ARG_Pref_enum_DEFAULT 2 /* The default value for this preference */
-#define WSLUA_ARG_Pref_enum_DESCR 3 /* A description of what this preference is */
-#define WSLUA_ARG_Pref_enum_ENUM 4 /* A enum table */
-#define WSLUA_ARG_Pref_enum_RADIO 5 /* Radio button (true) or Combobox (false) */
+ /* Creates an enum preference to be added to a `Proto.prefs` Lua table. */
+#define WSLUA_ARG_Pref_enum_LABEL 1 /* The Label (text in the right side of the
+ preference input) for this preference. */
+#define WSLUA_ARG_Pref_enum_DEFAULT 2 /* The default value for this preference. */
+#define WSLUA_ARG_Pref_enum_DESCR 3 /* A description of what this preference is. */
+#define WSLUA_ARG_Pref_enum_ENUM 4 /* An enum Lua table. */
+#define WSLUA_ARG_Pref_enum_RADIO 5 /* Radio button (true) or Combobox (false). */
return new_pref(L,PREF_ENUM);
}
WSLUA_CONSTRUCTOR Pref_range(lua_State* L) {
- /* Creates a range preference to be added to a Protocol's prefs table. */
-#define WSLUA_ARG_Pref_range_LABEL 1 /* The Label (text in the right side of the preference input) for this preference */
-#define WSLUA_ARG_Pref_range_DEFAULT 2 /* The default value for this preference, e.g., "53", "10-30", or "10-30,53,55,100-120" */
-#define WSLUA_ARG_Pref_range_DESCR 3 /* A description of what this preference is */
-#define WSLUA_ARG_Pref_range_MAX 4 /* The maximum value */
+ /* Creates a range preference to be added to a `Proto.prefs` Lua table. */
+#define WSLUA_ARG_Pref_range_LABEL 1 /* The Label (text in the right side of the preference
+ input) for this preference. */
+#define WSLUA_ARG_Pref_range_DEFAULT 2 /* The default value for this preference, e.g., "53",
+ "10-30", or "10-30,53,55,100-120". */
+#define WSLUA_ARG_Pref_range_DESCR 3 /* A description of what this preference is. */
+#define WSLUA_ARG_Pref_range_MAX 4 /* The maximum value. */
return new_pref(L,PREF_RANGE);
}
WSLUA_CONSTRUCTOR Pref_statictext(lua_State* L) {
- /* Creates a static text preference to be added to a Protocol's prefs table. */
-#define WSLUA_ARG_Pref_statictext_LABEL 1 /* The static text */
-#define WSLUA_ARG_Pref_statictext_DESCR 2 /* The static text description */
+ /* Creates a static text string to be added to a `Proto.prefs` Lua table. */
+#define WSLUA_ARG_Pref_statictext_LABEL 1 /* The static text. */
+#define WSLUA_ARG_Pref_statictext_DESCR 2 /* The static text description. */
return new_pref(L,PREF_STATIC_TEXT);
}
@@ -263,12 +282,12 @@ WSLUA_REGISTER Pref_register(lua_State* L) {
return 0;
}
-WSLUA_CLASS_DEFINE(Prefs,NOP,NOP); /* The table of preferences of a protocol */
+WSLUA_CLASS_DEFINE(Prefs,NOP,NOP); /* The table of preferences of a protocol. */
WSLUA_METAMETHOD Prefs__newindex(lua_State* L) {
- /* Creates a new preference */
-#define WSLUA_ARG_Prefs__newindex_NAME 2 /* The abbreviation of this preference */
-#define WSLUA_ARG_Prefs__newindex_PREF 3 /* A valid but still unassigned Pref object */
+ /* Creates a new preference. */
+#define WSLUA_ARG_Prefs__newindex_NAME 2 /* The abbreviation of this preference. */
+#define WSLUA_ARG_Prefs__newindex_PREF 3 /* A valid but still unassigned Pref object. */
Pref prefs_p = checkPrefs(L,1);
const gchar* name = luaL_checkstring(L,WSLUA_ARG_Prefs__newindex_NAME);
@@ -313,7 +332,8 @@ WSLUA_METAMETHOD Prefs__newindex(lua_State* L) {
if (!isascii((guchar)*c) ||
(!islower((guchar)*c) && !isdigit((guchar)*c) && *c != '_' && *c != '.'))
{
- luaL_error(L,"illegal preference name \"%s\", only lower-case ASCII letters, numbers, underscores and dots may be used",name);
+ luaL_error(L,"illegal preference name \"%s\", only lower-case ASCII letters, "
+ "numbers, underscores and dots may be used", name);
return 0;
}
}
@@ -326,7 +346,8 @@ WSLUA_METAMETHOD Prefs__newindex(lua_State* L) {
pref->label = g_strdup(name);
if (!prefs_p->proto->prefs_module) {
- prefs_p->proto->prefs_module = prefs_register_protocol(prefs_p->proto->hfid, wslua_prefs_changed);
+ prefs_p->proto->prefs_module = prefs_register_protocol(prefs_p->proto->hfid,
+ wslua_prefs_changed);
}
switch(pref->type) {
@@ -392,8 +413,8 @@ WSLUA_METAMETHOD Prefs__newindex(lua_State* L) {
}
WSLUA_METAMETHOD Prefs__index(lua_State* L) {
- /* Get the value of a preference setting */
-#define WSLUA_ARG_Prefs__index_NAME 2 /* The abbreviation of this preference */
+ /* Get the value of a preference setting. */
+#define WSLUA_ARG_Prefs__index_NAME 2 /* The abbreviation of this preference. */
Pref prefs_p = checkPrefs(L,1);
const gchar* name = luaL_checkstring(L,WSLUA_ARG_Prefs__index_NAME);
@@ -417,7 +438,7 @@ WSLUA_METAMETHOD Prefs__index(lua_State* L) {
case PREF_RANGE: lua_pushstring(L,range_convert_range(prefs_p->value.r)); break;
default: WSLUA_ERROR(Prefs__index,"Unknow Pref type"); return 0;
}
- WSLUA_RETURN(1); /* The current value of the preference */
+ WSLUA_RETURN(1); /* The current value of the preference. */
}
} while (( prefs_p = prefs_p->next ));
@@ -443,7 +464,7 @@ WSLUA_REGISTER Prefs_register(lua_State* L) {
}
WSLUA_CLASS_DEFINE(ProtoField,FAIL_ON_NULL("null ProtoField"),NOP);
- /* A Protocol field (to be used when adding items to the dissection tree) */
+ /* A Protocol field (to be used when adding items to the dissection tree). */
static const wslua_ft_types_t ftenums[] = {
{"ftypes.BOOLEAN", FT_BOOLEAN},
@@ -699,19 +720,27 @@ static const gchar* check_field_name(lua_State* L, const int abbr_idx, const enu
return abbr;
}
-WSLUA_CONSTRUCTOR ProtoField_new(lua_State* L) { /* Creates a new field to be used in a protocol. */
-#define WSLUA_ARG_ProtoField_new_NAME 1 /* Actual name of the field (the string that appears in the tree). */
-#define WSLUA_ARG_ProtoField_new_ABBR 2 /* Filter name of the field (the string that is used in filters). */
-#define WSLUA_ARG_ProtoField_new_TYPE 3 /* Field Type: one of ftypes.BOOLEAN,
- ftypes.UINT8, ftypes.UINT16, ftypes.UINT24, ftypes.UINT32, ftypes.UINT64, ftypes.INT8, ftypes.INT16
- ftypes.INT24, ftypes.INT32, ftypes.INT64, ftypes.FLOAT, ftypes.DOUBLE, ftypes.ABSOLUTE_TIME
- ftypes.RELATIVE_TIME, ftypes.STRING, ftypes.STRINGZ, ftypes.UINT_STRING, ftypes.ETHER, ftypes.BYTES
- ftypes.UINT_BYTES, ftypes.IPv4, ftypes.IPv6, ftypes.IPXNET, ftypes.FRAMENUM, ftypes.PCRE, ftypes.GUID
- ftypes.OID, ftypes.EUI64 */
-#define WSLUA_OPTARG_ProtoField_new_VALUESTRING 4 /* A table containing the text that corresponds to the values */
-#define WSLUA_OPTARG_ProtoField_new_BASE 5 /* The representation: one of base.NONE, base.DEC, base.HEX, base.OCT, base.DEC_HEX, base.HEX_DEC */
-#define WSLUA_OPTARG_ProtoField_new_MASK 6 /* The bitmask to be used. */
-#define WSLUA_OPTARG_ProtoField_new_DESCR 7 /* The description of the field. */
+WSLUA_CONSTRUCTOR ProtoField_new(lua_State* L) {
+ /* Creates a new `ProtoField` object to be used for a protocol field. */
+#define WSLUA_ARG_ProtoField_new_NAME 1 /* Actual name of the field (the string that
+ appears in the tree). */
+#define WSLUA_ARG_ProtoField_new_ABBR 2 /* Filter name of the field (the string that
+ is used in filters). */
+#define WSLUA_ARG_ProtoField_new_TYPE 3 /* Field Type: one of: `ftypes.BOOLEAN`, `ftypes.UINT8`,
+ `ftypes.UINT16`, `ftypes.UINT24`, `ftypes.UINT32`, `ftypes.UINT64`, `ftypes.INT8`,
+ `ftypes.INT16`, `ftypes.INT24`, `ftypes.INT32`, `ftypes.INT64`, `ftypes.FLOAT`,
+ `ftypes.DOUBLE` , `ftypes.ABSOLUTE_TIME`, `ftypes.RELATIVE_TIME`, `ftypes.STRING`,
+ `ftypes.STRINGZ`, `ftypes.UINT_STRING`, `ftypes.ETHER`, `ftypes.BYTES`,
+ `ftypes.UINT_BYTES`, `ftypes.IPv4`, `ftypes.IPv6`, `ftypes.IPXNET`, `ftypes.FRAMENUM`,
+ `ftypes.PCRE`, `ftypes.GUID`, `ftypes.OID`, or `ftypes.EUI64`.
+ */
+#define WSLUA_OPTARG_ProtoField_new_VALUESTRING 4 /* A table containing the text that
+ corresponds to the values. */
+#define WSLUA_OPTARG_ProtoField_new_BASE 5 /* The representation, one of: `base.NONE`, `base.DEC`,
+ `base.HEX`, `base.OCT`, `base.DEC_HEX`, or
+ `base.HEX_DEC`. */
+#define WSLUA_OPTARG_ProtoField_new_MASK 6 /* The bitmask to be used. */
+#define WSLUA_OPTARG_ProtoField_new_DESCR 7 /* The description of the field. */
ProtoField f;
int nargs = lua_gettop(L);
@@ -864,7 +893,7 @@ WSLUA_CONSTRUCTOR ProtoField_new(lua_State* L) { /* Creates a new field to be us
pushProtoField(L,f);
- WSLUA_RETURN(1); /* The newly created ProtoField object */
+ WSLUA_RETURN(1); /* The newly created ProtoField object. */
}
static int ProtoField_integer(lua_State* L, enum ftenum type) {
@@ -928,104 +957,104 @@ static int ProtoField_integer(lua_State* L, enum ftenum type) {
}
#define PROTOFIELD_INTEGER(lower,FT) static int ProtoField_##lower(lua_State* L) { return ProtoField_integer(L,FT); }
-/* _WSLUA_CONSTRUCTOR_ ProtoField_uint8 */
-/* WSLUA_ARG_Protofield_uint8_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_uint8_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_uint8_BASE One of base.DEC, base.HEX or base.OCT */
-/* WSLUA_OPTARG_Protofield_uint8_VALUESTRING A table containing the text that corresponds to the values */
-/* WSLUA_OPTARG_Protofield_uint8_MASK Integer mask of this field */
-/* WSLUA_OPTARG_Protofield_uint8_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_uint16 */
-/* WSLUA_ARG_Protofield_uint16_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_uint16_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_uint16_BASE One of base.DEC, base.HEX or base.OCT */
-/* WSLUA_OPTARG_Protofield_uint16_VALUESTRING A table containing the text that corresponds to the values */
-/* WSLUA_OPTARG_Protofield_uint16_MASK Integer mask of this field */
-/* WSLUA_OPTARG_Protofield_uint16_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_uint24 */
-/* WSLUA_ARG_Protofield_uint24_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_uint24_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_uint24_BASE One of base.DEC, base.HEX or base.OCT */
-/* WSLUA_OPTARG_Protofield_uint24_VALUESTRING A table containing the text that corresponds to the values */
-/* WSLUA_OPTARG_Protofield_uint24_MASK Integer mask of this field */
-/* WSLUA_OPTARG_Protofield_uint24_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_uint32 */
-/* WSLUA_ARG_Protofield_uint32_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_uint32_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_uint32_BASE One of base.DEC, base.HEX or base.OCT */
-/* WSLUA_OPTARG_Protofield_uint32_VALUESTRING A table containing the text that corresponds to the values */
-/* WSLUA_OPTARG_Protofield_uint32_MASK Integer mask of this field */
-/* WSLUA_OPTARG_Protofield_uint32_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_uint64 */
-/* WSLUA_ARG_Protofield_uint64_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_uint64_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_uint64_BASE One of base.DEC, base.HEX or base.OCT */
-/* WSLUA_OPTARG_Protofield_uint64_VALUESTRING A table containing the text that corresponds to the values */
-/* WSLUA_OPTARG_Protofield_uint64_MASK Integer mask of this field */
-/* WSLUA_OPTARG_Protofield_uint64_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_int8 */
-/* WSLUA_ARG_Protofield_int8_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_int8_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_int8_BASE One of base.DEC, base.HEX or base.OCT */
-/* WSLUA_OPTARG_Protofield_int8_VALUESTRING A table containing the text that corresponds to the values */
-/* WSLUA_OPTARG_Protofield_int8_MASK Integer mask of this field */
-/* WSLUA_OPTARG_Protofield_int8_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_int16 */
-/* WSLUA_ARG_Protofield_int16_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_int16_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_int16_BASE One of base.DEC, base.HEX or base.OCT */
-/* WSLUA_OPTARG_Protofield_int16_VALUESTRING A table containing the text that corresponds to the values */
-/* WSLUA_OPTARG_Protofield_int16_MASK Integer mask of this field */
-/* WSLUA_OPTARG_Protofield_int16_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_int24 */
-/* WSLUA_ARG_Protofield_int24_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_int24_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_int24_BASE One of base.DEC, base.HEX or base.OCT */
-/* WSLUA_OPTARG_Protofield_int24_VALUESTRING A table containing the text that corresponds to the values */
-/* WSLUA_OPTARG_Protofield_int24_MASK Integer mask of this field */
-/* WSLUA_OPTARG_Protofield_int24_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_int32 */
-/* WSLUA_ARG_Protofield_int32_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_int32_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_int32_BASE One of base.DEC, base.HEX or base.OCT */
-/* WSLUA_OPTARG_Protofield_int32_VALUESTRING A table containing the text that corresponds to the values */
-/* WSLUA_OPTARG_Protofield_int32_MASK Integer mask of this field */
-/* WSLUA_OPTARG_Protofield_int32_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_int64 */
-/* WSLUA_ARG_Protofield_int64_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_int64_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_int64_BASE One of base.DEC, base.HEX or base.OCT */
-/* WSLUA_OPTARG_Protofield_int64_VALUESTRING A table containing the text that corresponds to the values */
-/* WSLUA_OPTARG_Protofield_int64_MASK Integer mask of this field */
-/* WSLUA_OPTARG_Protofield_int64_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_framenum A frame number (for hyperlinks between frames) */
-/* WSLUA_ARG_Protofield_framenum_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_framenum_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_framenum_BASE One of base.DEC, base.HEX or base.OCT */
-/* WSLUA_OPTARG_Protofield_framenum_VALUESTRING A table containing the text that corresponds to the values */
-/* WSLUA_OPTARG_Protofield_framenum_MASK Integer mask of this field */
-/* WSLUA_OPTARG_Protofield_framenum_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
+/* _WSLUA_CONSTRUCTOR_ ProtoField_uint8 Creates a `ProtoField` of an unsigned 8-bit integer (i.e., a byte). */
+/* WSLUA_ARG_Protofield_uint8_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_uint8_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_uint8_BASE One of `base.DEC`, `base.HEX` or `base.OCT`. */
+/* WSLUA_OPTARG_Protofield_uint8_VALUESTRING A table containing the text that corresponds to the values. */
+/* WSLUA_OPTARG_Protofield_uint8_MASK Integer mask of this field. */
+/* WSLUA_OPTARG_Protofield_uint8_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_uint16 Creates a `ProtoField` of an unsigned 16-bit integer. */
+/* WSLUA_ARG_Protofield_uint16_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_uint16_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_uint16_BASE One of `base.DEC`, `base.HEX` or `base.OCT`. */
+/* WSLUA_OPTARG_Protofield_uint16_VALUESTRING A table containing the text that corresponds to the values. */
+/* WSLUA_OPTARG_Protofield_uint16_MASK Integer mask of this field. */
+/* WSLUA_OPTARG_Protofield_uint16_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_uint24 Creates a `ProtoField` of an unsigned 24-bit integer. */
+/* WSLUA_ARG_Protofield_uint24_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_uint24_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_uint24_BASE One of `base.DEC`, `base.HEX` or `base.OCT`. */
+/* WSLUA_OPTARG_Protofield_uint24_VALUESTRING A table containing the text that corresponds to the values. */
+/* WSLUA_OPTARG_Protofield_uint24_MASK Integer mask of this field. */
+/* WSLUA_OPTARG_Protofield_uint24_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_uint32 Creates a `ProtoField` of an unsigned 32-bit integer. */
+/* WSLUA_ARG_Protofield_uint32_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_uint32_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_uint32_BASE One of `base.DEC`, `base.HEX` or `base.OCT`. */
+/* WSLUA_OPTARG_Protofield_uint32_VALUESTRING A table containing the text that corresponds to the values. */
+/* WSLUA_OPTARG_Protofield_uint32_MASK Integer mask of this field. */
+/* WSLUA_OPTARG_Protofield_uint32_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_uint64 Creates a `ProtoField` of an unsigned 64-bit integer. */
+/* WSLUA_ARG_Protofield_uint64_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_uint64_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_uint64_BASE One of `base.DEC`, `base.HEX` or `base.OCT`. */
+/* WSLUA_OPTARG_Protofield_uint64_VALUESTRING A table containing the text that corresponds to the values. */
+/* WSLUA_OPTARG_Protofield_uint64_MASK Integer mask of this field. */
+/* WSLUA_OPTARG_Protofield_uint64_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_int8 Creates a `ProtoField` of a signed 8-bit integer (i.e., a byte). */
+/* WSLUA_ARG_Protofield_int8_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_int8_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_int8_BASE One of `base.DEC`, `base.HEX` or `base.OCT`. */
+/* WSLUA_OPTARG_Protofield_int8_VALUESTRING A table containing the text that corresponds to the values. */
+/* WSLUA_OPTARG_Protofield_int8_MASK Integer mask of this field. */
+/* WSLUA_OPTARG_Protofield_int8_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_int16 Creates a `ProtoField` of a signed 16-bit integer. */
+/* WSLUA_ARG_Protofield_int16_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_int16_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_int16_BASE One of `base.DEC`, `base.HEX` or `base.OCT`. */
+/* WSLUA_OPTARG_Protofield_int16_VALUESTRING A table containing the text that corresponds to the values. */
+/* WSLUA_OPTARG_Protofield_int16_MASK Integer mask of this field. */
+/* WSLUA_OPTARG_Protofield_int16_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_int24 Creates a `ProtoField` of a signed 24-bit integer. */
+/* WSLUA_ARG_Protofield_int24_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_int24_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_int24_BASE One of `base.DEC`, `base.HEX` or `base.OCT`. */
+/* WSLUA_OPTARG_Protofield_int24_VALUESTRING A table containing the text that corresponds to the values. */
+/* WSLUA_OPTARG_Protofield_int24_MASK Integer mask of this field. */
+/* WSLUA_OPTARG_Protofield_int24_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_int32 Creates a `ProtoField` of a signed 32-bit integer. */
+/* WSLUA_ARG_Protofield_int32_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_int32_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_int32_BASE One of `base.DEC`, `base.HEX` or `base.OCT`. */
+/* WSLUA_OPTARG_Protofield_int32_VALUESTRING A table containing the text that corresponds to the values. */
+/* WSLUA_OPTARG_Protofield_int32_MASK Integer mask of this field. */
+/* WSLUA_OPTARG_Protofield_int32_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_int64 Creates a `ProtoField` of a signed 64-bit integer. */
+/* WSLUA_ARG_Protofield_int64_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_int64_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_int64_BASE One of `base.DEC`, `base.HEX` or `base.OCT`. */
+/* WSLUA_OPTARG_Protofield_int64_VALUESTRING A table containing the text that corresponds to the values. */
+/* WSLUA_OPTARG_Protofield_int64_MASK Integer mask of this field. */
+/* WSLUA_OPTARG_Protofield_int64_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_framenum Creates a `ProtoField` for a frame number (for hyperlinks between frames). */
+/* WSLUA_ARG_Protofield_framenum_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_framenum_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_framenum_BASE One of `base.DEC`, `base.HEX` or `base.OCT`. */
+/* WSLUA_OPTARG_Protofield_framenum_VALUESTRING A table containing the text that corresponds to the values. */
+/* WSLUA_OPTARG_Protofield_framenum_MASK Integer mask of this field. */
+/* WSLUA_OPTARG_Protofield_framenum_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
PROTOFIELD_INTEGER(uint8,FT_UINT8)
PROTOFIELD_INTEGER(uint16,FT_UINT16)
@@ -1086,14 +1115,14 @@ static int ProtoField_boolean(lua_State* L, enum ftenum type) {
}
#define PROTOFIELD_BOOL(lower,FT) static int ProtoField_##lower(lua_State* L) { return ProtoField_boolean(L,FT); }
-/* _WSLUA_CONSTRUCTOR_ ProtoField_bool */
-/* WSLUA_ARG_Protofield_bool_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_bool_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_bool_DISPLAY how wide the parent bitfield is (base.NONE is used for NULL-value) */
-/* WSLUA_OPTARG_Protofield_bool_VALUESTRING A table containing the text that corresponds to the values */
-/* WSLUA_OPTARG_Protofield_bool_MASK Integer mask of this field */
-/* WSLUA_OPTARG_Protofield_bool_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
+/* _WSLUA_CONSTRUCTOR_ ProtoField_bool Creates a `ProtoField` for a boolean true/false value. */
+/* WSLUA_ARG_Protofield_bool_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_bool_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_bool_DISPLAY how wide the parent bitfield is (`base.NONE` is used for NULL-value). */
+/* WSLUA_OPTARG_Protofield_bool_VALUESTRING A table containing the text that corresponds to the values. */
+/* WSLUA_OPTARG_Protofield_bool_MASK Integer mask of this field. */
+/* WSLUA_OPTARG_Protofield_bool_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
/* XXX: T/F strings */
PROTOFIELD_BOOL(bool,FT_BOOLEAN)
@@ -1139,18 +1168,18 @@ static int ProtoField_time(lua_State* L,enum ftenum type) {
}
#define PROTOFIELD_TIME(lower,FT) static int ProtoField_##lower(lua_State* L) { return ProtoField_time(L,FT); }
-/* _WSLUA_CONSTRUCTOR_ ProtoField_absolute_time */
-/* WSLUA_ARG_Protofield_absolute_time_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_absolute_time_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_absolute_time_BASE One of base.LOCAL, base.UTC or base.DOY_UTC */
-/* WSLUA_OPTARG_Protofield_absolute_time_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
+/* _WSLUA_CONSTRUCTOR_ ProtoField_absolute_time Creates a `ProtoField` of a time_t structure value. */
+/* WSLUA_ARG_Protofield_absolute_time_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_absolute_time_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_absolute_time_BASE One of `base.LOCAL`, `base.UTC` or `base.DOY_UTC`. */
+/* WSLUA_OPTARG_Protofield_absolute_time_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
-/* _WSLUA_CONSTRUCTOR_ ProtoField_relative_time */
-/* WSLUA_ARG_Protofield_relative_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_relative_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_relative_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
+/* _WSLUA_CONSTRUCTOR_ ProtoField_relative_time Creates a `ProtoField` of a time_t structure value. */
+/* WSLUA_ARG_Protofield_relative_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_relative_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_relative_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
PROTOFIELD_TIME(absolute_time,FT_ABSOLUTE_TIME)
@@ -1183,77 +1212,83 @@ static int ProtoField_other(lua_State* L,enum ftenum type) {
}
#define PROTOFIELD_OTHER(lower,FT) static int ProtoField_##lower(lua_State* L) { return ProtoField_other(L,FT); }
-/* _WSLUA_CONSTRUCTOR_ ProtoField_ipv4 */
-/* WSLUA_ARG_Protofield_ipv4_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_ipv4_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_ipv4_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_ipv6 */
-/* WSLUA_ARG_Protofield_ipv6_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_ipv6_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_ipv6_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_ether */
-/* WSLUA_ARG_Protofield_ether_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_ether_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_ether_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_float */
-/* WSLUA_ARG_Protofield_float_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_float_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_float_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_double */
-/* WSLUA_ARG_Protofield_double_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_double_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_double_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_string */
-/* WSLUA_ARG_Protofield_string_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_string_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_string_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_stringz */
-/* WSLUA_ARG_Protofield_stringz_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_stringz_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_stringz_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_bytes */
-/* WSLUA_ARG_Protofield_bytes_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_bytes_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_bytes_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_ubytes */
-/* WSLUA_ARG_Protofield_ubytes_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_ubytes_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_ubytes_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_guid */
-/* WSLUA_ARG_Protofield_guid_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_guid_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_guid_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_oid */
-/* WSLUA_ARG_Protofield_oid_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_oid_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_oid_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
-
-/* _WSLUA_CONSTRUCTOR_ ProtoField_bool */
-/* WSLUA_ARG_Protofield_bool_ABBR Abbreviated name of the field (the string used in filters) */
-/* WSLUA_OPTARG_Protofield_bool_NAME Actual name of the field (the string that appears in the tree) */
-/* WSLUA_OPTARG_Protofield_bool_DESC Description of the field */
-/* _WSLUA_RETURNS_ A protofield item to be added to a ProtoFieldArray */
+/* _WSLUA_CONSTRUCTOR_ ProtoField_ipv4 Creates a `ProtoField` of an IPv4 address (4 bytes). */
+/* WSLUA_ARG_Protofield_ipv4_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_ipv4_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_ipv4_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_ipv6 Creates a `ProtoField` of an IPv6 address (16 bytes). */
+/* WSLUA_ARG_Protofield_ipv6_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_ipv6_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_ipv6_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_ether Creates a `ProtoField` of an Ethernet address (6 bytes). */
+/* WSLUA_ARG_Protofield_ether_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_ether_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_ether_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_float Creates a `ProtoField` of a floating point number (4 bytes). */
+/* WSLUA_ARG_Protofield_float_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_float_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_float_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_double Creates a `ProtoField` of a double-precision floating point (8 bytes). */
+/* WSLUA_ARG_Protofield_double_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_double_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_double_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_string Creates a `ProtoField` of a string value. */
+/* WSLUA_ARG_Protofield_string_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_string_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_string_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_stringz Creates a `ProtoField` of a zero-terminated string value. */
+/* WSLUA_ARG_Protofield_stringz_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_stringz_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_stringz_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_bytes Creates a `ProtoField` for an arbitrary number of bytes. */
+/* WSLUA_ARG_Protofield_bytes_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_bytes_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_bytes_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_ubytes Creates a `ProtoField` for an arbitrary number of unsigned bytes. */
+/* WSLUA_ARG_Protofield_ubytes_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_ubytes_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_ubytes_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_guid Creates a `ProtoField` for a Globally Unique IDentifier (GUID). */
+/* WSLUA_ARG_Protofield_guid_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_guid_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_guid_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_oid Creates a `ProtoField` for an ASN.1 Organizational IDentified (OID). */
+/* WSLUA_ARG_Protofield_oid_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_oid_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_oid_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_rel_oid Creates a `ProtoField` for an ASN.1 Relative-OID. */
+/* WSLUA_ARG_Protofield_rel_oid_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_rel_oid_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_rel_oid_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
+
+/* _WSLUA_CONSTRUCTOR_ ProtoField_systemid Creates a `ProtoField` for an OSI System ID. */
+/* WSLUA_ARG_Protofield_systemid_ABBR Abbreviated name of the field (the string used in filters). */
+/* WSLUA_OPTARG_Protofield_systemid_NAME Actual name of the field (the string that appears in the tree). */
+/* WSLUA_OPTARG_Protofield_systemid_DESC Description of the field. */
+/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
PROTOFIELD_OTHER(ipv4,FT_IPv4)
PROTOFIELD_OTHER(ipv6,FT_IPv6)
@@ -1272,9 +1307,13 @@ PROTOFIELD_OTHER(rel_oid,FT_REL_OID)
PROTOFIELD_OTHER(systemid,FT_SYSTEM_ID)
WSLUA_METAMETHOD ProtoField__tostring(lua_State* L) {
- /* Returns a string with info about a protofield (for debugging purposes) */
+ /* Returns a string with info about a protofield (for debugging purposes). */
ProtoField f = checkProtoField(L,1);
- gchar* s = (gchar *)ep_strdup_printf("ProtoField(%i): %s %s %s %s %p %.8x %s",f->hfid,f->name,f->abbr,ftenum_to_string(f->type),base_to_string(f->base),f->vs,f->mask,f->blob);
+ gchar* s = (gchar *)ep_strdup_printf("ProtoField(%i): %s %s %s %s %p %.8x %s",
+ f->hfid,f->name,f->abbr,
+ ftenum_to_string(f->type),
+ base_to_string(f->base),
+ f->vs,f->mask,f->blob);
lua_pushstring(L,s);
return 1;
}
@@ -1348,16 +1387,16 @@ int ProtoField_register(lua_State* L) {
WSLUA_CLASS_DEFINE(Proto,FAIL_ON_NULL("Proto"),NOP);
/*
- A new protocol in wireshark. Protocols have more uses, the main one is to dissect
- a protocol. But they can be just dummies used to register preferences for
+ A new protocol in Wireshark. Protocols have more uses, the main one is to dissect
+ a protocol. But they can also be just dummies used to register preferences for
other purposes.
*/
static int protocols_table_ref = LUA_NOREF;
WSLUA_CONSTRUCTOR Proto_new(lua_State* L) {
-#define WSLUA_ARG_Proto_new_NAME 1 /* The name of the protocol */
-#define WSLUA_ARG_Proto_new_DESC 2 /* A Long Text description of the protocol (usually lowercase) */
+#define WSLUA_ARG_Proto_new_NAME 1 /* The name of the protocol. */
+#define WSLUA_ARG_Proto_new_DESC 2 /* A Long Text description of the protocol (usually lowercase). */
const gchar* name = luaL_checkstring(L,WSLUA_ARG_Proto_new_NAME);
const gchar* desc = luaL_checkstring(L,WSLUA_ARG_Proto_new_DESC);
@@ -1408,7 +1447,7 @@ WSLUA_CONSTRUCTOR Proto_new(lua_State* L) {
pushProto(L,proto);
- WSLUA_RETURN(1); /* The newly created protocol */
+ WSLUA_RETURN(1); /* The newly created protocol. */
}
}
@@ -1416,11 +1455,11 @@ WSLUA_CONSTRUCTOR Proto_new(lua_State* L) {
return 0;
}
-WSLUA_METAMETHOD Proto__call(lua_State* L) { /* Creates a Proto object */
-#define WSLUA_ARG_Proto__call_NAME 1 /* The name of the protocol */
-#define WSLUA_ARG_Proto__call_DESC 2 /* A Long Text description of the protocol (usually lowercase) */
+WSLUA_METAMETHOD Proto__call(lua_State* L) { /* Creates a `Proto` object. */
+#define WSLUA_ARG_Proto__call_NAME 1 /* The name of the protocol. */
+#define WSLUA_ARG_Proto__call_DESC 2 /* A Long Text description of the protocol (usually lowercase). */
lua_remove(L,1); /* remove the table */
- WSLUA_RETURN(Proto_new(L)); /* The new Proto object. */
+ WSLUA_RETURN(Proto_new(L)); /* The new `Proto` object. */
}
static int Proto__tostring(lua_State* L) {
@@ -1434,9 +1473,11 @@ static int Proto__tostring(lua_State* L) {
}
WSLUA_FUNCTION wslua_register_postdissector(lua_State* L) {
- /* Make a protocol (with a dissector) a postdissector. It will be called for every frame after dissection */
-#define WSLUA_ARG_register_postdissector_PROTO 1 /* the protocol to be used as postdissector */
-#define WSLUA_OPTARG_register_postdissector_ALLFIELDS 2 /* Whether to generate all fields. Note: this impacts performance (default=false) */
+ /* Make a `Proto` protocol (with a dissector function) a post-dissector.
+ It will be called for every frame after dissection. */
+#define WSLUA_ARG_register_postdissector_PROTO 1 /* the protocol to be used as post-dissector. */
+#define WSLUA_OPTARG_register_postdissector_ALLFIELDS 2 /* Whether to generate all fields.
+ Note: this impacts performance (default=false). */
Proto proto = checkProto(L,WSLUA_ARG_register_postdissector_PROTO);
const gboolean all_fields = wslua_optbool(L, WSLUA_OPTARG_register_postdissector_ALLFIELDS, FALSE);
@@ -1459,14 +1500,27 @@ WSLUA_FUNCTION wslua_register_postdissector(lua_State* L) {
}
WSLUA_METHOD Proto_register_heuristic(lua_State* L) {
- /* Registers a heristic dissector function for this protocol, for the given heristic list name.
- When later called, the passed-in function will be given (1) a Tvb object, (2) a Pinfo object,
- and (3) a TreeItem object. The function must return true if the payload is for it, else false.
+ /* Registers a heuristic dissector function for this `Proto` protocol,
+ for the given heuristic list name.
+
+ When later called, the passed-in function will be given:
+ 1. A `Tvb` object
+ 2. A `Pinfo` object
+ 3. A `TreeItem` object
+
+ The function must return `true` if the payload is for it, else `false`.
+
The function should perform as much verification as possible to ensure the payload is for it,
and dissect the packet (including setting TreeItem info and such) only if the payload is for it,
- before returning true or false.*/
-#define WSLUA_ARG_Proto_register_heuristic_LISTNAME 2 /* the heristic list name this function is a heuristic for (e.g., "udp" or "infiniband.payload") */
-#define WSLUA_ARG_Proto_register_heuristic_FUNC 3 /* a Lua function that will be invoked for heuristic dissection */
+ before returning true or false.
+
+ @since 1.11.3
+ */
+#define WSLUA_ARG_Proto_register_heuristic_LISTNAME 2 /* The heuristic list name this function
+ is a heuristic for (e.g., "udp" or
+ "infiniband.payload"). */
+#define WSLUA_ARG_Proto_register_heuristic_FUNC 3 /* A Lua function that will be invoked for
+ heuristic dissection. */
Proto proto = checkProto(L,1);
const gchar *listname = luaL_checkstring(L, WSLUA_ARG_Proto_register_heuristic_LISTNAME);
const gchar *proto_name = proto->name;
@@ -1529,7 +1583,12 @@ WSLUA_METHOD Proto_register_heuristic(lua_State* L) {
}
/* WSLUA_ATTRIBUTE Proto_dissector RW The protocol's dissector, a function you define.
- The called dissector function will be given three arguments of (1) a Tvb object, (2) a Pinfo object, and (3) a TreeItem object. */
+
+ When later called, the function will be given:
+ 1. A `Tvb` object
+ 2. A `Pinfo` object
+ 3. A `TreeItem` object
+*/
static int Proto_get_dissector(lua_State* L) {
Proto proto = checkProto(L,1);
@@ -1564,14 +1623,16 @@ static int Proto_set_dissector(lua_State* L) {
return 0;
}
-/* WSLUA_ATTRIBUTE Proto_prefs RO The preferences of this dissector */
+/* WSLUA_ATTRIBUTE Proto_prefs RO The preferences of this dissector. */
static int Proto_get_prefs(lua_State* L) {
Proto proto = checkProto(L,1);
pushPrefs(L,&proto->prefs);
return 1;
}
-/* WSLUA_ATTRIBUTE Proto_prefs_changed WO The preferences changed routine of this dissector, a function you define. */
+/* WSLUA_ATTRIBUTE Proto_prefs_changed WO The preferences changed routine of this dissector,
+ a Lua function you define.
+ */
static int Proto_set_prefs_changed(lua_State* L) {
Proto proto = checkProto(L,1);
@@ -1589,7 +1650,9 @@ static int Proto_set_prefs_changed(lua_State* L) {
}
/* WSLUA_ATTRIBUTE Proto_init WO The init routine of this dissector, a function you define.
- The called init function is passed no arguments. */
+
+ The called init function is passed no arguments.
+*/
static int Proto_set_init(lua_State* L) {
Proto proto = checkProto(L,1);
@@ -1606,13 +1669,13 @@ static int Proto_set_init(lua_State* L) {
return 0;
}
-/* WSLUA_ATTRIBUTE Proto_name RO The name given to this dissector */
+/* WSLUA_ATTRIBUTE Proto_name RO The name given to this dissector. */
WSLUA_ATTRIBUTE_STRING_GETTER(Proto,name);
-/* WSLUA_ATTRIBUTE Proto_description RO The description given to this dissector */
+/* WSLUA_ATTRIBUTE Proto_description RO The description given to this dissector. */
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(Proto,description,desc);
-/* WSLUA_ATTRIBUTE Proto_fields RW The Fields Table of this dissector */
+/* WSLUA_ATTRIBUTE Proto_fields RW The `ProtoField`s Lua table of this dissector. */
static int Proto_get_fields(lua_State* L) {
Proto proto = checkProto(L,1);
lua_rawgeti(L, LUA_REGISTRYINDEX, proto->fields);
@@ -1776,8 +1839,8 @@ WSLUA_CLASS_DEFINE(Dissector,NOP,NOP);
*/
WSLUA_CONSTRUCTOR Dissector_get (lua_State *L) {
- /* Obtains a dissector reference by name */
-#define WSLUA_ARG_Dissector_get_NAME 1 /* The name of the dissector */
+ /* Obtains a dissector reference by name. */
+#define WSLUA_ARG_Dissector_get_NAME 1 /* The name of the dissector. */
const gchar* name = luaL_checkstring(L,WSLUA_ARG_Dissector_get_NAME);
Dissector d;
@@ -1788,14 +1851,14 @@ WSLUA_CONSTRUCTOR Dissector_get (lua_State *L) {
if ((d = find_dissector(name))) {
pushDissector(L, d);
- WSLUA_RETURN(1); /* The Dissector reference */
+ WSLUA_RETURN(1); /* The Dissector reference. */
}
WSLUA_ARG_ERROR(Dissector_get,NAME,"No such dissector");
return 0;
}
-/* Allow dissector key names to be sorted alphabetically */
+/* Allow dissector key names to be sorted alphabetically. */
static gint
compare_dissector_key_name(gconstpointer dissector_a, gconstpointer dissector_b)
{
@@ -1804,7 +1867,11 @@ compare_dissector_key_name(gconstpointer dissector_a, gconstpointer dissector_b)
WSLUA_CONSTRUCTOR Dissector_list (lua_State *L) {
/* Gets a Lua array table of all registered Dissector names.
- NOTE: this is an expensive operation, and should only be used for troubleshooting. */
+
+ Note: this is an expensive operation, and should only be used for troubleshooting.
+
+ @since 1.11.3
+ */
GList* list = get_dissector_names();
GList* elist = NULL;
int i = 1;
@@ -1821,14 +1888,14 @@ WSLUA_CONSTRUCTOR Dissector_list (lua_State *L) {
}
g_list_free(list);
- WSLUA_RETURN(1); /* The array table of registered dissector names */
+ WSLUA_RETURN(1); /* The array table of registered dissector names. */
}
WSLUA_METHOD Dissector_call(lua_State* L) {
- /* Calls a dissector against a given packet (or part of it) */
-#define WSLUA_ARG_Dissector_call_TVB 2 /* The buffer to dissect */
-#define WSLUA_ARG_Dissector_call_PINFO 3 /* The packet info */
-#define WSLUA_ARG_Dissector_call_TREE 4 /* The tree on which to add the protocol items */
+ /* Calls a dissector against a given packet (or part of it). */
+#define WSLUA_ARG_Dissector_call_TVB 2 /* The buffer to dissect. */
+#define WSLUA_ARG_Dissector_call_PINFO 3 /* The packet info. */
+#define WSLUA_ARG_Dissector_call_TREE 4 /* The tree on which to add the protocol items. */
Dissector d = checkDissector(L,1);
Tvb tvb = checkTvb(L,WSLUA_ARG_Dissector_call_TVB);
@@ -1852,19 +1919,19 @@ WSLUA_METHOD Dissector_call(lua_State* L) {
}
WSLUA_METAMETHOD Dissector__call(lua_State* L) {
- /* Calls a dissector against a given packet (or part of it) */
-#define WSLUA_ARG_Dissector__call_TVB 2 /* The buffer to dissect */
-#define WSLUA_ARG_Dissector__call_PINFO 3 /* The packet info */
-#define WSLUA_ARG_Dissector__call_TREE 4 /* The tree on which to add the protocol items */
+ /* Calls a dissector against a given packet (or part of it). */
+#define WSLUA_ARG_Dissector__call_TVB 2 /* The buffer to dissect. */
+#define WSLUA_ARG_Dissector__call_PINFO 3 /* The packet info. */
+#define WSLUA_ARG_Dissector__call_TREE 4 /* The tree on which to add the protocol items. */
return Dissector_call(L);
}
WSLUA_METAMETHOD Dissector__tostring(lua_State* L) {
- /* Gets the Dissector's protocol short name */
+ /* Gets the Dissector's protocol short name. */
Dissector d = checkDissector(L,1);
if (!d) return 0;
lua_pushstring(L,dissector_handle_get_short_name(d));
- WSLUA_RETURN(1); /* A string of the protocol's short name */
+ WSLUA_RETURN(1); /* A string of the protocol's short name. */
}
/* Gets registered as metamethod automatically by WSLUA_REGISTER_CLASS/META */
@@ -1893,16 +1960,24 @@ int Dissector_register(lua_State* L) {
WSLUA_CLASS_DEFINE(DissectorTable,NOP,NOP);
/*
- A table of subdissectors of a particular protocol (e.g. TCP subdissectors like http, smtp, sip are added to table "tcp.port").
+ A table of subdissectors of a particular protocol (e.g. TCP subdissectors like http, smtp,
+ sip are added to table "tcp.port").
+
Useful to add more dissectors to a table so that they appear in the Decode As... dialog.
*/
WSLUA_CONSTRUCTOR DissectorTable_new (lua_State *L) {
/* Creates a new DissectorTable for your dissector's use. */
#define WSLUA_ARG_DissectorTable_new_TABLENAME 1 /* The short name of the table. */
-#define WSLUA_OPTARG_DissectorTable_new_UINAME 2 /* The name of the table in the User Interface (defaults to the name given). */
-#define WSLUA_OPTARG_DissectorTable_new_TYPE 3 /* Either ftypes.UINT{8,16,24,32} or ftypes.STRING (defaults to ftypes.UINT32) */
-#define WSLUA_OPTARG_DissectorTable_new_BASE 4 /* Either base.NONE, base.DEC, base.HEX, base.OCT, base.DEC_HEX or base.HEX_DEC (defaults to base.DEC) */
+#define WSLUA_OPTARG_DissectorTable_new_UINAME 2 /* The name of the table in the User Interface
+ (defaults to the name given). */
+#define WSLUA_OPTARG_DissectorTable_new_TYPE 3 /* Either `ftypes.UINT8`, `ftypes.UINT16`,
+ `ftypes.UINT24`, `ftypes.UINT32`, or
+ `ftypes.STRING`
+ (defaults to `ftypes.UINT32`). */
+#define WSLUA_OPTARG_DissectorTable_new_BASE 4 /* Either `base.NONE`, `base.DEC`, `base.HEX`,
+ `base.OCT`, `base.DEC_HEX` or `base.HEX_DEC`
+ (defaults to `base.DEC`). */
const gchar* name = (const gchar*)luaL_checkstring(L,WSLUA_ARG_DissectorTable_new_TABLENAME);
const gchar* ui_name = (const gchar*)luaL_optstring(L,WSLUA_OPTARG_DissectorTable_new_UINAME,name);
enum ftenum type = (enum ftenum)luaL_optint(L,WSLUA_OPTARG_DissectorTable_new_TYPE,FT_UINT32);
@@ -1928,7 +2003,7 @@ WSLUA_CONSTRUCTOR DissectorTable_new (lua_State *L) {
dt->name = name;
pushDissectorTable(L, dt);
}
- WSLUA_RETURN(1); /* The newly created DissectorTable */
+ WSLUA_RETURN(1); /* The newly created DissectorTable. */
default:
WSLUA_OPTARG_ERROR(DissectorTable_new,TYPE,"must be ftypes.UINT{8,16,24,32} or ftypes.STRING");
break;
@@ -1936,7 +2011,7 @@ WSLUA_CONSTRUCTOR DissectorTable_new (lua_State *L) {
return 0;
}
-/* this struct is used for passing ourselves user_data through dissector_all_tables_foreach_table() */
+/* this struct is used for passing ourselves user_data through dissector_all_tables_foreach_table(). */
typedef struct dissector_tables_foreach_table_info {
int num;
lua_State *L;
@@ -1955,14 +2030,19 @@ dissector_tables_list_func(const gchar *table_name, const gchar *ui_name _U_, gp
WSLUA_CONSTRUCTOR DissectorTable_list (lua_State *L) {
/* Gets a Lua array table of all DissectorTable names - i.e., the string names you can
use for the first argument to DissectorTable.get().
- NOTE: this is an expensive operation, and should only be used for troubleshooting. */
+
+ Note: this is an expensive operation, and should only be used for troubleshooting.
+
+ @since 1.11.3
+ */
dissector_tables_foreach_table_info_t data = { 1, L };
lua_newtable(L);
- dissector_all_tables_foreach_table(dissector_tables_list_func, (gpointer)&data, (GCompareFunc)compare_dissector_key_name);
+ dissector_all_tables_foreach_table(dissector_tables_list_func, (gpointer)&data,
+ (GCompareFunc)compare_dissector_key_name);
- WSLUA_RETURN(1); /* The array table of registered DissectorTable names */
+ WSLUA_RETURN(1); /* The array table of registered DissectorTable names. */
}
/* this is the DATFunc_heur_table function used for dissector_all_heur_tables_foreach_table()
@@ -1978,7 +2058,11 @@ heur_dissector_tables_list_func(const gchar *table_name, gpointer table _U_, gpo
WSLUA_CONSTRUCTOR DissectorTable_heuristic_list (lua_State *L) {
/* Gets a Lua array table of all heuristic list names - i.e., the string names you can
use for the first argument in Proto:register_heuristic().
- NOTE: this is an expensive operation, and should only be used for troubleshooting. */
+
+ Note: this is an expensive operation, and should only be used for troubleshooting.
+
+ @since 1.11.3
+ */
dissector_tables_foreach_table_info_t data = { 1, L };
lua_newtable(L);
@@ -2007,7 +2091,7 @@ WSLUA_CONSTRUCTOR DissectorTable_get (lua_State *L) {
pushDissectorTable(L, dt);
- WSLUA_RETURN(1); /* The DissectorTable */
+ WSLUA_RETURN(1); /* The DissectorTable. */
}
WSLUA_ARG_ERROR(DissectorTable_get,TABLENAME,"no such dissector_table");
@@ -2016,10 +2100,11 @@ WSLUA_CONSTRUCTOR DissectorTable_get (lua_State *L) {
WSLUA_METHOD DissectorTable_add (lua_State *L) {
/*
- Add a dissector or a range of dissectors to a table.
+ Add a `Proto` with a dissector function, or a `Dissector` object, to the dissector table.
*/
-#define WSLUA_ARG_DissectorTable_add_PATTERN 2 /* The pattern to match (either an integer, a integer range or a string depending on the table's type). */
-#define WSLUA_ARG_DissectorTable_add_DISSECTOR 3 /* The dissector to add (either an Proto or a Dissector). */
+#define WSLUA_ARG_DissectorTable_add_PATTERN 2 /* The pattern to match (either an integer, a
+ integer range or a string depending on the table's type). */
+#define WSLUA_ARG_DissectorTable_add_DISSECTOR 3 /* The dissector to add (either a `Proto` or a `Dissector`). */
DissectorTable dt = checkDissectorTable(L,1);
ftenum_t type;
@@ -2077,9 +2162,11 @@ WSLUA_METHOD DissectorTable_add (lua_State *L) {
WSLUA_METHOD DissectorTable_set (lua_State *L) {
/*
Remove existing dissectors from a table and add a new or a range of new dissectors.
+
+ @since 1.11.3
*/
#define WSLUA_ARG_DissectorTable_set_PATTERN 2 /* The pattern to match (either an integer, a integer range or a string depending on the table's type). */
-#define WSLUA_ARG_DissectorTable_set_DISSECTOR 3 /* The dissector to add (either an Proto or a Dissector). */
+#define WSLUA_ARG_DissectorTable_set_DISSECTOR 3 /* The dissector to add (either a `Proto` or a `Dissector`). */
DissectorTable dt = checkDissectorTable(L,1);
ftenum_t type;
@@ -2139,7 +2226,7 @@ WSLUA_METHOD DissectorTable_remove (lua_State *L) {
Remove a dissector or a range of dissectors from a table
*/
#define WSLUA_ARG_DissectorTable_remove_PATTERN 2 /* The pattern to match (either an integer, a integer range or a string depending on the table's type). */
-#define WSLUA_ARG_DissectorTable_remove_DISSECTOR 3 /* The dissector to remove (either an Proto or a Dissector). */
+#define WSLUA_ARG_DissectorTable_remove_DISSECTOR 3 /* The dissector to remove (either a `Proto` or a `Dissector`). */
DissectorTable dt = checkDissectorTable(L,1);
ftenum_t type;
Dissector handle;
@@ -2188,9 +2275,11 @@ WSLUA_METHOD DissectorTable_remove (lua_State *L) {
WSLUA_METHOD DissectorTable_remove_all (lua_State *L) {
/*
- Remove all dissectors from a table
+ Remove all dissectors from a table.
+
+ @since 1.11.3
*/
-#define WSLUA_ARG_DissectorTable_remove_all_DISSECTOR 2 /* The dissector to add (either an Proto or a Dissector). */
+#define WSLUA_ARG_DissectorTable_remove_all_DISSECTOR 2 /* The dissector to remove (either a `Proto` or a `Dissector`). */
DissectorTable dt = checkDissectorTable(L,1);
Dissector handle;
@@ -2218,9 +2307,9 @@ WSLUA_METHOD DissectorTable_try (lua_State *L) {
Try to call a dissector from a table
*/
#define WSLUA_ARG_DissectorTable_try_PATTERN 2 /* The pattern to be matched (either an integer or a string depending on the table's type). */
-#define WSLUA_ARG_DissectorTable_try_TVB 3 /* The buffer to dissect */
-#define WSLUA_ARG_DissectorTable_try_PINFO 4 /* The packet info */
-#define WSLUA_ARG_DissectorTable_try_TREE 5 /* The tree on which to add the protocol items */
+#define WSLUA_ARG_DissectorTable_try_TVB 3 /* The buffer to dissect. */
+#define WSLUA_ARG_DissectorTable_try_PINFO 4 /* The packet info. */
+#define WSLUA_ARG_DissectorTable_try_TREE 5 /* The tree on which to add the protocol items. */
DissectorTable dt = checkDissectorTable(L,1);
Tvb tvb = checkTvb(L,WSLUA_ARG_DissectorTable_try_TVB);
Pinfo pinfo = checkPinfo(L,WSLUA_ARG_DissectorTable_try_PINFO);
@@ -2298,16 +2387,16 @@ WSLUA_METHOD DissectorTable_get_dissector (lua_State *L) {
if (handle) {
pushDissector(L,handle);
- WSLUA_RETURN(1); /* The dissector handle if found */
+ WSLUA_RETURN(1); /* The dissector handle if found. */
} else {
lua_pushnil(L);
- WSLUA_RETURN(1); /* nil if not found */
+ WSLUA_RETURN(1); /* nil if not found. */
}
}
/* XXX It would be nice to iterate and print which dissectors it has */
WSLUA_METAMETHOD DissectorTable__tostring(lua_State* L) {
- /* Gets some debug information about the DissectorTable */
+ /* Gets some debug information about the DissectorTable. */
DissectorTable dt = checkDissectorTable(L,1);
GString* s;
ftenum_t type;
@@ -2338,7 +2427,7 @@ WSLUA_METAMETHOD DissectorTable__tostring(lua_State* L) {
lua_pushstring(L,s->str);
g_string_free(s,TRUE);
- WSLUA_RETURN(1); /* A string of debug information about the DissectorTable */
+ WSLUA_RETURN(1); /* A string of debug information about the DissectorTable. */
}
/* Gets registered as metamethod automatically by WSLUA_REGISTER_CLASS/META */
diff --git a/epan/wslua/wslua_struct.c b/epan/wslua/wslua_struct.c
index a780c6a61b..d99b7ef059 100644
--- a/epan/wslua/wslua_struct.c
+++ b/epan/wslua/wslua_struct.c
@@ -39,7 +39,7 @@
** -Can mask out return values when you only want to calculate sizes or unmarshal pascal-style strings. '(' & ')'
**
** Changes I made:
-** -Added support for Int64/UIn64 being packed/unpacked, using 'e'/'E'
+** -Added support for Int64/UInt64 being packed/unpacked, using 'e'/'E'
** -Made it follow Wireshark's conventions so we could get API docs
** =======================================================
*/
@@ -88,13 +88,81 @@
#include "wslua.h"
- /* WSLUA_MODULE Struct Binary encode/decode support */
+/* WSLUA_MODULE Struct Binary encode/decode support
+
+ The Struct class offers basic facilities to convert Lua values to and from C-style structs
+ in binary Lua strings. This is based on Roberto Ierusalimschy's Lua struct library found
+ in [[http://www.inf.puc-rio.br/~roberto/struct/]], with some minor modifications as follows:
+ * Added support for `Int64`/`UInt64` being packed/unpacked, using 'e'/'E'.
+ * Can handle 'long long' integers (i8 / I8); though they're converted to doubles.
+ * Can insert/specify padding anywhere in a struct. ('X' eg. when a string is following a union).
+ * Can report current offset in both `pack` and `unpack` ('`=`').
+ * Can mask out return values when you only want to calculate sizes or unmarshal
+ pascal-style strings using '`(`' & '`)`'.
+
+ All but the first of those changes are based on an email from Flemming Madsen, on the lua-users
+ mailing list, which can be found [[http://lua-users.org/lists/lua-l/2009-10/msg00572.html|here]].
+
+ The main functions are `Struct.pack`, which packs multiple Lua values into a struct-like
+ Lua binary string; and `Struct.unpack`, which unpacks multiple Lua values from a given
+ struct-like Lua binary string. There are some additional helper functions available as well.
+
+ All functions in the Struct library are called as static member functions, not object methods,
+ so they are invoked as "Struct.pack(...)" instead of "object:pack(...)".
+
+ The fist argument to several of the `Struct` functions is a format string, which describes
+ the layout of the structure. The format string is a sequence of conversion elements, which
+ respect the current endianness and the current alignment requirements. Initially, the
+ current endianness is the machine's native endianness and the current alignment requirement
+ is 1 (meaning no alignment at all). You can change these settings with appropriate directives
+ in the format string.
+
+ The supported elements in the format string are as follows:
+
+ * "` `" (empty space) ignored.
+ * "`!`n" flag to set the current alignment requirement to 'n' (necessarily a power of 2);
+ an absent 'n' means the machine's native alignment.
+ * "`>`" flag to set mode to big endian (i.e., network-order).
+ * "`<`" flag to set mode to little endian.
+ * "`x`" a padding zero byte with no corresponding Lua value.
+ * "`b`" a signed char.
+ * "`B`" an unsigned char.
+ * "`h`" a signed short (native size).
+ * "`H`" an unsigned short (native size).
+ * "`l`" a signed long (native size).
+ * "`L`" an unsigned long (native size).
+ * "`T`" a size_t (native size).
+ * "`i`n" a signed integer with 'n' bytes. An absent 'n' means the native size of an int.
+ * "`I`n" like "`i`n" but unsigned.
+ * "`e`" signed 8-byte Integer (64-bits, long long), to/from a `Int64` object.
+ * "`E`" unsigned 8-byte Integer (64-bits, long long), to/from a `UInt64` object.
+ * "`f`" a float (native size).
+ * "`d`" a double (native size).
+ * "`s`" a zero-terminated string.
+ * "`c`n" a sequence of exactly 'n' chars corresponding to a single Lua string. An absent 'n'
+ means 1. When packing, the given string must have at least 'n' characters (extra
+ characters are discarded).
+ * "`c0`" this is like "`c`n", except that the 'n' is given by other means: When packing, 'n' is
+ the length of the given string; when unpacking, 'n' is the value of the previous unpacked
+ value (which must be a number). In that case, this previous value is not returned.
+ * "`x`n" pad to 'n' number of bytes, default 1.
+ * "`X`n" pad to 'n' alignment, default MAXALIGN.
+ * "`(`" to stop assigning items, and "`)`" start assigning (padding when packing).
+ * "`=`" to return the current position / offset.
+
+ @note Using `i`, `I`, `h`, `H`, `l`, `L`, `f`, and `T` is strongly discouraged, as those sizes
+ are system-dependent. Use the explicitly sized variants instead, such as `i4` or `E`.
+
+ @note Unpacking of `i`/`I` is done to a Lua number, a double-precision floating point,
+ so unpacking a 64-bit field (`i8`/`I8`) will lose precision.
+ Use `e`/`E` to unpack into a Wireshark `Int64`/`UInt64` object instead.
+
+ */
-/* TODO: figure out a way for wslua Module's to have (possibly long) description text */
/* The following line is here so that make-reg.pl does the right thing. This 'Struct' class
isn't really a class, so it doesn't have the checkStruct/pushStruct/etc. functions
- the following macro would generate; but it does need to be registered and such.
+ the following macro would generate; but it does need to be registered and such, so...
WSLUA_CLASS_DEFINE_BASE(Struct,NOP,NOP,0);
*/
diff --git a/epan/wslua/wslua_tree.c b/epan/wslua/wslua_tree.c
index 3f5eb2d383..f73efa5879 100644
--- a/epan/wslua/wslua_tree.c
+++ b/epan/wslua/wslua_tree.c
@@ -48,8 +48,8 @@ TreeItem* push_TreeItem(lua_State*L, TreeItem t) {
CLEAR_OUTSTANDING(TreeItem, expired, TRUE)
WSLUA_CLASS_DEFINE(TreeItem,FAIL_ON_NULL_OR_EXPIRED("TreeItem"),NOP);
-/* TreeItems represent information in the packet-details pane.
- A root TreeItem is passed to dissectors as the third argument. */
+/* `TreeItem`s represent information in the packet-details pane.
+ A root `TreeItem` is passed to dissectors as the third argument. */
WSLUA_METHOD TreeItem_add_packet_field(lua_State *L) {
/*
@@ -272,10 +272,12 @@ static int TreeItem_add_item_any(lua_State *L, gboolean little_endian) {
WSLUA_METHOD TreeItem_add(lua_State *L) {
/*
- Adds a child item to this tree item, returning the new child TreeItem.
- if the protofield represents a numeric value (int, uint or float), then it's treated as a Big Endian (network order) value.
+ Adds a child item to this tree item, returning the new child `TreeItem`.
+
+ If the `ProtoField` represents a numeric value (int, uint or float), then it's treated as a Big Endian (network order) value.
+
This function has a complicated form: 'treeitem:add(protofield, [tvbrange,] [[value], label]])', such that if the second
- argument is a tvbrange, and a third argument is given, it's a value; but if the second argument is a non-tvbrange type, then
+ argument is a `TvbRange`, and a third argument is given, it's a value; but if the second argument is a non-`TvbRange` type, then
it is the value (as opposed to filling that argument with 'nil', which is invalid for this function).
*/
#define WSLUA_ARG_TreeItem_add_PROTOFIELD 2 /* The ProtoField field or Proto protocol object to add to the tree. */
@@ -287,10 +289,12 @@ WSLUA_METHOD TreeItem_add(lua_State *L) {
WSLUA_METHOD TreeItem_add_le(lua_State *L) {
/*
- Adds a child item to this tree item, returning the new child TreeItem.
- if the protofield represents a numeric value (int, uint or float), then it's treated as a Little Endian value.
+ Adds a child item to this tree item, returning the new child `TreeItem`.
+
+ If the `ProtoField` represents a numeric value (int, uint or float), then it's treated as a Little Endian value.
+
This function has a complicated form: 'treeitem:add_le(protofield, [tvbrange,] [[value], label]])', such that if the second
- argument is a tvbrange, and a third argument is given, it's a value; but if the second argument is a non-tvbrange type, then
+ argument is a `TvbRange`, and a third argument is given, it's a value; but if the second argument is a non-`TvbRange` type, then
it is the value (as opposed to filling that argument with 'nil', which is invalid for this function).
*/
#define WSLUA_ARG_TreeItem_add_le_PROTOFIELD 2 /* The ProtoField field or Proto protocol object to add to the tree. */
@@ -301,7 +305,7 @@ WSLUA_METHOD TreeItem_add_le(lua_State *L) {
}
WSLUA_METHOD TreeItem_set_text(lua_State *L) {
- /* Sets the text of the label */
+ /* Sets the text of the label. */
#define WSLUA_ARG_TreeItem_set_text_TEXT 2 /* The text to be used. */
TreeItem ti = checkTreeItem(L,1);
const gchar* s = luaL_checkstring(L,WSLUA_ARG_TreeItem_set_text_TEXT);
@@ -312,7 +316,7 @@ WSLUA_METHOD TreeItem_set_text(lua_State *L) {
}
WSLUA_METHOD TreeItem_append_text(lua_State *L) {
- /* Appends text to the label */
+ /* Appends text to the label. */
#define WSLUA_ARG_TreeItem_append_text_TEXT 2 /* The text to be appended. */
TreeItem ti = checkTreeItem(L,1);
const gchar* s = luaL_checkstring(L,WSLUA_ARG_TreeItem_append_text_TEXT);
@@ -323,8 +327,8 @@ WSLUA_METHOD TreeItem_append_text(lua_State *L) {
}
WSLUA_METHOD TreeItem_prepend_text(lua_State *L) {
- /* Prepends text to the label */
-#define WSLUA_ARG_TreeItem_prepend_text_TEXT 2 /* The text to be prepended */
+ /* Prepends text to the label. */
+#define WSLUA_ARG_TreeItem_prepend_text_TEXT 2 /* The text to be prepended. */
TreeItem ti = checkTreeItem(L,1);
const gchar* s = luaL_checkstring(L,WSLUA_ARG_TreeItem_prepend_text_TEXT);
@@ -335,9 +339,13 @@ WSLUA_METHOD TreeItem_prepend_text(lua_State *L) {
WSLUA_METHOD TreeItem_add_expert_info(lua_State *L) {
/* Sets the expert flags of the item and adds expert info to the packet. */
-#define WSLUA_OPTARG_TreeItem_add_expert_info_GROUP 2 /* One of PI_CHECKSUM, PI_SEQUENCE, PI_RESPONSE_CODE, PI_REQUEST_CODE, PI_UNDECODED, PI_REASSEMBLE, PI_MALFORMED or PI_DEBUG */
-#define WSLUA_OPTARG_TreeItem_add_expert_info_SEVERITY 3 /* One of PI_CHAT, PI_NOTE, PI_WARN, PI_ERROR */
-#define WSLUA_OPTARG_TreeItem_add_expert_info_TEXT 4 /* The text for the expert info */
+#define WSLUA_OPTARG_TreeItem_add_expert_info_GROUP 2 /* One of `PI_CHECKSUM`, `PI_SEQUENCE`,
+ `PI_RESPONSE_CODE`, `PI_REQUEST_CODE`,
+ `PI_UNDECODED`, `PI_REASSEMBLE`,
+ `PI_MALFORMED` or `PI_DEBUG`. */
+#define WSLUA_OPTARG_TreeItem_add_expert_info_SEVERITY 3 /* One of `PI_CHAT`, `PI_NOTE`,
+ `PI_WARN`, or `PI_ERROR`. */
+#define WSLUA_OPTARG_TreeItem_add_expert_info_TEXT 4 /* The text for the expert info display. */
TreeItem ti = checkTreeItem(L,1);
int group = luaL_optint(L,WSLUA_OPTARG_TreeItem_add_expert_info_GROUP,PI_DEBUG);
int severity = luaL_optint(L,WSLUA_OPTARG_TreeItem_add_expert_info_SEVERITY,PI_CHAT);
@@ -349,7 +357,7 @@ WSLUA_METHOD TreeItem_add_expert_info(lua_State *L) {
}
WSLUA_METHOD TreeItem_set_generated(lua_State *L) {
- /* Marks the TreeItem as a generated field (with data infered but not contained in the packet). */
+ /* Marks the `TreeItem` as a generated field (with data inferred but not contained in the packet). */
TreeItem ti = checkTreeItem(L,1);
PROTO_ITEM_SET_GENERATED(ti->item);
@@ -368,7 +376,7 @@ WSLUA_METHOD TreeItem_set_hidden(lua_State *L) {
}
WSLUA_METHOD TreeItem_set_len(lua_State *L) {
- /* Set TreeItem's length inside tvb, after it has already been created. */
+ /* Set `TreeItem`'s length inside tvb, after it has already been created. */
#define WSLUA_ARG_TreeItem_set_len_LEN 2 /* The length to be used. */
TreeItem ti = checkTreeItem(L,1);
gint len = luaL_checkint(L,WSLUA_ARG_TreeItem_set_len_LEN);
diff --git a/epan/wslua/wslua_tvb.c b/epan/wslua/wslua_tvb.c
index 1dae9c3461..bfad06c51e 100644
--- a/epan/wslua/wslua_tvb.c
+++ b/epan/wslua/wslua_tvb.c
@@ -37,9 +37,11 @@
WSLUA_CLASS_DEFINE(ByteArray,FAIL_ON_NULL("ByteArray"),NOP);
-WSLUA_CONSTRUCTOR ByteArray_new(lua_State* L) { /* Creates a ByteArray Object */
-#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=" "); or if the boolean value 'true' is used, then the first arg is treated as raw binary data */
+WSLUA_CONSTRUCTOR ByteArray_new(lua_State* L) { /* Creates a `ByteArray` object. */
+#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=" "),
+ or if the boolean value `true` is used, then the first argument
+ is treated as raw binary data */
GByteArray* ba = g_byte_array_new();
const gchar* s;
size_t len = 0;
@@ -88,9 +90,9 @@ static int ByteArray__gc(lua_State* L) {
}
WSLUA_METAMETHOD ByteArray__concat(lua_State* L) {
- /* Concatenate two ByteArrays */
-#define WSLUA_ARG_ByteArray__cat_FIRST 1 /* First array */
-#define WSLUA_ARG_ByteArray__cat_SECOND 2 /* Second array */
+ /* Concatenate two `ByteArrays`. */
+#define WSLUA_ARG_ByteArray__cat_FIRST 1 /* First array. */
+#define WSLUA_ARG_ByteArray__cat_SECOND 2 /* Second array. */
ByteArray ba1 = checkByteArray(L,WSLUA_ARG_ByteArray__cat_FIRST);
ByteArray ba2 = checkByteArray(L,WSLUA_ARG_ByteArray__cat_SECOND);
@@ -101,12 +103,12 @@ WSLUA_METAMETHOD ByteArray__concat(lua_State* L) {
g_byte_array_append(ba,ba2->data,ba2->len);
pushByteArray(L,ba);
- WSLUA_RETURN(1); /* The new composite ByteArray. */
+ WSLUA_RETURN(1); /* The new composite `ByteArray`. */
}
WSLUA_METHOD ByteArray_prepend(lua_State* L) {
- /* Prepend a ByteArray to this ByteArray */
-#define WSLUA_ARG_ByteArray_prepend_PREPENDED 2 /* Array to be prepended */
+ /* Prepend a `ByteArray` to this `ByteArray`. */
+#define WSLUA_ARG_ByteArray_prepend_PREPENDED 2 /* `ByteArray` to be prepended. */
ByteArray ba = checkByteArray(L,1);
ByteArray ba2 = checkByteArray(L,WSLUA_ARG_ByteArray_prepend_PREPENDED);
@@ -116,8 +118,8 @@ WSLUA_METHOD ByteArray_prepend(lua_State* L) {
}
WSLUA_METHOD ByteArray_append(lua_State* L) {
- /* Append a ByteArray to this ByteArray */
-#define WSLUA_ARG_ByteArray_append_APPENDED 2 /* Array to be appended */
+ /* Append a `ByteArray` to this `ByteArray`. */
+#define WSLUA_ARG_ByteArray_append_APPENDED 2 /* `ByteArray` to be appended. */
ByteArray ba = checkByteArray(L,1);
ByteArray ba2 = checkByteArray(L,WSLUA_ARG_ByteArray_append_APPENDED);
@@ -127,8 +129,8 @@ WSLUA_METHOD ByteArray_append(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. */
-#define WSLUA_ARG_ByteArray_set_size_SIZE 2 /* New size of the array*/
+ /* Sets the size of a `ByteArray`, either truncating it or filling it with zeros. */
+#define WSLUA_ARG_ByteArray_set_size_SIZE 2 /* New size of the array. */
ByteArray ba = checkByteArray(L,1);
int siz = luaL_checkint(L,WSLUA_ARG_ByteArray_set_size_SIZE);
@@ -150,9 +152,9 @@ WSLUA_METHOD ByteArray_set_size(lua_State* L) {
}
WSLUA_METHOD ByteArray_set_index(lua_State* L) {
- /* Sets the value of an index of a ByteArray. */
-#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] */
+ /* Sets the value of an index of a `ByteArray`. */
+#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]. */
ByteArray ba = checkByteArray(L,1);
int idx = luaL_checkint(L,WSLUA_ARG_ByteArray_set_index_INDEX);
int v = luaL_checkint(L,WSLUA_ARG_ByteArray_set_index_VALUE);
@@ -179,8 +181,8 @@ WSLUA_METHOD ByteArray_set_index(lua_State* L) {
WSLUA_METHOD ByteArray_get_index(lua_State* L) {
- /* Get the value of a byte in a ByteArray */
-#define WSLUA_ARG_ByteArray_get_index_INDEX 2 /* The position of the byte to get */
+ /* Get the value of a byte in a `ByteArray`. */
+#define WSLUA_ARG_ByteArray_get_index_INDEX 2 /* The position of the byte to get. */
ByteArray ba = checkByteArray(L,1);
int idx = luaL_checkint(L,WSLUA_ARG_ByteArray_get_index_INDEX);
@@ -199,18 +201,18 @@ WSLUA_METHOD ByteArray_get_index(lua_State* L) {
}
WSLUA_METHOD ByteArray_len(lua_State* L) {
- /* Obtain the length of a ByteArray */
+ /* Obtain the length of a `ByteArray`. */
ByteArray ba = checkByteArray(L,1);
lua_pushnumber(L,(lua_Number)ba->len);
- WSLUA_RETURN(1); /* The length of the ByteArray. */
+ WSLUA_RETURN(1); /* The length of the `ByteArray`. */
}
WSLUA_METHOD ByteArray_subset(lua_State* L) {
- /* Obtain a segment of a ByteArray, as a new ByteArray. */
-#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 */
+ /* Obtain a segment of a `ByteArray`, as a new `ByteArray`. */
+#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. */
ByteArray ba = checkByteArray(L,1);
int offset = luaL_checkint(L,WSLUA_ARG_ByteArray_set_index_OFFSET);
int len = luaL_checkint(L,WSLUA_ARG_ByteArray_set_index_LENGTH);
@@ -226,11 +228,11 @@ WSLUA_METHOD ByteArray_subset(lua_State* L) {
pushByteArray(L,sub);
- WSLUA_RETURN(1); /* A ByteArray contaning the requested segment. */
+ WSLUA_RETURN(1); /* A `ByteArray` containing the requested segment. */
}
WSLUA_METHOD ByteArray_base64_decode(lua_State* L) {
- /* Obtain a base64 decoded ByteArray */
+ /* Obtain a base64 decoded `ByteArray`. */
ByteArray ba = checkByteArray(L,1);
ByteArray ba2;
gchar *data;
@@ -246,11 +248,11 @@ WSLUA_METHOD ByteArray_base64_decode(lua_State* L) {
g_free(data);
pushByteArray(L,ba2);
- WSLUA_RETURN(1); /* The created ByteArray. */
+ WSLUA_RETURN(1); /* The created `ByteArray`. */
}
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 `ByteArray`. */
#define WSLUA_OPTARG_ByteArray_raw_OFFSET 2 /* The position of the first byte (default=0/first). */
#define WSLUA_OPTARG_ByteArray_raw_LENGTH 3 /* The length of the segment to get (default=all). */
ByteArray ba = checkByteArray(L,1);
@@ -273,7 +275,7 @@ WSLUA_METHOD ByteArray_raw(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 `ByteArray` as hex-ascii, with given separator */
#define WSLUA_OPTARG_ByteArray_tohex_LOWERCASE 2 /* True to use lower-case hex characters (default=false). */
#define WSLUA_OPTARG_ByteArray_tohex_SEPARATOR 3 /* A string separator to insert between hex bytes (default=nil). */
ByteArray ba = checkByteArray(L,1);
@@ -287,18 +289,19 @@ WSLUA_METHOD ByteArray_tohex(lua_State* L) {
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 `ByteArray`. */
}
WSLUA_METAMETHOD ByteArray__tostring(lua_State* L) {
- /* Obtain a Lua string containing the bytes in a ByteArray so that it can be used in display filters (e.g. "01FE456789AB") */
+ /* Obtain a Lua string containing the bytes in a `ByteArray` so that it can be used in
+ display filters (e.g. "01FE456789AB"). */
ByteArray ba = checkByteArray(L,1);
if (!ba) return 0;
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 `ByteArray`. */
}
static int ByteArray_tvb (lua_State *L);
@@ -356,11 +359,16 @@ int ByteArray_register(lua_State* L) {
*/
WSLUA_CLASS_DEFINE(Tvb,FAIL_ON_NULL_OR_EXPIRED("Tvb"),NOP);
-/* 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. Beware that 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 has returned.
-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:len() )*/
+/* 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:len()`.
+
+ @warning `Tvb`s 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
+ has returned.
+*/
static GPtrArray* outstanding_Tvb = NULL;
static GPtrArray* outstanding_TvbRange = NULL;
@@ -421,7 +429,7 @@ Tvb* push_Tvb(lua_State* L, tvbuff_t* ws_tvb) {
* ByteArray_tvb(name)
*/
WSLUA_CONSTRUCTOR ByteArray_tvb (lua_State *L) {
- /* Creates a new Tvb from a bytearray (it gets added to the current frame too) */
+ /* 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. */
ByteArray ba = checkByteArray(L,1);
const gchar* name = luaL_optstring(L,WSLUA_ARG_ByteArray_tvb_NAME,"Unnamed") ;
@@ -443,12 +451,12 @@ WSLUA_CONSTRUCTOR ByteArray_tvb (lua_State *L) {
add_new_data_source(lua_pinfo, tvb->ws_tvb, name);
PUSH_TVB(L,tvb);
- WSLUA_RETURN(1); /* The created Tvb. */
+ WSLUA_RETURN(1); /* The created `Tvb`. */
}
WSLUA_CONSTRUCTOR TvbRange_tvb (lua_State *L) {
- /* Creates a (sub)Tvb from a TvbRange */
-#define WSLUA_ARG_Tvb_new_subset_RANGE 1 /* The TvbRange from which to create the new Tvb. */
+ /* Creates a (sub)`Tvb` from a `TvbRange`. */
+#define WSLUA_ARG_Tvb_new_subset_RANGE 1 /* The `TvbRange` from which to create the new `Tvb`. */
TvbRange tvbr = checkTvbRange(L,WSLUA_ARG_Tvb_new_subset_RANGE);
Tvb tvb;
@@ -473,7 +481,8 @@ WSLUA_CONSTRUCTOR TvbRange_tvb (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 in case the string is too long. */
+ /* Convert the bytes of a `Tvb` into a string, to be used for debugging purposes as '...'
+ will be appended in case the string is too long. */
Tvb tvb = checkTvb(L,1);
int len;
gchar* str;
@@ -495,37 +504,38 @@ static int Tvb__gc(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 `Tvb`. */
Tvb tvb = checkTvb(L,1);
lua_pushnumber(L,tvb_reported_length(tvb->ws_tvb));
- WSLUA_RETURN(1); /* The length of the Tvb. */
+ WSLUA_RETURN(1); /* The reported length of the `Tvb`. */
}
WSLUA_METHOD Tvb_len(lua_State* L) {
- /* Obtain the actual (captured) length of a TVB */
+ /* Obtain the actual (captured) length of a `Tvb`. */
Tvb tvb = checkTvb(L,1);
lua_pushnumber(L,tvb_length(tvb->ws_tvb));
- WSLUA_RETURN(1); /* The length of the Tvb. */
+ WSLUA_RETURN(1); /* The captured length of the `Tvb`. */
}
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 offset is beyond the end of the TVB */
+ /* Obtain the reported (not captured) length of packet data to end of a `Tvb` or -1 if the
+ offset is beyond the end of the `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);
lua_pushnumber(L,tvb_reported_length_remaining(tvb->ws_tvb, offset));
- WSLUA_RETURN(1); /* The length of the Tvb. */
+ WSLUA_RETURN(1); /* The captured 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. */
+ /* Returns the raw offset (from the beginning of the source `Tvb`) of a sub `Tvb`. */
Tvb tvb = checkTvb(L,1);
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 `Tvb`. */
}
@@ -538,9 +548,10 @@ WSLUA_METAMETHOD Tvb__call(lua_State* L) {
WSLUA_CLASS_DEFINE(TvbRange,FAIL_ON_NULL("TvbRange"),NOP);
/*
- A TvbRange represents a usable range of a Tvb and is used to extract data from the Tvb that generated it
- TvbRanges 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.
+ 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)'). If the `TvbRange` span is outside the
+ `Tvb`'s range the creation will cause a runtime error.
*/
gboolean push_TvbRange(lua_State* L, tvbuff_t* ws_tvb, int offset, int len) {
@@ -577,9 +588,9 @@ gboolean push_TvbRange(lua_State* L, tvbuff_t* ws_tvb, int offset, int len) {
WSLUA_METHOD Tvb_range(lua_State* L) {
- /* Creates a tvbr from this Tvb. This is used also as the Tvb:__call() metamethod. */
-#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_LENGTH 3 /* The length (in octets) of the range. Defaults to until the end of the Tvb. */
+ /* Creates a `TvbRange` from this `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_LENGTH 3 /* The length (in octets) of the range. Defaults to until the end of the `Tvb`. */
Tvb tvb = checkTvb(L,1);
int offset = luaL_optint(L,WSLUA_OPTARG_Tvb_range_OFFSET,0);
@@ -593,7 +604,7 @@ WSLUA_METHOD Tvb_range(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 `Tvb`. */
#define WSLUA_OPTARG_Tvb_raw_OFFSET 2 /* The position of the first byte (default=0/first). */
#define WSLUA_OPTARG_Tvb_raw_LENGTH 3 /* The length of the segment to get (default=all). */
Tvb tvb = checkTvb(L,1);
@@ -624,7 +635,7 @@ WSLUA_METHOD Tvb_raw(lua_State* L) {
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 `Tvb`. */
}
WSLUA_METHODS Tvb_methods[] = {
@@ -653,7 +664,8 @@ int Tvb_register(lua_State* L) {
* get a Blefuscuoan unsigned integer from a tvb
*/
WSLUA_METHOD TvbRange_uint(lua_State* L) {
- /* Get a Big Endian (network order) unsigned integer from a TvbRange. The range must be 1, 2, 3 or 4 octets long. */
+ /* Get a Big Endian (network order) unsigned integer from a `TvbRange`.
+ The range must be 1, 2, 3 or 4 octets long. */
TvbRange tvbr = checkTvbRange(L,1);
if (!(tvbr && tvbr->tvb)) return 0;
if (tvbr->tvb->expired) {
@@ -673,7 +685,7 @@ WSLUA_METHOD TvbRange_uint(lua_State* L) {
return 1;
case 4:
lua_pushnumber(L,tvb_get_ntohl(tvbr->tvb->ws_tvb,tvbr->offset));
- WSLUA_RETURN(1); /* The unsigned integer value */
+ WSLUA_RETURN(1); /* The unsigned integer value. */
/*
* XXX:
* lua uses double so we have 52 bits to play with
@@ -691,7 +703,8 @@ WSLUA_METHOD TvbRange_uint(lua_State* L) {
* get a Lilliputian unsigned integer from a tvb
*/
WSLUA_METHOD TvbRange_le_uint(lua_State* L) {
- /* Get a Little Endian unsigned integer from a TvbRange. The range must be 1, 2, 3 or 4 octets long. */
+ /* Get a Little Endian unsigned integer from a `TvbRange`.
+ The range must be 1, 2, 3 or 4 octets long. */
TvbRange tvbr = checkTvbRange(L,1);
if (!(tvbr && tvbr->tvb)) return 0;
if (tvbr->tvb->expired) {
@@ -723,7 +736,8 @@ WSLUA_METHOD TvbRange_le_uint(lua_State* L) {
* get a Blefuscuoan unsigned 64 bit integer from a tvb
*/
WSLUA_METHOD TvbRange_uint64(lua_State* L) {
- /* Get a Big Endian (network order) unsigned 64 bit integer from a TvbRange. The range must be 1-8 octets long. */
+ /* 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. */
TvbRange tvbr = checkTvbRange(L,1);
if (!(tvbr && tvbr->tvb)) return 0;
if (tvbr->tvb->expired) {
@@ -741,7 +755,7 @@ WSLUA_METHOD TvbRange_uint64(lua_State* L) {
case 7:
case 8: {
pushUInt64(L,tvb_get_ntoh64(tvbr->tvb->ws_tvb,tvbr->offset));
- WSLUA_RETURN(1);
+ WSLUA_RETURN(1); /* The `UInt64` object. */
}
default:
luaL_error(L,"TvbRange:uint64() does not handle %d byte integers",tvbr->len);
@@ -753,7 +767,8 @@ WSLUA_METHOD TvbRange_uint64(lua_State* L) {
* get a Lilliputian unsigned 64 bit integer from a tvb
*/
WSLUA_METHOD TvbRange_le_uint64(lua_State* L) {
- /* Get a Little Endian unsigned 64 bit integer from a TvbRange. The range must be 1-8 octets long. */
+ /* Get a Little Endian unsigned 64 bit integer from a `TvbRange`, as a `UInt64` object.
+ The range must be 1-8 octets long. */
TvbRange tvbr = checkTvbRange(L,1);
if (!(tvbr && tvbr->tvb)) return 0;
if (tvbr->tvb->expired) {
@@ -771,7 +786,7 @@ WSLUA_METHOD TvbRange_le_uint64(lua_State* L) {
case 7:
case 8: {
pushUInt64(L,tvb_get_letoh64(tvbr->tvb->ws_tvb,tvbr->offset));
- WSLUA_RETURN(1);
+ WSLUA_RETURN(1); /* The `UInt64` object. */
}
default:
luaL_error(L,"TvbRange:le_uint64() does not handle %d byte integers",tvbr->len);
@@ -783,7 +798,8 @@ WSLUA_METHOD TvbRange_le_uint64(lua_State* L) {
* get a Blefuscuoan signed integer from a tvb
*/
WSLUA_METHOD TvbRange_int(lua_State* L) {
- /* Get a Big Endian (network order) signed integer from a TvbRange. The range must be 1, 2 or 4 octets long. */
+ /* Get a Big Endian (network order) signed integer from a `TvbRange`.
+ The range must be 1, 2 or 4 octets long. */
TvbRange tvbr = checkTvbRange(L,1);
if (!(tvbr && tvbr->tvb)) return 0;
if (tvbr->tvb->expired) {
@@ -818,7 +834,8 @@ WSLUA_METHOD TvbRange_int(lua_State* L) {
* get a Lilliputian signed integer from a tvb
*/
WSLUA_METHOD TvbRange_le_int(lua_State* L) {
- /* Get a Little Endian signed integer from a TvbRange. The range must be 1, 2 or 4 octets long. */
+ /* Get a Little Endian signed integer from a `TvbRange`.
+ The range must be 1, 2 or 4 octets long. */
TvbRange tvbr = checkTvbRange(L,1);
if (!(tvbr && tvbr->tvb)) return 0;
if (tvbr->tvb->expired) {
@@ -835,7 +852,7 @@ WSLUA_METHOD TvbRange_le_int(lua_State* L) {
return 1;
case 4:
lua_pushnumber(L,(gint)tvb_get_letohl(tvbr->tvb->ws_tvb,tvbr->offset));
- WSLUA_RETURN(1); /* The signed integer value */
+ WSLUA_RETURN(1); /* The signed integer value. */
default:
luaL_error(L,"TvbRange:le_int() does not handle %d byte integers",tvbr->len);
return 0;
@@ -846,7 +863,8 @@ WSLUA_METHOD TvbRange_le_int(lua_State* L) {
* get a Blefuscuoan signed 64 bit integer from a tvb
*/
WSLUA_METHOD TvbRange_int64(lua_State* L) {
- /* Get a Big Endian (network order) signed 64 bit integer from a TvbRange. The range must be 1-8 octets long. */
+ /* 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. */
TvbRange tvbr = checkTvbRange(L,1);
if (!(tvbr && tvbr->tvb)) return 0;
if (tvbr->tvb->expired) {
@@ -864,7 +882,7 @@ WSLUA_METHOD TvbRange_int64(lua_State* L) {
case 7:
case 8: {
pushInt64(L,(gint64)tvb_get_ntoh64(tvbr->tvb->ws_tvb,tvbr->offset));
- WSLUA_RETURN(1);
+ WSLUA_RETURN(1); /* The `Int64` object. */
}
default:
luaL_error(L,"TvbRange:int64() does not handle %d byte integers",tvbr->len);
@@ -876,7 +894,8 @@ WSLUA_METHOD TvbRange_int64(lua_State* L) {
* get a Lilliputian signed 64 bit integer from a tvb
*/
WSLUA_METHOD TvbRange_le_int64(lua_State* L) {
- /* Get a Little Endian signed 64 bit integer from a TvbRange. The range must be 1-8 octets long. */
+ /* Get a Little Endian signed 64 bit integer from a `TvbRange`, as an `Int64` object.
+ The range must be 1-8 octets long. */
TvbRange tvbr = checkTvbRange(L,1);
if (!(tvbr && tvbr->tvb)) return 0;
if (tvbr->tvb->expired) {
@@ -894,7 +913,7 @@ WSLUA_METHOD TvbRange_le_int64(lua_State* L) {
case 7:
case 8: {
pushInt64(L,(gint64)tvb_get_letoh64(tvbr->tvb->ws_tvb,tvbr->offset));
- WSLUA_RETURN(1);
+ WSLUA_RETURN(1); /* The `Int64` object. */
}
default:
luaL_error(L,"TvbRange:le_int64() does not handle %d byte integers",tvbr->len);
@@ -906,7 +925,8 @@ WSLUA_METHOD TvbRange_le_int64(lua_State* L) {
* get a Blefuscuoan float
*/
WSLUA_METHOD TvbRange_float(lua_State* L) {
- /* Get a Big Endian (network order) floating point number from a TvbRange. The range must be 4 or 8 octets long. */
+ /* Get a Big Endian (network order) floating point number from a `TvbRange`.
+ The range must be 4 or 8 octets long. */
TvbRange tvbr = checkTvbRange(L,1);
if (!(tvbr && tvbr->tvb)) return 0;
if (tvbr->tvb->expired) {
@@ -920,7 +940,7 @@ WSLUA_METHOD TvbRange_float(lua_State* L) {
return 1;
case 8:
lua_pushnumber(L,tvb_get_ntohieee_double(tvbr->tvb->ws_tvb,tvbr->offset));
- WSLUA_RETURN(1); /* The floating point value */
+ WSLUA_RETURN(1); /* The floating point value. */
default:
luaL_error(L,"TvbRange:float() does not handle %d byte floating numbers",tvbr->len);
return 0;
@@ -931,7 +951,8 @@ WSLUA_METHOD TvbRange_float(lua_State* L) {
* get a Lilliputian float
*/
WSLUA_METHOD TvbRange_le_float(lua_State* L) {
- /* Get a Little Endian floating point number from a TvbRange. The range must be 4 or 8 octets long. */
+ /* Get a Little Endian floating point number from a `TvbRange`.
+ The range must be 4 or 8 octets long. */
TvbRange tvbr = checkTvbRange(L,1);
if (!(tvbr && tvbr->tvb)) return 0;
@@ -941,7 +962,7 @@ WSLUA_METHOD TvbRange_le_float(lua_State* L) {
return 1;
case 8:
lua_pushnumber(L,tvb_get_letohieee_double(tvbr->tvb->ws_tvb,tvbr->offset));
- WSLUA_RETURN(1); /* The floating point value */
+ WSLUA_RETURN(1); /* The floating point value. */
default:
luaL_error(L,"TvbRange:le_float() does not handle %d byte floating numbers",tvbr->len);
return 0;
@@ -949,7 +970,7 @@ WSLUA_METHOD TvbRange_le_float(lua_State* L) {
}
WSLUA_METHOD TvbRange_ipv4(lua_State* L) {
- /* Get an IPv4 Address from a TvbRange. */
+ /* Get an IPv4 Address from a `TvbRange`, as an `Address` object. */
TvbRange tvbr = checkTvbRange(L,1);
Address addr;
guint32* ip_addr;
@@ -973,11 +994,11 @@ WSLUA_METHOD TvbRange_ipv4(lua_State* L) {
SET_ADDRESS(addr, AT_IPv4, 4, ip_addr);
pushAddress(L,addr);
- WSLUA_RETURN(1); /* The IPv4 Address */
+ WSLUA_RETURN(1); /* The IPv4 `Address` object. */
}
WSLUA_METHOD TvbRange_le_ipv4(lua_State* L) {
- /* Get an Little Endian IPv4 Address from a TvbRange. */
+ /* Get an Little Endian IPv4 Address from a `TvbRange`, as an `Address` object. */
TvbRange tvbr = checkTvbRange(L,1);
Address addr;
guint32* ip_addr;
@@ -1002,11 +1023,11 @@ WSLUA_METHOD TvbRange_le_ipv4(lua_State* L) {
SET_ADDRESS(addr, AT_IPv4, 4, ip_addr);
pushAddress(L,addr);
- WSLUA_RETURN(1); /* The IPv4 Address */
+ WSLUA_RETURN(1); /* The IPv4 `Address` object. */
}
WSLUA_METHOD TvbRange_ether(lua_State* L) {
- /* Get an Ethernet Address from a TvbRange. */
+ /* Get an Ethernet Address from a `TvbRange`, as an `Address` object. */
TvbRange tvbr = checkTvbRange(L,1);
Address addr;
guint8* buff;
@@ -1029,11 +1050,11 @@ WSLUA_METHOD TvbRange_ether(lua_State* L) {
SET_ADDRESS(addr, AT_ETHER, 6, buff);
pushAddress(L,addr);
- WSLUA_RETURN(1); /* The Ethernet Address */
+ WSLUA_RETURN(1); /* The Ethernet `Address` object. */
}
WSLUA_METHOD TvbRange_nstime(lua_State* L) {
- /* Obtain a nstime from a TvbRange */
+ /* Obtain a time_t structure from a `TvbRange`, as an `NSTime` object. */
TvbRange tvbr = checkTvbRange(L,1);
NSTime nstime;
@@ -1059,11 +1080,11 @@ WSLUA_METHOD TvbRange_nstime(lua_State* L) {
pushNSTime(L, nstime);
- WSLUA_RETURN(1); /* The NSTime */
+ WSLUA_RETURN(1); /* The `NSTime` object. */
}
WSLUA_METHOD TvbRange_le_nstime(lua_State* L) {
- /* Obtain a nstime from a TvbRange */
+ /* Obtain a nstime from a `TvbRange`, as an `NSTime` object. */
TvbRange tvbr = checkTvbRange(L,1);
NSTime nstime;
@@ -1089,11 +1110,11 @@ WSLUA_METHOD TvbRange_le_nstime(lua_State* L) {
pushNSTime(L, nstime);
- WSLUA_RETURN(1); /* The NSTime */
+ WSLUA_RETURN(1); /* The `NSTime` object. */
}
WSLUA_METHOD TvbRange_string(lua_State* L) {
- /* Obtain a string from a TvbRange */
+ /* Obtain a string from a `TvbRange`. */
#define WSLUA_OPTARG_TvbRange_string_ENCODING 2 /* The encoding to use. Defaults to ENC_ASCII. */
TvbRange tvbr = checkTvbRange(L,1);
guint encoding = (guint)luaL_optint(L,WSLUA_OPTARG_TvbRange_string_ENCODING, ENC_ASCII|ENC_NA);
@@ -1110,7 +1131,7 @@ WSLUA_METHOD TvbRange_string(lua_State* L) {
}
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 `TvbRange`. */
TvbRange tvbr = checkTvbRange(L,1);
gchar * str;
@@ -1127,17 +1148,17 @@ static int TvbRange_ustring_any(lua_State* L, gboolean little_endian) {
}
WSLUA_METHOD TvbRange_ustring(lua_State* L) {
- /* Obtain a Big Endian (network order) UTF-16 encoded string from a TvbRange */
- WSLUA_RETURN(TvbRange_ustring_any(L, FALSE)); /* The string */
+ /* Obtain a Big Endian (network order) UTF-16 encoded string from a `TvbRange`. */
+ WSLUA_RETURN(TvbRange_ustring_any(L, FALSE)); /* The string. */
}
WSLUA_METHOD TvbRange_le_ustring(lua_State* L) {
- /* Obtain a Little Endian UTF-16 encoded string from a TvbRange */
- WSLUA_RETURN(TvbRange_ustring_any(L, TRUE)); /* The string */
+ /* Obtain a Little Endian UTF-16 encoded string from a `TvbRange`. */
+ WSLUA_RETURN(TvbRange_ustring_any(L, TRUE)); /* The string. */
}
WSLUA_METHOD TvbRange_stringz(lua_State* L) {
- /* Obtain a zero terminated string from a TvbRange */
+ /* Obtain a zero terminated string from a `TvbRange`. */
#define WSLUA_OPTARG_TvbRange_stringz_ENCODING 2 /* The encoding to use. Defaults to ENC_ASCII. */
TvbRange tvbr = checkTvbRange(L,1);
guint encoding = (guint)luaL_optint(L,WSLUA_OPTARG_TvbRange_stringz_ENCODING, ENC_ASCII|ENC_NA);
@@ -1176,11 +1197,12 @@ 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));
- WSLUA_RETURN(1); /* The zero terminated string */
+ WSLUA_RETURN(1); /* The zero terminated string. */
}
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 `TvbRange`.
+ The size of the string includes the terminating zero. */
#define WSLUA_OPTARG_TvbRange_strsize_ENCODING 2 /* The encoding to use. Defaults to ENC_ASCII. */
TvbRange tvbr = checkTvbRange(L,1);
guint encoding = (guint)luaL_optint(L,WSLUA_OPTARG_TvbRange_strsize_ENCODING, ENC_ASCII|ENC_NA);
@@ -1219,7 +1241,7 @@ WSLUA_METHOD TvbRange_strsize(lua_State* L) {
break;
}
- WSLUA_RETURN(1); /* Length of the zero terminated string */
+ WSLUA_RETURN(1); /* Length of the zero terminated string. */
}
@@ -1247,24 +1269,25 @@ static int TvbRange_ustringz_any(lua_State* L, gboolean little_endian) {
offset += 2;
} while (uchar != 0);
- lua_pushstring(L, (gchar*)tvb_get_stringz_enc(wmem_packet_scope(),tvbr->tvb->ws_tvb,tvbr->offset,&count,(little_endian ? ENC_UTF_16|ENC_LITTLE_ENDIAN : ENC_UTF_16|ENC_BIG_ENDIAN)) );
+ lua_pushstring(L, (gchar*)tvb_get_stringz_enc(wmem_packet_scope(),tvbr->tvb->ws_tvb,tvbr->offset,&count,
+ (little_endian ? ENC_UTF_16|ENC_LITTLE_ENDIAN : ENC_UTF_16|ENC_BIG_ENDIAN)) );
lua_pushinteger(L,count);
return 2; /* The zero terminated string, the length found in tvbr */
}
WSLUA_METHOD TvbRange_ustringz(lua_State* L) {
- /* Obtain a Big Endian (network order) UTF-16 encoded zero terminated string from a TvbRange */
- WSLUA_RETURN(TvbRange_ustringz_any(L, FALSE)); /* The zero terminated string, the length found in tvbr */
+ /* Obtain a Big Endian (network order) UTF-16 encoded zero terminated string from a `TvbRange`. */
+ WSLUA_RETURN(TvbRange_ustringz_any(L, FALSE)); /* Two return values: the zero terminated string, and the length. */
}
WSLUA_METHOD TvbRange_le_ustringz(lua_State* L) {
/* Obtain a Little Endian UTF-16 encoded zero terminated string from a TvbRange */
- WSLUA_RETURN(TvbRange_ustringz_any(L, TRUE)); /* The zero terminated string, the length found in tvbr */
+ WSLUA_RETURN(TvbRange_ustringz_any(L, TRUE)); /* Two return values: the zero terminated string, and the length. */
}
WSLUA_METHOD TvbRange_bytes(lua_State* L) {
- /* Obtain a ByteArray */
+ /* Obtain a `ByteArray` from a `TvbRange`. */
TvbRange tvbr = checkTvbRange(L,1);
GByteArray* ba;
@@ -1279,12 +1302,12 @@ WSLUA_METHOD TvbRange_bytes(lua_State* L) {
pushByteArray(L,ba);
- WSLUA_RETURN(1); /* The ByteArray */
+ WSLUA_RETURN(1); /* The `ByteArray` object. */
}
WSLUA_METHOD TvbRange_bitfield(lua_State* L) {
- /* Get a bitfield from a TvbRange. */
-#define WSLUA_OPTARG_TvbRange_bitfield_POSITION 2 /* The bit offset from the beginning of the TvbRange. Defaults to 0. */
+ /* Get a bitfield from a `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_LENGTH 3 /* The length (in bits) of the field. Defaults to 1. */
TvbRange tvbr = checkTvbRange(L,1);
@@ -1321,9 +1344,9 @@ WSLUA_METHOD TvbRange_bitfield(lua_State* L) {
}
WSLUA_METHOD TvbRange_range(lua_State* L) {
- /* Creates a sub-TvbRange from this TvbRange. This is used also as the TvbRange:__call() metamethod. */
-#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_LENGTH 3 /* The length (in octets) of the range. Defaults to until the end of the TvbRange. */
+ /* Creates a sub-`TvbRange` from this `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_LENGTH 3 /* The length (in octets) of the range. Defaults to until the end of the `TvbRange`. */
TvbRange tvbr = checkTvbRange(L,1);
int offset = luaL_optint(L,WSLUA_OPTARG_TvbRange_range_OFFSET,0);
@@ -1390,7 +1413,7 @@ static int TvbRange__gc(lua_State* L) {
}
WSLUA_METHOD TvbRange_len(lua_State* L) {
- /* Obtain the length of a TvbRange */
+ /* Obtain the length of a `TvbRange`. */
TvbRange tvbr = checkTvbRange(L,1);
if (!(tvbr && tvbr->tvb)) return 0;
@@ -1403,7 +1426,7 @@ WSLUA_METHOD TvbRange_len(lua_State* L) {
}
WSLUA_METHOD TvbRange_offset(lua_State* L) {
- /* Obtain the offset in a TvbRange */
+ /* Obtain the offset in a `TvbRange`. */
TvbRange tvbr = checkTvbRange(L,1);
if (!(tvbr && tvbr->tvb)) return 0;
@@ -1416,7 +1439,7 @@ WSLUA_METHOD TvbRange_offset(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 `TvbRange`. */
#define WSLUA_OPTARG_TvbRange_raw_OFFSET 2 /* The position of the first byte (default=0/first). */
#define WSLUA_OPTARG_TvbRange_raw_LENGTH 3 /* The length of the segment to get (default=all). */
TvbRange tvbr = checkTvbRange(L,1);
@@ -1447,12 +1470,12 @@ WSLUA_METHOD TvbRange_raw(lua_State* L) {
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 `TvbRange`. */
}
WSLUA_METAMETHOD TvbRange__tostring(lua_State* L) {
- /* Converts the TvbRange into a string. As the string gets truncated
+ /* Converts the `TvbRange` into a string. As the string gets truncated
you should use this only for debugging purposes
or if what you want is to have a truncated string in the format 67:89:AB:... */
TvbRange tvbr = checkTvbRange(L,1);
diff --git a/epan/wslua/wslua_util.c b/epan/wslua/wslua_util.c
index f66310bf7c..c9098aa980 100644
--- a/epan/wslua/wslua_util.c
+++ b/epan/wslua/wslua_util.c
@@ -31,13 +31,13 @@
#include <epan/stat_cmd_args.h>
-WSLUA_FUNCTION wslua_get_version(lua_State* L) { /* Get Wireshark version */
+WSLUA_FUNCTION wslua_get_version(lua_State* L) { /* Gets a string of the Wireshark version. */
const gchar* str = VERSION;
lua_pushstring(L,str);
WSLUA_RETURN(1); /* version string */
}
-WSLUA_FUNCTION wslua_format_date(lua_State* LS) { /* Formats an absolute timestamp into a human readable date */
+WSLUA_FUNCTION wslua_format_date(lua_State* LS) { /* Formats an absolute timestamp into a human readable date. */
#define WSLUA_ARG_format_date_TIMESTAMP 1 /* A timestamp value to convert. */
lua_Number timestamp = luaL_checknumber(LS,WSLUA_ARG_format_date_TIMESTAMP);
nstime_t then;
@@ -51,8 +51,8 @@ WSLUA_FUNCTION wslua_format_date(lua_State* LS) { /* Formats an absolute timesta
WSLUA_RETURN(1); /* A string with the formated date */
}
-WSLUA_FUNCTION wslua_format_time(lua_State* LS) { /* Formats a relative timestamp in a human readable form */
-#define WSLUA_ARG_format_time_TIMESTAMP 1 /* A timestamp value to convert */
+WSLUA_FUNCTION wslua_format_time(lua_State* LS) { /* Formats a relative timestamp in a human readable form. */
+#define WSLUA_ARG_format_time_TIMESTAMP 1 /* A timestamp value to convert. */
lua_Number timestamp = luaL_checknumber(LS,WSLUA_ARG_format_time_TIMESTAMP);
nstime_t then;
gchar* str;
@@ -65,8 +65,8 @@ WSLUA_FUNCTION wslua_format_time(lua_State* LS) { /* Formats a relative timestam
WSLUA_RETURN(1); /* A string with the formated time */
}
-WSLUA_FUNCTION wslua_report_failure(lua_State* LS) { /* Reports a failure to the user */
-#define WSLUA_ARG_report_failure_TEXT 1 /* Message */
+WSLUA_FUNCTION wslua_report_failure(lua_State* LS) { /* Reports a failure to the user. */
+#define WSLUA_ARG_report_failure_TEXT 1 /* Message text to report. */
const gchar* s = luaL_checkstring(LS,WSLUA_ARG_report_failure_TEXT);
report_failure("%s",s);
return 0;
@@ -99,27 +99,27 @@ static int wslua_log(lua_State* L, GLogLevelFlags log_level) {
return 0;
}
-WSLUA_FUNCTION wslua_critical( lua_State* L ) { /* Will add a log entry with critical severity*/
+WSLUA_FUNCTION wslua_critical( lua_State* L ) { /* Will add a log entry with critical severity. */
/* WSLUA_MOREARGS critical objects to be printed */
wslua_log(L,G_LOG_LEVEL_CRITICAL);
return 0;
}
-WSLUA_FUNCTION wslua_warn( lua_State* L ) { /* Will add a log entry with warn severity */
+WSLUA_FUNCTION wslua_warn( lua_State* L ) { /* Will add a log entry with warn severity. */
/* WSLUA_MOREARGS warn objects to be printed */
wslua_log(L,G_LOG_LEVEL_WARNING);
return 0;
}
-WSLUA_FUNCTION wslua_message( lua_State* L ) { /* Will add a log entry with message severity */
+WSLUA_FUNCTION wslua_message( lua_State* L ) { /* Will add a log entry with message severity. */
/* WSLUA_MOREARGS message objects to be printed */
wslua_log(L,G_LOG_LEVEL_MESSAGE);
return 0;
}
-WSLUA_FUNCTION wslua_info( lua_State* L ) { /* Will add a log entry with info severity */
+WSLUA_FUNCTION wslua_info( lua_State* L ) { /* Will add a log entry with info severity. */
/* WSLUA_MOREARGS info objects to be printed */
wslua_log(L,G_LOG_LEVEL_INFO);
return 0;
}
-WSLUA_FUNCTION wslua_debug( lua_State* L ) { /* Will add a log entry with debug severity */
+WSLUA_FUNCTION wslua_debug( lua_State* L ) { /* Will add a log entry with debug severity. */
/* WSLUA_MOREARGS debug objects to be printed */
wslua_log(L,G_LOG_LEVEL_DEBUG);
return 0;
@@ -177,8 +177,8 @@ static char* wslua_get_actual_filename(const char* fname) {
WSLUA_FUNCTION wslua_loadfile(lua_State* L) {
/* Lua's loadfile() has been modified so that if a file does not exist
- in the current directory it will look for it in wireshark's user and system directories */
-#define WSLUA_ARG_loadfile_FILENAME 1 /* Name of the file to be loaded */
+ in the current directory it will look for it in wireshark's user and system directories. */
+#define WSLUA_ARG_loadfile_FILENAME 1 /* Name of the file to be loaded. */
const char *given_fname = luaL_checkstring(L, WSLUA_ARG_loadfile_FILENAME);
char* filename;
@@ -202,8 +202,8 @@ WSLUA_FUNCTION wslua_loadfile(lua_State* L) {
WSLUA_FUNCTION wslua_dofile(lua_State* L) {
/* Lua's dofile() has been modified so that if a file does not exist
- in the current directory it will look for it in wireshark's user and system directories */
-#define WSLUA_ARG_dofile_FILENAME 1 /* Name of the file to be run */
+ in the current directory it will look for it in wireshark's user and system directories. */
+#define WSLUA_ARG_dofile_FILENAME 1 /* Name of the file to be run. */
const char *given_fname = luaL_checkstring(L, WSLUA_ARG_dofile_FILENAME);
char* filename;
int n;
@@ -229,13 +229,13 @@ WSLUA_FUNCTION wslua_dofile(lua_State* L) {
WSLUA_FUNCTION wslua_persconffile_path(lua_State* L) {
-#define WSLUA_OPTARG_persconffile_path_FILENAME 1 /* A filename */
+#define WSLUA_OPTARG_persconffile_path_FILENAME 1 /* A filename. */
const char *fname = luaL_optstring(L, WSLUA_OPTARG_persconffile_path_FILENAME,"");
char* filename = get_persconffile_path(fname,FALSE);
lua_pushstring(L,filename);
g_free(filename);
- WSLUA_RETURN(1); /* The full pathname for a file in the personal configuration directory */
+ WSLUA_RETURN(1); /* The full pathname for a file in the personal configuration directory. */
}
WSLUA_FUNCTION wslua_datafile_path(lua_State* L) {
@@ -253,16 +253,19 @@ WSLUA_FUNCTION wslua_datafile_path(lua_State* L) {
lua_pushstring(L,filename);
g_free(filename);
- WSLUA_RETURN(1); /* The full pathname for a file in wireshark's configuration directory */
+ WSLUA_RETURN(1); /* The full pathname for a file in wireshark's configuration directory. */
}
WSLUA_CLASS_DEFINE(Dir,FAIL_ON_NULL("Dir"),NOP); /* A Directory */
WSLUA_CONSTRUCTOR Dir_open(lua_State* L) {
- /* Usage: for filename in Dir.open(path) do ... end */
-#define WSLUA_ARG_Dir_open_PATHNAME 1 /* The pathname of the directory */
-#define WSLUA_OPTARG_Dir_open_EXTENSION 2 /* If given, only file with this extension will be returned */
+ /* Opens a directory and returns a `Dir` object representing the files in the directory.
+
+ @code for filename in Dir.open(path) do ... end @endcode
+ */
+#define WSLUA_ARG_Dir_open_PATHNAME 1 /* The pathname of the directory. */
+#define WSLUA_OPTARG_Dir_open_EXTENSION 2 /* If given, only files with this extension will be returned. */
const char* dirname = luaL_checkstring(L,WSLUA_ARG_Dir_open_PATHNAME);
const char* extension = luaL_optstring(L,WSLUA_OPTARG_Dir_open_EXTENSION,NULL);
@@ -302,11 +305,11 @@ WSLUA_CONSTRUCTOR Dir_open(lua_State* L) {
}
pushDir(L,dir);
- WSLUA_RETURN(1); /* the Dir object */
+ WSLUA_RETURN(1); /* the `Dir` object. */
}
WSLUA_METAMETHOD Dir__call(lua_State* L) {
- /* At every invocation will return one file (nil when done) */
+ /* At every invocation will return one file (nil when done). */
Dir dir = checkDir(L,1);
const gchar* file;
@@ -346,7 +349,7 @@ WSLUA_METAMETHOD Dir__call(lua_State* L) {
}
WSLUA_METHOD Dir_close(lua_State* L) {
- /* Closes the directory */
+ /* Closes the directory. */
Dir dir = checkDir(L,1);
if (dir->dir) {
@@ -446,114 +449,6 @@ WSLUA_FUNCTION wslua_register_stat_cmd_arg(lua_State* L) {
return 0;
}
-/* Pushes a hex string of the binary data argument. */
-int wslua_bin2hex(lua_State* L, const guint8* data, const guint len, const gboolean lowercase, const gchar* sep) {
- luaL_Buffer b;
- guint i = 0;
- static const char byte_to_str_upper[256][3] = {
- "00","01","02","03","04","05","06","07","08","09","0A","0B","0C","0D","0E","0F",
- "10","11","12","13","14","15","16","17","18","19","1A","1B","1C","1D","1E","1F",
- "20","21","22","23","24","25","26","27","28","29","2A","2B","2C","2D","2E","2F",
- "30","31","32","33","34","35","36","37","38","39","3A","3B","3C","3D","3E","3F",
- "40","41","42","43","44","45","46","47","48","49","4A","4B","4C","4D","4E","4F",
- "50","51","52","53","54","55","56","57","58","59","5A","5B","5C","5D","5E","5F",
- "60","61","62","63","64","65","66","67","68","69","6A","6B","6C","6D","6E","6F",
- "70","71","72","73","74","75","76","77","78","79","7A","7B","7C","7D","7E","7F",
- "80","81","82","83","84","85","86","87","88","89","8A","8B","8C","8D","8E","8F",
- "90","91","92","93","94","95","96","97","98","99","9A","9B","9C","9D","9E","9F",
- "A0","A1","A2","A3","A4","A5","A6","A7","A8","A9","AA","AB","AC","AD","AE","AF",
- "B0","B1","B2","B3","B4","B5","B6","B7","B8","B9","BA","BB","BC","BD","BE","BF",
- "C0","C1","C2","C3","C4","C5","C6","C7","C8","C9","CA","CB","CC","CD","CE","CF",
- "D0","D1","D2","D3","D4","D5","D6","D7","D8","D9","DA","DB","DC","DD","DE","DF",
- "E0","E1","E2","E3","E4","E5","E6","E7","E8","E9","EA","EB","EC","ED","EE","EF",
- "F0","F1","F2","F3","F4","F5","F6","F7","F8","F9","FA","FB","FC","FD","FE","FF"
- };
- static const char byte_to_str_lower[256][3] = {
- "00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f",
- "10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f",
- "20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f",
- "30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f",
- "40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f",
- "50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f",
- "60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f",
- "70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f",
- "80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f",
- "90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f",
- "a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af",
- "b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf",
- "c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf",
- "d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df",
- "e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef",
- "f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"
- };
- const char (*byte_to_str)[3] = byte_to_str_upper;
- const guint last = len - 1;
-
- if (lowercase) byte_to_str = byte_to_str_lower;
-
- luaL_buffinit(L, &b);
-
- for (i = 0; i < len; i++) {
- luaL_addlstring(&b, &(*byte_to_str[data[i]]), 2);
- if (sep && i < last) luaL_addstring(&b, sep);
- }
-
- luaL_pushresult(&b);
-
- return 1;
-}
-
-/* Pushes a binary string of the hex-ascii data argument. */
-int wslua_hex2bin(lua_State* L, const char* data, const guint len, const gchar* sep) {
- luaL_Buffer b;
- guint i = 0;
- guint seplen = 0;
- char c, d;
-
- static const char str_to_nibble[256] = {
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1,
- -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
- };
-
- if (sep) seplen = (guint) strlen(sep);
-
- luaL_buffinit(L, &b);
-
- for (i = 0; i < len;) {
- c = str_to_nibble[(int)data[i]];
- if (c < 0) {
- if (seplen && strncmp(&data[i], sep, seplen) == 0) {
- i += seplen;
- continue;
- } else {
- break;
- }
- }
- d = str_to_nibble[(int)data[++i]];
- if (d < 0) break;
- luaL_addchar(&b, (c * 16) + d);
- i++;
- }
-
- luaL_pushresult(&b);
-
- return 1;
-}
-
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*