summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-hpfeeds.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:33 +0000
commit9f153fbfec0fb9c9ce38e749a7c6f4a5e115d4e9 (patch)
tree2784370cda9bbf2da9114d70f05399c0b229d28c /epan/dissectors/packet-hpfeeds.c
parentAdding debian version 4.2.6-1. (diff)
downloadwireshark-9f153fbfec0fb9c9ce38e749a7c6f4a5e115d4e9.tar.xz
wireshark-9f153fbfec0fb9c9ce38e749a7c6f4a5e115d4e9.zip
Merging upstream version 4.4.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'epan/dissectors/packet-hpfeeds.c')
-rw-r--r--epan/dissectors/packet-hpfeeds.c132
1 files changed, 66 insertions, 66 deletions
diff --git a/epan/dissectors/packet-hpfeeds.c b/epan/dissectors/packet-hpfeeds.c
index 4148d1f4..ad28d324 100644
--- a/epan/dissectors/packet-hpfeeds.c
+++ b/epan/dissectors/packet-hpfeeds.c
@@ -27,15 +27,15 @@
#include "packet-tcp.h"
struct HpfeedsTap {
- guint payload_size;
- guint8* channel;
- guint8 opcode;
+ unsigned payload_size;
+ uint8_t* channel;
+ uint8_t opcode;
};
-static int hpfeeds_tap = -1;
+static int hpfeeds_tap;
-static const gchar* st_str_channels_payload = "Payload size per channel";
-static const gchar* st_str_opcodes = "Opcodes";
+static const char* st_str_channels_payload = "Payload size per channel";
+static const char* st_str_opcodes = "Opcodes";
static int st_node_channels_payload = -1;
static int st_node_opcodes = -1;
@@ -43,8 +43,8 @@ static int st_node_opcodes = -1;
static wmem_list_t* channels_list;
struct channel_node {
- guint8* channel;
- guint st_node_channel_payload;
+ uint8_t* channel;
+ unsigned st_node_channel_payload;
};
void proto_register_hpfeeds(void);
@@ -55,27 +55,27 @@ static dissector_handle_t hpfeeds_handle;
static heur_dissector_list_t heur_subdissector_list;
/* Preferences */
-static gboolean hpfeeds_desegment = TRUE;
-static gboolean try_heuristic = TRUE;
+static bool hpfeeds_desegment = true;
+static bool try_heuristic = true;
-static int proto_hpfeeds = -1;
+static int proto_hpfeeds;
-static int hf_hpfeeds_opcode = -1;
-static int hf_hpfeeds_msg_length = -1;
-static int hf_hpfeeds_nonce = -1;
-static int hf_hpfeeds_secret = -1;
-static int hf_hpfeeds_payload = -1;
-static int hf_hpfeeds_server_len = -1;
-static int hf_hpfeeds_server = -1;
-static int hf_hpfeeds_ident_len = -1;
-static int hf_hpfeeds_ident = -1;
-static int hf_hpfeeds_channel = -1;
-static int hf_hpfeeds_chan_len = -1;
-static int hf_hpfeeds_errmsg = -1;
+static int hf_hpfeeds_opcode;
+static int hf_hpfeeds_msg_length;
+static int hf_hpfeeds_nonce;
+static int hf_hpfeeds_secret;
+static int hf_hpfeeds_payload;
+static int hf_hpfeeds_server_len;
+static int hf_hpfeeds_server;
+static int hf_hpfeeds_ident_len;
+static int hf_hpfeeds_ident;
+static int hf_hpfeeds_channel;
+static int hf_hpfeeds_chan_len;
+static int hf_hpfeeds_errmsg;
-static gint ett_hpfeeds = -1;
+static int ett_hpfeeds;
-static expert_field ei_hpfeeds_opcode_unknown = EI_INIT;
+static expert_field ei_hpfeeds_opcode_unknown;
/* OPCODE */
#define OP_ERROR 0 /* error message*/
@@ -97,21 +97,21 @@ static const value_string opcode_vals[] = {
};
static void
-dissect_hpfeeds_error_pdu(tvbuff_t *tvb, proto_tree *tree, guint offset)
+dissect_hpfeeds_error_pdu(tvbuff_t *tvb, proto_tree *tree, unsigned offset)
{
proto_tree_add_item(tree, hf_hpfeeds_errmsg, tvb, offset, -1, ENC_ASCII);
}
static void
-dissect_hpfeeds_info_pdu(tvbuff_t *tvb, proto_tree *tree, guint offset)
+dissect_hpfeeds_info_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned offset)
{
- guint8 len = 0;
+ uint8_t len = 0;
proto_tree *data_subtree;
- guint8 *strptr = NULL;
+ uint8_t *strptr = NULL;
- len = tvb_get_guint8(tvb, offset);
+ len = tvb_get_uint8(tvb, offset);
/* don't move the offset yet as we need to get data after this operation */
- strptr = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, len, ENC_ASCII);
+ strptr = tvb_get_string_enc(pinfo->pool, tvb, offset + 1, len, ENC_ASCII);
data_subtree = proto_tree_add_subtree_format(tree, tvb, offset, -1, ett_hpfeeds, NULL, "Broker: %s", strptr);
proto_tree_add_item(data_subtree, hf_hpfeeds_server_len, tvb, offset, 1,
@@ -127,11 +127,11 @@ dissect_hpfeeds_info_pdu(tvbuff_t *tvb, proto_tree *tree, guint offset)
}
static void
-dissect_hpfeeds_auth_pdu(tvbuff_t *tvb, proto_tree *tree, guint offset)
+dissect_hpfeeds_auth_pdu(tvbuff_t *tvb, proto_tree *tree, unsigned offset)
{
- guint8 len = 0;
+ uint8_t len = 0;
- len = tvb_get_guint8(tvb, offset);
+ len = tvb_get_uint8(tvb, offset);
proto_tree_add_item(tree, hf_hpfeeds_ident_len, tvb,
offset, 1, ENC_BIG_ENDIAN);
offset += 1;
@@ -143,47 +143,47 @@ dissect_hpfeeds_auth_pdu(tvbuff_t *tvb, proto_tree *tree, guint offset)
offset, -1, ENC_NA);
}
-static guint8*
-hpfeeds_get_channel_name(tvbuff_t* tvb, guint offset)
+static uint8_t*
+hpfeeds_get_channel_name(tvbuff_t* tvb, unsigned offset)
{
- guint8 len = tvb_get_guint8(tvb, offset);
+ uint8_t len = tvb_get_uint8(tvb, offset);
offset += len + 1;
- len = tvb_get_guint8(tvb, offset);
+ len = tvb_get_uint8(tvb, offset);
offset += 1;
return tvb_get_string_enc(wmem_file_scope(), tvb, offset, len, ENC_ASCII);
}
-static guint
-hpfeeds_get_payload_size(tvbuff_t* tvb, guint offset)
+static unsigned
+hpfeeds_get_payload_size(tvbuff_t* tvb, unsigned offset)
{
- guint message_len = tvb_get_ntohl(tvb, offset);
- guint ident_len = tvb_get_guint8(tvb, offset + 5);
- guint channel_len = tvb_get_guint8(tvb, offset + 6 + ident_len);
+ unsigned message_len = tvb_get_ntohl(tvb, offset);
+ unsigned ident_len = tvb_get_uint8(tvb, offset + 5);
+ unsigned channel_len = tvb_get_uint8(tvb, offset + 6 + ident_len);
return (message_len - 2 - ident_len - 1 - channel_len);
}
static void
dissect_hpfeeds_publish_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
- guint offset)
+ unsigned offset)
{
- guint8 len = 0;
+ uint8_t len = 0;
heur_dtbl_entry_t *hdtbl_entry;
tvbuff_t *next_tvb;
- const guint8 *channelname = NULL;
+ const uint8_t *channelname = NULL;
const char* save_match_string = NULL;
- len = tvb_get_guint8(tvb, offset);
+ len = tvb_get_uint8(tvb, offset);
proto_tree_add_item(tree, hf_hpfeeds_ident_len, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(tree, hf_hpfeeds_ident, tvb, offset, len, ENC_ASCII);
offset += len;
- len = tvb_get_guint8(tvb, offset);
+ len = tvb_get_uint8(tvb, offset);
proto_tree_add_item(tree, hf_hpfeeds_chan_len, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
/* get the channel name as ephemeral string to pass it to the heuristic decoders */
proto_tree_add_item_ret_string(tree, hf_hpfeeds_channel, tvb, offset, len, ENC_ASCII|ENC_NA,
- wmem_packet_scope(), &channelname);
+ pinfo->pool, &channelname);
offset += len;
/* try the heuristic dissectors */
@@ -208,7 +208,7 @@ dissect_hpfeeds_publish_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
static void hpfeeds_stats_tree_init(stats_tree* st)
{
- st_node_channels_payload = stats_tree_create_node(st, st_str_channels_payload, 0, STAT_DT_INT, TRUE);
+ st_node_channels_payload = stats_tree_create_node(st, st_str_channels_payload, 0, STAT_DT_INT, true);
st_node_opcodes = stats_tree_create_pivot(st, st_str_opcodes, 0);
channels_list = wmem_list_new(wmem_epan_scope());
@@ -225,7 +225,7 @@ static tap_packet_status hpfeeds_stats_tree_packet(stats_tree* st _U_, packet_in
/* search an existing channel node and create it if it does not */
while(cur != NULL) {
ch_node = (struct channel_node*)wmem_list_frame_data(cur);
- if (strncmp((gchar*)ch_node->channel, (gchar*)pi->channel, strlen((gchar*)pi->channel)) == 0) {
+ if (strncmp((char*)ch_node->channel, (char*)pi->channel, strlen((char*)pi->channel)) == 0) {
break;
}
cur = wmem_list_frame_next(cur);
@@ -233,14 +233,14 @@ static tap_packet_status hpfeeds_stats_tree_packet(stats_tree* st _U_, packet_in
if (cur == NULL) {
ch_node = wmem_new0(wmem_file_scope(), struct channel_node);
- ch_node->channel = (guchar*)wmem_strdup(wmem_file_scope(), (gchar*)pi->channel);
- ch_node->st_node_channel_payload = stats_tree_create_node(st, (gchar*)ch_node->channel,
- st_node_channels_payload, STAT_DT_INT, FALSE);
+ ch_node->channel = (unsigned char*)wmem_strdup(wmem_file_scope(), (char*)pi->channel);
+ ch_node->st_node_channel_payload = stats_tree_create_node(st, (char*)ch_node->channel,
+ st_node_channels_payload, STAT_DT_INT, false);
wmem_list_append(channels_list, ch_node);
}
- avg_stat_node_add_value_int(st, st_str_channels_payload, 0, FALSE, pi->payload_size);
- avg_stat_node_add_value_int(st, (gchar*)ch_node->channel, 0, FALSE, pi->payload_size);
+ avg_stat_node_add_value_int(st, st_str_channels_payload, 0, false, pi->payload_size);
+ avg_stat_node_add_value_int(st, (char*)ch_node->channel, 0, false, pi->payload_size);
}
stats_tree_tick_pivot(st, st_node_opcodes,
@@ -249,11 +249,11 @@ static tap_packet_status hpfeeds_stats_tree_packet(stats_tree* st _U_, packet_in
}
static void
-dissect_hpfeeds_subscribe_pdu(tvbuff_t *tvb, proto_tree *tree, guint offset)
+dissect_hpfeeds_subscribe_pdu(tvbuff_t *tvb, proto_tree *tree, unsigned offset)
{
- guint8 len = 0;
+ uint8_t len = 0;
/* get length of ident field */
- len = tvb_get_guint8(tvb, offset);
+ len = tvb_get_uint8(tvb, offset);
proto_tree_add_item(tree, hf_hpfeeds_ident_len, tvb, offset, 1,
ENC_BIG_ENDIAN);
offset += 1;
@@ -271,7 +271,7 @@ dissect_hpfeeds_subscribe_pdu(tvbuff_t *tvb, proto_tree *tree, guint offset)
* This is a trivial function, but it's mandatory as it is used as a callback
* by the routine to re-assemble the protocol spread on multiple TCP packets
*/
-static guint
+static unsigned
get_hpfeeds_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
{
return tvb_get_ntohl(tvb, offset + 0);
@@ -283,9 +283,9 @@ dissect_hpfeeds_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
struct HpfeedsTap *hpfeeds_stats;
/* We have already parsed msg length we need to skip to opcode offset */
- guint offset = 0;
+ unsigned offset = 0;
- guint8 opcode;
+ uint8_t opcode;
proto_item *ti;
proto_tree *hpfeeds_tree, *data_subtree;
@@ -298,7 +298,7 @@ dissect_hpfeeds_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
offset += 4;
/* Get opcode and write it */
- opcode = tvb_get_guint8(tvb, offset);
+ opcode = tvb_get_uint8(tvb, offset);
/* Clear out stuff in the info column */
col_add_fstr(pinfo->cinfo, COL_INFO, "Type %s",
@@ -320,7 +320,7 @@ dissect_hpfeeds_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
dissect_hpfeeds_error_pdu(tvb, data_subtree, offset);
break;
case OP_INFO:
- dissect_hpfeeds_info_pdu(tvb, data_subtree, offset);
+ dissect_hpfeeds_info_pdu(tvb, pinfo, data_subtree, offset);
break;
case OP_AUTH:
dissect_hpfeeds_auth_pdu(tvb, data_subtree, offset);
@@ -437,7 +437,7 @@ proto_register_hpfeeds(void)
/* Setup protocol subtree array */
- static gint *ett[] = {
+ static int *ett[] = {
&ett_hpfeeds
};
@@ -454,7 +454,7 @@ proto_register_hpfeeds(void)
"hpfeeds" /* abbrev */
);
- heur_subdissector_list = register_heur_dissector_list("hpfeeds", proto_hpfeeds);
+ heur_subdissector_list = register_heur_dissector_list_with_description("hpfeeds", "HPFEEDS Publish payload", proto_hpfeeds);
proto_register_field_array(proto_hpfeeds, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));