2006-09-25 01:09:00 +00:00
|
|
|
/*
|
|
|
|
* wslua.h
|
|
|
|
*
|
|
|
|
* Wireshark's interface to the Lua Programming Language
|
|
|
|
*
|
2008-08-05 21:03:46 +00:00
|
|
|
* (c) 2006, Luis E. Garcia Ontanon <luis@ontanon.org>
|
2007-05-02 23:39:44 +00:00
|
|
|
* (c) 2007, Tamas Regos <tamas.regos@ericsson.com>
|
2008-07-26 23:41:31 +00:00
|
|
|
* (c) 2008, Balint Reczey <balint.reczey@ericsson.com>
|
2006-09-25 01:09:00 +00:00
|
|
|
*
|
2006-10-19 17:02:23 +00:00
|
|
|
* $Id$
|
2006-09-25 01:09:00 +00:00
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _PACKET_LUA_H
|
|
|
|
#define _PACKET_LUA_H
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
2009-11-22 22:13:11 +00:00
|
|
|
#include <ctype.h>
|
2006-09-25 01:09:00 +00:00
|
|
|
#include <lua.h>
|
|
|
|
#include <lualib.h>
|
|
|
|
#include <lauxlib.h>
|
|
|
|
#include <wiretap/wtap.h>
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/strutil.h>
|
|
|
|
#include <epan/prefs.h>
|
|
|
|
#include <epan/proto.h>
|
|
|
|
#include <epan/epan_dissect.h>
|
|
|
|
#include <epan/tap.h>
|
|
|
|
#include <epan/filesystem.h>
|
|
|
|
#include <epan/report_err.h>
|
|
|
|
#include <epan/emem.h>
|
|
|
|
#include <epan/funnel.h>
|
|
|
|
#include <epan/tvbparse.h>
|
|
|
|
#include <epan/epan.h>
|
2011-08-19 08:36:02 +00:00
|
|
|
#include <epan/nstime.h>
|
2006-09-25 01:09:00 +00:00
|
|
|
|
2006-10-03 14:27:45 +00:00
|
|
|
#include "declare_wslua.h"
|
2006-09-25 01:09:00 +00:00
|
|
|
|
2010-08-28 19:27:19 +00:00
|
|
|
/** @file
|
|
|
|
* @ingroup wslua_group
|
|
|
|
*/
|
|
|
|
|
2006-09-25 01:09:00 +00:00
|
|
|
#define WSLUA_INIT_ROUTINES "init_routines"
|
|
|
|
#define LOG_DOMAIN_LUA "wslua"
|
|
|
|
|
2008-07-26 23:41:31 +00:00
|
|
|
struct _wslua_tvb {
|
|
|
|
tvbuff_t* ws_tvb;
|
|
|
|
gboolean expired;
|
2011-11-06 17:39:13 +00:00
|
|
|
gboolean need_free;
|
2008-07-26 23:41:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _wslua_pinfo {
|
|
|
|
packet_info* ws_pinfo;
|
|
|
|
gboolean expired;
|
|
|
|
};
|
|
|
|
|
2006-09-25 01:09:00 +00:00
|
|
|
struct _wslua_tvbrange {
|
2008-07-26 23:41:31 +00:00
|
|
|
struct _wslua_tvb* tvb;
|
2006-09-25 01:09:00 +00:00
|
|
|
int offset;
|
|
|
|
int len;
|
|
|
|
};
|
|
|
|
|
2008-11-05 15:00:46 +00:00
|
|
|
struct _wslua_tw {
|
|
|
|
funnel_text_window_t* ws_tw;
|
|
|
|
gboolean expired;
|
|
|
|
};
|
|
|
|
|
2006-09-25 01:09:00 +00:00
|
|
|
typedef struct _wslua_field_t {
|
|
|
|
int hfid;
|
|
|
|
int ett;
|
|
|
|
char* name;
|
|
|
|
char* abbr;
|
|
|
|
char* blob;
|
|
|
|
enum ftenum type;
|
|
|
|
base_display_e base;
|
From Tamas Regos:
WSLUA improvement.
The existing ProtoField.bool looks like the following:
ProtoField.bool(abbr, [name], [desc])
But checking any protocol dissector with bool protofield, it can be seen that
in C code we have more options than thru the WSLUA interface.
E.g.: {&hf_gtp_qos_sig_ind,{"Signalling Indication", "gtp.sig_ind", FT_BOOLEAN,
8, TFS(>p_sig_ind), GTP_EXT_QOS_SIG_IND_MASK, NULL, HFILL}},
So I've extended ProtoField.bool to have more options like this:
ProtoField.bool(abbr, [name], [bitfield], [true_false_string], [mask], [desc])
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4700
svn path=/trunk/; revision=32771
2010-05-12 10:31:41 +00:00
|
|
|
const void* vs;
|
2006-09-25 01:09:00 +00:00
|
|
|
guint32 mask;
|
|
|
|
} wslua_field_t;
|
|
|
|
|
2010-08-28 19:27:19 +00:00
|
|
|
/**
|
2007-05-02 23:39:44 +00:00
|
|
|
* PREF_OBSOLETE is used for preferences that a module used to support
|
|
|
|
* but no longer supports; we give different error messages for them.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
2010-05-12 08:08:01 +00:00
|
|
|
PREF_UINT,
|
|
|
|
PREF_BOOL,
|
|
|
|
PREF_ENUM,
|
|
|
|
PREF_STRING,
|
|
|
|
PREF_RANGE,
|
|
|
|
PREF_STATIC_TEXT,
|
|
|
|
PREF_OBSOLETE
|
2007-05-02 23:39:44 +00:00
|
|
|
} pref_type_t;
|
2006-09-25 01:09:00 +00:00
|
|
|
|
|
|
|
typedef struct _wslua_pref_t {
|
|
|
|
gchar* name;
|
|
|
|
gchar* label;
|
|
|
|
gchar* desc;
|
|
|
|
pref_type_t type;
|
|
|
|
union {
|
|
|
|
gboolean b;
|
|
|
|
guint u;
|
|
|
|
const gchar* s;
|
2007-05-02 23:39:44 +00:00
|
|
|
gint e;
|
From Tamas Regos:
WSLUA improvement.
The existing ProtoField.bool looks like the following:
ProtoField.bool(abbr, [name], [desc])
But checking any protocol dissector with bool protofield, it can be seen that
in C code we have more options than thru the WSLUA interface.
E.g.: {&hf_gtp_qos_sig_ind,{"Signalling Indication", "gtp.sig_ind", FT_BOOLEAN,
8, TFS(>p_sig_ind), GTP_EXT_QOS_SIG_IND_MASK, NULL, HFILL}},
So I've extended ProtoField.bool to have more options like this:
ProtoField.bool(abbr, [name], [bitfield], [true_false_string], [mask], [desc])
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4700
svn path=/trunk/; revision=32771
2010-05-12 10:31:41 +00:00
|
|
|
range_t *r;
|
|
|
|
void* p;
|
2006-09-25 01:09:00 +00:00
|
|
|
} value;
|
2007-05-02 23:39:44 +00:00
|
|
|
union {
|
2010-08-28 19:27:19 +00:00
|
|
|
guint32 max_value; /**< maximum value of a range */
|
2010-05-12 08:08:01 +00:00
|
|
|
struct {
|
2010-08-28 19:27:19 +00:00
|
|
|
const enum_val_t *enumvals; /**< list of name & values */
|
|
|
|
gboolean radio_buttons; /**< TRUE if it should be shown as
|
2010-05-12 08:08:01 +00:00
|
|
|
radio buttons rather than as an
|
|
|
|
option menu or combo box in
|
|
|
|
the preferences tab */
|
2010-08-28 19:27:19 +00:00
|
|
|
} enum_info; /**< for PREF_ENUM */
|
|
|
|
} info; /**< display/text file information */
|
2010-05-12 08:08:01 +00:00
|
|
|
|
2006-09-25 01:09:00 +00:00
|
|
|
struct _wslua_pref_t* next;
|
|
|
|
struct _wslua_proto_t* proto;
|
|
|
|
} wslua_pref_t;
|
|
|
|
|
|
|
|
typedef struct _wslua_proto_t {
|
2010-05-12 08:08:01 +00:00
|
|
|
gchar* name;
|
|
|
|
gchar* desc;
|
|
|
|
int hfid;
|
|
|
|
int ett;
|
2006-09-25 01:09:00 +00:00
|
|
|
wslua_pref_t prefs;
|
2010-05-12 08:08:01 +00:00
|
|
|
int fields;
|
2006-09-25 01:09:00 +00:00
|
|
|
module_t *prefs_module;
|
|
|
|
dissector_handle_t handle;
|
2010-05-12 08:08:01 +00:00
|
|
|
gboolean is_postdissector;
|
2006-09-25 01:09:00 +00:00
|
|
|
} wslua_proto_t;
|
|
|
|
|
|
|
|
struct _wslua_distbl_t {
|
|
|
|
dissector_table_t table;
|
|
|
|
gchar* name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _wslua_col_info {
|
|
|
|
column_info* cinfo;
|
|
|
|
gint col;
|
2008-07-26 23:41:31 +00:00
|
|
|
gboolean expired;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _wslua_cols {
|
|
|
|
column_info* cinfo;
|
|
|
|
gboolean expired;
|
2006-09-25 01:09:00 +00:00
|
|
|
};
|
|
|
|
|
2011-10-18 17:46:00 +00:00
|
|
|
struct _wslua_private_table {
|
|
|
|
GHashTable *table;
|
|
|
|
gboolean is_allocated;
|
|
|
|
gboolean expired;
|
|
|
|
};
|
|
|
|
|
2006-09-25 01:09:00 +00:00
|
|
|
struct _wslua_treeitem {
|
2010-05-12 08:08:01 +00:00
|
|
|
proto_item* item;
|
|
|
|
proto_tree* tree;
|
2008-08-11 01:33:31 +00:00
|
|
|
gboolean expired;
|
2006-09-25 01:09:00 +00:00
|
|
|
};
|
|
|
|
|
2006-10-17 18:20:44 +00:00
|
|
|
typedef void (*tap_extractor_t)(lua_State*,const void*);
|
|
|
|
|
|
|
|
struct _wslua_tap {
|
|
|
|
gchar* name;
|
|
|
|
gchar* filter;
|
|
|
|
tap_extractor_t extractor;
|
|
|
|
lua_State* L;
|
|
|
|
int packet_ref;
|
|
|
|
int draw_ref;
|
|
|
|
int init_ref;
|
|
|
|
};
|
2006-10-12 17:00:11 +00:00
|
|
|
|
|
|
|
# define DIRECTORY_T GDir
|
|
|
|
# define FILE_T gchar
|
|
|
|
# define OPENDIR_OP(name) g_dir_open(name, 0, dir->dummy)
|
|
|
|
# define DIRGETNEXT_OP(dir) g_dir_read_name(dir)
|
|
|
|
# define GETFNAME_OP(file) (file);
|
|
|
|
# define CLOSEDIR_OP(dir) g_dir_close(dir)
|
|
|
|
|
|
|
|
struct _wslua_dir {
|
2010-05-12 08:08:01 +00:00
|
|
|
DIRECTORY_T* dir;
|
|
|
|
char* ext;
|
|
|
|
GError** dummy;
|
2008-08-11 01:33:31 +00:00
|
|
|
};
|
2006-09-25 01:09:00 +00:00
|
|
|
|
2008-08-11 01:33:31 +00:00
|
|
|
struct _wslua_progdlg {
|
|
|
|
funnel_progress_window_t* pw;
|
|
|
|
char* title;
|
|
|
|
char* task;
|
|
|
|
gboolean stopped;
|
2006-10-12 17:00:11 +00:00
|
|
|
};
|
|
|
|
|
2006-09-25 01:09:00 +00:00
|
|
|
typedef struct { const char* name; tap_extractor_t extractor; } tappable_t;
|
|
|
|
|
|
|
|
typedef struct {const gchar* str; enum ftenum id; } wslua_ft_types_t;
|
|
|
|
|
|
|
|
typedef wslua_pref_t* Pref;
|
|
|
|
typedef wslua_pref_t* Prefs;
|
|
|
|
typedef struct _wslua_field_t* ProtoField;
|
|
|
|
typedef struct _wslua_proto_t* Proto;
|
|
|
|
typedef struct _wslua_distbl_t* DissectorTable;
|
|
|
|
typedef dissector_handle_t Dissector;
|
|
|
|
typedef GByteArray* ByteArray;
|
2008-07-26 23:41:31 +00:00
|
|
|
typedef struct _wslua_tvb* Tvb;
|
2006-09-25 01:09:00 +00:00
|
|
|
typedef struct _wslua_tvbrange* TvbRange;
|
|
|
|
typedef struct _wslua_col_info* Column;
|
2008-07-26 23:41:31 +00:00
|
|
|
typedef struct _wslua_cols* Columns;
|
|
|
|
typedef struct _wslua_pinfo* Pinfo;
|
2006-09-25 01:09:00 +00:00
|
|
|
typedef struct _wslua_treeitem* TreeItem;
|
|
|
|
typedef address* Address;
|
2011-08-19 08:36:02 +00:00
|
|
|
typedef nstime_t* NSTime;
|
2008-09-16 14:37:00 +00:00
|
|
|
typedef gint64* Int64;
|
|
|
|
typedef guint64* UInt64;
|
2006-09-25 01:09:00 +00:00
|
|
|
typedef header_field_info** Field;
|
|
|
|
typedef field_info* FieldInfo;
|
|
|
|
typedef struct _wslua_tap* Listener;
|
2008-11-05 15:00:46 +00:00
|
|
|
typedef struct _wslua_tw* TextWindow;
|
2008-08-11 01:33:31 +00:00
|
|
|
typedef struct _wslua_progdlg* ProgDlg;
|
2006-09-25 01:09:00 +00:00
|
|
|
typedef wtap_dumper* Dumper;
|
|
|
|
typedef struct lua_pseudo_header* PseudoHeader;
|
|
|
|
typedef tvbparse_t* Parser;
|
|
|
|
typedef tvbparse_wanted_t* Rule;
|
|
|
|
typedef tvbparse_elem_t* Node;
|
|
|
|
typedef tvbparse_action_t* Shortcut;
|
|
|
|
typedef struct _wslua_main* WireShark;
|
2006-10-12 17:00:11 +00:00
|
|
|
typedef struct _wslua_dir* Dir;
|
2011-10-18 17:46:00 +00:00
|
|
|
typedef struct _wslua_private_table* PrivateTable;
|
2006-09-25 01:09:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* toXxx(L,idx) gets a Xxx from an index (Lua Error if fails)
|
|
|
|
* checkXxx(L,idx) gets a Xxx from an index after calling check_code (No Lua Error if it fails)
|
|
|
|
* pushXxx(L,xxx) pushes an Xxx into the stack
|
|
|
|
* isXxx(L,idx) tests whether we have an Xxx at idx
|
2008-04-14 21:16:32 +00:00
|
|
|
* shiftXxx(L,idx) removes and returns an Xxx from idx only if it has a type of Xxx, returns NULL otherwise
|
|
|
|
* WSLUA_CLASS_DEFINE must be used with a trailing ';'
|
|
|
|
* (a dummy typedef is used to be syntactically correct)
|
2006-09-25 01:09:00 +00:00
|
|
|
*/
|
|
|
|
#define WSLUA_CLASS_DEFINE(C,check_code,push_code) \
|
2010-01-28 15:39:15 +00:00
|
|
|
C to##C(lua_State* L, int idx) { \
|
|
|
|
C* v = (C*)lua_touserdata (L, idx); \
|
|
|
|
if (!v) luaL_typerror(L,idx,#C); \
|
2006-09-25 01:09:00 +00:00
|
|
|
return *v; \
|
|
|
|
} \
|
2010-01-28 15:39:15 +00:00
|
|
|
C check##C(lua_State* L, int idx) { \
|
2006-09-25 01:09:00 +00:00
|
|
|
C* p; \
|
2010-01-28 15:39:15 +00:00
|
|
|
luaL_checktype(L,idx,LUA_TUSERDATA); \
|
|
|
|
p = (C*)luaL_checkudata(L, idx, #C); \
|
2006-09-25 01:09:00 +00:00
|
|
|
check_code; \
|
|
|
|
return p ? *p : NULL; \
|
|
|
|
} \
|
|
|
|
C* push##C(lua_State* L, C v) { \
|
2008-12-31 01:20:20 +00:00
|
|
|
C* p; \
|
|
|
|
luaL_checkstack(L,2,"Unable to grow stack\n"); \
|
|
|
|
p = lua_newuserdata(L,sizeof(C)); *p = v; \
|
2006-09-25 01:09:00 +00:00
|
|
|
luaL_getmetatable(L, #C); lua_setmetatable(L, -2); \
|
2010-05-12 08:08:01 +00:00
|
|
|
push_code; \
|
2006-09-25 01:09:00 +00:00
|
|
|
return p; \
|
|
|
|
}\
|
|
|
|
gboolean is##C(lua_State* L,int i) { \
|
2010-05-12 08:08:01 +00:00
|
|
|
void *p; \
|
|
|
|
if(!lua_isuserdata(L,i)) return FALSE; \
|
|
|
|
p = lua_touserdata(L, i); \
|
|
|
|
lua_getfield(L, LUA_REGISTRYINDEX, #C); \
|
|
|
|
if (p == NULL || !lua_getmetatable(L, i) || !lua_rawequal(L, -1, -2)) p=NULL; \
|
|
|
|
lua_pop(L, 2); \
|
|
|
|
return p ? TRUE : FALSE; \
|
2006-09-25 01:09:00 +00:00
|
|
|
} \
|
|
|
|
C shift##C(lua_State* L,int i) { \
|
|
|
|
C* p; \
|
2010-05-12 08:08:01 +00:00
|
|
|
if(!lua_isuserdata(L,i)) return NULL; \
|
|
|
|
p = lua_touserdata(L, i); \
|
|
|
|
lua_getfield(L, LUA_REGISTRYINDEX, #C); \
|
|
|
|
if (p == NULL || !lua_getmetatable(L, i) || !lua_rawequal(L, -1, -2)) p=NULL; \
|
|
|
|
lua_pop(L, 2); \
|
|
|
|
if (p) { lua_remove(L,i); return *p; }\
|
|
|
|
else return NULL;\
|
2006-09-25 01:09:00 +00:00
|
|
|
} \
|
2008-04-14 21:16:32 +00:00
|
|
|
typedef int dummy##C
|
2006-09-25 01:09:00 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LUA_5_1
|
|
|
|
|
|
|
|
#define WSLUA_REGISTER_CLASS(C) { \
|
2010-05-12 08:08:01 +00:00
|
|
|
luaL_register (L, #C, C ## _methods); \
|
|
|
|
luaL_newmetatable (L, #C); \
|
|
|
|
luaL_register (L, NULL, C ## _meta); \
|
|
|
|
lua_pushliteral(L, "__index"); \
|
|
|
|
lua_pushvalue(L, -3); \
|
|
|
|
lua_rawset(L, -3); \
|
|
|
|
lua_pushliteral(L, "__metatable"); \
|
|
|
|
lua_pushvalue(L, -3); \
|
|
|
|
lua_rawset(L, -3); \
|
|
|
|
lua_pop(L, 2); \
|
2006-09-25 01:09:00 +00:00
|
|
|
}
|
|
|
|
|
2008-12-31 01:20:20 +00:00
|
|
|
#define WSLUA_REGISTER_META(C) { \
|
2010-05-12 08:08:01 +00:00
|
|
|
luaL_newmetatable (L, #C); \
|
|
|
|
luaL_register (L, NULL, C ## _meta); \
|
|
|
|
lua_pop(L,1); \
|
2008-12-31 01:20:20 +00:00
|
|
|
}
|
2006-09-25 01:09:00 +00:00
|
|
|
|
|
|
|
#define WSLUA_INIT(L) \
|
2010-05-12 08:08:01 +00:00
|
|
|
luaL_openlibs(L); \
|
|
|
|
wslua_register_classes(L); \
|
|
|
|
wslua_register_functions(L);
|
2006-09-25 01:09:00 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define WSLUA_FUNCTION extern int
|
|
|
|
#define WSLUA_REGISTER_FUNCTION(name) { lua_pushstring(L, #name); lua_pushcfunction(L, wslua_## name); lua_settable(L, LUA_GLOBALSINDEX); }
|
|
|
|
#define WSLUA_REGISTER extern int
|
|
|
|
|
|
|
|
#define WSLUA_METHOD static int
|
|
|
|
#define WSLUA_CONSTRUCTOR static int
|
|
|
|
#define WSLUA_ATTR_SET static int
|
|
|
|
#define WSLUA_ATTR_GET static int
|
|
|
|
#define WSLUA_METAMETHOD static int
|
|
|
|
|
|
|
|
#define WSLUA_METHODS static const luaL_reg
|
|
|
|
#define WSLUA_META static const luaL_reg
|
|
|
|
#define WSLUA_CLASS_FNREG(class,name) { #name, class##_##name }
|
|
|
|
|
2007-03-04 16:00:05 +00:00
|
|
|
#define WSLUA_ERROR(name,error) { luaL_error(L, ep_strdup_printf("%s%s", #name ": " ,error) ); return 0; }
|
2006-09-25 01:09:00 +00:00
|
|
|
#define WSLUA_ARG_ERROR(name,attr,error) { luaL_argerror(L,WSLUA_ARG_ ## name ## _ ## attr, #name ": " error); return 0; }
|
|
|
|
#define WSLUA_OPTARG_ERROR(name,attr,error) { luaL_argerror(L,WSLUA_OPTARG_##name##_ ##attr, #name ": " error); return 0; }
|
|
|
|
|
|
|
|
#define WSLUA_REG_GLOBAL_BOOL(L,n,v) { lua_pushstring(L,n); lua_pushboolean(L,v); lua_settable(L, LUA_GLOBALSINDEX); }
|
2008-11-21 15:47:14 +00:00
|
|
|
#define WSLUA_REG_GLOBAL_STRING(L,n,v) { lua_pushstring(L,n); lua_pushstring(L,v); lua_settable(L, LUA_GLOBALSINDEX); }
|
|
|
|
#define WSLUA_REG_GLOBAL_NUMBER(L,n,v) { lua_pushstring(L,n); lua_pushnumber(L,v); lua_settable(L, LUA_GLOBALSINDEX); }
|
2006-09-25 01:09:00 +00:00
|
|
|
|
|
|
|
#define WSLUA_RETURN(i) return (i);
|
|
|
|
|
|
|
|
#define WSLUA_API extern
|
|
|
|
|
|
|
|
#define NOP
|
2010-01-28 15:39:15 +00:00
|
|
|
#define FAIL_ON_NULL(s) if (! *p) luaL_argerror(L,idx,s)
|
2006-09-25 01:09:00 +00:00
|
|
|
|
2008-07-26 23:41:31 +00:00
|
|
|
/* Clears or marks references that connects Lua to Wireshark structures */
|
|
|
|
#define CLEAR_OUTSTANDING(C, marker, marker_val) void clear_outstanding_##C(void) { \
|
|
|
|
while (outstanding_##C->len) { \
|
|
|
|
C p = (C)g_ptr_array_remove_index_fast(outstanding_##C,0); \
|
|
|
|
if (p) { \
|
|
|
|
if (p->marker != marker_val) \
|
|
|
|
p->marker = marker_val; \
|
|
|
|
else \
|
|
|
|
g_free(p); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
2006-09-25 01:09:00 +00:00
|
|
|
|
|
|
|
#define WSLUA_CLASS_DECLARE(C) \
|
2010-01-28 15:39:15 +00:00
|
|
|
extern C to##C(lua_State* L, int idx); \
|
|
|
|
extern C check##C(lua_State* L, int idx); \
|
2006-09-25 01:09:00 +00:00
|
|
|
extern C* push##C(lua_State* L, C v); \
|
|
|
|
extern int C##_register(lua_State* L); \
|
|
|
|
extern gboolean is##C(lua_State* L,int i); \
|
|
|
|
extern C shift##C(lua_State* L,int i)
|
|
|
|
|
|
|
|
extern packet_info* lua_pinfo;
|
|
|
|
extern TreeItem lua_tree;
|
|
|
|
extern tvbuff_t* lua_tvb;
|
|
|
|
extern int lua_malformed;
|
|
|
|
extern dissector_handle_t lua_data_handle;
|
|
|
|
extern gboolean lua_initialized;
|
|
|
|
extern int lua_dissectors_table_ref;
|
|
|
|
|
|
|
|
WSLUA_DECLARE_CLASSES()
|
|
|
|
WSLUA_DECLARE_FUNCTIONS()
|
|
|
|
|
|
|
|
extern lua_State* wslua_state(void);
|
|
|
|
|
2006-10-19 17:02:23 +00:00
|
|
|
extern gboolean wslua_optbool(lua_State* L, int n, gboolean def);
|
2006-09-25 01:09:00 +00:00
|
|
|
extern const gchar* lua_shiftstring(lua_State* L,int idx);
|
2008-01-07 21:24:23 +00:00
|
|
|
extern int dissect_lua(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree);
|
2006-09-25 01:09:00 +00:00
|
|
|
|
|
|
|
extern void proto_register_lua(void);
|
|
|
|
extern GString* lua_register_all_taps(void);
|
|
|
|
extern void lua_prime_all_fields(proto_tree* tree);
|
|
|
|
|
|
|
|
extern int Proto_commit(lua_State* L);
|
|
|
|
|
2008-07-26 23:41:31 +00:00
|
|
|
extern Tvb* push_Tvb(lua_State* L, tvbuff_t* tvb);
|
|
|
|
extern void clear_outstanding_Tvb(void);
|
2011-11-06 17:39:13 +00:00
|
|
|
extern void clear_outstanding_TvbRange(void);
|
2006-09-25 01:09:00 +00:00
|
|
|
|
2008-07-26 23:41:31 +00:00
|
|
|
extern Pinfo* push_Pinfo(lua_State* L, packet_info* p);
|
|
|
|
extern void clear_outstanding_Pinfo(void);
|
|
|
|
extern void clear_outstanding_Column(void);
|
|
|
|
extern void clear_outstanding_Columns(void);
|
2011-10-18 17:46:00 +00:00
|
|
|
extern void clear_outstanding_PrivateTable(void);
|
2006-09-25 01:09:00 +00:00
|
|
|
|
2008-07-26 23:41:31 +00:00
|
|
|
extern TreeItem* push_TreeItem(lua_State* L, TreeItem ti);
|
|
|
|
extern void clear_outstanding_TreeItem(void);
|
2006-09-25 01:09:00 +00:00
|
|
|
|
|
|
|
extern void wslua_print_stack(char* s, lua_State* L);
|
|
|
|
|
2011-10-02 13:39:35 +00:00
|
|
|
extern int wslua_init(register_cb cb, gpointer client_data);
|
2006-09-25 01:09:00 +00:00
|
|
|
|
2006-10-17 18:20:44 +00:00
|
|
|
extern tap_extractor_t wslua_get_tap_extractor(const gchar* name);
|
|
|
|
extern int wslua_set_tap_enums(lua_State* L);
|
|
|
|
|
2009-09-29 11:27:26 +00:00
|
|
|
extern int luaopen_bit(lua_State *L);
|
|
|
|
|
2006-09-25 01:09:00 +00:00
|
|
|
#endif
|