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 f64eddfd01)

Conflicts:
	epan/dissectors/packet-nas_5gs.c
This commit is contained in:
Pascal Quantin 2021-01-20 14:41:12 +01:00 committed by Wireshark GitLab Utility
parent 632df36405
commit 4ea329548c
1 changed files with 11 additions and 8 deletions

View File

@ -21,6 +21,7 @@
#include <epan/etypes.h>
#include <wsutil/pow2.h>
#include <wsutil/pint.h>
#include <wsutil/wsjson.h>
#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,