summaryrefslogtreecommitdiff
path: root/epan/wslua/wslua_tree.c
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2014-02-06 01:33:12 -0500
committerEvan Huus <eapache@gmail.com>2014-02-07 19:19:54 +0000
commit217f9fd0d9f2d6a9084da3fc945cce001414eea3 (patch)
treed262451cdc6f04d4bc8629bb5b89ce6c5b1eb542 /epan/wslua/wslua_tree.c
parent373bf9bd86a5522f0beadbbadc5e07047dc64c65 (diff)
downloadwireshark-217f9fd0d9f2d6a9084da3fc945cce001414eea3.tar.gz
Fix Bug 9728 'Lua: ProtoField.bool() VALUESTRING argument is not optional but was supposed to be'
Similar to bug 9725 and ProtoField.new(), the way the VALUESTRING argument is being checked in the code for ProtoField.bool() ends up making it non-optional. This patch fixes that, along with some minor API documentation fixes (text). Change-Id: Iadb9a8ace9c5514fc623d882301fe16b637fe4ce Reviewed-on: https://code.wireshark.org/review/125 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan/wslua/wslua_tree.c')
-rw-r--r--epan/wslua/wslua_tree.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/epan/wslua/wslua_tree.c b/epan/wslua/wslua_tree.c
index 1cbc6253a7..14a5cb6836 100644
--- a/epan/wslua/wslua_tree.c
+++ b/epan/wslua/wslua_tree.c
@@ -250,6 +250,8 @@ static int TreeItem_add_item_any(lua_State *L, gboolean little_endian) {
const gchar* s = lua_tostring(L,1);
item = proto_tree_add_text(tree_item->tree, tvbr->tvb->ws_tvb, tvbr->offset, tvbr->len,"%s",s);
lua_remove(L,1);
+ } else {
+ luaL_error(L,"Tree item ProtoField/Protocol handle is invalid (ProtoField/Proto not registered?)");
}
}
@@ -272,20 +274,32 @@ static int TreeItem_add_item_any(lua_State *L, gboolean little_endian) {
WSLUA_METHOD TreeItem_add(lua_State *L) {
/*
- Adds an child item to a given item, returning the child.
- tree_item:add([proto_field | proto], [tvbrange], [label], ...)
- if the proto_field represents a numeric value (int, uint or float) is to be 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
+ it is the value (as opposed to filling that argument with 'nil', which is invalid for this function).
*/
- WSLUA_RETURN(TreeItem_add_item_any(L,FALSE)); /* The child item */
+#define WSLUA_ARG_TreeItem_add_PROTOFIELD 2 /* The ProtoField field or Proto protocol object to add to the tree. */
+#define WSLUA_OPTARG_TreeItem_add_TVBRANGE 3 /* The TvbRange of bytes in the packet this tree item covers/represents. */
+#define WSLUA_OPTARG_TreeItem_add_VALUE 4 /* The field's value, instead of the ProtoField/Proto one. */
+#define WSLUA_OPTARG_TreeItem_add_LABEL 5 /* One or more strings to use for the tree item label, instead of the ProtoField/Proto one. */
+ WSLUA_RETURN(TreeItem_add_item_any(L,FALSE)); /* The new child TreeItem */
}
WSLUA_METHOD TreeItem_add_le(lua_State *L) {
/*
- Adds (and returns) an child item to a given item, returning the child.
- tree_item:add([proto_field | proto], [tvbrange], [label], ...)
- if the proto_field represents a numeric value (int, uint or float) is to be 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
+ it is the value (as opposed to filling that argument with 'nil', which is invalid for this function).
*/
- WSLUA_RETURN(TreeItem_add_item_any(L,TRUE)); /* The child item */
+#define WSLUA_ARG_TreeItem_add_le_PROTOFIELD 2 /* The ProtoField field or Proto protocol object to add to the tree. */
+#define WSLUA_OPTARG_TreeItem_add_le_TVBRANGE 3 /* The TvbRange of bytes in the packet this tree item covers/represents. */
+#define WSLUA_OPTARG_TreeItem_add_le_VALUE 4 /* The field's value, instead of the ProtoField/Proto one. */
+#define WSLUA_OPTARG_TreeItem_add_le_LABEL 5 /* One or more strings to use for the tree item label, instead of the ProtoField/Proto one. */
+ WSLUA_RETURN(TreeItem_add_item_any(L,TRUE)); /* The new child TreeItem */
}
WSLUA_METHOD TreeItem_set_text(lua_State *L) {