summaryrefslogtreecommitdiffstats
path: root/epan/wslua/wslua_pinfo.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:26 +0000
commitc4e8a3222648fcf22ca207f1815ebbf7cd144eeb (patch)
tree93d5c6aa93d9987680dd1adad5685e2ad698f223 /epan/wslua/wslua_pinfo.c
parentAdding upstream version 4.2.6. (diff)
downloadwireshark-upstream.tar.xz
wireshark-upstream.zip
Adding upstream version 4.4.0.upstream/4.4.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'epan/wslua/wslua_pinfo.c')
-rw-r--r--epan/wslua/wslua_pinfo.c106
1 files changed, 60 insertions, 46 deletions
diff --git a/epan/wslua/wslua_pinfo.c b/epan/wslua/wslua_pinfo.c
index a735d601..1b0bb621 100644
--- a/epan/wslua/wslua_pinfo.c
+++ b/epan/wslua/wslua_pinfo.c
@@ -30,18 +30,18 @@
* see comment on wslua_tvb.c
*/
-static GPtrArray* outstanding_Pinfo = NULL;
-static GPtrArray* outstanding_PrivateTable = NULL;
+static GPtrArray* outstanding_Pinfo;
+static GPtrArray* outstanding_PrivateTable;
-CLEAR_OUTSTANDING(Pinfo,expired, TRUE)
-CLEAR_OUTSTANDING(PrivateTable,expired, TRUE)
+CLEAR_OUTSTANDING(Pinfo,expired, true)
+CLEAR_OUTSTANDING(PrivateTable,expired, true)
Pinfo* push_Pinfo(lua_State* L, packet_info* ws_pinfo) {
Pinfo pinfo = NULL;
if (ws_pinfo) {
pinfo = (Pinfo)g_malloc(sizeof(struct _wslua_pinfo));
pinfo->ws_pinfo = ws_pinfo;
- pinfo->expired = FALSE;
+ pinfo->expired = false;
g_ptr_array_add(outstanding_Pinfo,pinfo);
}
return pushPinfo(L,pinfo);
@@ -65,7 +65,7 @@ WSLUA_METAMETHOD PrivateTable__tostring(lua_State* L) {
keys = g_hash_table_get_keys (priv->table);
key = g_list_first (keys);
while (key) {
- key_string = g_string_append (key_string, (const gchar *)key->data);
+ key_string = g_string_append (key_string, (const char *)key->data);
key = g_list_next (key);
if (key) {
key_string = g_string_append_c (key_string, ',');
@@ -83,10 +83,10 @@ WSLUA_METAMETHOD PrivateTable__tostring(lua_State* L) {
static int PrivateTable__index(lua_State* L) {
/* Gets the text of a specific entry. */
PrivateTable priv = checkPrivateTable(L,1);
- const gchar* name = luaL_checkstring(L,2);
- const gchar* string;
+ const char* name = luaL_checkstring(L,2);
+ const char* string;
- string = (const gchar *)(g_hash_table_lookup (priv->table, name));
+ string = (const char *)(g_hash_table_lookup (priv->table, name));
if (string) {
lua_pushstring(L, string);
@@ -100,8 +100,8 @@ static int PrivateTable__index(lua_State* L) {
static int PrivateTable__newindex(lua_State* L) {
/* Sets the text of a specific entry. */
PrivateTable priv = checkPrivateTable(L,1);
- const gchar* name = luaL_checkstring(L,2);
- const gchar* string = NULL;
+ const char* name = luaL_checkstring(L,2);
+ const char* string = NULL;
if (lua_isstring(L,3)) {
/* This also catches numbers, which is converted to string */
@@ -115,9 +115,9 @@ static int PrivateTable__newindex(lua_State* L) {
}
if (string) {
- g_hash_table_replace (priv->table, (gpointer) g_strdup(name), (gpointer) g_strdup(string));
+ g_hash_table_replace (priv->table, (void *) g_strdup(name), (void *) g_strdup(string));
} else {
- g_hash_table_remove (priv->table, (gconstpointer) name);
+ g_hash_table_remove (priv->table, (const void *) name);
}
return 1;
@@ -130,7 +130,7 @@ static int PrivateTable__gc(lua_State* L) {
if (!priv) return 0;
if (!priv->expired) {
- priv->expired = TRUE;
+ priv->expired = true;
} else {
if (priv->is_allocated) {
g_hash_table_destroy (priv->table);
@@ -182,17 +182,17 @@ static int Pinfo__tostring(lua_State *L) { lua_pushstring(L,"a Pinfo"); return 1
#define PINFO_NAMED_BOOLEAN_SETTER(name,member) \
WSLUA_ATTRIBUTE_NAMED_BOOLEAN_SETTER(Pinfo,name,ws_pinfo->member)
-#define PINFO_NUMBER_GETTER(name) \
- WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(Pinfo,name,ws_pinfo->name)
+#define PINFO_INTEGER_GETTER(name) \
+ WSLUA_ATTRIBUTE_NAMED_INTEGER_GETTER(Pinfo,name,ws_pinfo->name)
-#define PINFO_NAMED_NUMBER_GETTER(name,member) \
- WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(Pinfo,name,ws_pinfo->member)
+#define PINFO_NAMED_INTEGER_GETTER(name,member) \
+ WSLUA_ATTRIBUTE_NAMED_INTEGER_GETTER(Pinfo,name,ws_pinfo->member)
#define PINFO_NUMBER_SETTER(name,cast) \
- WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(Pinfo,name,ws_pinfo->name,cast)
+ WSLUA_ATTRIBUTE_NAMED_INTEGER_SETTER(Pinfo,name,ws_pinfo->name,cast)
-#define PINFO_NAMED_NUMBER_SETTER(name,member,cast) \
- WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(Pinfo,name,ws_pinfo->member,cast)
+#define PINFO_NAMED_INTEGER_SETTER(name,member,cast) \
+ WSLUA_ATTRIBUTE_NAMED_INTEGER_SETTER(Pinfo,name,ws_pinfo->member,cast)
static double
lua_nstime_to_sec(const nstime_t *nstime)
@@ -201,7 +201,7 @@ lua_nstime_to_sec(const nstime_t *nstime)
}
static double
-lua_delta_nstime_to_sec(const Pinfo pinfo, const frame_data *fd, guint32 prev_num)
+lua_delta_nstime_to_sec(const Pinfo pinfo, const frame_data *fd, uint32_t prev_num)
{
nstime_t del;
@@ -214,13 +214,13 @@ lua_delta_nstime_to_sec(const Pinfo pinfo, const frame_data *fd, guint32 prev_nu
PINFO_NAMED_BOOLEAN_GETTER(visited,fd->visited);
/* WSLUA_ATTRIBUTE Pinfo_number RO The number of this packet in the current file. */
-PINFO_NAMED_NUMBER_GETTER(number,num);
+PINFO_NAMED_INTEGER_GETTER(number,num);
/* WSLUA_ATTRIBUTE Pinfo_len RO The length of the frame. */
-PINFO_NAMED_NUMBER_GETTER(len,fd->pkt_len);
+PINFO_NAMED_INTEGER_GETTER(len,fd->pkt_len);
/* WSLUA_ATTRIBUTE Pinfo_caplen RO The captured length of the frame. */
-PINFO_NAMED_NUMBER_GETTER(caplen,fd->cap_len);
+PINFO_NAMED_INTEGER_GETTER(caplen,fd->cap_len);
/* WSLUA_ATTRIBUTE Pinfo_abs_ts RO When the packet was captured. */
WSLUA_ATTRIBUTE_BLOCK_NUMBER_GETTER(Pinfo,abs_ts,lua_nstime_to_sec(&obj->ws_pinfo->abs_ts));
@@ -238,15 +238,21 @@ WSLUA_ATTRIBUTE_BLOCK_NUMBER_GETTER(Pinfo,delta_dis_ts,lua_delta_nstime_to_sec(o
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(Pinfo,curr_proto,ws_pinfo->current_proto);
/* WSLUA_ATTRIBUTE Pinfo_can_desegment RW Set if this segment could be desegmented. */
-PINFO_NUMBER_GETTER(can_desegment);
-PINFO_NUMBER_SETTER(can_desegment,guint16);
+PINFO_INTEGER_GETTER(can_desegment);
+PINFO_NUMBER_SETTER(can_desegment,uint16_t);
+
+/* WSLUA_ATTRIBUTE Pinfo_saved_can_desegment RO Value of can_desegment before the current dissector was called.
+ Supplied so that proxy protocols like SOCKS can restore it to whatever the previous dissector (e.g. TCP) set it,
+ so that the dissectors they call are desegmented via the previous dissector.
+ @since 4.3.1 */
+PINFO_INTEGER_GETTER(saved_can_desegment);
/* WSLUA_ATTRIBUTE Pinfo_desegment_len RW Estimated number of additional bytes required for completing the PDU. */
-PINFO_NUMBER_GETTER(desegment_len);
-PINFO_NUMBER_SETTER(desegment_len,guint32);
+PINFO_INTEGER_GETTER(desegment_len);
+PINFO_NUMBER_SETTER(desegment_len,uint32_t);
/* WSLUA_ATTRIBUTE Pinfo_desegment_offset RW Offset in the tvbuff at which the dissector will continue processing when next called. */
-PINFO_NUMBER_GETTER(desegment_offset);
+PINFO_INTEGER_GETTER(desegment_offset);
PINFO_NUMBER_SETTER(desegment_offset,int);
/* WSLUA_ATTRIBUTE Pinfo_fragmented RO If the protocol is only a fragment. */
@@ -257,21 +263,22 @@ PINFO_NAMED_BOOLEAN_GETTER(in_error_pkt,flags.in_error_pkt);
PINFO_NAMED_BOOLEAN_SETTER(in_error_pkt,flags.in_error_pkt);
/* WSLUA_ATTRIBUTE Pinfo_match_uint RO Matched uint for calling subdissector from table. */
-PINFO_NUMBER_GETTER(match_uint);
+PINFO_INTEGER_GETTER(match_uint);
/* WSLUA_ATTRIBUTE Pinfo_match_string RO Matched string for calling subdissector from table. */
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(Pinfo,match_string,ws_pinfo->match_string);
/* WSLUA_ATTRIBUTE Pinfo_port_type RW Type of Port of .src_port and .dst_port. */
-PINFO_NAMED_NUMBER_GETTER(port_type,ptype);
+PINFO_NAMED_INTEGER_GETTER(port_type,ptype);
+PINFO_NAMED_INTEGER_SETTER(port_type,ptype,uint8_t);
/* WSLUA_ATTRIBUTE Pinfo_src_port RW Source Port of this Packet. */
-PINFO_NAMED_NUMBER_GETTER(src_port,srcport);
-PINFO_NAMED_NUMBER_SETTER(src_port,srcport,guint32);
+PINFO_NAMED_INTEGER_GETTER(src_port,srcport);
+PINFO_NAMED_INTEGER_SETTER(src_port,srcport,uint32_t);
/* WSLUA_ATTRIBUTE Pinfo_dst_port RW Destination Port of this Packet. */
-PINFO_NAMED_NUMBER_GETTER(dst_port,destport);
-PINFO_NAMED_NUMBER_SETTER(dst_port,destport,guint32);
+PINFO_NAMED_INTEGER_GETTER(dst_port,destport);
+PINFO_NAMED_INTEGER_SETTER(dst_port,destport,uint32_t);
/* WSLUA_ATTRIBUTE Pinfo_dl_src RW Data Link Source Address of this Packet. */
PINFO_ADDRESS_GETTER(dl_src);
@@ -298,7 +305,7 @@ PINFO_ADDRESS_GETTER(dst);
PINFO_ADDRESS_SETTER(dst);
/* WSLUA_ATTRIBUTE Pinfo_p2p_dir RW Direction of this Packet. (incoming / outgoing) */
-PINFO_NUMBER_GETTER(p2p_dir);
+PINFO_INTEGER_GETTER(p2p_dir);
PINFO_NUMBER_SETTER(p2p_dir,int);
/* WSLUA_ATTRIBUTE Pinfo_match RO Port/Data we are matching. */
@@ -308,7 +315,7 @@ static int Pinfo_get_match(lua_State *L) {
if (pinfo->ws_pinfo->match_string) {
lua_pushstring(L,pinfo->ws_pinfo->match_string);
} else {
- lua_pushnumber(L,(lua_Number)(pinfo->ws_pinfo->match_uint));
+ lua_pushinteger(L,(lua_Integer)(pinfo->ws_pinfo->match_uint));
}
return 1;
@@ -319,11 +326,11 @@ static int Pinfo_get_match(lua_State *L) {
static int Pinfo_get_columns(lua_State *L) {
Columns cols = NULL;
Pinfo pinfo = checkPinfo(L,1);
- const gchar* colname = luaL_optstring(L,2,NULL);
+ const char* colname = luaL_optstring(L,2,NULL);
cols = (Columns)g_malloc(sizeof(struct _wslua_cols));
cols->cinfo = pinfo->ws_pinfo->cinfo;
- cols->expired = FALSE;
+ cols->expired = false;
if (!colname) {
Push_Columns(L,cols);
@@ -340,18 +347,18 @@ static int Pinfo_get_columns(lua_State *L) {
static int Pinfo_get_private(lua_State *L) {
PrivateTable priv = NULL;
Pinfo pinfo = checkPinfo(L,1);
- const gchar* privname = luaL_optstring(L,2,NULL);
- gboolean is_allocated = FALSE;
+ const char* privname = luaL_optstring(L,2,NULL);
+ bool is_allocated = false;
if (!pinfo->ws_pinfo->private_table) {
pinfo->ws_pinfo->private_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
- is_allocated = TRUE;
+ is_allocated = true;
}
priv = (PrivateTable)g_malloc(sizeof(struct _wslua_private_table));
priv->table = pinfo->ws_pinfo->private_table;
priv->is_allocated = is_allocated;
- priv->expired = FALSE;
+ priv->expired = false;
if (!privname) {
PUSH_PRIVATE_TABLE(L,priv);
@@ -420,7 +427,7 @@ static int Pinfo__gc(lua_State* L) {
if (!pinfo) return 0;
if (!pinfo->expired)
- pinfo->expired = TRUE;
+ pinfo->expired = true;
else
g_free(pinfo);
@@ -449,7 +456,7 @@ WSLUA_ATTRIBUTES Pinfo_attributes[] = {
WSLUA_ATTRIBUTE_RWREG(Pinfo,dl_dst),
WSLUA_ATTRIBUTE_RWREG(Pinfo,net_src),
WSLUA_ATTRIBUTE_RWREG(Pinfo,net_dst),
- WSLUA_ATTRIBUTE_ROREG(Pinfo,port_type),
+ WSLUA_ATTRIBUTE_RWREG(Pinfo,port_type),
WSLUA_ATTRIBUTE_RWREG(Pinfo,src_port),
WSLUA_ATTRIBUTE_RWREG(Pinfo,dst_port),
WSLUA_ATTRIBUTE_ROREG(Pinfo,match),
@@ -457,6 +464,7 @@ WSLUA_ATTRIBUTES Pinfo_attributes[] = {
WSLUA_ATTRIBUTE_ROREG(Pinfo,columns),
{ "cols", Pinfo_get_columns, NULL },
WSLUA_ATTRIBUTE_RWREG(Pinfo,can_desegment),
+ WSLUA_ATTRIBUTE_ROREG(Pinfo,saved_can_desegment),
WSLUA_ATTRIBUTE_RWREG(Pinfo,desegment_len),
WSLUA_ATTRIBUTE_RWREG(Pinfo,desegment_offset),
WSLUA_ATTRIBUTE_ROREG(Pinfo,private),
@@ -476,7 +484,13 @@ WSLUA_META Pinfo_meta[] = {
int Pinfo_register(lua_State* L) {
WSLUA_REGISTER_META_WITH_ATTRS(Pinfo);
+ if (outstanding_Pinfo != NULL) {
+ g_ptr_array_unref(outstanding_Pinfo);
+ }
outstanding_Pinfo = g_ptr_array_new();
+ if (outstanding_PrivateTable != NULL) {
+ g_ptr_array_unref(outstanding_PrivateTable);
+ }
outstanding_PrivateTable = g_ptr_array_new();
return 0;
}