NAS 5GS: add dissection og multiple payloads container

Change-Id: If2fb7916e757cdbba445a7cd3a41208cab208c9f
Reviewed-on: https://code.wireshark.org/review/36696
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
This commit is contained in:
Pascal Quantin 2020-04-04 17:42:56 +02:00
parent 6b87ea0562
commit 7fb4ae4c34
1 changed files with 137 additions and 3 deletions

View File

@ -35,6 +35,10 @@ static gboolean g_nas_5gs_null_decipher = FALSE;
static int dissect_nas_5gs_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, void* data);
static int dissect_nas_5gs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data);
static guint16 de_nas_5gs_cmn_dnn(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_);
static guint16 de_nas_5gs_mm_pdu_ses_id_2(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_);
static guint16 de_nas_5gs_cmn_add_inf(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_);
static void nas_5gs_mm_5gmm_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len);
static guint16 de_nas_5gs_mm_req_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_);
static dissector_handle_t nas_5gs_handle = NULL;
static dissector_handle_t eap_handle = NULL;
@ -79,6 +83,7 @@ static int hf_nas_5gs_spare_half_octet = -1;
static int hf_nas_5gs_pdu_session_id = -1;
static int hf_nas_5gs_msg_elems = -1;
static int hf_nas_5gs_mm_for = -1;
static int hf_nas_5gs_cmn_add_info = -1;
static int hf_nas_5gs_cmn_dnn = -1;
static int hf_nas_5gs_mm_sms_requested = -1;
static int hf_nas_5gs_mm_5gs_reg_type = -1;
@ -107,6 +112,13 @@ static int hf_nas_5gs_mm_type_id = -1;
static int hf_nas_5gs_mm_odd_even = -1;
static int hf_nas_5gs_mm_length = -1;
static int hf_nas_5gs_mm_pld_cont = -1;
static int hf_nas_5gs_mm_pld_cont_nb_entries = -1;
static int hf_nas_5gs_mm_pld_cont_pld_cont_len = -1;
static int hf_nas_5gs_mm_pld_cont_nb_opt_ies = -1;
static int hf_nas_5gs_mm_pld_cont_pld_cont_type = -1;
static int hf_nas_5gs_mm_pld_cont_opt_ie_type = -1;
static int hf_nas_5gs_mm_pld_cont_opt_ie_len = -1;
static int hf_nas_5gs_mm_pld_cont_opt_ie_val = -1;
static int hf_nas_5gs_mm_req_type = -1;
static int hf_nas_5gs_mm_serv_type = -1;
static int hf_nas_5gs_mm_5g_ea0 = -1;
@ -315,6 +327,8 @@ static int ett_nas_5gs_ursp_r_sel_desc_cont = -1;
static int ett_nas_5gs_updp_upsi_list = -1;
static int ett_nas_5gs_mm_rej_nssai = -1;
static int ett_nas_5gs_mm_scheme_output = -1;
static int ett_nas_5gs_mm_pld_cont_pld_entry = -1;
static int ett_nas_5gs_mm_pld_cont_opt_ie = -1;
static int hf_nas_5gs_mm_abba = -1;
static int hf_nas_5gs_mm_supi_fmt = -1;
@ -1704,6 +1718,18 @@ de_nas_5gs_mm_op_def_acc_cat_def(tvbuff_t *tvb, proto_tree *tree, packet_info *p
return len;
}
static const value_string nas_5gs_mm_pld_cont_opt_ie_type_vals[] = {
{ 0x12, "PDU session ID" },
{ 0x22, "S-NSSAI" },
{ 0x24, "Additional information" },
{ 0x25, "DNN" },
{ 0x37, "Back-off timer value" },
{ 0x58, "5GMM cause" },
{ 0x59, "Old PDU session ID" },
{ 0x80, "Request type" },
{ 0, NULL }
};
/*
* 9.11.3.39 Payload container
*/
@ -1735,6 +1761,72 @@ de_nas_5gs_mm_pld_cont(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
case 5: /* UE policy container */
dissect_nas_5gs_updp(tvb_new_subset_length(tvb, offset, len), pinfo, tree, 0);
break;
case 15: /* multiple payloads */
{
guint32 curr_offset, entry_offset, payloads_count, payload_len, opt_ies_count, payload_type;
guint32 opt_ie_type, opt_ie_len, type_backup;
guint i, j;
curr_offset = offset;
proto_tree_add_item_ret_uint(tree, hf_nas_5gs_mm_pld_cont_nb_entries, tvb, curr_offset, 1, ENC_NA, &payloads_count);
curr_offset++;
for (i = 0; i < payloads_count; i++) {
proto_item *item;
proto_tree *subtree, *subtree2;
entry_offset = curr_offset;
subtree = proto_tree_add_subtree_format(tree, tvb, curr_offset, -1, ett_nas_5gs_mm_pld_cont_pld_entry, &item, "Payload container entry %d", i + 1);
proto_tree_add_item_ret_uint(subtree, hf_nas_5gs_mm_pld_cont_pld_cont_len, tvb, curr_offset, 2, ENC_BIG_ENDIAN, &payload_len);
proto_item_set_len(item, payload_len + 2);
curr_offset += 2;
proto_tree_add_item_ret_uint(subtree, hf_nas_5gs_mm_pld_cont_nb_opt_ies, tvb, curr_offset, 1, ENC_NA, &opt_ies_count);
proto_tree_add_item_ret_uint(subtree, hf_nas_5gs_mm_pld_cont_pld_cont_type, tvb, curr_offset, 1, ENC_NA, &payload_type);
curr_offset++;
for (j = 0; j < opt_ies_count; j++) {
item = proto_tree_add_item_ret_uint(subtree, hf_nas_5gs_mm_pld_cont_opt_ie_type, tvb, curr_offset, 1, ENC_NA, &opt_ie_type);
curr_offset++;
subtree2 = proto_item_add_subtree(item, ett_nas_5gs_mm_pld_cont_opt_ie);
proto_tree_add_item_ret_uint(subtree2, hf_nas_5gs_mm_pld_cont_opt_ie_len, tvb, curr_offset, 1, ENC_NA, &opt_ie_len);
curr_offset++;
switch (opt_ie_type) {
case 0x12:
de_nas_5gs_mm_pdu_ses_id_2(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
break;
case 0x22:
de_nas_5gs_cmn_s_nssai(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
break;
case 0x24:
de_nas_5gs_cmn_add_inf(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
break;
case 0x25:
de_nas_5gs_cmn_dnn(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
break;
case 0x37:
de_gc_timer3(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
break;
case 0x58:
nas_5gs_mm_5gmm_status(tvb, subtree2, pinfo, curr_offset, opt_ie_len);
break;
case 0x59:
de_nas_5gs_mm_pdu_ses_id_2(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
break;
case 0x80:
de_nas_5gs_mm_req_type(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
break;
default:
proto_tree_add_item(subtree2, hf_nas_5gs_mm_pld_cont_opt_ie_val, tvb, curr_offset, opt_ie_len, ENC_NA);
break;
}
curr_offset += opt_ie_len;
}
type_backup = nas5gs_data->payload_container_type;
nas5gs_data->payload_container_type = payload_type;
de_nas_5gs_mm_pld_cont(tvb, subtree, pinfo, curr_offset, payload_len - (curr_offset - entry_offset), NULL, 0);
curr_offset = entry_offset + payload_len + 2;
nas5gs_data->payload_container_type = type_backup;
}
}
break;
default:
proto_tree_add_item(tree, hf_nas_5gs_mm_pld_cont, tvb, offset, len, ENC_NA);
break;
@ -3635,11 +3727,11 @@ de_nas_5gs_sm_ssc_mode(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
/* 9.10.2.1 Additional information*/
static guint16
de_nas_5gs_cmn_add_inf(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
de_nas_5gs_cmn_add_inf(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
guint32 offset, guint len,
gchar *add_string _U_, int string_len _U_)
{
proto_tree_add_expert(tree, pinfo, &ei_nas_5gs_ie_not_dis, tvb, offset, len);
proto_tree_add_item(tree, hf_nas_5gs_cmn_add_info, tvb, offset, len, ENC_NA);
return len;
}
@ -7051,6 +7143,11 @@ proto_register_nas_5gs(void)
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_nas_5gs_cmn_add_info,
{ "Additional information", "nas_5gs.cmn.add_info",
FT_BYTES, BASE_NONE, NULL,0x0,
NULL, HFILL }
},
{ &hf_nas_5gs_cmn_dnn,
{ "DNN", "nas_5gs.cmn.dnn",
FT_STRING, BASE_NONE, NULL,0x0,
@ -7201,6 +7298,41 @@ proto_register_nas_5gs(void)
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_nas_5gs_mm_pld_cont_nb_entries,
{ "Number of entries", "nas_5gs.mm.pld_cont.nb_entries",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_nas_5gs_mm_pld_cont_pld_cont_len,
{ "Length of Payload container entry", "nas_5gs.mm.pld_cont.pld_cont_len",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_nas_5gs_mm_pld_cont_nb_opt_ies,
{ "Number of optional IEs", "nas_5gs.mm.pld_cont.nb_opt_ies",
FT_UINT8, BASE_DEC, NULL, 0xf0,
NULL, HFILL }
},
{ &hf_nas_5gs_mm_pld_cont_pld_cont_type,
{ "Payload container type", "nas_5gs.mm.pld_cont.pld_cont_type",
FT_UINT8, BASE_DEC, VALS(nas_5gs_mm_pld_cont_type_vals), 0x0f,
NULL, HFILL }
},
{ &hf_nas_5gs_mm_pld_cont_opt_ie_type,
{ "Type of optional IE", "nas_5gs.mm.pld_cont.opt_ie_type",
FT_UINT8, BASE_HEX, VALS(nas_5gs_mm_pld_cont_opt_ie_type_vals), 0x0,
NULL, HFILL }
},
{ &hf_nas_5gs_mm_pld_cont_opt_ie_len,
{ "Length of optional IE", "nas_5gs.mm.pld_cont.opt_ie_len",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_nas_5gs_mm_pld_cont_opt_ie_val,
{ "Value of optional IE", "nas_5gs.mm.pld_cont.opt_ie_val",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_nas_5gs_mm_req_type,
{ "Request type", "nas_5gs.mm.req_typ",
FT_UINT8, BASE_DEC, VALS(nas_5gs_mm_req_type_vals), 0x0f,
@ -8561,7 +8693,7 @@ proto_register_nas_5gs(void)
guint last_offset;
/* Setup protocol subtree array */
#define NUM_INDIVIDUAL_ELEMS 23
#define NUM_INDIVIDUAL_ELEMS 25
gint *ett[NUM_INDIVIDUAL_ELEMS +
NUM_NAS_5GS_COMMON_ELEM +
NUM_NAS_5GS_MM_MSG + NUM_NAS_5GS_MM_ELEM +
@ -8592,6 +8724,8 @@ proto_register_nas_5gs(void)
ett[20] = &ett_nas_5gs_updp_upsi_list;
ett[21] = &ett_nas_5gs_mm_rej_nssai;
ett[22] = &ett_nas_5gs_mm_scheme_output;
ett[23] = &ett_nas_5gs_mm_pld_cont_pld_entry;
ett[24] = &ett_nas_5gs_mm_pld_cont_opt_ie;
last_offset = NUM_INDIVIDUAL_ELEMS;