summaryrefslogtreecommitdiffstats
path: root/epan/wslua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--epan/wslua/init_wslua.c34
-rw-r--r--epan/wslua/lrexlib/pcre2/lpcre2.c2
-rwxr-xr-xepan/wslua/make-taps.py24
-rw-r--r--epan/wslua/wslua.h4
-rw-r--r--epan/wslua/wslua_byte_array.c12
-rw-r--r--epan/wslua/wslua_dissector.c53
-rw-r--r--epan/wslua/wslua_field.c12
-rw-r--r--epan/wslua/wslua_file.c6
-rw-r--r--epan/wslua/wslua_file_handler.c8
-rw-r--r--epan/wslua/wslua_frame_info.c8
-rw-r--r--epan/wslua/wslua_int64.c2
-rw-r--r--epan/wslua/wslua_pinfo.c2
-rw-r--r--epan/wslua/wslua_pref.c4
-rw-r--r--epan/wslua/wslua_proto.c4
-rw-r--r--epan/wslua/wslua_struct.c10
-rw-r--r--epan/wslua/wslua_tree.c10
-rw-r--r--epan/wslua/wslua_tvb.c56
-rw-r--r--epan/wslua/wslua_wtap.c10
18 files changed, 160 insertions, 101 deletions
diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c
index 9217a4ab..3e701ffc 100644
--- a/epan/wslua/init_wslua.c
+++ b/epan/wslua/init_wslua.c
@@ -969,7 +969,7 @@ add_table_symbol(const char *table, const char *name, int value)
lua_getglobal(L, table);
/* Set symbol in table. */
lua_pushstring(L, name);
- lua_pushinteger(L, value);
+ lua_pushnumber(L, value);
lua_settable(L, -3);
/* Pop table from stack. */
lua_pop(L, 1);
@@ -979,7 +979,7 @@ static void
add_global_symbol(const char *name, int value)
{
/* Set symbol in global environment. */
- lua_pushinteger(L, value);
+ lua_pushnumber(L, value);
lua_setglobal(L, name);
}
@@ -988,7 +988,7 @@ add_pi_severity_symbol(const char *name, int value)
{
lua_getglobal(L, WSLUA_EXPERT_TABLE);
lua_getfield(L, -1, WSLUA_EXPERT_SEVERITY_TABLE);
- lua_pushinteger(L, value);
+ lua_pushnumber(L, value);
lua_setfield(L, -2, name);
lua_pop(L, 2);
}
@@ -998,7 +998,7 @@ add_pi_group_symbol(const char *name, int value)
{
lua_getglobal(L, WSLUA_EXPERT_TABLE);
lua_getfield(L, -1, WSLUA_EXPERT_GROUP_TABLE);
- lua_pushinteger(L, value);
+ lua_pushnumber(L, value);
lua_setfield(L, -2, name);
lua_pop(L, 2);
}
@@ -1007,7 +1007,7 @@ static void
add_menu_group_symbol(const char *name, int value)
{
/* Set symbol in global environment. */
- lua_pushinteger(L, value);
+ lua_pushnumber(L, value);
char *str = g_strdup(name);
char *s = strstr(str, "_GROUP_");
if (s == NULL)
@@ -1392,6 +1392,7 @@ void wslua_init(register_cb cb, gpointer client_data) {
int file_count = 1;
static gboolean first_time = TRUE;
int i;
+ int error;
static hf_register_info hf[] = {
{ &hf_wslua_fake,
@@ -1704,7 +1705,28 @@ void wslua_init(register_cb cb, gpointer client_data) {
lua_tree = NULL;
lua_tvb = NULL;
- Proto_commit(L);
+ /* Unfortunately, by waiting to register the hfi and ei now, Lua
+ * can't figure out which file had the error and provide a traceback,
+ * so no special error handler.
+ */
+ lua_pushcfunction(L, Proto_commit);
+ error = lua_pcall(L, 0, 0, 0);
+ if (error) {
+ switch (error) {
+ case LUA_ERRRUN:
+ report_failure("Lua: Error initializing protocols:\n%s", lua_tostring(L, -1));
+ break;
+ case LUA_ERRMEM:
+ report_failure("Lua: Error initializing protocols: out of memory");
+ break;
+ case LUA_ERRERR:
+ report_failure("Lua: Error initializing protocols: error while retrieving error message");
+ break;
+ default:
+ report_failure("Lua: Error initializing protocols: unknown error %d", error);
+ break;
+ }
+ }
first_time = FALSE;
}
diff --git a/epan/wslua/lrexlib/pcre2/lpcre2.c b/epan/wslua/lrexlib/pcre2/lpcre2.c
index ee1926f8..f24cbec8 100644
--- a/epan/wslua/lrexlib/pcre2/lpcre2.c
+++ b/epan/wslua/lrexlib/pcre2/lpcre2.c
@@ -432,7 +432,7 @@ static int Lpcre2_jit_compile (lua_State *L) {
#define SET_INFO_FIELD(L,ud,what,name,valtype) { \
valtype val; \
if (0 == pcre2_pattern_info (ud->pr, what, &val)) { \
- lua_pushinteger (L, val); \
+ lua_pushnumber (L, val); \
lua_setfield (L, -2, name); \
} \
}
diff --git a/epan/wslua/make-taps.py b/epan/wslua/make-taps.py
index ed677ff5..14c5a397 100755
--- a/epan/wslua/make-taps.py
+++ b/epan/wslua/make-taps.py
@@ -34,18 +34,18 @@ def get_tap_info(tap_name, header_file, struct_name, enum_types):
types = {
'gchar[]': 'lua_pushstring(L,(const char*)v->STR);',
'gchar*': 'lua_pushstring(L,(const char*)v->STR);',
- 'guint': 'lua_pushinteger(L,(lua_Integer)v->STR);',
- 'guint8': 'lua_pushinteger(L,(lua_Integer)v->STR);',
- 'guint16': 'lua_pushinteger(L,(lua_Integer)v->STR);',
- 'guint32': 'lua_pushinteger(L,(lua_Integer)v->STR);',
- 'gint': 'lua_pushinteger(L,(lua_Integer)v->STR);',
- 'gint8': 'lua_pushinteger(L,(lua_Integer)v->STR);',
- 'gint16': 'lua_pushinteger(L,(lua_Integer)v->STR);',
- 'gint32': 'lua_pushinteger(L,(lua_Integer)v->STR);',
+ 'guint': 'lua_pushnumber(L,(lua_Number)v->STR);',
+ 'guint8': 'lua_pushnumber(L,(lua_Number)v->STR);',
+ 'guint16': 'lua_pushnumber(L,(lua_Number)v->STR);',
+ 'guint32': 'lua_pushnumber(L,(lua_Number)v->STR);',
+ 'gint': 'lua_pushnumber(L,(lua_Number)v->STR);',
+ 'gint8': 'lua_pushnumber(L,(lua_Number)v->STR);',
+ 'gint16': 'lua_pushnumber(L,(lua_Number)v->STR);',
+ 'gint32': 'lua_pushnumber(L,(lua_Number)v->STR);',
'gboolean': 'lua_pushboolean(L,(int)v->STR);',
'address': '{ Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->STR)); pushAddress(L,a); }',
'address*': '{ Address a = (Address)g_malloc(sizeof(address)); copy_address(a, v->STR); pushAddress(L,a); }',
- 'int': 'lua_pushinteger(L,(lua_Integer)v->STR);',
+ 'int': 'lua_pushnumber(L,(lua_Number)v->STR);',
'nstime_t': 'lua_pushnumber(L,(lua_Number)nstime_to_sec(&(v->STR)));',
'nstime_t*': 'lua_pushnumber(L,(lua_Number)nstime_to_sec(v->STR));',
}
@@ -79,7 +79,7 @@ def get_tap_info(tap_name, header_file, struct_name, enum_types):
for enum in enum_types:
m = re.search(fr'typedef\s+enum[^{{]*{{([^}}]*)}}[\s\n]*{enum}[\s\n]*;', buf, flags=re.DOTALL)
if m:
- types[enum] = f'lua_pushinteger(L,(lua_Integer)v->STR); /* {enum} */'
+ types[enum] = f'lua_pushnumber(L,(lua_Number)v->STR); /* {enum} */'
econsts = m.group(1).splitlines()
econsts = [re.sub(r'\s+', '', item) for item in econsts]
econsts = [re.sub(',', '', item) for item in econsts]
@@ -183,9 +183,9 @@ def main():
c_body += f'\n\t/*\n\t * {enum}\n\t */\n\tlua_newtable(L);\n'
for econst in enums[enum]:
c_body += f'''\
- lua_pushinteger(L,(lua_Integer){econst});
+ lua_pushnumber(L,(lua_Number){econst});
lua_setglobal(L,"{econst}");
- lua_pushinteger(L,(lua_Integer){econst});
+ lua_pushnumber(L,(lua_Number){econst});
lua_pushstring(L,"{econst}");
lua_settable(L,-3);
'''
diff --git a/epan/wslua/wslua.h b/epan/wslua/wslua.h
index 0f6a146e..c96f4f2c 100644
--- a/epan/wslua/wslua.h
+++ b/epan/wslua/wslua.h
@@ -188,8 +188,12 @@ typedef struct _wslua_proto_t {
gboolean expired;
} wslua_proto_t;
+/* a "DissectorTable" object can be different things under the hood,
+ * since its heuristic_new() can create a heur_dissector_list_t that
+ * needs to be deregistered. */
struct _wslua_distbl_t {
dissector_table_t table;
+ heur_dissector_list_t heur_list;
const gchar* name;
const gchar* ui_name;
gboolean created;
diff --git a/epan/wslua/wslua_byte_array.c b/epan/wslua/wslua_byte_array.c
index b0449912..6e6ae304 100644
--- a/epan/wslua/wslua_byte_array.c
+++ b/epan/wslua/wslua_byte_array.c
@@ -214,7 +214,7 @@ WSLUA_METHOD ByteArray_get_index(lua_State* L) {
luaL_argerror(L,2,"index out of range");
return 0;
}
- lua_pushinteger(L,ba->data[idx]);
+ lua_pushnumber(L,ba->data[idx]);
WSLUA_RETURN(1); /* The value [0-255] of the byte. */
}
@@ -255,7 +255,7 @@ WSLUA_METHOD ByteArray_le_int(lua_State* L) {
value |= (guint8)ba->data[offset + i];
}
- lua_pushinteger(L, value);
+ lua_pushnumber(L, value);
WSLUA_RETURN(1); /* The value of the little endian encoded signed integer beginning at given offset with given length. */
}
@@ -337,7 +337,7 @@ WSLUA_METHOD ByteArray_le_uint(lua_State* L) {
value |= (guint8)ba->data[offset + i];
}
- lua_pushinteger(L, value);
+ lua_pushnumber(L, value);
WSLUA_RETURN(1); /* The value of the little endian encoded unsigned integer beginning at given offset with given length. */
}
@@ -419,7 +419,7 @@ WSLUA_METHOD ByteArray_int(lua_State* L) {
value |= (guint8)ba->data[offset + i];
}
- lua_pushinteger(L, value);
+ lua_pushnumber(L, value);
WSLUA_RETURN(1); /* The value of the big endian encoded 32 bit signed integer beginning at given offset with given length. */
}
@@ -501,7 +501,7 @@ WSLUA_METHOD ByteArray_uint(lua_State* L) {
value |= (guint8)ba->data[offset + i];
}
- lua_pushinteger(L, value);
+ lua_pushnumber(L, value);
WSLUA_RETURN(1); /* The value of the big endian encoded 32 bit unsigned integer beginning at given offset with given length. */
}
@@ -551,7 +551,7 @@ WSLUA_METHOD ByteArray_len(lua_State* L) {
/* Obtain the length of a <<lua_class_ByteArray,`ByteArray`>>. */
ByteArray ba = checkByteArray(L,1);
- lua_pushinteger(L,(lua_Integer)ba->len);
+ lua_pushnumber(L,(lua_Number)ba->len);
WSLUA_RETURN(1); /* The length of the <<lua_class_ByteArray,`ByteArray`>>. */
}
diff --git a/epan/wslua/wslua_dissector.c b/epan/wslua/wslua_dissector.c
index 6181ffbf..4fb7a9a1 100644
--- a/epan/wslua/wslua_dissector.c
+++ b/epan/wslua/wslua_dissector.c
@@ -107,7 +107,7 @@ WSLUA_METHOD Dissector_call(lua_State* L) {
are normal conditions and possibly don't need the Lua traceback. */
if (error) { WSLUA_ERROR(Dissector_call,error); }
- lua_pushinteger(L,(lua_Integer)len);
+ lua_pushnumber(L,(lua_Number)len);
WSLUA_RETURN(1); /* Number of bytes dissected. Note that some dissectors always return number of bytes in incoming buffer, so be aware. */
}
@@ -213,6 +213,7 @@ WSLUA_CONSTRUCTOR DissectorTable_new (lua_State *L) {
dt->table = (type == FT_NONE) ?
register_decode_as_next_proto(proto_id, name, ui_name, NULL) :
register_dissector_table(name, ui_name, proto_id, type, base);
+ dt->heur_list = NULL;
dt->name = g_strdup(name);
dt->ui_name = g_strdup(ui_name);
dt->created = TRUE;
@@ -228,7 +229,11 @@ WSLUA_CONSTRUCTOR DissectorTable_new (lua_State *L) {
}
WSLUA_CONSTRUCTOR DissectorTable_heuristic_new(lua_State *L) {
- /* Creates a new heuristic `DissectorTable` for your dissector's use. Returns true iff table was created successfully. */
+ /* Creates a new heuristic `DissectorTable` for your dissector's use. Returns true if table was created successfully.
+ * XXX - Currently it always returns nil.
+
+ @since 4.2.0
+ */
#define WSLUA_ARG_DissectorTable_heuristic_new_TABLENAME 1 /* The short name of the table. Use lower-case alphanumeric, dot, and/or underscores. */
#define WSLUA_ARG_DissectorTable_heuristic_new_PROTO 2 /* The <<lua_class_Proto,`Proto`>> object that uses this dissector table. */
const gchar* name = (const gchar*)luaL_checkstring(L,WSLUA_ARG_DissectorTable_heuristic_new_TABLENAME);
@@ -242,7 +247,29 @@ WSLUA_CONSTRUCTOR DissectorTable_heuristic_new(lua_State *L) {
return 0;
}
- register_heur_dissector_list(name, proto_id);
+ DissectorTable dt;
+ dt = (DissectorTable)g_malloc(sizeof(struct _wslua_distbl_t));
+ dt->table = NULL;
+ dt->heur_list = register_heur_dissector_list(name, proto_id);
+ dt->name = g_strdup(name);
+ dt->ui_name = g_strdup(name);
+ dt->created = TRUE;
+ dt->expired = FALSE;
+
+ lua_rawgeti(L, LUA_REGISTRYINDEX, dissectortable_table_ref);
+ lua_pushstring(L, name);
+ pushDissectorTable(L, dt);
+ lua_settable(L, -3);
+
+#if 0
+ /* Return nil because this is not a regular DissectorTable that could
+ * be used with _try, _set, _add, etc., and so we need to build checks
+ * into the functions similar to File and CaptureInfo so that it
+ * doesn't get used as one. However, not returning it means that it
+ * doesn't get properly garbage collected. */
+ pushDissectorTable(L, dt);
+ WSLUA_RETURN(1); /* The newly created DissectorTable. */
+#endif
return 0;
}
@@ -347,6 +374,7 @@ WSLUA_CONSTRUCTOR DissectorTable_get (lua_State *L) {
if (table) {
DissectorTable dt = (DissectorTable)g_malloc(sizeof(struct _wslua_distbl_t));
dt->table = table;
+ dt->heur_list = NULL;
dt->name = g_strdup(name);
dt->ui_name = NULL;
dt->created = FALSE;
@@ -399,7 +427,7 @@ WSLUA_METHOD DissectorTable_add (lua_State *L) {
g_free (pattern);
} else if ( type == FT_UINT32 || type == FT_UINT16 || type == FT_UINT8 || type == FT_UINT24 ) {
if (lua_isnumber(L, WSLUA_ARG_DissectorTable_add_PATTERN)) {
- int port = (int)luaL_checkinteger(L, WSLUA_ARG_DissectorTable_add_PATTERN);
+ guint32 port = wslua_checkguint32(L, WSLUA_ARG_DissectorTable_add_PATTERN);
dissector_add_uint(dt->name, port, handle);
} else {
/* Not a number, try as range */
@@ -461,7 +489,7 @@ WSLUA_METHOD DissectorTable_set (lua_State *L) {
dissector_add_string(dt->name, pattern,handle);
} else if ( type == FT_UINT32 || type == FT_UINT16 || type == FT_UINT8 || type == FT_UINT24 ) {
if (lua_isnumber(L, WSLUA_ARG_DissectorTable_set_PATTERN)) {
- int port = (int)luaL_checkinteger(L, WSLUA_ARG_DissectorTable_set_PATTERN);
+ guint32 port = wslua_checkguint32(L, WSLUA_ARG_DissectorTable_set_PATTERN);
dissector_delete_all(dt->name, handle);
dissector_add_uint(dt->name, port, handle);
} else {
@@ -517,7 +545,7 @@ WSLUA_METHOD DissectorTable_remove (lua_State *L) {
g_free (pattern);
} else if ( type == FT_UINT32 || type == FT_UINT16 || type == FT_UINT8 || type == FT_UINT24 ) {
if (lua_isnumber(L, WSLUA_ARG_DissectorTable_remove_PATTERN)) {
- int port = (int)luaL_checkinteger(L, WSLUA_ARG_DissectorTable_remove_PATTERN);
+ guint32 port = wslua_checkguint32(L, WSLUA_ARG_DissectorTable_remove_PATTERN);
dissector_delete_uint(dt->name, port, handle);
} else {
/* Not a number, try as range */
@@ -597,7 +625,7 @@ WSLUA_METHOD DissectorTable_try (lua_State *L) {
handled = TRUE;
}
} else if ( type == FT_UINT32 || type == FT_UINT16 || type == FT_UINT8 || type == FT_UINT24 ) {
- int port = (int)luaL_checkinteger(L, WSLUA_ARG_DissectorTable_try_PATTERN);
+ guint32 port = wslua_checkguint32(L, WSLUA_ARG_DissectorTable_try_PATTERN);
len = dissector_try_uint(dt->table,port,tvb->ws_tvb,pinfo->ws_pinfo,ti->tree);
if (len > 0) {
@@ -618,7 +646,7 @@ WSLUA_METHOD DissectorTable_try (lua_State *L) {
if (error) { WSLUA_ERROR(DissectorTable_try,error); }
- lua_pushinteger(L,(lua_Integer)len);
+ lua_pushnumber(L,(lua_Number)len);
WSLUA_RETURN(1); /* Number of bytes dissected. Note that some dissectors always return number of bytes in incoming buffer, so be aware. */
}
@@ -640,7 +668,7 @@ WSLUA_METHOD DissectorTable_get_dissector (lua_State *L) {
const gchar* pattern = luaL_checkstring(L,WSLUA_ARG_DissectorTable_get_dissector_PATTERN);
handle = dissector_get_string_handle(dt->table,pattern);
} else if ( type == FT_UINT32 || type == FT_UINT16 || type == FT_UINT8 || type == FT_UINT24 ) {
- int port = (int)luaL_checkinteger(L, WSLUA_ARG_DissectorTable_get_dissector_PATTERN);
+ guint32 port = wslua_checkguint32(L, WSLUA_ARG_DissectorTable_get_dissector_PATTERN);
handle = dissector_get_uint_handle(dt->table,port);
}
@@ -770,7 +798,12 @@ int wslua_deregister_dissector_tables(lua_State* L) {
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
DissectorTable dt = checkDissectorTable(L, -1);
if (dt->created) {
- deregister_dissector_table(dt->name);
+ if (dt->table) {
+ deregister_dissector_table(dt->name);
+ }
+ if (dt->heur_list) {
+ deregister_heur_dissector_list(dt->name);
+ }
}
}
diff --git a/epan/wslua/wslua_field.c b/epan/wslua/wslua_field.c
index d7d3e9d7..17db1974 100644
--- a/epan/wslua/wslua_field.c
+++ b/epan/wslua/wslua_field.c
@@ -50,7 +50,7 @@ WSLUA_METAMETHOD FieldInfo__len(lua_State* L) {
*/
FieldInfo fi = checkFieldInfo(L,1);
- lua_pushinteger(L,fi->ws_fi->length);
+ lua_pushnumber(L,fi->ws_fi->length);
return 1;
}
@@ -61,7 +61,7 @@ WSLUA_METAMETHOD FieldInfo__unm(lua_State* L) {
*/
FieldInfo fi = checkFieldInfo(L,1);
- lua_pushinteger(L,fi->ws_fi->start);
+ lua_pushnumber(L,fi->ws_fi->start);
return 1;
}
@@ -91,13 +91,13 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) {
case FT_UINT24:
case FT_UINT32:
case FT_FRAMENUM:
- lua_pushinteger(L,(lua_Integer)(fvalue_get_uinteger(fi->ws_fi->value)));
+ lua_pushnumber(L,(lua_Number)(fvalue_get_uinteger(fi->ws_fi->value)));
return 1;
case FT_INT8:
case FT_INT16:
case FT_INT24:
case FT_INT32:
- lua_pushinteger(L,(lua_Integer)(fvalue_get_sinteger(fi->ws_fi->value)));
+ lua_pushnumber(L,(lua_Number)(fvalue_get_sinteger(fi->ws_fi->value)));
return 1;
case FT_FLOAT:
case FT_DOUBLE:
@@ -268,7 +268,7 @@ static int FieldInfo_get_type(lua_State* L) {
FieldInfo fi = checkFieldInfo(L,1);
if (fi->ws_fi->hfinfo) {
- lua_pushinteger(L, fi->ws_fi->hfinfo->type);
+ lua_pushnumber(L, fi->ws_fi->hfinfo->type);
}
else {
lua_pushnil(L);
@@ -710,7 +710,7 @@ static int Field_get_type(lua_State* L) {
Field f = checkField(L,1);
header_field_info* hfinfo = NULL;
- GET_HFINFO_MEMBER(lua_pushinteger, type);
+ GET_HFINFO_MEMBER(lua_pushnumber, type);
return 1;
}
diff --git a/epan/wslua/wslua_file.c b/epan/wslua/wslua_file.c
index ff74760f..d9f1ff99 100644
--- a/epan/wslua/wslua_file.c
+++ b/epan/wslua/wslua_file.c
@@ -152,7 +152,7 @@ static int File_read_number (lua_State *L, FILE_T ft) {
buff[buff_end] = '\0';
if (buff_end > 0 && num_digits > 0 && sscanf(buff, "%lf", &d) == 1) {
- lua_pushinteger(L, d);
+ lua_pushnumber(L, d);
return 1;
}
else {
@@ -355,7 +355,7 @@ WSLUA_METHOD File_seek(lua_State* L) {
return 2;
}
- lua_pushinteger(L, (lua_Integer)(file_tell(f->file)));
+ lua_pushnumber(L, (lua_Number)(file_tell(f->file)));
}
else {
offset = wtap_dump_file_seek(f->wdh, offset, mode[op], &err);
@@ -374,7 +374,7 @@ WSLUA_METHOD File_seek(lua_State* L) {
return 2;
}
- lua_pushinteger(L, (lua_Integer)(offset));
+ lua_pushnumber(L, (lua_Number)(offset));
}
WSLUA_RETURN(1); /* The current file cursor position as a number. */
diff --git a/epan/wslua/wslua_file_handler.c b/epan/wslua/wslua_file_handler.c
index 47f72d45..f0c9ad83 100644
--- a/epan/wslua/wslua_file_handler.c
+++ b/epan/wslua/wslua_file_handler.c
@@ -326,7 +326,7 @@ wslua_filehandler_seek_read_packet(wtap *wth, gint64 seek_off, wtap_rec *rec, Bu
fp = push_File(L, wth->random_fh);
fc = push_CaptureInfo(L, wth, FALSE);
fi = push_FrameInfo(L, rec, buf);
- lua_pushinteger(L, (lua_Integer)seek_off);
+ lua_pushnumber(L, (lua_Number)seek_off);
switch ( lua_pcall(L,4,1,1) ) {
case 0:
@@ -474,7 +474,7 @@ wslua_filehandler_can_write_encap(int encap, void* data)
INIT_FILEHANDLER_ROUTINE(can_write_encap,WTAP_ERR_UNWRITABLE_ENCAP,NULL,NULL);
- lua_pushinteger(L, encap);
+ lua_pushnumber(L, encap);
switch ( lua_pcall(L,1,1,1) ) {
case 0:
@@ -842,7 +842,7 @@ WSLUA_FUNCTION wslua_register_filehandler(lua_State* L) {
fh->registered = TRUE;
registered_file_handlers = g_slist_prepend(registered_file_handlers, fh);
- lua_pushinteger(L, fh->file_type);
+ lua_pushnumber(L, fh->file_type);
WSLUA_RETURN(1); /* the new type number for this file reader/write */
}
@@ -1207,7 +1207,7 @@ WSLUA_ATTRIBUTE_GET(FileHandler,supported_comment_types,{ \
break;\
} \
} \
- lua_pushinteger(L, (lua_Integer)supported_comment_types); \
+ lua_pushnumber(L, (lua_Number)supported_comment_types); \
});
WSLUA_ATTRIBUTE_SET(FileHandler,supported_comment_types, { \
guint supported_comment_types; \
diff --git a/epan/wslua/wslua_frame_info.c b/epan/wslua/wslua_frame_info.c
index 72701d6f..401abd73 100644
--- a/epan/wslua/wslua_frame_info.c
+++ b/epan/wslua/wslua_frame_info.c
@@ -89,7 +89,7 @@ WSLUA_METHOD FrameInfo_read_data(lua_State* L) {
g_free(err_info); /* is this right? */
}
else lua_pushnil(L);
- lua_pushinteger(L, err);
+ lua_pushnumber(L, err);
return 3;
}
@@ -120,7 +120,7 @@ static int FrameInfo_get_comment (lua_State* L) {
lua_createtable(L, n_comments, 0);
for (i = 0; i < n_comments; i++) {
comment = NULL;
- lua_pushinteger(L, i+1);
+ lua_pushnumber(L, i+1);
if (WTAP_OPTTYPE_SUCCESS ==
wtap_block_get_nth_string_option_value(block, OPT_COMMENT, i, &comment)) {
lua_pushstring(L, comment);
@@ -371,7 +371,7 @@ WSLUA_METHOD FrameInfoConst_write_data(lua_State* L) {
if (!wtap_dump_file_write(fh->wdh, fi->pd, (size_t)(len), &err)) {
lua_pushboolean(L, FALSE);
lua_pushfstring(L, "FrameInfoConst write_data() error: %s", g_strerror(err));
- lua_pushinteger(L, err);
+ lua_pushnumber(L, err);
return 3;
}
@@ -403,7 +403,7 @@ static int FrameInfoConst_get_comment (lua_State* L) {
lua_createtable(L, n_comments, 0);
for (i = 0; i < n_comments; i++) {
comment = NULL;
- lua_pushinteger(L, i+1);
+ lua_pushnumber(L, i+1);
if (WTAP_OPTTYPE_SUCCESS ==
wtap_block_get_nth_string_option_value(block, OPT_COMMENT, i, &comment)) {
lua_pushstring(L, comment);
diff --git a/epan/wslua/wslua_int64.c b/epan/wslua/wslua_int64.c
index e540d6d2..17c00f06 100644
--- a/epan/wslua/wslua_int64.c
+++ b/epan/wslua/wslua_int64.c
@@ -656,7 +656,7 @@ guint64 getUInt64(lua_State *L, int i)
case LUA_TNUMBER:
return wslua_checkguint64(L,i);
case LUA_TSTRING:
- return g_ascii_strtoull(luaL_checkstring(L,i), &end, 10);
+ return g_ascii_strtoull(luaL_checkstring(L,i), &end, 0);
case LUA_TUSERDATA:
if (isInt64(L, i)) {
return (UInt64) toInt64(L, i);
diff --git a/epan/wslua/wslua_pinfo.c b/epan/wslua/wslua_pinfo.c
index 3e60715e..a735d601 100644
--- a/epan/wslua/wslua_pinfo.c
+++ b/epan/wslua/wslua_pinfo.c
@@ -308,7 +308,7 @@ static int Pinfo_get_match(lua_State *L) {
if (pinfo->ws_pinfo->match_string) {
lua_pushstring(L,pinfo->ws_pinfo->match_string);
} else {
- lua_pushinteger(L,(lua_Integer)(pinfo->ws_pinfo->match_uint));
+ lua_pushnumber(L,(lua_Number)(pinfo->ws_pinfo->match_uint));
}
return 1;
diff --git a/epan/wslua/wslua_pref.c b/epan/wslua/wslua_pref.c
index 3d6ed540..234170d3 100644
--- a/epan/wslua/wslua_pref.c
+++ b/epan/wslua/wslua_pref.c
@@ -515,9 +515,9 @@ WSLUA_METAMETHOD Prefs__index(lua_State* L) {
if ( g_str_equal(prefs_p->name,name) ) {
switch (prefs_p->type) {
case PREF_BOOL: lua_pushboolean(L, prefs_p->value.b); break;
- case PREF_UINT: lua_pushinteger(L,(lua_Integer)prefs_p->value.u); break;
+ case PREF_UINT: lua_pushnumber(L,(lua_Number)prefs_p->value.u); break;
case PREF_STRING: lua_pushstring(L,prefs_p->value.s); break;
- case PREF_ENUM: lua_pushinteger(L,(lua_Integer)prefs_p->value.e); break;
+ case PREF_ENUM: lua_pushnumber(L,(lua_Number)prefs_p->value.e); break;
case PREF_RANGE:
{
char *push_str = range_convert_range(NULL, prefs_p->value.r);
diff --git a/epan/wslua/wslua_proto.c b/epan/wslua/wslua_proto.c
index 92a1d192..b7f170d7 100644
--- a/epan/wslua/wslua_proto.c
+++ b/epan/wslua/wslua_proto.c
@@ -767,7 +767,7 @@ int Proto_commit(lua_State* L) {
// XXX this will leak resources.
if (f->hfid != -2) {
- return luaL_error(L,"fields can be registered only once");
+ return luaL_error(L,"%s is already registered; fields can be registered only once", f->abbrev);
}
f->hfid = -1;
@@ -802,7 +802,7 @@ int Proto_commit(lua_State* L) {
eiri.eiinfo.summary = e->text;
if (e->ids.ei != EI_INIT_EI || e->ids.hf != -2) {
- return luaL_error(L,"expert fields can be registered only once");
+ return luaL_error(L,"%s is already registered; expert fields can be registered only once", e->abbrev);
}
e->ids.hf = -1;
diff --git a/epan/wslua/wslua_struct.c b/epan/wslua/wslua_struct.c
index 440a0900..7d62dc09 100644
--- a/epan/wslua/wslua_struct.c
+++ b/epan/wslua/wslua_struct.c
@@ -410,7 +410,7 @@ WSLUA_CONSTRUCTOR Struct_pack (lua_State *L) {
* given endianness and size. If the integer type is signed, this makes
* the Lua number be +/- correctly as well.
*/
-static lua_Integer getinteger (const gchar *buff, int endian,
+static lua_Number getinteger (const gchar *buff, int endian,
int issigned, int size) {
Uinttype l = 0;
int i;
@@ -427,12 +427,12 @@ static lua_Integer getinteger (const gchar *buff, int endian,
}
}
if (!issigned)
- return (lua_Integer)l;
+ return (lua_Number)l;
else { /* signed format */
Uinttype mask = (Uinttype)(~((Uinttype)0)) << (size*8 - 1);
if (l & mask) /* negative value? */
l |= mask; /* signal extension */
- return (lua_Integer)(Inttype)l;
+ return (lua_Number)(Inttype)l;
}
}
@@ -470,8 +470,8 @@ WSLUA_CONSTRUCTOR Struct_unpack (lua_State *L) {
case 'b': case 'B': case 'h': case 'H':
case 'l': case 'L': case 'T': case 'i': case 'I': { /* integer types */
int issigned = g_ascii_islower(opt);
- lua_Integer res = getinteger(data+pos, h.endian, issigned, (int)size);
- lua_pushinteger(L, res);
+ lua_Number res = getinteger(data+pos, h.endian, issigned, (int)size);
+ lua_pushnumber(L, res);
break;
}
case 'e': {
diff --git a/epan/wslua/wslua_tree.c b/epan/wslua/wslua_tree.c
index 5d8dc7c7..ff2ac781 100644
--- a/epan/wslua/wslua_tree.c
+++ b/epan/wslua/wslua_tree.c
@@ -123,7 +123,7 @@ try_add_packet_field(lua_State *L, TreeItem tree_item, TvbRange tvbr, const int
item = proto_tree_add_item_ret_int(tree_item->tree, hfid, tvbr->tvb->ws_tvb,
tvbr->offset, tvbr->len, encoding,
&ret);
- lua_pushinteger(L, (lua_Integer)ret);
+ lua_pushnumber(L, (lua_Number)ret);
lua_pushinteger(L, tvbr->offset + tvbr->len);
}
break;
@@ -152,7 +152,7 @@ try_add_packet_field(lua_State *L, TreeItem tree_item, TvbRange tvbr, const int
item = proto_tree_add_item_ret_uint(tree_item-> tree, hfid, tvbr->tvb->ws_tvb,
tvbr->offset, tvbr->len, encoding,
&ret);
- lua_pushinteger(L, (lua_Integer)ret);
+ lua_pushnumber(L, (lua_Number)ret);
lua_pushinteger(L, tvbr->offset + tvbr->len);
}
break;
@@ -502,7 +502,7 @@ static int TreeItem_add_item_any(lua_State *L, gboolean little_endian) {
switch(type) {
case FT_PROTOCOL:
item = proto_tree_add_item(tree_item->tree,hfid,tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len,ENC_NA);
- lua_pushinteger(L,0);
+ lua_pushnumber(L,0);
lua_insert(L,1);
break;
case FT_BOOLEAN:
@@ -524,7 +524,7 @@ static int TreeItem_add_item_any(lua_State *L, gboolean little_endian) {
case FT_INT16:
case FT_INT24:
case FT_INT32:
- item = proto_tree_add_int(tree_item->tree,hfid,tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len,wslua_checkguint32(L,1));
+ item = proto_tree_add_int(tree_item->tree,hfid,tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len,wslua_checkgint32(L,1));
break;
case FT_FLOAT:
item = proto_tree_add_float(tree_item->tree,hfid,tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len,(float)luaL_checknumber(L,1));
@@ -664,7 +664,7 @@ WSLUA_METHOD TreeItem_add(lua_State *L) {
which is invalid for this function). If the first argument is a non-<<lua_class_ProtoField,`ProtoField`>> and a non-<<lua_class_Proto,`Proto`>> then this argument can
be either a <<lua_class_TvbRange,`TvbRange`>> or a label, and the value is not in use.
- ==== Example
+ ====== Example
[source,lua]
----
diff --git a/epan/wslua/wslua_tvb.c b/epan/wslua/wslua_tvb.c
index f315e83e..031023d0 100644
--- a/epan/wslua/wslua_tvb.c
+++ b/epan/wslua/wslua_tvb.c
@@ -135,7 +135,7 @@ WSLUA_METHOD Tvb_reported_len(lua_State* L) {
/* Obtain the reported length (length on the network) of a <<lua_class_Tvb,`Tvb`>>. */
Tvb tvb = checkTvb(L,1);
- lua_pushinteger(L,tvb_reported_length(tvb->ws_tvb));
+ lua_pushnumber(L,tvb_reported_length(tvb->ws_tvb));
WSLUA_RETURN(1); /* The reported length of the <<lua_class_Tvb,`Tvb`>>. */
}
@@ -143,7 +143,7 @@ WSLUA_METHOD Tvb_captured_len(lua_State* L) {
/* Obtain the captured length (amount saved in the capture process) of a <<lua_class_Tvb,`Tvb`>>. */
Tvb tvb = checkTvb(L,1);
- lua_pushinteger(L,tvb_captured_length(tvb->ws_tvb));
+ lua_pushnumber(L,tvb_captured_length(tvb->ws_tvb));
WSLUA_RETURN(1); /* The captured length of the <<lua_class_Tvb,`Tvb`>>. */
}
@@ -152,18 +152,18 @@ WSLUA_METHOD Tvb_len(lua_State* L) {
Same as captured_len; kept only for backwards compatibility */
Tvb tvb = checkTvb(L,1);
- lua_pushinteger(L,tvb_captured_length(tvb->ws_tvb));
+ lua_pushnumber(L,tvb_captured_length(tvb->ws_tvb));
WSLUA_RETURN(1); /* The captured length of the <<lua_class_Tvb,`Tvb`>>. */
}
WSLUA_METHOD Tvb_reported_length_remaining(lua_State* L) {
/* Obtain the reported (not captured) length of packet data to end of a <<lua_class_Tvb,`Tvb`>> or 0 if the
offset is beyond the end of the <<lua_class_Tvb,`Tvb`>>. */
-#define Tvb_reported_length_remaining_OFFSET 2 /* offset */
+#define WSLUA_OPTARG_Tvb_reported_length_remaining_OFFSET 2 /* offset */
Tvb tvb = checkTvb(L,1);
- int offset = (int) luaL_optinteger(L, Tvb_reported_length_remaining_OFFSET, 0);
+ int offset = (int) luaL_optinteger(L, WSLUA_OPTARG_Tvb_reported_length_remaining_OFFSET, 0);
- lua_pushinteger(L,tvb_reported_length_remaining(tvb->ws_tvb, offset));
+ lua_pushnumber(L,tvb_reported_length_remaining(tvb->ws_tvb, offset));
WSLUA_RETURN(1); /* The captured length of the <<lua_class_Tvb,`Tvb`>>. */
}
@@ -210,7 +210,7 @@ WSLUA_METHOD Tvb_offset(lua_State* L) {
/* Returns the raw offset (from the beginning of the source <<lua_class_Tvb,`Tvb`>>) of a sub <<lua_class_Tvb,`Tvb`>>. */
Tvb tvb = checkTvb(L,1);
- lua_pushinteger(L,tvb_raw_offset(tvb->ws_tvb));
+ lua_pushnumber(L,tvb_raw_offset(tvb->ws_tvb));
WSLUA_RETURN(1); /* The raw offset of the <<lua_class_Tvb,`Tvb`>>. */
}
@@ -441,16 +441,16 @@ WSLUA_METHOD TvbRange_uint(lua_State* L) {
switch (tvbr->len) {
case 1:
- lua_pushinteger(L,tvb_get_guint8(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,tvb_get_guint8(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 2:
- lua_pushinteger(L,tvb_get_ntohs(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,tvb_get_ntohs(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 3:
- lua_pushinteger(L,tvb_get_ntoh24(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,tvb_get_ntoh24(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 4:
- lua_pushinteger(L,tvb_get_ntohl(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,tvb_get_ntohl(tvbr->tvb->ws_tvb,tvbr->offset));
WSLUA_RETURN(1); /* The unsigned integer value. */
default:
luaL_error(L,"TvbRange:uint() does not handle %d byte integers",tvbr->len);
@@ -474,16 +474,16 @@ WSLUA_METHOD TvbRange_le_uint(lua_State* L) {
switch (tvbr->len) {
case 1:
/* XXX unsigned anyway */
- lua_pushinteger(L,(lua_Integer)(guint)tvb_get_guint8(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,(lua_Number)(guint)tvb_get_guint8(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 2:
- lua_pushinteger(L,tvb_get_letohs(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,tvb_get_letohs(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 3:
- lua_pushinteger(L,tvb_get_letoh24(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,tvb_get_letoh24(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 4:
- lua_pushinteger(L,tvb_get_letohl(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,tvb_get_letohl(tvbr->tvb->ws_tvb,tvbr->offset));
WSLUA_RETURN(1); /* The unsigned integer value */
default:
luaL_error(L,"TvbRange:le_uint() does not handle %d byte integers",tvbr->len);
@@ -594,16 +594,16 @@ WSLUA_METHOD TvbRange_int(lua_State* L) {
switch (tvbr->len) {
case 1:
- lua_pushinteger(L,tvb_get_gint8(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,tvb_get_gint8(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 2:
- lua_pushinteger(L,tvb_get_ntohis(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,tvb_get_ntohis(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 3:
- lua_pushinteger(L,tvb_get_ntohi24(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,tvb_get_ntohi24(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 4:
- lua_pushinteger(L,tvb_get_ntohil(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,tvb_get_ntohil(tvbr->tvb->ws_tvb,tvbr->offset));
WSLUA_RETURN(1); /* The signed integer value. */
/*
* XXX:
@@ -633,16 +633,16 @@ WSLUA_METHOD TvbRange_le_int(lua_State* L) {
switch (tvbr->len) {
case 1:
- lua_pushinteger(L,tvb_get_gint8(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,tvb_get_gint8(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 2:
- lua_pushinteger(L,tvb_get_letohis(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,tvb_get_letohis(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 3:
- lua_pushinteger(L,tvb_get_letohi24(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,tvb_get_letohi24(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 4:
- lua_pushinteger(L,tvb_get_letohil(tvbr->tvb->ws_tvb,tvbr->offset));
+ lua_pushnumber(L,tvb_get_letohil(tvbr->tvb->ws_tvb,tvbr->offset));
WSLUA_RETURN(1); /* The signed integer value. */
default:
luaL_error(L,"TvbRange:le_int() does not handle %d byte integers",tvbr->len);
@@ -1237,13 +1237,13 @@ WSLUA_METHOD TvbRange_bitfield(lua_State* L) {
}
if (len <= 8) {
- lua_pushinteger(L,(lua_Integer)(guint)tvb_get_bits8(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len));
+ lua_pushnumber(L,(lua_Number)(guint)tvb_get_bits8(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len));
return 1;
} else if (len <= 16) {
- lua_pushinteger(L,tvb_get_bits16(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len, FALSE));
+ lua_pushnumber(L,tvb_get_bits16(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len, FALSE));
return 1;
} else if (len <= 32) {
- lua_pushinteger(L,tvb_get_bits32(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len, FALSE));
+ lua_pushnumber(L,tvb_get_bits32(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len, FALSE));
return 1;
} else if (len <= 64) {
pushUInt64(L,tvb_get_bits64(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len, FALSE));
@@ -1334,7 +1334,7 @@ WSLUA_METHOD TvbRange_len(lua_State* L) {
luaL_error(L,"expired tvb");
return 0;
}
- lua_pushinteger(L,(lua_Integer)tvbr->len);
+ lua_pushnumber(L,(lua_Number)tvbr->len);
return 1;
}
@@ -1347,7 +1347,7 @@ WSLUA_METHOD TvbRange_offset(lua_State* L) {
luaL_error(L,"expired tvb");
return 0;
}
- lua_pushinteger(L,(lua_Integer)tvbr->offset);
+ lua_pushnumber(L,(lua_Number)tvbr->offset);
return 1;
}
diff --git a/epan/wslua/wslua_wtap.c b/epan/wslua/wslua_wtap.c
index 9fa27879..524ed7c3 100644
--- a/epan/wslua/wslua_wtap.c
+++ b/epan/wslua/wslua_wtap.c
@@ -85,7 +85,7 @@ WSLUA_FUNCTION wslua_wtap_name_to_file_type_subtype(lua_State* LS) {
if (filetype == -1)
lua_pushnil(LS);
else
- lua_pushinteger(LS,filetype);
+ lua_pushnumber(LS,filetype);
WSLUA_RETURN(1); /* The filetype value for the file type with that name, or nil if there is no such file type. */
}
@@ -96,7 +96,7 @@ WSLUA_FUNCTION wslua_wtap_pcap_file_type_subtype(lua_State* LS) {
@since 3.2.12, 3.4.4
*/
lua_Number filetype = wtap_pcap_file_type_subtype();
- lua_pushinteger(LS,filetype);
+ lua_pushnumber(LS,filetype);
WSLUA_RETURN(1); /* The filetype value for pcap files. */
}
@@ -107,7 +107,7 @@ WSLUA_FUNCTION wslua_wtap_pcap_nsec_file_type_subtype(lua_State* LS) {
@since 3.2.12, 3.4.4
*/
lua_Number filetype = wtap_pcap_nsec_file_type_subtype();
- lua_pushinteger(LS,filetype);
+ lua_pushnumber(LS,filetype);
WSLUA_RETURN(1); /* The filetype value for nanosecond-resolution pcap files. */
}
@@ -118,7 +118,7 @@ WSLUA_FUNCTION wslua_wtap_pcapng_file_type_subtype(lua_State* LS) {
@since 3.2.12, 3.4.4
*/
lua_Number filetype = wtap_pcapng_file_type_subtype();
- lua_pushinteger(LS,filetype);
+ lua_pushnumber(LS,filetype);
WSLUA_RETURN(1); /* The filetype value for pcapng files. */
}
@@ -148,7 +148,7 @@ extern void wslua_init_wtap_filetypes(lua_State* LS) {
* it.
*/
lua_pushstring(LS, entry->name);
- lua_pushinteger(LS, entry->ft);
+ lua_pushnumber(LS, entry->ft);
/*
* The -3 is the index, relative to the top of the stack, of
* the table; the two elements on top of it are the ft and