Skip to content

Commit

Permalink
NAS 5GS: fix display of IPv6 interface identifier
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pquantin committed Jan 20, 2021
1 parent b794e47 commit f64eddf
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions epan/dissectors/packet-nas_5gs.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <epan/to_str.h>

#include <wsutil/pow2.h>
#include <wsutil/pint.h>
#include <wsutil/wsjson.h>

#include "packet-gsm_a_common.h"
Expand Down Expand Up @@ -4051,9 +4052,7 @@ de_nas_5gs_sm_pdu_address(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
proto_item *ti;
gboolean si6lla;
guint32 pdu_addr;
ws_in6_addr interface_id;

memset(&interface_id, 0, sizeof(interface_id));
guint8 interface_id[8];

/* 0 Spare 0 Spare 0 Spare 0 Spare SI6LLA PDU session type value */
proto_tree_add_item_ret_boolean(tree, hf_nas_5gs_sm_si6lla, tvb, offset, 1, ENC_BIG_ENDIAN, &si6lla);
Expand All @@ -4071,17 +4070,21 @@ 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]));
offset += 8;
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);
offset += 4;
Expand Down Expand Up @@ -10180,7 +10183,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_smf_ipv6_lla,
Expand Down

0 comments on commit f64eddf

Please sign in to comment.