NAS EPS: 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 b794e4798a)
This commit is contained in:
Pascal Quantin 2021-01-20 13:39:09 +00:00
parent 79b075365f
commit 632df36405
1 changed files with 11 additions and 7 deletions

View File

@ -23,6 +23,7 @@
#include <epan/to_str.h>
#include <epan/proto_data.h>
#include <wsutil/pow2.h>
#include <wsutil/pint.h>
#include "packet-gsm_map.h"
#include "packet-gsm_a_common.h"
#include "packet-e212.h"
@ -3347,9 +3348,8 @@ de_esm_pdn_addr(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
{
guint32 curr_offset;
guint8 pdn_type;
ws_in6_addr interface_id;
guint8 interface_id[8];
memset(&interface_id, 0, sizeof(interface_id));
curr_offset = offset;
pdn_type = tvb_get_guint8(tvb, offset) & 0x7;
@ -3369,8 +3369,10 @@ de_esm_pdn_addr(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
* contains an IPv6 interface identifier. Bit 8 of octet 4 represents the most significant bit
* of the IPv6 interface identifier and bit 1 of octet 11 the least significant bit.
*/
tvb_memcpy(tvb, (guint8*)&interface_id.bytes[8], curr_offset, 8);
proto_tree_add_ipv6(tree, hf_nas_eps_esm_pdn_ipv6_if_id, tvb, curr_offset, 8, &interface_id);
tvb_memcpy(tvb, interface_id, curr_offset, 8);
proto_tree_add_bytes_format_value(tree, hf_nas_eps_esm_pdn_ipv6_if_id, tvb, curr_offset, 8, NULL,
"::%x:%x:%x:%x", pntoh16(&interface_id[0]), pntoh16(&interface_id[2]),
pntoh16(&interface_id[4]), pntoh16(&interface_id[6]));
curr_offset+=8;
break;
case 3:
@ -3381,8 +3383,10 @@ de_esm_pdn_addr(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
* significant bit. Bit 8 of octet 12 represents the most significant bit of the IPv4 address
* and bit 1 of octet 15 the least significant bit.
*/
tvb_memcpy(tvb, (guint8*)&interface_id.bytes[8], curr_offset, 8);
proto_tree_add_ipv6(tree, hf_nas_eps_esm_pdn_ipv6_if_id, tvb, curr_offset, 8, &interface_id);
tvb_memcpy(tvb, interface_id, curr_offset, 8);
proto_tree_add_bytes_format_value(tree, hf_nas_eps_esm_pdn_ipv6_if_id, tvb, curr_offset, 8, NULL,
"::%x:%x:%x:%x", pntoh16(&interface_id[0]), pntoh16(&interface_id[2]),
pntoh16(&interface_id[4]), pntoh16(&interface_id[6]));
curr_offset+=8;
proto_tree_add_item(tree, hf_nas_eps_esm_pdn_ipv4, tvb, curr_offset, 4, ENC_BIG_ENDIAN);
curr_offset+=4;
@ -7895,7 +7899,7 @@ proto_register_nas_eps(void)
},
{ &hf_nas_eps_esm_pdn_ipv6_if_id,
{"PDN IPv6 if id", "nas_eps.esm.pdn_ipv6_if_id",
FT_IPv6, BASE_NONE, NULL, 0x0,
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_nas_eps_esm_eplmnc,