From 4ea329548c09bf1a0cbdceda5bc0fb8d97c3e3fa Mon Sep 17 00:00:00 2001 From: Pascal Quantin Date: Wed, 20 Jan 2021 14:41:12 +0100 Subject: [PATCH] NAS 5GS: fix display of IPv6 interface identifier Do not use FT_IPV6 as an interface identifier could be wrongly identified as an IPv4-Compatible IPv6 Address format by inet_ntop() and displayed as such. (cherry picked from commit f64eddfd010248104716be3435b09c42082b5461) Conflicts: epan/dissectors/packet-nas_5gs.c --- epan/dissectors/packet-nas_5gs.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/epan/dissectors/packet-nas_5gs.c b/epan/dissectors/packet-nas_5gs.c index b2efc70b98..9bcf51fd90 100644 --- a/epan/dissectors/packet-nas_5gs.c +++ b/epan/dissectors/packet-nas_5gs.c @@ -21,6 +21,7 @@ #include #include +#include #include #include "packet-gsm_a_common.h" @@ -3095,9 +3096,7 @@ de_nas_5gs_sm_pdu_address(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, { proto_item *ti; guint32 value; - ws_in6_addr interface_id; - - memset(&interface_id, 0, sizeof(interface_id)); + guint8 interface_id[8]; /* 0 Spare 0 Spare 0 Spare 0 Spare 0 Spare PDU session type value */ ti = proto_tree_add_item_ret_uint(tree, hf_nas_5gs_sm_pdu_ses_type, tvb, offset, 1, ENC_BIG_ENDIAN, &value); @@ -3113,16 +3112,20 @@ de_nas_5gs_sm_pdu_address(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, /* If the PDU session type value indicates IPv6, the PDU address information in octet 4 to octet 11 * contains an interface identifier for the IPv6 link local address. */ - tvb_memcpy(tvb, (guint8*)&interface_id.bytes[8], offset, 8); - proto_tree_add_ipv6(tree, hf_nas_5gs_sm_pdu_addr_inf_ipv6, tvb, offset, 8, &interface_id); + tvb_memcpy(tvb, interface_id, offset, 8); + proto_tree_add_bytes_format_value(tree, hf_nas_5gs_sm_pdu_addr_inf_ipv6, tvb, offset, 8, NULL, + "::%x:%x:%x:%x", pntoh16(&interface_id[0]), pntoh16(&interface_id[2]), + pntoh16(&interface_id[4]), pntoh16(&interface_id[6])); break; case 3: /* If the PDU session type value indicates IPv4v6, the PDU address information in octet 4 to octet 11 * contains an interface identifier for the IPv6 link local address and in octet 12 to octet 15 * contains an IPv4 address. */ - tvb_memcpy(tvb, (guint8*)&interface_id.bytes[8], offset, 8); - proto_tree_add_ipv6(tree, hf_nas_5gs_sm_pdu_addr_inf_ipv6, tvb, offset, 8, &interface_id); + tvb_memcpy(tvb, interface_id, offset, 8); + proto_tree_add_bytes_format_value(tree, hf_nas_5gs_sm_pdu_addr_inf_ipv6, tvb, offset, 8, NULL, + "::%x:%x:%x:%x", pntoh16(&interface_id[0]), pntoh16(&interface_id[2]), + pntoh16(&interface_id[4]), pntoh16(&interface_id[6])); offset += 8; proto_tree_add_item(tree, hf_nas_5gs_sm_pdu_addr_inf_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN); break; @@ -7869,7 +7872,7 @@ proto_register_nas_5gs(void) }, { &hf_nas_5gs_sm_pdu_addr_inf_ipv6, { "PDU address information", "nas_5gs.sm.pdu_addr_inf_ipv6", - FT_IPv6, BASE_NONE, NULL, 0x0, + FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } }, { &hf_nas_5gs_sm_qos_rule_id,