![]() |
Wireshark 4.5.0
The Wireshark network protocol analyzer
|
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include <ws_log_defs.h>
#include <wiretap/wtap.h>
#include <wsutil/report_message.h>
#include <wsutil/nstime.h>
#include <wsutil/ws_assert.h>
#include <wsutil/wslog.h>
#include <epan/packet.h>
#include <epan/strutil.h>
#include <epan/to_str.h>
#include <epan/uat-int.h>
#include <epan/uat.h>
#include <epan/prefs.h>
#include <epan/proto.h>
#include <epan/epan_dissect.h>
#include <epan/tap.h>
#include <epan/column-utils.h>
#include <wsutil/filesystem.h>
#include <wsutil/wsgcrypt.h>
#include <epan/funnel.h>
#include <epan/tvbparse.h>
#include <epan/epan.h>
#include <epan/expert.h>
#include <epan/exceptions.h>
#include <epan/show_exception.h>
#include <epan/conversation.h>
#include <epan/wslua/declare_wslua.h>
Go to the source code of this file.
Classes | |
struct | _wslua_tvb |
struct | _wslua_pinfo |
struct | _wslua_tvbrange |
struct | _wslua_tw |
struct | _wslua_field_t |
struct | _wslua_expert_field_t |
struct | _wslua_pref_t |
struct | _wslua_proto_t |
struct | _wslua_conv_data_t |
struct | _wslua_distbl_t |
struct | _wslua_col_info |
struct | _wslua_cols |
struct | _wslua_private_table |
struct | _wslua_treeitem |
struct | _wslua_header_field_info |
struct | _wslua_field_info |
struct | _wslua_tap |
struct | _wslua_file |
struct | _wslua_captureinfo |
struct | _wslua_rec |
struct | _wslua_const_rec |
struct | _wslua_filehandler |
struct | _wslua_dir |
struct | _wslua_progdlg |
struct | tappable_t |
struct | wslua_ft_types_t |
struct | wslua_conv_types_t |
struct | _wslua_attribute_table |
struct | _wslua_class |
Type for defining new classes. More... | |
Macros | |
#define | WSLUA_INIT_ROUTINES "init_routines" |
#define | WSLUA_PREFS_CHANGED "prefs_changed" |
#define | wslua_toint(L, i) (int) ( lua_tointeger(L,i) ) |
#define | wslua_toint32(L, i) (int32_t) ( lua_tointeger(L,i) ) |
#define | wslua_toint64(L, i) (int64_t) ( lua_tonumber(L,i) ) |
#define | wslua_touint64(L, i) (uint64_t) ( lua_tonumber(L,i) ) |
#define | wslua_checkint(L, i) (int) ( luaL_checkinteger(L,i) ) |
#define | wslua_checkint32(L, i) (int32_t) ( luaL_checkinteger(L,i) ) |
#define | wslua_checkint64(L, i) (int64_t) ( luaL_checknumber(L,i) ) |
#define | wslua_checkuint64(L, i) (uint64_t) ( luaL_checknumber(L,i) ) |
#define | wslua_optint(L, i, d) (int) ( luaL_optinteger(L,i,d) ) |
#define | wslua_optint32(L, i, d) (int32_t) ( luaL_optinteger(L,i,d) ) |
#define | wslua_optint64(L, i, d) (int64_t) ( luaL_optnumber(L,i,d) ) |
#define | wslua_optuint64(L, i, d) (uint64_t) ( luaL_optnumber(L,i,d) ) |
#define | wslua_touint(L, i) (unsigned) ( lua_tounsigned(L,i) ) |
#define | wslua_touint32(L, i) (uint32_t) ( lua_tounsigned(L,i) ) |
#define | wslua_checkuint(L, i) (unsigned) ( luaL_checkunsigned(L,i) ) |
#define | wslua_checkuint32(L, i) (uint32_t) ( luaL_checkunsigned(L,i) ) |
#define | wslua_optuint(L, i, d) (unsigned) ( luaL_optunsigned(L,i,d) ) |
#define | wslua_optuint32(L, i, d) (uint32_t) ( luaL_optunsigned(L,i,d) ) |
#define | WSLUA_CLASS_DEFINE(C, check_code) WSLUA_CLASS_DEFINE_BASE(C,check_code,NULL) |
#define | WSLUA_CLASS_DEFINE_BASE(C, check_code, retval) |
#define | WSLUA_TYPEOF_FIELD "__typeof" |
#define | WSLUA_FUNCTION extern int |
#define | WSLUA_INTERNAL_FUNCTION extern int |
#define | WSLUA_REGISTER_FUNCTION(name) { lua_pushcfunction(L, wslua_## name); lua_setglobal(L, #name); } |
#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 } |
#define | WSLUA_CLASS_FNREG_ALIAS(class, aliasname, name) { #aliasname, class##_##name } |
#define | WSLUA_CLASS_MTREG(class, name) { "__" #name, class##__##name } |
#define | WSLUA_ATTRIBUTES static const wslua_attribute_table |
#define | WSLUA_ATTRIBUTE_RWREG(class, name) { #name, class##_get_##name, class##_set_##name } |
#define | WSLUA_ATTRIBUTE_ROREG(class, name) { #name, class##_get_##name, NULL } |
#define | WSLUA_ATTRIBUTE_WOREG(class, name) { #name, NULL, class##_set_##name } |
#define | WSLUA_ATTRIBUTE_FUNC_SETTER(C, field) |
#define | WSLUA_ATTRIBUTE_GET(C, name, block) |
#define | WSLUA_ATTRIBUTE_NAMED_BOOLEAN_GETTER(C, name, member) WSLUA_ATTRIBUTE_GET(C,name,{lua_pushboolean(L, obj->member );}) |
#define | WSLUA_ATTRIBUTE_NAMED_INTEGER_GETTER(C, name, member) WSLUA_ATTRIBUTE_GET(C,name,{lua_pushinteger(L,(lua_Integer)(obj->member));}) |
#define | WSLUA_ATTRIBUTE_INTEGER_GETTER(C, member) WSLUA_ATTRIBUTE_NAMED_INTEGER_GETTER(C,member,member) |
#define | WSLUA_ATTRIBUTE_BLOCK_NUMBER_GETTER(C, name, block) WSLUA_ATTRIBUTE_GET(C,name,{lua_pushnumber(L,(lua_Number)(block));}) |
#define | WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(C, name, member) |
#define | WSLUA_ATTRIBUTE_STRING_GETTER(C, member) WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(C,member,member) |
#define | WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(C, name, member, option) |
#define | WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_NTH_STRING_GETTER(C, name, member, option) |
#define | WSLUA_ATTRIBUTE_SET(C, name, block) |
#define | WSLUA_ATTRIBUTE_NAMED_BOOLEAN_SETTER(C, name, member) |
#define | WSLUA_ATTRIBUTE_NAMED_INTEGER_SETTER(C, name, member, cast) |
#define | WSLUA_ATTRIBUTE_INTEGER_SETTER(C, member, cast) WSLUA_ATTRIBUTE_NAMED_INTEGER_SETTER(C,member,member,cast) |
#define | WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(C, field, member, need_free) |
#define | WSLUA_ATTRIBUTE_STRING_SETTER(C, field, need_free) WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(C,field,field,need_free) |
#define | WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(C, field, member, option) |
#define | WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_NTH_STRING_SETTER(C, field, member, option) |
#define | WSLUA_ERROR(name, error) { luaL_error(L, "%s%s", #name ": ", error); } |
#define | WSLUA_ARG_ERROR(name, attr, error) { luaL_argerror(L,WSLUA_ARG_ ## name ## _ ## attr, #name ": " error); } |
#define | WSLUA_OPTARG_ERROR(name, attr, error) { luaL_argerror(L,WSLUA_OPTARG_##name##_ ##attr, #name ": " error); } |
#define | WSLUA_REG_GLOBAL_BOOL(L, n, v) { lua_pushboolean(L,v); lua_setglobal(L,n); } |
#define | WSLUA_REG_GLOBAL_STRING(L, n, v) { lua_pushstring(L,v); lua_setglobal(L,n); } |
#define | WSLUA_REG_GLOBAL_INTEGER(L, n, v) { lua_pushinteger(L,v); lua_setglobal(L,n); } |
#define | WSLUA_RETURN(i) return (i) |
#define | WSLUA_API extern |
#define | NOP (void)p |
#define | FAIL_ON_NULL(s) if (! *p) luaL_argerror(L,idx,"null " s) |
#define | FAIL_ON_NULL_OR_EXPIRED(s) |
#define | CLEAR_OUTSTANDING(C, marker, marker_val) |
#define | WSLUA_CLASS_DECLARE(C) |
#define | THROW_LUA_ERROR(...) THROW_FORMATTED(DissectorError, __VA_ARGS__) |
#define | WRAP_NON_LUA_EXCEPTIONS(code) |
Typedefs | |
typedef struct _wslua_field_t | wslua_field_t |
typedef struct _wslua_expert_field_t | wslua_expert_field_t |
typedef struct _wslua_pref_t | wslua_pref_t |
typedef struct _wslua_proto_t | wslua_proto_t |
typedef struct _wslua_conv_data_t | wslua_conv_data_t |
typedef void(* | tap_extractor_t) (lua_State *, const void *) |
typedef wslua_pref_t * | Pref |
typedef wslua_pref_t * | Prefs |
typedef struct _wslua_field_t * | ProtoField |
typedef struct _wslua_expert_field_t * | ProtoExpert |
typedef struct _wslua_proto_t * | Proto |
typedef struct _wslua_distbl_t * | DissectorTable |
typedef dissector_handle_t | Dissector |
typedef GByteArray * | ByteArray |
typedef gcry_cipher_hd_t * | GcryptCipher |
typedef struct _wslua_tvb * | Tvb |
typedef struct _wslua_tvbrange * | TvbRange |
typedef struct _wslua_col_info * | Column |
typedef struct _wslua_cols * | Columns |
typedef struct _wslua_pinfo * | Pinfo |
typedef struct _wslua_treeitem * | TreeItem |
typedef address * | Address |
typedef nstime_t * | NSTime |
typedef int64_t | Int64 |
typedef uint64_t | UInt64 |
typedef struct _wslua_header_field_info * | Field |
typedef struct _wslua_field_info * | FieldInfo |
typedef struct _wslua_tap * | Listener |
typedef struct _wslua_tw * | TextWindow |
typedef struct _wslua_progdlg * | ProgDlg |
typedef struct _wslua_file * | File |
typedef struct _wslua_captureinfo * | CaptureInfo |
typedef struct _wslua_captureinfo * | CaptureInfoConst |
typedef struct _wslua_rec * | FrameInfo |
typedef struct _wslua_const_rec * | FrameInfoConst |
typedef struct _wslua_filehandler * | FileHandler |
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_dir * | Dir |
typedef struct _wslua_private_table * | PrivateTable |
typedef conversation_t * | Conversation |
typedef char * | Struct |
typedef struct _wslua_attribute_table | wslua_attribute_table |
typedef struct _wslua_class | wslua_class |
Type for defining new classes. | |
Enumerations | |
enum | pref_type_t { PREF_UINT , PREF_BOOL , PREF_ENUM , PREF_STRING , PREF_RANGE , PREF_STATIC_TEXT , PREF_UAT , PREF_OBSOLETE } |
Functions | |
int | wslua_reg_attributes (lua_State *L, const wslua_attribute_table *t, bool is_getter) |
lua_State * | wslua_state (void) |
void | wslua_register_classinstance_meta (lua_State *L, const wslua_class *cls_def) |
void | wslua_register_class (lua_State *L, const wslua_class *cls_def) |
int | wslua__concat (lua_State *L) |
bool | wslua_toboolean (lua_State *L, int n) |
bool | wslua_checkboolean (lua_State *L, int n) |
bool | wslua_optbool (lua_State *L, int n, bool def) |
lua_Integer | wslua_tointeger (lua_State *L, int n) |
int | wslua_optboolint (lua_State *L, int n, int def) |
const char * | wslua_checklstring_only (lua_State *L, int n, size_t *l) |
const char * | wslua_checkstring_only (lua_State *L, int n) |
void | wslua_setfuncs (lua_State *L, const luaL_Reg *l, int nup) |
const char * | wslua_typeof (lua_State *L, int idx) |
bool | wslua_get_table (lua_State *L, int idx, const char *name) |
bool | wslua_get_field (lua_State *L, int idx, const char *name) |
int | dissect_lua (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) |
bool | heur_dissect_lua (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) |
expert_field * | wslua_get_expert_field (const int group, const int severity) |
void | wslua_prefs_changed (void) |
void | proto_register_lua (void) |
GString * | lua_register_all_taps (void) |
void | wslua_prime_dfilter (epan_dissect_t *edt) |
bool | wslua_has_field_extractors (void) |
void | lua_prime_all_fields (proto_tree *tree) |
int | Proto_commit (lua_State *L) |
TreeItem | create_TreeItem (proto_tree *tree, proto_item *item) |
void | clear_outstanding_FuncSavers (void) |
void | Int64_pack (lua_State *L, luaL_Buffer *b, int idx, bool asLittleEndian) |
int | Int64_unpack (lua_State *L, const char *buff, bool asLittleEndian) |
void | UInt64_pack (lua_State *L, luaL_Buffer *b, int idx, bool asLittleEndian) |
int | UInt64_unpack (lua_State *L, const char *buff, bool asLittleEndian) |
uint64_t | getUInt64 (lua_State *L, int i) |
Tvb * | push_Tvb (lua_State *L, tvbuff_t *tvb) |
int | push_wsluaTvb (lua_State *L, Tvb t) |
bool | push_TvbRange (lua_State *L, tvbuff_t *tvb, int offset, int len) |
void | clear_outstanding_Tvb (void) |
void | clear_outstanding_TvbRange (void) |
Pinfo * | push_Pinfo (lua_State *L, packet_info *p) |
void | clear_outstanding_Pinfo (void) |
void | clear_outstanding_Column (void) |
void | clear_outstanding_Columns (void) |
void | clear_outstanding_PrivateTable (void) |
int | get_hf_wslua_text (void) |
TreeItem | push_TreeItem (lua_State *L, proto_tree *tree, proto_item *item) |
void | clear_outstanding_TreeItem (void) |
FieldInfo * | push_FieldInfo (lua_State *L, field_info *f) |
void | clear_outstanding_FieldInfo (void) |
void | wslua_print_stack (char *s, lua_State *L) |
void | wslua_init (register_cb cb, void *client_data) |
void | wslua_early_cleanup (void) |
void | wslua_cleanup (void) |
tap_extractor_t | wslua_get_tap_extractor (const char *name) |
int | wslua_set_tap_enums (lua_State *L) |
ProtoField | wslua_is_field_available (lua_State *L, const char *field_abbr) |
char * | wslua_get_actual_filename (const char *fname) |
int | wslua_bin2hex (lua_State *L, const uint8_t *data, const unsigned len, const bool lowercase, const char *sep) |
int | wslua_hex2bin (lua_State *L, const char *data, const unsigned len, const char *sep) |
int | luaopen_rex_pcre2 (lua_State *L) |
const char * | get_current_plugin_version (void) |
void | clear_current_plugin_version (void) |
int | wslua_deregister_heur_dissectors (lua_State *L) |
int | wslua_deregister_protocols (lua_State *L) |
int | wslua_deregister_dissector_tables (lua_State *L) |
int | wslua_deregister_listeners (lua_State *L) |
int | wslua_deregister_fields (lua_State *L) |
int | wslua_deregister_filehandlers (lua_State *L) |
void | wslua_deregister_menus (void) |
void | wslua_init_wtap_filetypes (lua_State *L) |
const wslua_conv_types_t * | wslua_inspect_convtype_enum (void) |
Variables | |
packet_info * | lua_pinfo |
TreeItem | lua_tree |
tvbuff_t * | lua_tvb |
bool | lua_initialized |
int | lua_dissectors_table_ref |
int | lua_heur_dissectors_table_ref |
const char * | wslua_typeof_unknown |
#define CLEAR_OUTSTANDING | ( | C, | |
marker, | |||
marker_val | |||
) |
#define FAIL_ON_NULL_OR_EXPIRED | ( | s | ) |
#define WRAP_NON_LUA_EXCEPTIONS | ( | code | ) |
#define WSLUA_ATTRIBUTE_FUNC_SETTER | ( | C, | |
field | |||
) |
#define WSLUA_ATTRIBUTE_GET | ( | C, | |
name, | |||
block | |||
) |
#define WSLUA_ATTRIBUTE_NAMED_BOOLEAN_SETTER | ( | C, | |
name, | |||
member | |||
) |
#define WSLUA_ATTRIBUTE_NAMED_INTEGER_SETTER | ( | C, | |
name, | |||
member, | |||
cast | |||
) |
#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_NTH_STRING_GETTER | ( | C, | |
name, | |||
member, | |||
option | |||
) |
#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_NTH_STRING_SETTER | ( | C, | |
field, | |||
member, | |||
option | |||
) |
#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER | ( | C, | |
name, | |||
member, | |||
option | |||
) |
#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER | ( | C, | |
field, | |||
member, | |||
option | |||
) |
#define WSLUA_ATTRIBUTE_NAMED_STRING_GETTER | ( | C, | |
name, | |||
member | |||
) |
#define WSLUA_ATTRIBUTE_NAMED_STRING_SETTER | ( | C, | |
field, | |||
member, | |||
need_free | |||
) |
#define WSLUA_ATTRIBUTE_SET | ( | C, | |
name, | |||
block | |||
) |
#define WSLUA_CLASS_DECLARE | ( | C | ) |
#define wslua_touint | ( | L, | |
i | |||
) | (unsigned) ( lua_tounsigned(L,i) ) |
On Lua 5.3 and later, the unsigned conversions may not be defined (depending on a compatibility define), and they're just casts if they are.
typedef struct _wslua_class wslua_class |
Type for defining new classes.
A new class is defined as a Lua table type. Instances of this class are created through pushXxx which sets the appropriate metatable.
enum pref_type_t |
PREF_OBSOLETE is used for preferences that a module used to support but no longer supports; we give different error messages for them.
|
extern |
Query field abbr that is defined and bound to a Proto in lua. They are not registered until the end of the initialization.
void wslua_register_class | ( | lua_State * | L, |
const wslua_class * | cls_def | ||
) |
Registers a new class for use in Lua with the specified properties. The metatable for the class instance is internally registered with the given name.
This functions basically creates a class (type table) with this structure:
Class = { class_methods } Class.__typeof = "Class" – NOTE: Might be removed in future Class.__metatable = { class_meta } Class.__metatable.__typeof = "Class" – NOTE: Might be removed in future Class.__metatable.__index = function_that_errors_out Class.__metatable.__newindex = function_that_errors_out
It also registers another metatable for class instances (type userdata):
mt = { instance_meta } mt.__typeof = "Class" – will be passed upvalues (see wslua_instancemeta_index_impl). mt.__index = function_that_finds_right_property_or_method_getter mt.__newindex = function_thaon_that_finds_right_property_or_method_setter
For backwards compatibility, introspection is still possible (this detail might be removed in the future though, do not rely on this!):
Class.__metatable.__methods = Class Class.__metatable.__getters = { __typeof = "getter", getter_attrs } Class.__metatable.__setters = { __typeof = "setter", setter_attrs }
void wslua_register_classinstance_meta | ( | lua_State * | L, |
const wslua_class * | cls_def | ||
) |
Registers the metatable for class instances. See the documentation of wslua_register_class for the exact metatable.