diff options
Diffstat (limited to 'epan/dissectors/packet-btrfcomm.c')
-rw-r--r-- | epan/dissectors/packet-btrfcomm.c | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/epan/dissectors/packet-btrfcomm.c b/epan/dissectors/packet-btrfcomm.c index 60b1ddb689..a97d2f1809 100644 --- a/epan/dissectors/packet-btrfcomm.c +++ b/epan/dissectors/packet-btrfcomm.c @@ -271,24 +271,48 @@ void proto_reg_handoff_btgnss(void); static void btrfcomm_serv_prompt(packet_info *pinfo, gchar* result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "RFCOMM SERVICE %d as", - GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_SERVICE_CONV ))); + gulong *value_data; + + value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_SERVICE_CONV); + if (value_data) + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "RFCOMM SERVICE %d as", (guint) *value_data); + else + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Unknown RFCOMM SERVICE"); } static gpointer btrfcomm_serv_value(packet_info *pinfo) { - return p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_SERVICE_CONV ); + gulong *value_data; + + value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_SERVICE_CONV); + + if (value_data) + return (gpointer) *value_data; + + return NULL; } static void btrfcomm_chan_prompt(packet_info *pinfo, gchar* result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "RFCOMM Channel %d as", - GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_CHANNEL_CONV ))); + gulong *value_data; + + value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_CHANNEL_CONV); + if (value_data) + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "RFCOMM Channel %d as", (guint) *value_data); + else + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Unknown RFCOMM Channel"); } static gpointer btrfcomm_chan_value(packet_info *pinfo) { - return p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_CHANNEL_CONV ); + gulong *value_data; + + value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_CHANNEL_CONV); + + if (value_data) + return (gpointer) *value_data; + + return NULL; } static dissector_handle_t @@ -469,8 +493,13 @@ dissect_btrfcomm_address(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tr channel = dlci >> 1; proto_item_append_text(dlci_item, " (Direction: %d, Channel: %u)", dlci & 0x01, channel); - if (p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_CHANNEL_CONV ) == NULL) { - p_add_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_CHANNEL_CONV, GUINT_TO_POINTER((guint)channel)); + if (p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_CHANNEL_CONV) == NULL) { + gulong *value_data; + + value_data = wmem_new(wmem_file_scope(), gulong); + *value_data = channel; + + p_add_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_CHANNEL_CONV, value_data); } dlci_tree = proto_item_add_subtree(dlci_item, ett_dlci); @@ -843,7 +872,12 @@ dissect_btrfcomm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data rfcomm_data->remote_bd_addr_id = l2cap_data->remote_bd_addr_id; if (p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_SERVICE_CONV ) == NULL) { - p_add_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_SERVICE_CONV, GUINT_TO_POINTER((guint)service_info->uuid.bt_uuid)); + gulong *value_data; + + value_data = wmem_new(wmem_file_scope(), gulong); + *value_data = service_info->uuid.bt_uuid; + + p_add_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_SERVICE_CONV, value_data); } if (!dissector_try_uint_new(rfcomm_channel_dissector_table, (guint32) dlci >> 1, |