29#include <ws_log_defs.h>
59#include <epan/wslua/declare_wslua.h>
65#define WSLUA_INIT_ROUTINES "init_routines"
66#define WSLUA_PREFS_CHANGED "prefs_changed"
68#ifdef HAVE_LUA_UNICODE
69 #define ABOUT_LUA_RELEASE LUA_RELEASE" (UfW patched)"
71 #define ABOUT_LUA_RELEASE LUA_RELEASE
98#define wslua_toint(L,i) (int) ( lua_tointeger(L,i) )
99#define wslua_toint32(L,i) (int32_t) ( lua_tointeger(L,i) )
100#define wslua_toint64(L,i) (int64_t) ( lua_tonumber(L,i) )
101#define wslua_touint64(L,i) (uint64_t) ( lua_tonumber(L,i) )
103#define wslua_checkint(L,i) (int) ( luaL_checkinteger(L,i) )
104#define wslua_checkint32(L,i) (int32_t) ( luaL_checkinteger(L,i) )
105#define wslua_checkint64(L,i) (int64_t) ( luaL_checknumber(L,i) )
106#define wslua_checkuint64(L,i) (uint64_t) ( luaL_checknumber(L,i) )
108#define wslua_optint(L,i,d) (int) ( luaL_optinteger(L,i,d) )
109#define wslua_optint32(L,i,d) (int32_t) ( luaL_optinteger(L,i,d) )
110#define wslua_optint64(L,i,d) (int64_t) ( luaL_optnumber(L,i,d) )
111#define wslua_optuint64(L,i,d) (uint64_t) ( luaL_optnumber(L,i,d) )
118#if LUA_VERSION_NUM < 503
119#define wslua_touint(L,i) (unsigned) ( lua_tounsigned(L,i) )
120#define wslua_touint32(L,i) (uint32_t) ( lua_tounsigned(L,i) )
121#define wslua_checkuint(L,i) (unsigned) ( luaL_checkunsigned(L,i) )
122#define wslua_checkuint32(L,i) (uint32_t) ( luaL_checkunsigned(L,i) )
123#define wslua_optuint(L,i,d) (unsigned) ( luaL_optunsigned(L,i,d) )
124#define wslua_optuint32(L,i,d) (uint32_t) ( luaL_optunsigned(L,i,d) )
126#define wslua_touint(L,i) (unsigned) ( lua_tointeger(L,i) )
127#define wslua_touint32(L,i) (uint32_t) ( lua_tointeger(L,i) )
128#define wslua_checkuint(L,i) (unsigned) ( luaL_checkinteger(L,i) )
129#define wslua_checkuint32(L,i) (uint32_t) ( luaL_checkinteger(L,i) )
130#define wslua_optuint(L,i,d) (unsigned) ( luaL_optinteger(L,i,d) )
131#define wslua_optuint32(L,i,d) (uint32_t) ( luaL_optinteger(L,i,d) )
479typedef GByteArray* ByteArray;
480typedef gcry_cipher_hd_t* GcryptCipher;
489typedef int64_t Int64;
490typedef uint64_t UInt64;
507typedef tvbparse_action_t* Shortcut;
522#define WSLUA_CLASS_DEFINE(C,check_code) \
523 WSLUA_CLASS_DEFINE_BASE(C,check_code,NULL)
525#define WSLUA_CLASS_DEFINE_BASE(C,check_code,retval) \
526C to##C(lua_State* L, int idx) { \
527 C* v = (C*)lua_touserdata (L, idx); \
528 if (!v) luaL_error(L, "bad argument %d (%s expected, got %s)", idx, #C, lua_typename(L, lua_type(L, idx))); \
529 return v ? *v : retval; \
531C check##C(lua_State* L, int idx) { \
533 luaL_checktype(L,idx,LUA_TUSERDATA); \
534 p = (C*)luaL_checkudata(L, idx, #C); \
536 return p ? *p : retval; \
538C* push##C(lua_State* L, C v) { \
540 luaL_checkstack(L,2,"Unable to grow stack\n"); \
541 p = (C*)lua_newuserdata(L,sizeof(C)); *p = v; \
542 luaL_getmetatable(L, #C); lua_setmetatable(L, -2); \
545bool is##C(lua_State* L,int i) { \
547 if(!lua_isuserdata(L,i)) return false; \
548 p = lua_touserdata(L, i); \
549 lua_getfield(L, LUA_REGISTRYINDEX, #C); \
550 if (p == NULL || !lua_getmetatable(L, i) || !lua_rawequal(L, -1, -2)) p=NULL; \
552 return p ? true : false; \
554C shift##C(lua_State* L,int i) { \
556 if(!lua_isuserdata(L,i)) return retval; \
557 p = (C*)lua_touserdata(L, i); \
558 lua_getfield(L, LUA_REGISTRYINDEX, #C); \
559 if (p == NULL || !lua_getmetatable(L, i) || !lua_rawequal(L, -1, -2)) p=NULL; \
561 if (p) { lua_remove(L,i); return *p; }\
587#define WSLUA_TYPEOF_FIELD "__typeof"
592#define WSLUA_REGISTER_GC(C) \
593 luaL_getmetatable(L, #C); \
596 lua_pushcfunction(L, C ## __gc); \
597 lua_setfield(L, -2, "__gc"); \
601#define __WSLUA_REGISTER_META(C, ATTRS) { \
602 const wslua_class C ## _class = { \
604 .instance_meta = C ## _meta, \
607 wslua_register_classinstance_meta(L, &C ## _class); \
608 WSLUA_REGISTER_GC(C); \
611#define WSLUA_REGISTER_META(C) __WSLUA_REGISTER_META(C, NULL)
612#define WSLUA_REGISTER_META_WITH_ATTRS(C) \
613 __WSLUA_REGISTER_META(C, C ## _attributes)
615#define __WSLUA_REGISTER_CLASS(C, ATTRS) { \
616 const wslua_class C ## _class = { \
618 .class_methods = C ## _methods, \
619 .class_meta = C ## _meta, \
620 .instance_methods = C ## _methods, \
621 .instance_meta = C ## _meta, \
624 wslua_register_class(L, &C ## _class); \
625 WSLUA_REGISTER_GC(C); \
628#define WSLUA_REGISTER_CLASS(C) __WSLUA_REGISTER_CLASS(C, NULL)
629#define WSLUA_REGISTER_CLASS_WITH_ATTRS(C) \
630 __WSLUA_REGISTER_CLASS(C, C ## _attributes)
632#define WSLUA_INIT(L) \
634 wslua_register_classes(L); \
635 wslua_register_functions(L);
639#define WSLUA_FUNCTION extern int
641#define WSLUA_INTERNAL_FUNCTION extern int
643#define WSLUA_REGISTER_FUNCTION(name) { lua_pushcfunction(L, wslua_## name); lua_setglobal(L, #name); }
645#define WSLUA_REGISTER extern int
647#define WSLUA_METHOD static int
648#define WSLUA_CONSTRUCTOR static int
649#define WSLUA_ATTR_SET static int
650#define WSLUA_ATTR_GET static int
651#define WSLUA_METAMETHOD static int
653#define WSLUA_METHODS static const luaL_Reg
654#define WSLUA_META static const luaL_Reg
655#define WSLUA_CLASS_FNREG(class,name) { #name, class##_##name }
656#define WSLUA_CLASS_FNREG_ALIAS(class,aliasname,name) { #aliasname, class##_##name }
657#define WSLUA_CLASS_MTREG(class,name) { "__" #name, class##__##name }
659#define WSLUA_ATTRIBUTES static const wslua_attribute_table
661#define WSLUA_ATTRIBUTE_RWREG(class,name) { #name, class##_get_##name, class##_set_##name }
662#define WSLUA_ATTRIBUTE_ROREG(class,name) { #name, class##_get_##name, NULL }
663#define WSLUA_ATTRIBUTE_WOREG(class,name) { #name, NULL, class##_set_##name }
670#define WSLUA_STATELESS_PAIRS_BODY(C) \
672 lua_pushcfunction(L, C##_pairs_iter); \
673 lua_pushvalue(L, 1); \
677#define WSLUA_ATTRIBUTE_FUNC_SETTER(C,field) \
678 static int C##_set_##field (lua_State* L) { \
679 C obj = check##C (L,1); \
680 if (! lua_isfunction(L,-1) ) \
681 return luaL_error(L, "%s's attribute `%s' must be a function", #C , #field ); \
682 if (obj->field##_ref != LUA_NOREF) \
684 luaL_unref(L, LUA_REGISTRYINDEX, obj->field##_ref); \
685 obj->field##_ref = luaL_ref(L, LUA_REGISTRYINDEX); \
689 typedef void __dummy##C##_set_##field
691#define WSLUA_ATTRIBUTE_GET(C,name,block) \
692 static int C##_get_##name (lua_State* L) { \
693 C obj = check##C (L,1); \
698 typedef void __dummy##C##_get_##name
700#define WSLUA_ATTRIBUTE_NAMED_BOOLEAN_GETTER(C,name,member) \
701 WSLUA_ATTRIBUTE_GET(C,name,{lua_pushboolean(L, obj->member );})
703#define WSLUA_ATTRIBUTE_NAMED_INTEGER_GETTER(C,name,member) \
704 WSLUA_ATTRIBUTE_GET(C,name,{lua_pushinteger(L,(lua_Integer)(obj->member));})
706#define WSLUA_ATTRIBUTE_INTEGER_GETTER(C,member) \
707 WSLUA_ATTRIBUTE_NAMED_INTEGER_GETTER(C,member,member)
709#define WSLUA_ATTRIBUTE_BLOCK_NUMBER_GETTER(C,name,block) \
710 WSLUA_ATTRIBUTE_GET(C,name,{lua_pushnumber(L,(lua_Number)(block));})
712#define WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(C,name,member) \
713 WSLUA_ATTRIBUTE_GET(C,name, { \
714 lua_pushstring(L,obj->member); \
717#define WSLUA_ATTRIBUTE_STRING_GETTER(C,member) \
718 WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(C,member,member)
720#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(C,name,member,option) \
721 WSLUA_ATTRIBUTE_GET(C,name, { \
723 if ((obj->member) && (obj->member->len > 0)) { \
724 if (wtap_block_get_string_option_value(g_array_index(obj->member, wtap_block_t, 0), option, &str) == WTAP_OPTTYPE_SUCCESS) { \
725 lua_pushstring(L,str); \
734#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_NTH_STRING_GETTER(C,name,member,option) \
735 WSLUA_ATTRIBUTE_GET(C,name, { \
737 if ((obj->member) && (obj->member->len > 0)) { \
738 if (wtap_block_get_nth_string_option_value(g_array_index(obj->member, wtap_block_t, 0), option, 0, &str) == WTAP_OPTTYPE_SUCCESS) { \
739 lua_pushstring(L,str); \
744#define WSLUA_ATTRIBUTE_SET(C,name,block) \
745 static int C##_set_##name (lua_State* L) { \
746 C obj = check##C (L,1); \
751 typedef void __dummy##C##_set_##name
753#define WSLUA_ATTRIBUTE_NAMED_BOOLEAN_SETTER(C,name,member) \
754 WSLUA_ATTRIBUTE_SET(C,name, { \
755 if (! lua_isboolean(L,-1) ) \
756 return luaL_error(L, "%s's attribute `%s' must be a boolean", #C , #name ); \
757 obj->member = lua_toboolean(L,-1); \
762#define WSLUA_ATTRIBUTE_NAMED_INTEGER_SETTER(C,name,member,cast) \
763 WSLUA_ATTRIBUTE_SET(C,name, { \
764 if (! lua_isinteger(L,-1) ) \
765 return luaL_error(L, "%s's attribute `%s' must be an integer", #C , #name ); \
766 obj->member = (cast) wslua_toint32(L,-1); \
769#define WSLUA_ATTRIBUTE_INTEGER_SETTER(C,member,cast) \
770 WSLUA_ATTRIBUTE_NAMED_INTEGER_SETTER(C,member,member,cast)
772#define WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(C,field,member,need_free) \
773 static int C##_set_##field (lua_State* L) { \
774 C obj = check##C (L,1); \
776 if (lua_isstring(L,-1) || lua_isnil(L,-1)) { \
777 s = g_strdup(lua_tostring(L,-1)); \
779 return luaL_error(L, "%s's attribute `%s' must be a string or nil", #C , #field ); \
781 if (obj->member != NULL && need_free) \
782 g_free((void*) obj->member); \
787 typedef void __dummy##C##_set_##field
789#define WSLUA_ATTRIBUTE_STRING_SETTER(C,field,need_free) \
790 WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(C,field,field,need_free)
792#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(C,field,member,option) \
793 static int C##_set_##field (lua_State* L) { \
794 C obj = check##C (L,1); \
796 if (lua_isstring(L,-1) || lua_isnil(L,-1)) { \
797 s = g_strdup(lua_tostring(L,-1)); \
799 return luaL_error(L, "%s's attribute `%s' must be a string or nil", #C , #field ); \
801 if ((obj->member) && (obj->member->len > 0)) { \
802 wtap_block_set_string_option_value(g_array_index(obj->member, wtap_block_t, 0), option, s, strlen(s)); \
808 typedef void __dummy##C##_set_##field
810#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_NTH_STRING_SETTER(C,field,member,option) \
811 static int C##_set_##field (lua_State* L) { \
812 C obj = check##C (L,1); \
814 if (lua_isstring(L,-1) || lua_isnil(L,-1)) { \
815 s = g_strdup(lua_tostring(L,-1)); \
817 return luaL_error(L, "%s's attribute `%s' must be a string or nil", #C , #field ); \
819 if ((obj->member) && (obj->member->len > 0)) { \
820 wtap_block_set_nth_string_option_value(g_array_index(obj->member, wtap_block_t, 0), option, 0, s, strlen(s)); \
826 typedef void __dummy##C##_set_##field
828#define WSLUA_ERROR(name,error) { luaL_error(L, "%s%s", #name ": ", error); }
829#define WSLUA_ARG_ERROR(name,attr,error) { luaL_argerror(L,WSLUA_ARG_ ## name ## _ ## attr, #name ": " error); }
830#define WSLUA_OPTARG_ERROR(name,attr,error) { luaL_argerror(L,WSLUA_OPTARG_##name##_ ##attr, #name ": " error); }
832#define WSLUA_REG_GLOBAL_BOOL(L,n,v) { lua_pushboolean(L,v); lua_setglobal(L,n); }
833#define WSLUA_REG_GLOBAL_STRING(L,n,v) { lua_pushstring(L,v); lua_setglobal(L,n); }
834#define WSLUA_REG_GLOBAL_INTEGER(L,n,v) { lua_pushinteger(L,v); lua_setglobal(L,n); }
836#define WSLUA_RETURN(i) return (i)
838#define WSLUA_API extern
843#define FAIL_ON_NULL(s) if (! *p) luaL_argerror(L,idx,"null " s)
845#define FAIL_ON_NULL_OR_EXPIRED(s) if (!*p) { \
846 luaL_argerror(L,idx,"null " s); \
847 } else if ((*p)->expired) { \
848 luaL_argerror(L,idx,"expired " s); \
852#define CLEAR_OUTSTANDING(C, marker, marker_val) void clear_outstanding_##C(void) { \
853 while (outstanding_##C->len) { \
854 C p = (C)g_ptr_array_remove_index_fast(outstanding_##C,0); \
856 if (p->marker != marker_val) \
857 p->marker = marker_val; \
864#define WSLUA_CLASS_DECLARE(C) \
865extern C to##C(lua_State* L, int idx); \
866extern C check##C(lua_State* L, int idx); \
867extern C* push##C(lua_State* L, C v); \
868extern int C##_register(lua_State* L); \
869extern bool is##C(lua_State* L,int i); \
870extern C shift##C(lua_State* L,int i)
874#define THROW_LUA_ERROR(...) \
875 THROW_FORMATTED(DissectorError, __VA_ARGS__)
896#define WRAP_NON_LUA_EXCEPTIONS(code) \
898 volatile bool has_error = false; \
901 } CATCH3(BoundsError, FragmentBoundsError, ScsiBoundsError) { \
902 show_exception(lua_tvb, lua_pinfo, lua_tree->tree, EXCEPT_CODE, GET_MESSAGE); \
904 show_exception(lua_tvb, lua_pinfo, lua_tree->tree, EXCEPT_CODE, GET_MESSAGE); \
905 lua_pushfstring(L, "%s: %s", __func__, GET_MESSAGE ? GET_MESSAGE : "Malformed packet"); \
908 if (has_error) { lua_error(L); } \
915extern bool lua_initialized;
916extern int lua_dissectors_table_ref;
917extern int lua_heur_dissectors_table_ref;
918extern const char* lua_app_env_var_prefix;
919extern GPtrArray* lua_outstanding_FuncSavers;
921WSLUA_DECLARE_CLASSES()
922WSLUA_DECLARE_FUNCTIONS()
1058extern void wslua_setfuncs(lua_State *L,
const luaL_Reg *l,
int nup);
1060extern const char* wslua_typeof_unknown;
1217extern void Int64_pack(lua_State* L, luaL_Buffer *b,
int idx,
bool asLittleEndian);
1227extern int Int64_unpack(lua_State* L,
const char *buff,
bool asLittleEndian);
1237extern void UInt64_pack(lua_State* L, luaL_Buffer *b,
int idx,
bool asLittleEndian);
1247extern int UInt64_unpack(lua_State* L,
const char *buff,
bool asLittleEndian);
1259extern uint64_t
getUInt64(lua_State *L,
int i);
1436extern int wslua_bin2hex(lua_State* L,
const uint8_t* data,
const unsigned len,
const bool lowercase,
const char* sep);
1447extern int wslua_hex2bin(lua_State* L,
const char* data,
const unsigned len,
const char* sep);
conversation_type
Conversation key types recognized by Wireshark dissectors.
Definition conversation.h:65
ftenum
Fundamental field value types used throughout the Wireshark dissector framework.
Definition ftypes.h:26
pref_type_e
Discriminator tag identifying the type and UI representation of a preference entry.
Definition prefs-int.h:138
Holds a network or link-layer address of any supported type.
Definition address.h:62
Definition tap-funnel.c:21
Represents the metadata and indexing information for a single captured frame.
Definition packet_info.h:43
Represents a single token matched by the tvbuff parser, forming part of a linked tree of parse result...
Definition tvbparse.h:165
Represents an instance of a per-packet parser for tvbuff data.
Definition tvbparse.h:151
Describes a parsing rule or expectation for a tvbuff parser.
Definition tvbparse.h:96
Describes a single editable field within a UAT (User Accessible Table).
Definition uat.h:234
Defines a single attribute entry in a Lua class attribute dispatch table, binding a field name to its...
Definition wslua.h:569
lua_CFunction getfunc
Definition wslua.h:571
lua_CFunction setfunc
Definition wslua.h:572
const char * fieldname
Definition wslua.h:570
Wraps capture file metadata for access from the Lua scripting environment.
Definition wslua.h:381
bool expired
Definition wslua.h:384
wtap_dumper * wdh
Definition wslua.h:383
wtap * wth
Definition wslua.h:382
Type for defining new classes.
Definition wslua.h:941
const wslua_attribute_table * attrs
Definition wslua.h:947
const luaL_Reg * class_meta
Definition wslua.h:944
const char * name
Definition wslua.h:942
const luaL_Reg * class_methods
Definition wslua.h:943
const luaL_Reg * instance_methods
Definition wslua.h:945
const luaL_Reg * instance_meta
Definition wslua.h:946
Wraps a single column within a column_info for access from the Lua scripting environment.
Definition wslua.h:285
column_info * cinfo
Definition wslua.h:286
int col
Definition wslua.h:287
bool expired
Definition wslua.h:288
Wraps a column_info for bulk column access from the Lua scripting environment.
Definition wslua.h:294
column_info * cinfo
Definition wslua.h:295
bool expired
Definition wslua.h:296
Wraps a read-only wtap_rec and its associated raw packet data for access from the Lua scripting envir...
Definition wslua.h:398
const wtap_rec * rec
Definition wslua.h:399
const uint8_t * pd
Definition wslua.h:400
bool expired
Definition wslua.h:401
Associates a conversation with a Lua registry reference holding per-conversation dissector data.
Definition wslua.h:265
conversation_t * conv
Definition wslua.h:266
int data_ref
Definition wslua.h:267
Wraps a GDir iterator with extension filtering and path tracking for directory traversal from Lua.
Definition wslua.h:432
GDir * dir
Definition wslua.h:433
char * ext
Definition wslua.h:434
char * path
Definition wslua.h:435
Represents a Lua DissectorTable, which may back either a standard dissector_table_t or a heuristic di...
Definition wslua.h:273
dissector_table_t table
Definition wslua.h:274
const char * name
Definition wslua.h:276
bool expired
Definition wslua.h:279
bool created
Definition wslua.h:278
heur_dissector_list_t heur_list
Definition wslua.h:275
const char * ui_name
Definition wslua.h:277
Describes an expert info field registered from a Lua dissector script.
Definition wslua.h:190
const char * abbrev
Definition wslua.h:192
expert_field ids
Definition wslua.h:191
const char * text
Definition wslua.h:193
int severity
Definition wslua.h:195
int group
Definition wslua.h:194
Wraps a field_info for access from the Lua scripting environment, tracking validity.
Definition wslua.h:328
bool expired
Definition wslua.h:330
field_info * ws_fi
Definition wslua.h:329
Describes a protocol header field registered from a Lua dissector script.
Definition wslua.h:174
unsigned base
Definition wslua.h:181
int hfid
Definition wslua.h:175
char * name
Definition wslua.h:177
char * blob
Definition wslua.h:179
char * abbrev
Definition wslua.h:178
const void * vs
Definition wslua.h:182
uint64_t mask
Definition wslua.h:184
int ett
Definition wslua.h:176
int valuestring_ref
Definition wslua.h:183
enum ftenum type
Definition wslua.h:180
Wraps a wtap file handle or wtap_dumper for read/write access from the Lua scripting environment.
Definition wslua.h:369
FILE_T file
Definition wslua.h:370
wtap_dumper * wdh
Definition wslua.h:371
bool expired
Definition wslua.h:372
Describes a Lua-registered file format handler for reading and/or writing capture files.
Definition wslua.h:407
int seek_read_ref
Definition wslua.h:417
int read_open_ref
Definition wslua.h:415
int write_ref
Definition wslua.h:422
int write_close_ref
Definition wslua.h:423
int file_type
Definition wslua.h:424
char * type
Definition wslua.h:412
char * internal_description
Definition wslua.h:411
int write_open_ref
Definition wslua.h:421
bool is_writer
Definition wslua.h:410
bool registered
Definition wslua.h:425
char * extensions
Definition wslua.h:413
int read_ref
Definition wslua.h:416
int can_write_encap_ref
Definition wslua.h:420
lua_State * L
Definition wslua.h:414
int seq_read_close_ref
Definition wslua.h:419
int read_close_ref
Definition wslua.h:418
struct file_type_subtype_info finfo
Definition wslua.h:408
bool removed
Definition wslua.h:426
bool is_reader
Definition wslua.h:409
Stores Lua function references to prevent garbage collection for functions used by tcp_dissect_pdus()...
Definition wslua.h:336
int get_len_ref
Definition wslua.h:338
lua_State * state
Definition wslua.h:337
int dissect_ref
Definition wslua.h:339
Wraps a packet_info pointer with expiry tracking for use in the Lua scripting environment.
Definition wslua.h:146
packet_info * ws_pinfo
Definition wslua.h:147
bool expired
Definition wslua.h:148
Represents a single Wireshark preference registered from a Lua dissector script.
Definition wslua.h:201
void * p
Definition wslua.h:214
uat_field_t * uat_field_list
Definition wslua.h:229
unsigned u
Definition wslua.h:210
bool radio_buttons
Definition wslua.h:224
char * desc
Definition wslua.h:204
struct _wslua_proto_t * proto
Definition wslua.h:236
char * s
Definition wslua.h:211
char * default_s
Definition wslua.h:232
bool b
Definition wslua.h:209
uint32_t max_value
Definition wslua.h:219
char * name
Definition wslua.h:202
range_t * r
Definition wslua.h:213
int ref
Definition wslua.h:237
struct _wslua_pref_t::@510::@512 uat_field_list_info
struct _wslua_pref_t * next
Definition wslua.h:235
const enum_val_t * enumvals
Definition wslua.h:223
char * label
Definition wslua.h:203
int e
Definition wslua.h:212
struct _wslua_pref_t::@510::@511 enum_info
pref_type_e type
Definition wslua.h:205
union _wslua_pref_t::@509 value
union _wslua_pref_t::@510 info
Wraps a GHashTable for use as a Lua private data table, tracking ownership and expiry.
Definition wslua.h:302
bool expired
Definition wslua.h:305
bool is_allocated
Definition wslua.h:304
GHashTable * table
Definition wslua.h:303
Wraps a GUI progress dialog for control from the Lua scripting environment.
Definition wslua.h:441
char * title
Definition wslua.h:443
struct progdlg * pw
Definition wslua.h:442
bool stopped
Definition wslua.h:445
char * task
Definition wslua.h:444
Represents a Wireshark protocol registered from a Lua dissector script.
Definition wslua.h:243
bool expired
Definition wslua.h:259
int ett
Definition wslua.h:248
GArray * eia
Definition wslua.h:257
dissector_handle_t handle
Definition wslua.h:254
int fields
Definition wslua.h:250
bool is_postdissector
Definition wslua.h:258
expert_module_t * expert_module
Definition wslua.h:252
int expert_info_table_ref
Definition wslua.h:251
char * desc
Definition wslua.h:246
module_t * prefs_module
Definition wslua.h:253
GArray * hfa
Definition wslua.h:255
int hfid
Definition wslua.h:247
GArray * etta
Definition wslua.h:256
char * name
Definition wslua.h:244
char * loname
Definition wslua.h:245
wslua_pref_t prefs
Definition wslua.h:249
Wraps a wtap_rec for access from the Lua scripting environment, tracking validity.
Definition wslua.h:390
wtap_rec * rec
Definition wslua.h:391
bool expired
Definition wslua.h:392
Represents a Lua tap listener, binding a tap name and filter to Lua callback functions.
Definition wslua.h:352
int draw_ref
Definition wslua.h:358
bool all_fields
Definition wslua.h:360
lua_State * L
Definition wslua.h:356
int packet_ref
Definition wslua.h:357
char * filter
Definition wslua.h:354
int reset_ref
Definition wslua.h:359
char * name
Definition wslua.h:353
tap_extractor_t extractor
Definition wslua.h:355
Wraps a proto_item and its associated proto_tree for manipulation from the Lua scripting environment.
Definition wslua.h:311
proto_tree * tree
Definition wslua.h:313
bool expired
Definition wslua.h:314
proto_item * item
Definition wslua.h:312
Wraps a tvbuff_t with ownership and expiry tracking for use in the Lua scripting environment.
Definition wslua.h:137
tvbuff_t * ws_tvb
Definition wslua.h:138
bool expired
Definition wslua.h:139
bool need_free
Definition wslua.h:140
Represents a sub-range of a Lua tvbuff, defined by an offset and length within the parent tvb.
Definition wslua.h:155
unsigned offset
Definition wslua.h:157
unsigned len
Definition wslua.h:158
struct _wslua_tvb * tvb
Definition wslua.h:156
Wraps a funnel text window for use in the Lua scripting environment, tracking expiry and close callba...
Definition wslua.h:164
funnel_text_window_t * ws_tw
Definition wslua.h:165
bool expired
Definition wslua.h:166
void * close_cb_data
Definition wslua.h:167
char * title
Definition wslua.h:168
Definition packet-bt-dht.c:97
Definition conversation.h:229
Defines a single named value within an enumerated preference or option type.
Definition params.h:16
Definition column-info.h:59
Holds all state for the dissection of a single byte array, including session, buffer,...
Definition epan_dissect.h:28
Pairs an expert info index with its associated header field index for registration and display.
Definition expert.h:41
Represents a preference module grouping related preferences under a named, hierarchical entry in the ...
Definition prefs-int.h:27
Define the structure describing a progress dialog.
Definition progress_frame.h:33
Maps a tap name to its Lua data extractor callback for use in the tappable protocol registry.
Definition wslua.h:451
tap_extractor_t extractor
Definition wslua.h:453
const char * name
Definition wslua.h:452
Core tvbuff (testy virtual buffer) structure representing a region of packet data,...
Definition tvbuff-int.h:95
Maps a conversation type name string to its conversation_type identifier for use in Lua conversation ...
Definition wslua.h:467
const char * str
Definition wslua.h:468
conversation_type id
Definition wslua.h:469
Maps a field type name string to its ftenum identifier for use in Lua field type lookups.
Definition wslua.h:459
const char * str
Definition wslua.h:460
enum ftenum id
Definition wslua.h:461
Wiretap dumper handle and associated state.
Definition wtap_module.h:163
Definition file_wrappers.c:96
Definition wtap_module.h:58
void clear_outstanding_TvbRange(void)
Clears all outstanding TvbRange objects.
Definition wslua_tvb.c:396
void wslua_init(register_cb cb, void *client_data, const char *app_env_var_prefix)
Initialize Wireshark Lua support.
Definition init_wslua.c:1655
int dissect_lua(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
C-side entry point for all Lua-based protocol dissectors.
bool wslua_get_table(lua_State *L, int idx, const char *name)
Push a named field from a Lua table onto the stack.
Definition wslua_internals.c:199
tap_extractor_t wslua_get_tap_extractor(const char *name)
Retrieves a tap extractor by name.
struct _wslua_field_t wslua_field_t
Describes a protocol header field registered from a Lua dissector script.
void wslua_print_stack(char *s, lua_State *L)
Prints the stack of a Lua state with a given prefix.
Definition wslua_internals.c:167
int push_wsluaTvb(lua_State *L, Tvb t)
Pushes a Tvb object onto the Lua stack.
Definition wslua_tvb.c:77
const char * wslua_checklstring_only(lua_State *L, int n, size_t *l)
Checks if the value at the given index is a Lua string and returns it.
Definition wslua_internals.c:119
const char * wslua_checkstring_only(lua_State *L, int n)
Checks if a Lua value at a given index is a string.
Definition wslua_internals.c:129
bool heur_dissect_lua(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
C-side entry point for all Lua-based heuristic dissectors.
void lua_prime_all_fields(proto_tree *tree)
Primes all fields in the protocol tree.
void wslua_early_cleanup(void)
Performs early cleanup of Lua resources.
Definition init_wslua.c:2046
void clear_outstanding_Column(void)
Clears all outstanding Column objects.
Definition wslua_column.c:28
int UInt64_unpack(lua_State *L, const char *buff, bool asLittleEndian)
Unpacks a 64-bit unsigned integer from a buffer with specified endianness and pushes it onto the Lua ...
Definition wslua_int64.c:661
void wslua_cleanup(void)
Cleans up Lua resources.
Definition init_wslua.c:2093
int wslua_deregister_protocols(lua_State *L)
Deregisters all Lua-based protocol dissectors.
Definition wslua_proto.c:791
TreeItem create_TreeItem(proto_tree *tree, proto_item *item)
Creates a new TreeItem.
Definition wslua_tree.c:43
FieldInfo * push_FieldInfo(lua_State *L, field_info *f)
Pushes a field information object onto the Lua stack.
Definition wslua_field.c:36
void wslua_register_class(lua_State *L, const wslua_class *cls_def)
Registers a new Lua class in the global table.
Definition wslua_internals.c:547
const char * get_current_plugin_version(void)
Get the current plugin version.
Definition wslua_utility.c:39
int wslua_deregister_dissector_tables(lua_State *L)
Deregisters all registered dissector tables.
Definition wslua_dissector.c:1111
int wslua_deregister_filehandlers(lua_State *L)
Deregisters file handlers and menus in Wireshark's Lua environment.
int luaopen_rex_pcre2(lua_State *L)
Open the Lua library for PCRE2 regular expressions.
Definition lpcre2.c:481
void wslua_prefs_changed(void)
Notify Lua scripts that preferences have changed.
Definition init_wslua.c:668
lua_State * wslua_state(void)
Retrieves the Lua state associated with Wireshark.
Definition init_wslua.c:2102
Pinfo * push_Pinfo(lua_State *L, packet_info *p)
Pushes a packet information structure onto the Lua stack.
Definition wslua_pinfo.c:39
void clear_outstanding_Pinfo(void)
Clears all outstanding Pinfo objects.
Definition wslua_pinfo.c:36
bool wslua_has_field_extractors(void)
Checks if there are any registered field extractors.
Definition wslua_field.c:521
int wslua_deregister_fields(lua_State *L)
Deregisters Lua fields.
int wslua_optboolint(lua_State *L, int n, int def)
Retrieves an optional boolean or integer value from the Lua stack.
Definition wslua_internals.c:102
int get_hf_wslua_text(void)
Retrieves the value of hf_wslua_text.
Definition init_wslua.c:187
bool wslua_get_field(lua_State *L, int idx, const char *name)
Push a named field from a Lua value's metatable or environment.
Definition wslua_internals.c:213
bool wslua_optbool(lua_State *L, int n, bool def)
Checks if a Lua value at a given index is a boolean and returns its value, or a default value if not.
Definition wslua_internals.c:69
int wslua_deregister_heur_dissectors(lua_State *L)
Deregisters all Lua-based heuristics dissectors.
Definition wslua_proto.c:775
int wslua_reg_attributes(lua_State *L, const wslua_attribute_table *t, bool is_getter)
Registers attributes for a Lua table.
void UInt64_pack(lua_State *L, luaL_Buffer *b, int idx, bool asLittleEndian)
Packs a 64-bit unsigned integer into a Lua string buffer with specified endianness.
Definition wslua_int64.c:620
void wslua_deregister_menus(void)
Deregisters all menus registered by Wireshark Lua.
Definition wslua_gui.c:110
void clear_current_plugin_version(void)
Clear the current plugin version.
Definition wslua_utility.c:43
struct _wslua_proto_t wslua_proto_t
Represents a Wireshark protocol registered from a Lua dissector script.
void clear_outstanding_Columns(void)
Clears all outstanding Column objects.
Definition wslua_column.c:29
void clear_outstanding_FieldInfo(void)
Clears any outstanding FieldInfo structures.
Definition wslua_field.c:44
int wslua__concat(lua_State *L)
Concatenates two objects to a string.
Definition wslua_internals.c:27
bool push_TvbRange(lua_State *L, tvbuff_t *tvb, int offset, int len)
Pushes a TvbRange object onto the Lua stack.
Definition wslua_tvb.c:404
expert_field * wslua_get_expert_field(const int group, const int severity)
Retrieves an expert field based on group and severity.
Definition init_wslua.c:1185
bool wslua_toboolean(lua_State *L, int n)
Converts a Lua value to a boolean.
Definition wslua_internals.c:44
ProtoField wslua_is_field_available(lua_State *L, const char *field_abbr)
Definition wslua_proto.c:744
int Proto_commit(lua_State *L)
Commits protocol changes.
Definition wslua_proto.c:875
int Int64_unpack(lua_State *L, const char *buff, bool asLittleEndian)
Unpacks a 64-bit integer from a buffer with specified endianness and pushes it onto the Lua stack.
Definition wslua_int64.c:169
const char * wslua_typeof(lua_State *L, int idx)
Return a human-readable type name for the Lua value at a stack index.
Definition wslua_internals.c:180
int wslua_bin2hex(lua_State *L, const uint8_t *data, const unsigned len, const bool lowercase, const char *sep)
Convert binary data to hexadecimal string.
Definition wslua_internals.c:318
void clear_outstanding_Tvb(void)
Clears all outstanding Tvb objects.
Definition wslua_tvb.c:98
void wslua_register_classinstance_meta(lua_State *L, const wslua_class *cls_def)
Registers a class instance meta table.
Definition wslua_internals.c:470
struct _wslua_expert_field_t wslua_expert_field_t
Describes an expert info field registered from a Lua dissector script.
void wslua_init_wtap_filetypes(lua_State *L)
Initialize Wireshark Lua file types.
Definition wslua_wtap.c:111
struct _wslua_class wslua_class
Type for defining new classes.
int wslua_deregister_listeners(lua_State *L)
Deregisters all registered listeners.
Definition wslua_listener.c:444
Tvb * push_Tvb(lua_State *L, tvbuff_t *tvb)
Pushes a tvbuff_t to the Lua stack as a Tvb object.
Definition wslua_tvb.c:106
void proto_register_lua(void)
Registers the Lua protocol.
struct _wslua_conv_data_t wslua_conv_data_t
Associates a conversation with a Lua registry reference holding per-conversation dissector data.
struct _wslua_pref_t wslua_pref_t
Represents a single Wireshark preference registered from a Lua dissector script.
char * wslua_get_actual_filename(const char *fname)
Retrieves the actual filename with normalized path separators.
Definition wslua_utility.c:380
const wslua_conv_types_t * wslua_inspect_convtype_enum(void)
Retrieves the enumeration of conversation types for Lua inspection.
Definition wslua_conversation.c:77
bool wslua_checkboolean(lua_State *L, int n)
Checks if a Lua value at a given index is a boolean.
Definition wslua_internals.c:60
int wslua_set_tap_enums(lua_State *L)
Set tap enumerations in Lua.
void clear_outstanding_FuncSavers(lua_State *L)
Clears outstanding function savers associated with a Lua state.
Definition wslua_proto.c:49
void clear_outstanding_PrivateTable(void)
Clears any outstanding PrivateTable entries.
Definition wslua_pinfo.c:37
void(* tap_extractor_t)(lua_State *L, const void *data)
Callback type for extracting tap data from a C tap structure into a Lua state.
Definition wslua.h:347
GString * lua_register_all_taps(void)
Registers all Lua taps.
struct _wslua_attribute_table wslua_attribute_table
Defines a single attribute entry in a Lua class attribute dispatch table, binding a field name to its...
uint64_t getUInt64(lua_State *L, int i)
Retrieves a 64-bit unsigned integer from the Lua stack.
Definition wslua_int64.c:599
lua_Integer wslua_tointeger(lua_State *L, int n)
Converts a Lua value to an integer.
Definition wslua_internals.c:85
void clear_outstanding_TreeItem(void)
Clears all outstanding TreeItem objects.
Definition wslua_tree.c:53
void wslua_prime_dfilter(epan_dissect_t *edt)
Prime the dissector filter with a protocol tree.
Definition wslua_field.c:514
TreeItem push_TreeItem(lua_State *L, proto_tree *tree, proto_item *item)
Pushes a TreeItem onto the Lua stack.
Definition wslua_tree.c:30
int wslua_hex2bin(lua_State *L, const char *data, const unsigned len, const char *sep)
Convert hexadecimal string to binary data.
Definition wslua_internals.c:375
void Int64_pack(lua_State *L, luaL_Buffer *b, int idx, bool asLittleEndian)
Packs a 64-bit integer into a Lua string using the specified endianness.
Definition wslua_int64.c:128
void wslua_setfuncs(lua_State *L, const luaL_Reg *l, int nup)
Set functions in a Lua table.
Definition wslua_internals.c:134