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) )
485typedef dissector_handle_t Dissector;
486typedef GByteArray* ByteArray;
487typedef gcry_cipher_hd_t* GcryptCipher;
496typedef int64_t Int64;
497typedef uint64_t UInt64;
511typedef tvbparse_t* Parser;
512typedef tvbparse_wanted_t* Rule;
513typedef tvbparse_elem_t* Node;
514typedef tvbparse_action_t* Shortcut;
529#define WSLUA_CLASS_DEFINE(C,check_code) \
530 WSLUA_CLASS_DEFINE_BASE(C,check_code,NULL)
532#define WSLUA_CLASS_DEFINE_BASE(C,check_code,retval) \
533 WSLUA_CLASS_DEFINE_BASE_PUSH(C,check_code,retval,)
539#define WSLUA_CLASS_DEFINE_BASE_PUSH(C,check_code,retval,push_code) \
540C to##C(lua_State* L, int idx) { \
541 C* v = (C*)lua_touserdata (L, idx); \
542 if (!v) luaL_error(L, "bad argument %d (%s expected, got %s)", idx, #C, lua_typename(L, lua_type(L, idx))); \
543 return v ? *v : retval; \
545C check##C(lua_State* L, int idx) { \
547 luaL_checktype(L,idx,LUA_TUSERDATA); \
548 p = (C*)luaL_checkudata(L, idx, #C); \
550 return p ? *p : retval; \
552C* push##C(lua_State* L, C v) { \
554 luaL_checkstack(L,2,"Unable to grow stack\n"); \
555 p = (C*)lua_newuserdata(L,sizeof(C)); *p = v; \
556 luaL_getmetatable(L, #C); lua_setmetatable(L, -2); \
560bool is##C(lua_State* L,int i) { \
562 if(!lua_isuserdata(L,i)) return false; \
563 p = lua_touserdata(L, i); \
564 lua_getfield(L, LUA_REGISTRYINDEX, #C); \
565 if (p == NULL || !lua_getmetatable(L, i) || !lua_rawequal(L, -1, -2)) p=NULL; \
567 return p ? true : false; \
569C shift##C(lua_State* L,int i) { \
571 if(!lua_isuserdata(L,i)) return retval; \
572 p = (C*)lua_touserdata(L, i); \
573 lua_getfield(L, LUA_REGISTRYINDEX, #C); \
574 if (p == NULL || !lua_getmetatable(L, i) || !lua_rawequal(L, -1, -2)) p=NULL; \
576 if (p) { lua_remove(L,i); return *p; }\
604#define WSLUA_CLASS_DEFINE_INLINE_BASE(C,check_code) \
605C to##C(lua_State* L, int idx) { \
606 C v = (C)lua_touserdata (L, idx); \
607 if (!v) luaL_error(L, "bad argument %d (%s expected, got %s)", idx, #C, lua_typename(L, lua_type(L, idx))); \
610C check##C(lua_State* L, int idx) { \
612 luaL_checktype(L,idx,LUA_TUSERDATA); \
613 p = (C)luaL_checkudata(L, idx, #C); \
617bool is##C(lua_State* L,int i) { \
619 if(!lua_isuserdata(L,i)) return false; \
620 p = lua_touserdata(L, i); \
621 lua_getfield(L, LUA_REGISTRYINDEX, #C); \
622 if (p == NULL || !lua_getmetatable(L, i) || !lua_rawequal(L, -1, -2)) p=NULL; \
624 return p ? true : false; \
626C shift##C(lua_State* L,int i,C buf) { \
628 if(!lua_isuserdata(L,i)) return NULL; \
629 p = (C)lua_touserdata(L, i); \
630 lua_getfield(L, LUA_REGISTRYINDEX, #C); \
631 if (p == NULL || !lua_getmetatable(L, i) || !lua_rawequal(L, -1, -2)) p=NULL; \
633 if (p) { *buf = *p; lua_remove(L,i); return buf; }\
638#define WSLUA_CLASS_DEFINE_INLINE(C,check_code) \
639C push##C(lua_State* L, C v) { \
641 luaL_checkstack(L,2,"Unable to grow stack\n"); \
642 p = (C)lua_newuserdata(L,sizeof(*v)); *p = *v; \
643 luaL_getmetatable(L, #C); lua_setmetatable(L, -2); \
646WSLUA_CLASS_DEFINE_INLINE_BASE(C,check_code)
652extern uint64_t wslua_packet_generation;
655#define WSLUA_EXPIRED(obj) ((obj)->generation != wslua_packet_generation)
669extern uint64_t wslua_file_generation;
672#define WSLUA_FILE_EXPIRED(obj) ((obj)->generation != wslua_file_generation)
679extern uint64_t wslua_state_generation;
712#define WSLUA_TYPEOF_FIELD "__typeof"
717#define WSLUA_REGISTER_GC(C) \
718 luaL_getmetatable(L, #C); \
721 lua_pushcfunction(L, C ## __gc); \
722 lua_setfield(L, -2, "__gc"); \
726#define __WSLUA_REGISTER_META(C, ATTRS) { \
727 const wslua_class C ## _class = { \
729 .instance_meta = C ## _meta, \
732 wslua_register_classinstance_meta(L, &C ## _class); \
735#define WSLUA_REGISTER_META(C) { __WSLUA_REGISTER_META(C, NULL) WSLUA_REGISTER_GC(C); }
736#define WSLUA_REGISTER_META_WITH_ATTRS(C) \
737 { __WSLUA_REGISTER_META(C, C ## _attributes) WSLUA_REGISTER_GC(C); }
739#define __WSLUA_REGISTER_CLASS(C, ATTRS) { \
740 const wslua_class C ## _class = { \
742 .class_methods = C ## _methods, \
743 .class_meta = C ## _meta, \
744 .instance_methods = C ## _methods, \
745 .instance_meta = C ## _meta, \
748 wslua_register_class(L, &C ## _class); \
751#define WSLUA_REGISTER_CLASS(C) { __WSLUA_REGISTER_CLASS(C, NULL) WSLUA_REGISTER_GC(C); }
752#define WSLUA_REGISTER_CLASS_WITH_ATTRS(C) \
753 { __WSLUA_REGISTER_CLASS(C, C ## _attributes) WSLUA_REGISTER_GC(C); }
759#define WSLUA_REGISTER_META_NOGC(C) __WSLUA_REGISTER_META(C, NULL)
760#define WSLUA_REGISTER_META_WITH_ATTRS_NOGC(C) \
761 __WSLUA_REGISTER_META(C, C ## _attributes)
762#define WSLUA_REGISTER_CLASS_NOGC(C) __WSLUA_REGISTER_CLASS(C, NULL)
763#define WSLUA_REGISTER_CLASS_WITH_ATTRS_NOGC(C) \
764 __WSLUA_REGISTER_CLASS(C, C ## _attributes)
766#define WSLUA_INIT(L) \
768 wslua_register_classes(L); \
769 wslua_register_functions(L);
773#define WSLUA_FUNCTION extern int
775#define WSLUA_INTERNAL_FUNCTION extern int
777#define WSLUA_REGISTER_FUNCTION(name) { lua_pushcfunction(L, wslua_## name); lua_setglobal(L, #name); }
779#define WSLUA_REGISTER extern int
781#define WSLUA_METHOD static int
782#define WSLUA_CONSTRUCTOR static int
783#define WSLUA_ATTR_SET static int
784#define WSLUA_ATTR_GET static int
785#define WSLUA_METAMETHOD static int
787#define WSLUA_METHODS static const luaL_Reg
788#define WSLUA_META static const luaL_Reg
789#define WSLUA_CLASS_FNREG(class,name) { #name, class##_##name }
790#define WSLUA_CLASS_FNREG_ALIAS(class,aliasname,name) { #aliasname, class##_##name }
791#define WSLUA_CLASS_MTREG(class,name) { "__" #name, class##__##name }
793#define WSLUA_ATTRIBUTES static const wslua_attribute_table
795#define WSLUA_ATTRIBUTE_RWREG(class,name) { #name, class##_get_##name, class##_set_##name }
796#define WSLUA_ATTRIBUTE_ROREG(class,name) { #name, class##_get_##name, NULL }
797#define WSLUA_ATTRIBUTE_WOREG(class,name) { #name, NULL, class##_set_##name }
804#define WSLUA_STATELESS_PAIRS_BODY(C) \
806 lua_pushcfunction(L, C##_pairs_iter); \
807 lua_pushvalue(L, 1); \
811#define WSLUA_ATTRIBUTE_FUNC_SETTER(C,field) \
812 static int C##_set_##field (lua_State* L) { \
813 C obj = check##C (L,1); \
814 if (! lua_isfunction(L,-1) ) \
815 return luaL_error(L, "%s's attribute `%s' must be a function", #C , #field ); \
816 if (obj->field##_ref != LUA_NOREF) \
818 luaL_unref(L, LUA_REGISTRYINDEX, obj->field##_ref); \
819 obj->field##_ref = luaL_ref(L, LUA_REGISTRYINDEX); \
823 typedef void __dummy##C##_set_##field
825#define WSLUA_ATTRIBUTE_GET(C,name,block) \
826 static int C##_get_##name (lua_State* L) { \
827 C obj = check##C (L,1); \
832 typedef void __dummy##C##_get_##name
834#define WSLUA_ATTRIBUTE_NAMED_BOOLEAN_GETTER(C,name,member) \
835 WSLUA_ATTRIBUTE_GET(C,name,{lua_pushboolean(L, obj->member );})
837#define WSLUA_ATTRIBUTE_NAMED_INTEGER_GETTER(C,name,member) \
838 WSLUA_ATTRIBUTE_GET(C,name,{lua_pushinteger(L,(lua_Integer)(obj->member));})
840#define WSLUA_ATTRIBUTE_INTEGER_GETTER(C,member) \
841 WSLUA_ATTRIBUTE_NAMED_INTEGER_GETTER(C,member,member)
843#define WSLUA_ATTRIBUTE_BLOCK_NUMBER_GETTER(C,name,block) \
844 WSLUA_ATTRIBUTE_GET(C,name,{lua_pushnumber(L,(lua_Number)(block));})
846#define WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(C,name,member) \
847 WSLUA_ATTRIBUTE_GET(C,name, { \
848 lua_pushstring(L,obj->member); \
851#define WSLUA_ATTRIBUTE_STRING_GETTER(C,member) \
852 WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(C,member,member)
854#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(C,name,member,option) \
855 WSLUA_ATTRIBUTE_GET(C,name, { \
857 if ((obj->member) && (obj->member->len > 0)) { \
858 if (wtap_block_get_string_option_value(g_array_index(obj->member, wtap_block_t, 0), option, &str) == WTAP_OPTTYPE_SUCCESS) { \
859 lua_pushstring(L,str); \
868#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_NTH_STRING_GETTER(C,name,member,option) \
869 WSLUA_ATTRIBUTE_GET(C,name, { \
871 if ((obj->member) && (obj->member->len > 0)) { \
872 if (wtap_block_get_nth_string_option_value(g_array_index(obj->member, wtap_block_t, 0), option, 0, &str) == WTAP_OPTTYPE_SUCCESS) { \
873 lua_pushstring(L,str); \
878#define WSLUA_ATTRIBUTE_SET(C,name,block) \
879 static int C##_set_##name (lua_State* L) { \
880 C obj = check##C (L,1); \
885 typedef void __dummy##C##_set_##name
887#define WSLUA_ATTRIBUTE_NAMED_BOOLEAN_SETTER(C,name,member) \
888 WSLUA_ATTRIBUTE_SET(C,name, { \
889 if (! lua_isboolean(L,-1) ) \
890 return luaL_error(L, "%s's attribute `%s' must be a boolean", #C , #name ); \
891 obj->member = lua_toboolean(L,-1); \
896#define WSLUA_ATTRIBUTE_NAMED_INTEGER_SETTER(C,name,member,cast) \
897 WSLUA_ATTRIBUTE_SET(C,name, { \
898 if (! lua_isinteger(L,-1) ) \
899 return luaL_error(L, "%s's attribute `%s' must be an integer", #C , #name ); \
900 obj->member = (cast) wslua_toint32(L,-1); \
903#define WSLUA_ATTRIBUTE_INTEGER_SETTER(C,member,cast) \
904 WSLUA_ATTRIBUTE_NAMED_INTEGER_SETTER(C,member,member,cast)
906#define WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(C,field,member,need_free) \
907 static int C##_set_##field (lua_State* L) { \
908 C obj = check##C (L,1); \
910 if (lua_isstring(L,-1) || lua_isnil(L,-1)) { \
911 s = g_strdup(lua_tostring(L,-1)); \
913 return luaL_error(L, "%s's attribute `%s' must be a string or nil", #C , #field ); \
915 if (obj->member != NULL && need_free) \
916 g_free((void*) obj->member); \
921 typedef void __dummy##C##_set_##field
923#define WSLUA_ATTRIBUTE_STRING_SETTER(C,field,need_free) \
924 WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(C,field,field,need_free)
926#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(C,field,member,option) \
927 static int C##_set_##field (lua_State* L) { \
928 C obj = check##C (L,1); \
930 if (lua_isstring(L,-1) || lua_isnil(L,-1)) { \
931 s = g_strdup(lua_tostring(L,-1)); \
933 return luaL_error(L, "%s's attribute `%s' must be a string or nil", #C , #field ); \
935 if ((obj->member) && (obj->member->len > 0)) { \
936 wtap_block_set_string_option_value(g_array_index(obj->member, wtap_block_t, 0), option, s, strlen(s)); \
942 typedef void __dummy##C##_set_##field
944#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_NTH_STRING_SETTER(C,field,member,option) \
945 static int C##_set_##field (lua_State* L) { \
946 C obj = check##C (L,1); \
948 if (lua_isstring(L,-1) || lua_isnil(L,-1)) { \
949 s = g_strdup(lua_tostring(L,-1)); \
951 return luaL_error(L, "%s's attribute `%s' must be a string or nil", #C , #field ); \
953 if ((obj->member) && (obj->member->len > 0)) { \
954 wtap_block_set_nth_string_option_value(g_array_index(obj->member, wtap_block_t, 0), option, 0, s, strlen(s)); \
960 typedef void __dummy##C##_set_##field
962#define WSLUA_ERROR(name,error) { luaL_error(L, "%s%s", #name ": ", error); }
963#define WSLUA_ARG_ERROR(name,attr,error) { luaL_argerror(L,WSLUA_ARG_ ## name ## _ ## attr, #name ": " error); }
964#define WSLUA_OPTARG_ERROR(name,attr,error) { luaL_argerror(L,WSLUA_OPTARG_##name##_ ##attr, #name ": " error); }
966#define WSLUA_REG_GLOBAL_BOOL(L,n,v) { lua_pushboolean(L,v); lua_setglobal(L,n); }
967#define WSLUA_REG_GLOBAL_STRING(L,n,v) { lua_pushstring(L,v); lua_setglobal(L,n); }
968#define WSLUA_REG_GLOBAL_INTEGER(L,n,v) { lua_pushinteger(L,v); lua_setglobal(L,n); }
970#define WSLUA_RETURN(i) return (i)
972#define WSLUA_API extern
977#define FAIL_ON_NULL(s) if (! *p) luaL_argerror(L,idx,"null " s)
979#define FAIL_ON_NULL_OR_EXPIRED(s) if (!*p) { \
980 luaL_argerror(L,idx,"null " s); \
981 } else if ((*p)->expired) { \
982 luaL_argerror(L,idx,"expired " s); \
986#define FAIL_ON_EXPIRED(s) if (WSLUA_EXPIRED(p)) luaL_argerror(L,idx,"expired " s)
988#define WSLUA_CLASS_DECLARE(C) \
989extern C to##C(lua_State* L, int idx); \
990extern C check##C(lua_State* L, int idx); \
991extern C* push##C(lua_State* L, C v); \
992extern int C##_register(lua_State* L); \
993extern bool is##C(lua_State* L,int i); \
994extern C shift##C(lua_State* L,int i)
996#define WSLUA_CLASS_DECLARE_INLINE(C) \
997extern C to##C(lua_State* L, int idx); \
998extern C check##C(lua_State* L, int idx); \
999extern C push##C(lua_State* L, C v); \
1000extern int C##_register(lua_State* L); \
1001extern bool is##C(lua_State* L,int i); \
1002extern C shift##C(lua_State* L,int i,C buf)
1006#define THROW_LUA_ERROR(...) \
1007 THROW_FORMATTED(DissectorError, __VA_ARGS__)
1028#define WRAP_NON_LUA_EXCEPTIONS(code) \
1030 volatile bool has_error = false; \
1033 } CATCH3(BoundsError, FragmentBoundsError, ScsiBoundsError) { \
1034 show_exception(lua_tvb, lua_pinfo, lua_tree->tree, EXCEPT_CODE, GET_MESSAGE); \
1036 show_exception(lua_tvb, lua_pinfo, lua_tree->tree, EXCEPT_CODE, GET_MESSAGE); \
1037 lua_pushfstring(L, "%s: %s", __func__, GET_MESSAGE ? GET_MESSAGE : "Malformed packet"); \
1040 if (has_error) { lua_error(L); } \
1045extern TreeItem lua_tree;
1046extern tvbuff_t* lua_tvb;
1047extern bool lua_initialized;
1048extern int lua_dissectors_table_ref;
1049extern int lua_heur_dissectors_table_ref;
1050extern const char* lua_app_env_var_prefix;
1051extern GPtrArray* lua_outstanding_FuncSavers;
1053WSLUA_DECLARE_CLASSES()
1054WSLUA_DECLARE_FUNCTIONS()
1063extern lua_State* wslua_state(
void);
1190extern void wslua_setfuncs(lua_State *L,
const luaL_Reg *l,
int nup);
1192extern const char* wslua_typeof_unknown;
1240 proto_tree *tree,
void *data);
1255 proto_tree *tree,
void *data);
1351extern void Int64_pack(lua_State* L, luaL_Buffer *b,
int idx,
bool asLittleEndian);
1361extern int Int64_unpack(lua_State* L,
const char *buff,
bool asLittleEndian);
1371extern void UInt64_pack(lua_State* L, luaL_Buffer *b,
int idx,
bool asLittleEndian);
1381extern int UInt64_unpack(lua_State* L,
const char *buff,
bool asLittleEndian);
1393extern uint64_t
getUInt64(lua_State *L,
int i);
1402extern Tvb
push_Tvb(lua_State* L, tvbuff_t* tvb);
1413extern bool push_TvbRange(lua_State* L, tvbuff_t* tvb,
int offset,
int len);
1528extern int wslua_bin2hex(lua_State* L,
const uint8_t* data,
const unsigned len,
const bool lowercase,
const char* sep);
1539extern int wslua_hex2bin(lua_State* L,
const char* data,
const unsigned len,
const char* sep);
struct _address address
Holds a network or link-layer address of any supported type.
struct conversation conversation_t
conversation_type
Conversation key types recognized by Wireshark dissectors.
Definition conversation.h:115
struct epan_dissect epan_dissect_t
Opaque type representing a single packet dissection context.
Definition epan.h:62
ftenum
Fundamental field value types used throughout the Wireshark dissector framework.
Definition ftypes.h:26
struct _packet_info packet_info
Represents the metadata and indexing information for a single captured frame.
proto_node proto_item
Definition proto.h:952
struct _header_field_info header_field_info
Definition proto.h:795
pref_type_e
Discriminator tag identifying the type and UI representation of a preference entry.
Definition prefs-int.h:138
struct epan_range range_t
Defines a single attribute entry in a Lua class attribute dispatch table, binding a field name to its...
Definition wslua.h:694
lua_CFunction getfunc
Definition wslua.h:696
lua_CFunction setfunc
Definition wslua.h:697
const char * fieldname
Definition wslua.h:695
Wraps capture file metadata for access from the Lua scripting environment.
Definition wslua.h:388
bool expired
Definition wslua.h:391
wtap_dumper * wdh
Definition wslua.h:390
wtap * wth
Definition wslua.h:389
Type for defining new classes.
Definition wslua.h:1073
const wslua_attribute_table * attrs
Definition wslua.h:1079
const luaL_Reg * class_meta
Definition wslua.h:1076
const char * name
Definition wslua.h:1074
const luaL_Reg * class_methods
Definition wslua.h:1075
const luaL_Reg * instance_methods
Definition wslua.h:1077
const luaL_Reg * instance_meta
Definition wslua.h:1078
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
uint64_t generation
Definition wslua.h:288
int col
Definition wslua.h:287
Wraps a column_info for bulk column access from the Lua scripting environment.
Definition wslua.h:294
column_info * cinfo
Definition wslua.h:295
uint64_t generation
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:405
const wtap_rec * rec
Definition wslua.h:406
const uint8_t * pd
Definition wslua.h:407
bool expired
Definition wslua.h:408
Associates a conversation with a Lua registry reference holding per-conversation dissector data.
Definition wslua.h:264
uint64_t state_generation
Definition wslua.h:267
conversation_t * conv
Definition wslua.h:265
int data_ref
Definition wslua.h:266
Wraps a conversation_t, which is allocated in file scope, tracking expiry.
Definition wslua.h:310
uint64_t generation
Definition wslua.h:312
conversation_t * conv
Definition wslua.h:311
Wraps a GDir iterator with extension filtering and path tracking for directory traversal from Lua.
Definition wslua.h:439
GDir * dir
Definition wslua.h:440
char * ext
Definition wslua.h:441
char * path
Definition wslua.h:442
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:189
const char * abbrev
Definition wslua.h:191
expert_field ids
Definition wslua.h:190
const char * text
Definition wslua.h:192
int severity
Definition wslua.h:194
int group
Definition wslua.h:193
Wraps a field_info for access from the Lua scripting environment, tracking validity.
Definition wslua.h:335
uint64_t generation
Definition wslua.h:337
field_info * ws_fi
Definition wslua.h:336
Describes a protocol header field registered from a Lua dissector script.
Definition wslua.h:173
unsigned base
Definition wslua.h:180
int hfid
Definition wslua.h:174
char * name
Definition wslua.h:176
char * blob
Definition wslua.h:178
char * abbrev
Definition wslua.h:177
const void * vs
Definition wslua.h:181
uint64_t mask
Definition wslua.h:183
int ett
Definition wslua.h:175
int valuestring_ref
Definition wslua.h:182
enum ftenum type
Definition wslua.h:179
Wraps a wtap file handle or wtap_dumper for read/write access from the Lua scripting environment.
Definition wslua.h:376
FILE_T file
Definition wslua.h:377
wtap_dumper * wdh
Definition wslua.h:378
bool expired
Definition wslua.h:379
Describes a Lua-registered file format handler for reading and/or writing capture files.
Definition wslua.h:414
int seek_read_ref
Definition wslua.h:424
int read_open_ref
Definition wslua.h:422
int write_ref
Definition wslua.h:429
int write_close_ref
Definition wslua.h:430
int file_type
Definition wslua.h:431
char * type
Definition wslua.h:419
char * internal_description
Definition wslua.h:418
int write_open_ref
Definition wslua.h:428
bool is_writer
Definition wslua.h:417
bool registered
Definition wslua.h:432
char * extensions
Definition wslua.h:420
int read_ref
Definition wslua.h:423
int can_write_encap_ref
Definition wslua.h:427
lua_State * L
Definition wslua.h:421
int seq_read_close_ref
Definition wslua.h:426
int read_close_ref
Definition wslua.h:425
struct file_type_subtype_info finfo
Definition wslua.h:415
bool removed
Definition wslua.h:433
bool is_reader
Definition wslua.h:416
Stores Lua function references to prevent garbage collection for functions used by tcp_dissect_pdus()...
Definition wslua.h:343
int get_len_ref
Definition wslua.h:345
lua_State * state
Definition wslua.h:344
int dissect_ref
Definition wslua.h:346
Wraps a packet_info pointer with expiry tracking for use in the Lua scripting environment.
Definition wslua.h:145
packet_info * ws_pinfo
Definition wslua.h:146
uint64_t generation
Definition wslua.h:147
Represents a single Wireshark preference registered from a Lua dissector script.
Definition wslua.h:200
void * p
Definition wslua.h:213
uat_field_t * uat_field_list
Definition wslua.h:228
struct _wslua_pref_t::@217040237106063345351274302246224144004201267160::@020354106077367206330115123310115110030014002216 enum_info
unsigned u
Definition wslua.h:209
struct _wslua_pref_t::@217040237106063345351274302246224144004201267160::@302242053311026123101057072277315265131022170020 uat_field_list_info
bool radio_buttons
Definition wslua.h:223
char * desc
Definition wslua.h:203
struct _wslua_proto_t * proto
Definition wslua.h:235
char * s
Definition wslua.h:210
char * default_s
Definition wslua.h:231
bool b
Definition wslua.h:208
uint32_t max_value
Definition wslua.h:218
char * name
Definition wslua.h:201
range_t * r
Definition wslua.h:212
int ref
Definition wslua.h:236
struct _wslua_pref_t * next
Definition wslua.h:234
const enum_val_t * enumvals
Definition wslua.h:222
char * label
Definition wslua.h:202
int e
Definition wslua.h:211
pref_type_e type
Definition wslua.h:204
union _wslua_pref_t::@265022225263267215273077122115002146144266147256 value
Wraps a GHashTable for use as a Lua private data table, tracking expiry.
Definition wslua.h:302
GHashTable * table
Definition wslua.h:303
uint64_t generation
Definition wslua.h:304
Wraps a GUI progress dialog for control from the Lua scripting environment.
Definition wslua.h:448
char * title
Definition wslua.h:450
struct progdlg * pw
Definition wslua.h:449
bool stopped
Definition wslua.h:452
char * task
Definition wslua.h:451
Represents a Wireshark protocol registered from a Lua dissector script.
Definition wslua.h:242
bool expired
Definition wslua.h:258
int ett
Definition wslua.h:247
GArray * eia
Definition wslua.h:256
dissector_handle_t handle
Definition wslua.h:253
int fields
Definition wslua.h:249
bool is_postdissector
Definition wslua.h:257
expert_module_t * expert_module
Definition wslua.h:251
int expert_info_table_ref
Definition wslua.h:250
char * desc
Definition wslua.h:245
module_t * prefs_module
Definition wslua.h:252
GArray * hfa
Definition wslua.h:254
int hfid
Definition wslua.h:246
GArray * etta
Definition wslua.h:255
char * name
Definition wslua.h:243
char * loname
Definition wslua.h:244
wslua_pref_t prefs
Definition wslua.h:248
Wraps a wtap_rec for access from the Lua scripting environment, tracking validity.
Definition wslua.h:397
wtap_rec * rec
Definition wslua.h:398
bool expired
Definition wslua.h:399
Represents a Lua tap listener, binding a tap name and filter to Lua callback functions.
Definition wslua.h:359
int draw_ref
Definition wslua.h:365
bool all_fields
Definition wslua.h:367
lua_State * L
Definition wslua.h:363
int packet_ref
Definition wslua.h:364
char * filter
Definition wslua.h:361
int reset_ref
Definition wslua.h:366
char * name
Definition wslua.h:360
tap_extractor_t extractor
Definition wslua.h:362
Wraps a proto_item and its associated proto_tree for manipulation from the Lua scripting environment.
Definition wslua.h:318
proto_tree * tree
Definition wslua.h:320
proto_item * item
Definition wslua.h:319
uint64_t generation
Definition wslua.h:321
Wraps a tvbuff_t with expiry tracking for use in the Lua scripting environment.
Definition wslua.h:137
tvbuff_t * ws_tvb
Definition wslua.h:138
uint64_t generation
Definition wslua.h:139
Represents a sub-range of a Lua tvbuff, defined by an offset and length within the parent tvb.
Definition wslua.h:154
unsigned offset
Definition wslua.h:156
struct _wslua_tvb tvb
Definition wslua.h:155
unsigned len
Definition wslua.h:157
Wraps a funnel text window for use in the Lua scripting environment, tracking expiry and close callba...
Definition wslua.h:163
funnel_text_window_t * ws_tw
Definition wslua.h:164
bool expired
Definition wslua.h:165
void * close_cb_data
Definition wslua.h:166
char * title
Definition wslua.h:167
Definition packet-bt-dht.c:98
Defines a single named value within an enumerated preference or option type.
Definition params.h:16
Pairs an expert info index with its associated header field index for registration and display.
Definition expert.h:41
Describes a single capture file type/subtype, including its metadata, capability flags,...
Definition wtap.h:2051
Definition file-pcapng.h:57
Define the structure describing a progress dialog.
Definition progress_frame.h:28
Maps a tap name to its Lua data extractor callback for use in the tappable protocol registry.
Definition wslua.h:458
tap_extractor_t extractor
Definition wslua.h:460
const char * name
Definition wslua.h:459
Maps a conversation type name string to its conversation_type identifier for use in Lua conversation ...
Definition wslua.h:474
const char * str
Definition wslua.h:475
conversation_type id
Definition wslua.h:476
Maps a field type name string to its ftenum identifier for use in Lua field type lookups.
Definition wslua.h:466
const char * str
Definition wslua.h:467
enum ftenum id
Definition wslua.h:468
Wiretap dumper handle and associated state.
Definition wtap_module.h:166
Represents a single capture record read from or written to a capture file, regardless of record type.
Definition wtap.h:1613
Definition wtap_module.h:58
struct _uat_field_t uat_field_t
Describes a single editable field within a UAT (User Accessible Table).
void wslua_init(register_cb cb, void *client_data, const char *app_env_var_prefix)
Initialize Wireshark Lua support.
Definition init_wslua.c:1747
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
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
Conversation push_Conversation(lua_State *L, conversation_t *conv)
Pushes a Conversation onto the Lua stack.
Definition wslua_conversation.c:110
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:2174
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:656
void wslua_cleanup(void)
Cleans up Lua resources.
Definition init_wslua.c:2221
int wslua_deregister_protocols(lua_State *L)
Deregisters all Lua-based protocol dissectors.
Definition wslua_proto.c:799
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:1106
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:760
bool wslua_has_field_extractors(void)
Checks if there are any registered field extractors.
Definition wslua_field.c:501
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:215
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:783
int wslua_reg_attributes(lua_State *L, const wslua_attribute_table *t, bool is_getter)
Registers attributes for a Lua table.
Pinfo push_Pinfo(lua_State *L, packet_info *p)
Pushes a packet information structure onto the Lua stack.
Definition wslua_pinfo.c:33
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:615
FieldInfo push_FieldInfo(lua_State *L, field_info *f)
Pushes a field information object onto the Lua stack.
Definition wslua_field.c:34
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:74
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.
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:338
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:1277
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:752
int Proto_commit(lua_State *L)
Commits protocol changes.
Definition wslua_proto.c:901
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 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:451
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:78
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:52
void wslua_expire_packet_objects(void)
Expires all existing per-packet Lua objects (Tvb, TvbRange, Pinfo, etc.).
Definition init_wslua.c:165
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:354
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...
void wslua_gc_report_external(lua_State *L, size_t bytes)
Reports memory allocated outside of Lua for a Lua object (such as the contents of a ByteArray) to the...
Definition init_wslua.c:700
uint64_t getUInt64(lua_State *L, int i)
Retrieves a 64-bit unsigned integer from the Lua stack.
Definition wslua_int64.c:594
lua_Integer wslua_tointeger(lua_State *L, int n)
Converts a Lua value to an integer.
Definition wslua_internals.c:85
void wslua_prime_dfilter(epan_dissect_t *edt)
Prime the dissector filter with a protocol tree.
Definition wslua_field.c:494
void wslua_set_postdissector_wanted_hfids(const GArray *hfids)
Sets the fields wanted by every Lua postdissector.
Definition wslua_proto.c:888
TreeItem push_TreeItem(lua_State *L, proto_tree *tree, proto_item *item)
Pushes a TreeItem onto the Lua stack.
Definition wslua_tree.c:27
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