mqtt: Add a preference to show message as text

Make a configurable preference to show the publish message as text
to bring back the old behavior.

Ping-Bug: 15738
Change-Id: I90ff4ab4c8fe857fa7ea585f67aef516d84c22c1
Reviewed-on: https://code.wireshark.org/review/33284
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
This commit is contained in:
Stig Bjørlykke 2019-05-20 20:44:52 +02:00
parent 2b916d6424
commit 707f46459f
1 changed files with 22 additions and 1 deletions

View File

@ -519,6 +519,7 @@ static int hf_mqtt_username = -1;
static int hf_mqtt_passwd_len = -1;
static int hf_mqtt_passwd = -1;
static int hf_mqtt_pubmsg = -1;
static int hf_mqtt_pubmsg_text = -1;
static int hf_mqtt_pubmsg_decoded = -1;
static int hf_mqtt_proto_len = -1;
static int hf_mqtt_proto_name = -1;
@ -581,6 +582,9 @@ static gint ett_mqtt_subscription_flags = -1;
/* Reassemble SMPP TCP segments */
static gboolean reassemble_mqtt_over_tcp = TRUE;
/* Show Publish Message as text */
static gboolean show_msg_as_text;
static guint get_mqtt_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb,
int offset, void *data _U_)
{
@ -1106,7 +1110,14 @@ static int dissect_mqtt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
}
mqtt_payload_len = tvb_reported_length(tvb) - offset;
proto_tree_add_item(mqtt_tree, hf_mqtt_pubmsg, tvb, offset, mqtt_payload_len, ENC_UTF_8|ENC_NA);
if (show_msg_as_text)
{
proto_tree_add_item(mqtt_tree, hf_mqtt_pubmsg_text, tvb, offset, mqtt_payload_len, ENC_UTF_8|ENC_NA);
}
else
{
proto_tree_add_item(mqtt_tree, hf_mqtt_pubmsg, tvb, offset, mqtt_payload_len, ENC_NA);
}
if (num_mqtt_message_decodes > 0)
{
@ -1429,6 +1440,10 @@ void proto_register_mqtt(void)
{ "Message", "mqtt.msg",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_mqtt_pubmsg_text,
{ "Message", "mqtt.msg",
FT_STRING, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_mqtt_pubmsg_decoded,
{ "Message decoded as", "mqtt.msg_decoded_as",
FT_STRING, BASE_NONE, NULL, 0,
@ -1660,6 +1675,12 @@ void proto_register_mqtt(void)
"Message Decoding",
"A table that enumerates custom message decodes to be used for a certain topic",
message_uat);
prefs_register_bool_preference(mqtt_module, "show_msg_as_text",
"Show Message as text",
"Show Publish Message as text",
&show_msg_as_text);
}
/*