diff --git a/epan/crypt/dot11decrypt.c b/epan/crypt/dot11decrypt.c index 02c21fa7ff..dc4cea4a29 100644 --- a/epan/crypt/dot11decrypt.c +++ b/epan/crypt/dot11decrypt.c @@ -1106,13 +1106,14 @@ Dot11DecryptCleanKeys( } static void -Dot11DecryptRecurseCleanSA( +Dot11DecryptCleanSA( void * first_sa) { - DOT11DECRYPT_SEC_ASSOCIATION *sa = (DOT11DECRYPT_SEC_ASSOCIATION *)first_sa; - if (sa != NULL) { - Dot11DecryptRecurseCleanSA((void *)sa->next); - g_free(sa); + DOT11DECRYPT_SEC_ASSOCIATION *cur_sa = (DOT11DECRYPT_SEC_ASSOCIATION *)first_sa; + while (cur_sa) { + DOT11DECRYPT_SEC_ASSOCIATION *next_sa = cur_sa->next; + g_free(cur_sa); + cur_sa = next_sa; } } @@ -1174,7 +1175,7 @@ int Dot11DecryptInitContext( ctx->pkt_ssid_len = 0; ctx->sa_hash = g_hash_table_new_full(Dot11DecryptSaHash, Dot11DecryptIsSaIdEqual, - g_free, Dot11DecryptRecurseCleanSA); + g_free, Dot11DecryptCleanSA); if (ctx->sa_hash == NULL) { return DOT11DECRYPT_RET_UNSUCCESS; } diff --git a/epan/dissectors/packet-cmip.c b/epan/dissectors/packet-cmip.c index 8bee65f341..ad5d8c6399 100644 --- a/epan/dissectors/packet-cmip.c +++ b/epan/dissectors/packet-cmip.c @@ -1015,13 +1015,15 @@ dissect_cmip_CMISFilter(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 3; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_choice(actx, tree, tvb, offset, CMISFilter_choice, hf_index, ett_cmip_CMISFilter, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-cmp.c b/epan/dissectors/packet-cmp.c index 9df3193b43..323e2a1abf 100644 --- a/epan/dissectors/packet-cmp.c +++ b/epan/dissectors/packet-cmp.c @@ -1091,12 +1091,14 @@ dissect_cmp_PKIMessage(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 5; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset, PKIMessage_sequence, hf_index, ett_cmp_PKIMessage); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-dap.c b/epan/dissectors/packet-dap.c index 3da59b53fa..fcbabfe438 100644 --- a/epan/dissectors/packet-dap.c +++ b/epan/dissectors/packet-dap.c @@ -1269,12 +1269,14 @@ dissect_dap_FamilyEntries(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 5; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset, FamilyEntries_sequence, hf_index, ett_dap_FamilyEntries); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -1473,13 +1475,15 @@ dissect_dap_Filter(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 3; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_choice(actx, tree, tvb, offset, Filter_choice, hf_index, ett_dap_Filter, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -2935,13 +2939,15 @@ dissect_dap_ListResultData(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 4; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_choice(actx, tree, tvb, offset, ListResultData_choice, hf_index, ett_dap_ListResultData, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -3326,13 +3332,15 @@ dissect_dap_SearchResultData(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offse const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 4; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_choice(actx, tree, tvb, offset, SearchResultData_choice, hf_index, ett_dap_SearchResultData, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-disp.c b/epan/dissectors/packet-disp.c index e5326a9df9..833758d060 100644 --- a/epan/dissectors/packet-disp.c +++ b/epan/dissectors/packet-disp.c @@ -1045,12 +1045,14 @@ dissect_disp_Subtree(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, a const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 3; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset, Subtree_sequence, hf_index, ett_disp_Subtree); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -1209,12 +1211,14 @@ dissect_disp_IncrementalStepRefresh(bool implicit_tag _U_, tvbuff_t *tvb _U_, in const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 4; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset, IncrementalStepRefresh_sequence, hf_index, ett_disp_IncrementalStepRefresh); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-e2ap.c b/epan/dissectors/packet-e2ap.c index dbd497d428..f560a94da7 100644 --- a/epan/dissectors/packet-e2ap.c +++ b/epan/dissectors/packet-e2ap.c @@ -7428,12 +7428,14 @@ dissect_e2ap_RANParameter_Testing_Item(tvbuff_t *tvb _U_, int offset _U_, asn1_c const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 5; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_e2ap_RANParameter_Testing_Item, RANParameter_Testing_Item_sequence); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -7821,12 +7823,14 @@ dissect_e2ap_RANParameter_Definition(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 6; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_e2ap_RANParameter_Definition, RANParameter_Definition_sequence); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -7979,13 +7983,15 @@ dissect_e2ap_RANParameter_ValueType(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 6; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_per_choice(tvb, offset, actx, tree, hf_index, ett_e2ap_RANParameter_ValueType, RANParameter_ValueType_choice, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-glow.c b/epan/dissectors/packet-glow.c index a924eab7cd..7ef6910cdd 100644 --- a/epan/dissectors/packet-glow.c +++ b/epan/dissectors/packet-glow.c @@ -1089,12 +1089,14 @@ dissect_glow_ElementCollection(bool implicit_tag _U_, tvbuff_t *tvb _U_, int off const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 6; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset, hf_index, BER_CLASS_APP, 4, TRUE, dissect_glow_SEQUENCE_OF_Element); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -1121,12 +1123,14 @@ dissect_glow_Parameter(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 6; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset, hf_index, BER_CLASS_APP, 1, TRUE, dissect_glow_Parameter_U); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -1179,12 +1183,14 @@ dissect_glow_Template(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 9; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset, hf_index, BER_CLASS_APP, 24, TRUE, dissect_glow_Template_U); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-goose.c b/epan/dissectors/packet-goose.c index 1a8d5ac9b3..5eb23541ff 100644 --- a/epan/dissectors/packet-goose.c +++ b/epan/dissectors/packet-goose.c @@ -714,13 +714,15 @@ dissect_goose_Data(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 3; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_choice(actx, tree, tvb, offset, Data_choice, hf_index, ett_goose_Data, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-h225.c b/epan/dissectors/packet-h225.c index 3d77297d73..aa71c04287 100644 --- a/epan/dissectors/packet-h225.c +++ b/epan/dissectors/packet-h225.c @@ -3971,8 +3971,10 @@ dissect_h225_EnumeratedParameter(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t * const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 4; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + gef_ctx_t *parent_gefx; parent_gefx = gef_ctx_get(actx->private_data); @@ -3980,7 +3982,7 @@ dissect_h225_EnumeratedParameter(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t * offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_h225_EnumeratedParameter, EnumeratedParameter_sequence); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); actx->private_data = parent_gefx; return offset; } @@ -3997,8 +3999,10 @@ dissect_h225_GenericData(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 6; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + void *priv_data = actx->private_data; gef_ctx_t *gefx; @@ -4011,7 +4015,7 @@ dissect_h225_GenericData(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_ offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_h225_GenericData, GenericData_sequence); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); actx->private_data = priv_data; return offset; } diff --git a/epan/dissectors/packet-h245.c b/epan/dissectors/packet-h245.c index 2334ab99d1..d8154276d5 100644 --- a/epan/dissectors/packet-h245.c +++ b/epan/dissectors/packet-h245.c @@ -3868,12 +3868,14 @@ dissect_h245_GenericParameter(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *act const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 4; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_h245_GenericParameter, GenericParameter_sequence); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -5669,8 +5671,10 @@ dissect_h245_VideoCapability(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 4; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + gint32 value; offset = dissect_per_choice(tvb, offset, actx, tree, hf_index, @@ -5680,7 +5684,7 @@ dissect_h245_VideoCapability(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx codec_type = val_to_str(value, h245_VideoCapability_vals, ""); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -5991,8 +5995,10 @@ dissect_h245_AudioCapability(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 3; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + gint32 value; offset = dissect_per_choice(tvb, offset, actx, tree, hf_index, @@ -6001,7 +6007,7 @@ dissect_h245_AudioCapability(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx codec_type = val_to_str(value, h245_AudioCapability_short_vals, ""); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -7155,8 +7161,10 @@ dissect_h245_DataType(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, p const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 5; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + gint choice_index; offset = dissect_per_choice(tvb, offset, actx, tree, hf_index, @@ -7173,7 +7181,7 @@ if (upcoming_channel){ } - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -8877,8 +8885,10 @@ dissect_h245_MultiplexElement(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *act const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 4; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + /*MultiplexElement*/ h223_mux_element* me = wmem_new(wmem_file_scope(), h223_mux_element); h223_me->next = me; @@ -8887,7 +8897,7 @@ dissect_h245_MultiplexElement(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *act offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_h245_MultiplexElement, MultiplexElement_sequence); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -9512,8 +9522,10 @@ dissect_h245_AudioMode(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 3; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + gint32 value; offset = dissect_per_choice(tvb, offset, actx, tree, hf_index, @@ -9522,7 +9534,7 @@ dissect_h245_AudioMode(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, codec_type = val_to_str(value, h245_AudioMode_vals, ""); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -9871,13 +9883,15 @@ dissect_h245_ModeElementType(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 6; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_per_choice(tvb, offset, actx, tree, hf_index, ett_h245_ModeElementType, ModeElementType_choice, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-h248.c b/epan/dissectors/packet-h248.c index 3f1e6f3a8c..3d7b3d6296 100644 --- a/epan/dissectors/packet-h248.c +++ b/epan/dissectors/packet-h248.c @@ -4251,12 +4251,14 @@ dissect_h248_SecondEventsDescriptor(bool implicit_tag _U_, tvbuff_t *tvb _U_, in const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 7; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset, SecondEventsDescriptor_sequence, hf_index, ett_h248_SecondEventsDescriptor); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-ieee1609dot2.c b/epan/dissectors/packet-ieee1609dot2.c index 3de7da808c..59aa447d45 100644 --- a/epan/dissectors/packet-ieee1609dot2.c +++ b/epan/dissectors/packet-ieee1609dot2.c @@ -3027,13 +3027,15 @@ dissect_ieee1609dot2_Ieee1609Dot2Data(tvbuff_t *tvb _U_, int offset _U_, asn1_ct const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 6; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + actx->private_data = (void*)wmem_new0(actx->pinfo->pool, ieee1609_private_data_t); offset = dissect_oer_sequence(tvb, offset, actx, tree, hf_index, ett_ieee1609dot2_Ieee1609Dot2Data, Ieee1609Dot2Data_sequence); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-infiniband.c b/epan/dissectors/packet-infiniband.c index e60a726ce3..312c6170f2 100644 --- a/epan/dissectors/packet-infiniband.c +++ b/epan/dissectors/packet-infiniband.c @@ -3584,9 +3584,11 @@ static void parse_CM_Req(proto_tree *top_tree, packet_info *pinfo, tvbuff_t *tvb local_offset += 16; proto_tree_add_item(CM_header_tree, hf_cm_req_primary_flow_label, tvb, local_offset, 3, ENC_BIG_ENDIAN); + local_offset += 2; proto_tree_add_item(CM_header_tree, hf_cm_req_primary_reserved0, tvb, local_offset, 1, ENC_BIG_ENDIAN); + local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_primary_packet_rate, tvb, local_offset, 1, ENC_BIG_ENDIAN); - local_offset += 4; + local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_primary_traffic_class, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_primary_hop_limit, tvb, local_offset, 1, ENC_BIG_ENDIAN); @@ -3607,9 +3609,11 @@ static void parse_CM_Req(proto_tree *top_tree, packet_info *pinfo, tvbuff_t *tvb proto_tree_add_item(CM_header_tree, hf_cm_req_alt_remote_gid, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_tree_add_item(CM_header_tree, hf_cm_req_flow_label, tvb, local_offset, 3, ENC_BIG_ENDIAN); + local_offset += 2; proto_tree_add_item(CM_header_tree, hf_cm_req_alt_reserved0, tvb, local_offset, 1, ENC_BIG_ENDIAN); + local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_packet_rate, tvb, local_offset, 1, ENC_BIG_ENDIAN); - local_offset += 4; + local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_alt_traffic_class, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_alt_hop_limit, tvb, local_offset, 1, ENC_BIG_ENDIAN); diff --git a/epan/dissectors/packet-iso15765.c b/epan/dissectors/packet-iso15765.c index 496b08d0a8..d5ca0fab86 100644 --- a/epan/dissectors/packet-iso15765.c +++ b/epan/dissectors/packet-iso15765.c @@ -49,6 +49,7 @@ #include #include #include +#include #include "packet-socketcan.h" #include "packet-lin.h" @@ -340,11 +341,10 @@ masked_guint32_value(const guint32 value, const guint32 mask) { } /* - * setting addresses to 0xffffffff, if not found or configured - * returning number of addresses (0: none, 1:ecu (both addr same), 2:source+target) + * returning number of addresses (0:none, 1:ecu (both addr same), 2:source+target) */ static guint8 -find_config_can_addr_mapping(gboolean ext_id, guint32 can_id, guint32 *source_addr, guint32 *target_addr) { +find_config_can_addr_mapping(gboolean ext_id, guint32 can_id, guint16 *source_addr, guint16 *target_addr, guint8 *addr_len) { config_can_addr_mapping_t *tmp = NULL; guint32 i; @@ -361,15 +361,23 @@ find_config_can_addr_mapping(gboolean ext_id, guint32 can_id, guint32 *source_ad } } + *addr_len = 0; + if (tmp != NULL) { if (tmp->ecu_addr_mask != 0) { *source_addr = masked_guint32_value(can_id, tmp->ecu_addr_mask); *target_addr = *source_addr; + *addr_len = (7 + ws_count_ones(tmp->ecu_addr_mask)) / 8; return 1; } if (tmp->source_addr_mask != 0 && tmp->target_addr_mask != 0) { *source_addr = masked_guint32_value(can_id, tmp->source_addr_mask); *target_addr = masked_guint32_value(can_id, tmp->target_addr_mask); + guint8 tmp_len = ws_count_ones(tmp->source_addr_mask); + if (ws_count_ones(tmp->target_addr_mask) > tmp_len) { + tmp_len = ws_count_ones(tmp->target_addr_mask); + } + *addr_len = (7 + tmp_len) / 8; return 2; } } @@ -494,36 +502,46 @@ handle_pdu_transport_addresses(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree config_pdu_transport_config_t *config = find_pdu_transport_config(pdu_id); iso15765data->number_of_addresses_valid = 0; - iso15765data->source_address = 0xffffffff; - iso15765data->target_address = 0xffffffff; + iso15765data->source_address = 0xffff; + iso15765data->target_address = 0xffff; if (config == NULL) { return offset - offset_orig; } guint32 tmp; + /* single address, in payload */ if (config->ecu_address_size != 0) { proto_tree_add_item_ret_uint(tree, hf_iso15765_address, tvb, offset, config->ecu_address_size, ENC_BIG_ENDIAN, &tmp); offset += config->ecu_address_size; iso15765data->number_of_addresses_valid = 1; - iso15765data->source_address = tmp; - iso15765data->target_address = tmp; + iso15765data->source_address = (guint16)tmp; + iso15765data->target_address = (guint16)tmp; + iso15765data->address_length = config->ecu_address_size; return offset - offset_orig; } + /* single address, fixed */ if (config->ecu_address_fixed != ISO15765_ADDR_INVALID) { iso15765data->number_of_addresses_valid = 1; iso15765data->source_address = config->ecu_address_fixed; iso15765data->target_address = config->ecu_address_fixed; + iso15765data->address_length = 2; /* could be also 1 Byte but we cannot know for sure */ return offset - offset_orig; } + /* no address possible */ if (config->source_address_size == 0 && config->source_address_fixed == ISO15765_ADDR_INVALID && config->target_address_size == 0 && config->target_address_fixed == ISO15765_ADDR_INVALID) { + iso15765data->address_length = 0; return offset - offset_orig; } /* now we can only have two addresses! */ iso15765data->number_of_addresses_valid = 2; + iso15765data->address_length = config->source_address_size; + if (config->target_address_size > iso15765data->address_length) { + iso15765data->address_length = config->target_address_size; + } if (config->source_address_size != 0) { proto_tree_add_item_ret_uint(tree, hf_iso15765_source_address, tvb, offset, config->source_address_size, ENC_BIG_ENDIAN, &tmp); @@ -531,6 +549,7 @@ handle_pdu_transport_addresses(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree iso15765data->source_address = tmp; } else if (config->source_address_fixed != ISO15765_ADDR_INVALID) { iso15765data->source_address = config->source_address_fixed; + iso15765data->address_length = 2; /* could be also 1 Byte but we cannot know for sure */ } if (config->target_address_size != 0) { @@ -539,6 +558,7 @@ handle_pdu_transport_addresses(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree iso15765data->target_address = tmp; } else if (config->target_address_fixed != ISO15765_ADDR_INVALID) { iso15765data->target_address = config->target_address_fixed; + iso15765data->address_length = 2; /* could be also 1 Byte but we cannot know for sure */ } return offset - offset_orig; @@ -583,6 +603,7 @@ dissect_iso15765(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 bu iso15765data.bus_type = bus_type; iso15765data.id = frame_id; iso15765data.number_of_addresses_valid = 0; + iso15765data.address_length = 0; if (bus_type == ISO15765_TYPE_FLEXRAY) { guint32 tmp; @@ -591,6 +612,7 @@ dissect_iso15765(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 bu proto_tree_add_item_ret_uint(iso15765_tree, hf_iso15765_target_address, tvb, flexray_addressing, flexray_addressing, ENC_BIG_ENDIAN, &tmp); iso15765data.target_address = (guint16)tmp; iso15765data.number_of_addresses_valid = 2; + iso15765data.address_length = flexray_addressing; ae = 2 * flexray_addressing; } else if (bus_type == ISO15765_TYPE_IPDUM && ipdum_addressing > 0) { guint32 tmp; @@ -599,6 +621,7 @@ dissect_iso15765(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 bu proto_tree_add_item_ret_uint(iso15765_tree, hf_iso15765_target_address, tvb, ipdum_addressing, ipdum_addressing, ENC_BIG_ENDIAN, &tmp); iso15765data.target_address = (guint16)tmp; iso15765data.number_of_addresses_valid = 2; + iso15765data.address_length = ipdum_addressing; ae = 2 * ipdum_addressing; } else if (bus_type == ISO15765_TYPE_PDU_TRANSPORT) { ae = handle_pdu_transport_addresses(tvb, pinfo, iso15765_tree, 0, frame_id, &iso15765data); @@ -606,6 +629,7 @@ dissect_iso15765(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 bu if (ae != 0) { guint32 tmp; iso15765data.number_of_addresses_valid = 1; + iso15765data.address_length = ae; proto_tree_add_item_ret_uint(iso15765_tree, hf_iso15765_address, tvb, 0, ae, ENC_NA, &tmp); iso15765data.source_address = (guint16)tmp; iso15765data.target_address = (guint16)tmp; @@ -614,13 +638,12 @@ dissect_iso15765(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 bu if (bus_type == ISO15765_TYPE_CAN || bus_type == ISO15765_TYPE_CAN_FD) { gboolean ext_id = (CAN_EFF_FLAG & frame_id) == CAN_EFF_FLAG; guint32 can_id = ext_id ? frame_id & CAN_EFF_MASK : frame_id & CAN_SFF_MASK; - iso15765data.number_of_addresses_valid = find_config_can_addr_mapping(ext_id, can_id, &(iso15765data.source_address), &(iso15765data.target_address)); + iso15765data.number_of_addresses_valid = find_config_can_addr_mapping(ext_id, can_id, &(iso15765data.source_address), &(iso15765data.target_address), &(iso15765data.address_length)); } } } - message_type_item = proto_tree_add_item(iso15765_tree, hf_iso15765_message_type, tvb, - ae, ISO15765_PCI_LEN, ENC_BIG_ENDIAN); + message_type_item = proto_tree_add_item(iso15765_tree, hf_iso15765_message_type, tvb, ae, ISO15765_PCI_LEN, ENC_BIG_ENDIAN); pci = tvb_get_guint8(tvb, ae); message_type = masked_guint16_value(pci, ISO15765_MESSAGE_TYPE_MASK); diff --git a/epan/dissectors/packet-iso15765.h b/epan/dissectors/packet-iso15765.h index f977ab0371..2ada7e5eab 100644 --- a/epan/dissectors/packet-iso15765.h +++ b/epan/dissectors/packet-iso15765.h @@ -19,16 +19,15 @@ #define ISO15765_TYPE_PDU_TRANSPORT 6 -struct iso15765_info { +typedef struct _iso15765_info { guint32 bus_type; guint32 id; guint32 len; - guint32 target_address; - guint32 source_address; + guint16 target_address; + guint16 source_address; guint8 number_of_addresses_valid; -}; - -typedef struct iso15765_info iso15765_info_t; + guint8 address_length; +} iso15765_info_t; #endif /* __PACKET_ISO15765_H__ */ diff --git a/epan/dissectors/packet-its.c b/epan/dissectors/packet-its.c index 9efb8055ca..cc26b3246e 100644 --- a/epan/dissectors/packet-its.c +++ b/epan/dissectors/packet-its.c @@ -15002,12 +15002,14 @@ dissect_gdd_GddStructure(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 9; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_gdd_GddStructure, gdd_GddStructure_sequence); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c index 9215d9b61f..e5323d9c5f 100644 --- a/epan/dissectors/packet-ldap.c +++ b/epan/dissectors/packet-ldap.c @@ -2177,8 +2177,10 @@ dissect_ldap_Filter(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, as const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 4; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + proto_tree *tr; proto_item *it; attributedesc_string=NULL; @@ -2204,7 +2206,7 @@ dissect_ldap_Filter(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, as proto_item_append_text(it, "%s", string_or_null(Filter_string)); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-mms.c b/epan/dissectors/packet-mms.c index 9464d1cd58..3df293be3a 100644 --- a/epan/dissectors/packet-mms.c +++ b/epan/dissectors/packet-mms.c @@ -1561,13 +1561,15 @@ dissect_mms_TypeSpecification(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offs const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 3; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_choice(actx, tree, tvb, offset, TypeSpecification_choice, hf_index, ett_mms_TypeSpecification, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -1752,12 +1754,14 @@ dissect_mms_AlternateAccess(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 5; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset, AlternateAccess_sequence_of, hf_index, ett_mms_AlternateAccess); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -1814,13 +1818,15 @@ dissect_mms_VariableSpecification(bool implicit_tag _U_, tvbuff_t *tvb _U_, int const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 4; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_choice(actx, tree, tvb, offset, VariableSpecification_choice, hf_index, ett_mms_VariableSpecification, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -2100,13 +2106,15 @@ dissect_mms_Data(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 3; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_choice(actx, tree, tvb, offset, Data_choice, hf_index, ett_mms_Data, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-oran.c b/epan/dissectors/packet-oran.c index faf908a48b..534c4d3746 100644 --- a/epan/dissectors/packet-oran.c +++ b/epan/dissectors/packet-oran.c @@ -12,7 +12,8 @@ /* * Dissector for the O-RAN Fronthaul CUS protocol specification. * The current implementation is based on the - * ORAN-WG4.CUS.0-v01.00 specification, dated 2019/01/31. + * ORAN-WG4.CUS.0-v10.00 specification, dated 2022/07/23 (plus some enums from v13) + * * N.B. by now, descriptions have been taken from a variety of versions, so some section number references * referring to earlier specs are now out of date. */ @@ -1173,10 +1174,10 @@ static int dissect_oran_c_section(tvbuff_t *tvb, proto_tree *tree, packet_info * guint32 sectionType, proto_item *protocol_item) { guint offset = 0; - proto_tree *oran_tree = NULL; + proto_tree *c_section_tree = NULL; proto_item *sectionHeading = NULL; - oran_tree = proto_tree_add_subtree(tree, tvb, offset, 8, ett_oran_section, §ionHeading, "Section"); + c_section_tree = proto_tree_add_subtree(tree, tvb, offset, 0, ett_oran_section, §ionHeading, "Section"); guint32 sectionId = 0; guint32 startPrbc; @@ -1195,7 +1196,7 @@ static int dissect_oran_c_section(tvbuff_t *tvb, proto_tree *tree, packet_info * /* These sections are similar, so handle as common with per-type differences */ if (sectionType <= SEC_C_UE_SCHED) { /* sectionID */ - proto_item *ti = proto_tree_add_item_ret_uint(oran_tree, hf_oran_section_id, tvb, offset, 2, ENC_BIG_ENDIAN, §ionId); + proto_item *ti = proto_tree_add_item_ret_uint(c_section_tree, hf_oran_section_id, tvb, offset, 2, ENC_BIG_ENDIAN, §ionId); if (sectionId == 4095) { proto_item_append_text(ti, " (not default coupling C/U planes using sectionId)"); } @@ -1203,24 +1204,24 @@ static int dissect_oran_c_section(tvbuff_t *tvb, proto_tree *tree, packet_info * /* rb */ guint32 rb; - proto_tree_add_item_ret_uint(oran_tree, hf_oran_rb, tvb, offset, 1, ENC_NA, &rb); + proto_tree_add_item_ret_uint(c_section_tree, hf_oran_rb, tvb, offset, 1, ENC_NA, &rb); /* symInc */ - proto_tree_add_item(oran_tree, hf_oran_symInc, tvb, offset, 1, ENC_NA); + proto_tree_add_item(c_section_tree, hf_oran_symInc, tvb, offset, 1, ENC_NA); /* startPrbc */ - proto_tree_add_item_ret_uint(oran_tree, hf_oran_startPrbc, tvb, offset, 2, ENC_BIG_ENDIAN, &startPrbc); + proto_tree_add_item_ret_uint(c_section_tree, hf_oran_startPrbc, tvb, offset, 2, ENC_BIG_ENDIAN, &startPrbc); offset += 2; /* numPrbc */ - proto_item *numprbc_ti = proto_tree_add_item_ret_uint(oran_tree, hf_oran_numPrbc, tvb, offset, 1, ENC_NA, &numPrbc); + proto_item *numprbc_ti = proto_tree_add_item_ret_uint(c_section_tree, hf_oran_numPrbc, tvb, offset, 1, ENC_NA, &numPrbc); if (numPrbc == 0) { proto_item_append_text(numprbc_ti, " (all PRBs - configured as %u)", pref_data_plane_section_total_rbs); } offset += 1; /* reMask */ - proto_tree_add_item(oran_tree, hf_oran_reMask, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_reMask, tvb, offset, 2, ENC_BIG_ENDIAN); offset++; /* numSymbol */ guint32 numSymbol; - proto_tree_add_item_ret_uint(oran_tree, hf_oran_numSymbol, tvb, offset, 1, ENC_NA, &numSymbol); + proto_tree_add_item_ret_uint(c_section_tree, hf_oran_numSymbol, tvb, offset, 1, ENC_NA, &numSymbol); offset++; /* [ef] (extension flag) */ @@ -1228,7 +1229,7 @@ static int dissect_oran_c_section(tvbuff_t *tvb, proto_tree *tree, packet_info * case SEC_C_NORMAL: /* Section Type "1" */ case SEC_C_PRACH: /* Section Type "3" */ case SEC_C_UE_SCHED: /* Section Type "5" */ - proto_tree_add_item_ret_boolean(oran_tree, hf_oran_ef, tvb, offset, 1, ENC_BIG_ENDIAN, &extension_flag); + proto_tree_add_item_ret_boolean(c_section_tree, hf_oran_ef, tvb, offset, 1, ENC_BIG_ENDIAN, &extension_flag); break; default: break; @@ -1247,13 +1248,13 @@ static int dissect_oran_c_section(tvbuff_t *tvb, proto_tree *tree, packet_info * switch (sectionType) { case SEC_C_UNUSED_RB: /* Section Type "0" - Table 5.4 */ /* reserved */ - proto_tree_add_item(oran_tree, hf_oran_rsvd16, tvb, offset, 2, ENC_NA); + proto_tree_add_item(c_section_tree, hf_oran_rsvd16, tvb, offset, 2, ENC_NA); offset += 2; break; case SEC_C_NORMAL: /* Section Type "1" - Table 5.5 */ /* beamId */ - beamId_ti = proto_tree_add_item_ret_uint(oran_tree, hf_oran_beamId, tvb, offset, 2, ENC_BIG_ENDIAN, &beamId); + beamId_ti = proto_tree_add_item_ret_uint(c_section_tree, hf_oran_beamId, tvb, offset, 2, ENC_BIG_ENDIAN, &beamId); offset += 2; proto_item_append_text(sectionHeading, ", BeamId: %d", beamId); @@ -1262,18 +1263,18 @@ static int dissect_oran_c_section(tvbuff_t *tvb, proto_tree *tree, packet_info * case SEC_C_PRACH: /* Section Type "3" - Table 5.6 */ { /* beamId */ - beamId_ti = proto_tree_add_item_ret_uint(oran_tree, hf_oran_beamId, tvb, offset, 2, ENC_BIG_ENDIAN, &beamId); + beamId_ti = proto_tree_add_item_ret_uint(c_section_tree, hf_oran_beamId, tvb, offset, 2, ENC_BIG_ENDIAN, &beamId); offset += 2; /* freqOffset */ gint32 freqOffset; /* Yes, this is signed, so the implicit cast is intentional. */ - proto_item *freq_offset_item = proto_tree_add_item_ret_uint(oran_tree, hf_oran_freqOffset, tvb, offset, 3, ENC_BIG_ENDIAN, &freqOffset); + proto_item *freq_offset_item = proto_tree_add_item_ret_uint(c_section_tree, hf_oran_freqOffset, tvb, offset, 3, ENC_BIG_ENDIAN, &freqOffset); freqOffset |= 0xff000000; /* Must sign-extend */ proto_item_set_text(freq_offset_item, "Frequency offset: %d \u0394f", freqOffset); offset += 3; /* reserved */ - proto_tree_add_item(oran_tree, hf_oran_rsvd8, tvb, offset, 1, ENC_NA); + proto_tree_add_item(c_section_tree, hf_oran_rsvd8, tvb, offset, 1, ENC_NA); offset += 1; proto_item_append_text(sectionHeading, ", BeamId: %d, FreqOffset: %d \u0394f", beamId, freqOffset); @@ -1282,7 +1283,7 @@ static int dissect_oran_c_section(tvbuff_t *tvb, proto_tree *tree, packet_info * case SEC_C_UE_SCHED: /* Section Type "5" - Table 5.7 */ /* ueId */ - proto_tree_add_item_ret_uint(oran_tree, hf_oran_ueId, tvb, offset, 2, ENC_NA, &ueId); + proto_tree_add_item_ret_uint(c_section_tree, hf_oran_ueId, tvb, offset, 2, ENC_NA, &ueId); offset += 2; proto_item_append_text(sectionHeading, ", UEId: %d", ueId); @@ -1294,24 +1295,24 @@ static int dissect_oran_c_section(tvbuff_t *tvb, proto_tree *tree, packet_info * } else if (sectionType == SEC_C_CH_INFO) { /* Section Type "6" */ /* ef */ - proto_tree_add_item_ret_boolean(oran_tree, hf_oran_ef, tvb, offset, 1, ENC_BIG_ENDIAN, &extension_flag); + proto_tree_add_item_ret_boolean(c_section_tree, hf_oran_ef, tvb, offset, 1, ENC_BIG_ENDIAN, &extension_flag); /* ueId */ - proto_tree_add_item_ret_uint(oran_tree, hf_oran_ueId, tvb, offset, 2, ENC_NA, &ueId); + proto_tree_add_item_ret_uint(c_section_tree, hf_oran_ueId, tvb, offset, 2, ENC_NA, &ueId); offset += 2; /* regularizationFactor */ - proto_tree_add_item(oran_tree, hf_oran_regularizationFactor, tvb, offset, 2, ENC_NA); + proto_tree_add_item(c_section_tree, hf_oran_regularizationFactor, tvb, offset, 2, ENC_NA); offset += 2; /* reserved */ - proto_tree_add_item(oran_tree, hf_oran_reserved_4bits, tvb, offset, 1, ENC_NA); + proto_tree_add_item(c_section_tree, hf_oran_reserved_4bits, tvb, offset, 1, ENC_NA); /* rb */ - proto_tree_add_item(oran_tree, hf_oran_rb, tvb, offset, 1, ENC_NA); + proto_tree_add_item(c_section_tree, hf_oran_rb, tvb, offset, 1, ENC_NA); /* symInc */ - proto_tree_add_item(oran_tree, hf_oran_symInc, tvb, offset, 1, ENC_NA); + proto_tree_add_item(c_section_tree, hf_oran_symInc, tvb, offset, 1, ENC_NA); /* startPrbc */ - proto_tree_add_item_ret_uint(oran_tree, hf_oran_startPrbc, tvb, offset, 2, ENC_BIG_ENDIAN, &startPrbc); + proto_tree_add_item_ret_uint(c_section_tree, hf_oran_startPrbc, tvb, offset, 2, ENC_BIG_ENDIAN, &startPrbc); offset += 2; /* numPrbc */ - proto_tree_add_item_ret_uint(oran_tree, hf_oran_numPrbc, tvb, offset, 1, ENC_NA, &numPrbc); + proto_tree_add_item_ret_uint(c_section_tree, hf_oran_numPrbc, tvb, offset, 1, ENC_NA, &numPrbc); offset += 1; /* ciIsample,ciQsample pairs */ @@ -1332,7 +1333,7 @@ static int dissect_oran_c_section(tvbuff_t *tvb, proto_tree *tree, packet_info * /* PRB subtree */ guint prb_start_offset = bit_offset; - proto_item *prb_ti = proto_tree_add_string_format(oran_tree, hf_oran_samples_prb, + proto_item *prb_ti = proto_tree_add_string_format(c_section_tree, hf_oran_samples_prb, tvb, bit_offset/8, 0, "", "PRB=%u", prb); proto_tree *prb_tree = proto_item_add_subtree(prb_ti, ett_oran_prb_cisamples); @@ -1378,10 +1379,10 @@ static int dissect_oran_c_section(tvbuff_t *tvb, proto_tree *tree, packet_info * /* laaMsgType */ guint32 laa_msg_type; - proto_tree_add_item_ret_uint(oran_tree, hf_oran_laaMsgType, tvb, offset, 1, ENC_NA, &laa_msg_type); + proto_tree_add_item_ret_uint(c_section_tree, hf_oran_laaMsgType, tvb, offset, 1, ENC_NA, &laa_msg_type); /* laaMsgLen */ guint32 laa_msg_len; - proto_item *len_ti = proto_tree_add_item_ret_uint(oran_tree, hf_oran_laaMsgLen, tvb, offset, 1, ENC_NA, &laa_msg_len); + proto_item *len_ti = proto_tree_add_item_ret_uint(c_section_tree, hf_oran_laaMsgLen, tvb, offset, 1, ENC_NA, &laa_msg_len); proto_item_append_text(len_ti, " (%u bytes)", 4*(laa_msg_len+1)); offset += 1; @@ -1392,102 +1393,102 @@ static int dissect_oran_c_section(tvbuff_t *tvb, proto_tree *tree, packet_info * case 0: /* LBT_PDSCH_REQ */ /* lbtHandle (16 bits) */ - proto_tree_add_item(oran_tree, hf_oran_lbtHandle, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtHandle, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* lbtOffset (10 bits) */ - proto_tree_add_item(oran_tree, hf_oran_lbtOffset, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtOffset, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 1; /* lbtMode (2 bits) */ - proto_tree_add_bits_item(oran_tree, hf_oran_lbtMode, tvb, offset*8, 2, ENC_BIG_ENDIAN); + proto_tree_add_bits_item(c_section_tree, hf_oran_lbtMode, tvb, offset*8, 2, ENC_BIG_ENDIAN); /* reserved (1 bit) */ /* lbtDeferFactor (3 bits) */ - proto_tree_add_item(oran_tree, hf_oran_lbtDeferFactor, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtDeferFactor, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; /* lbtBackoffCounter (10 bits) */ - proto_tree_add_item(oran_tree, hf_oran_lbtBackoffCounter, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtBackoffCounter, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 1; /* MCOT (4 bits) */ - proto_tree_add_item(oran_tree, hf_oran_MCOT, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_MCOT, tvb, offset, 1, ENC_BIG_ENDIAN); /* reserved (10 bits) */ - proto_tree_add_bits_item(oran_tree, hf_oran_reserved, tvb, (offset*8)+6, 10, ENC_BIG_ENDIAN); + proto_tree_add_bits_item(c_section_tree, hf_oran_reserved, tvb, (offset*8)+6, 10, ENC_BIG_ENDIAN); break; case 1: /* LBT_DRS_REQ */ /* lbtHandle (16 bits) */ - proto_tree_add_item(oran_tree, hf_oran_lbtHandle, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtHandle, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* lbtOffset (10 bits) */ - proto_tree_add_item(oran_tree, hf_oran_lbtOffset, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtOffset, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 1; /* lbtMode (2 bits) */ - proto_tree_add_bits_item(oran_tree, hf_oran_lbtMode, tvb, offset*8, 2, ENC_BIG_ENDIAN); + proto_tree_add_bits_item(c_section_tree, hf_oran_lbtMode, tvb, offset*8, 2, ENC_BIG_ENDIAN); /* reserved (28 bits) */ - proto_tree_add_bits_item(oran_tree, hf_oran_reserved, tvb, (offset*8)+4, 28, ENC_BIG_ENDIAN); + proto_tree_add_bits_item(c_section_tree, hf_oran_reserved, tvb, (offset*8)+4, 28, ENC_BIG_ENDIAN); break; case 2: /* LBT_PDSCH_RSP */ /* lbtHandle (16 bits) */ - proto_tree_add_item(oran_tree, hf_oran_lbtHandle, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtHandle, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* lbtPdschRes (2 bits) */ - proto_tree_add_item(oran_tree, hf_oran_lbtPdschRes, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtPdschRes, tvb, offset, 1, ENC_BIG_ENDIAN); /* inParSF (1 bit) */ - proto_tree_add_item(oran_tree, hf_oran_initialPartialSF, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_initialPartialSF, tvb, offset, 1, ENC_BIG_ENDIAN); /* sfStatus (1 bit) */ - proto_tree_add_item(oran_tree, hf_oran_sfStatus, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_sfStatus, tvb, offset, 1, ENC_BIG_ENDIAN); /* sfnSf (12 bits) */ - proto_tree_add_item(oran_tree, hf_oran_sfnSfEnd, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_sfnSfEnd, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* reserved (24 bits) */ - proto_tree_add_bits_item(oran_tree, hf_oran_reserved, tvb, (offset*8), 24, ENC_BIG_ENDIAN); + proto_tree_add_bits_item(c_section_tree, hf_oran_reserved, tvb, (offset*8), 24, ENC_BIG_ENDIAN); break; case 3: /* LBT_DRS_RSP */ /* lbtHandle (16 bits) */ - proto_tree_add_item(oran_tree, hf_oran_lbtHandle, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtHandle, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* lbtDrsRes (1 bit) */ - proto_tree_add_item(oran_tree, hf_oran_lbtDrsRes, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtDrsRes, tvb, offset, 1, ENC_BIG_ENDIAN); /* reserved (7 bits) */ - proto_tree_add_bits_item(oran_tree, hf_oran_reserved, tvb, (offset*8)+1, 7, ENC_BIG_ENDIAN); + proto_tree_add_bits_item(c_section_tree, hf_oran_reserved, tvb, (offset*8)+1, 7, ENC_BIG_ENDIAN); break; case 4: /* LBT_Buffer_Error */ /* lbtHandle (16 bits) */ - proto_tree_add_item(oran_tree, hf_oran_lbtHandle, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtHandle, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* lbtBufErr (1 bit) */ - proto_tree_add_item(oran_tree, hf_oran_lbtBufErr, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtBufErr, tvb, offset, 1, ENC_BIG_ENDIAN); /* reserved (7 bits) */ - proto_tree_add_bits_item(oran_tree, hf_oran_reserved, tvb, (offset*8)+1, 7, ENC_BIG_ENDIAN); + proto_tree_add_bits_item(c_section_tree, hf_oran_reserved, tvb, (offset*8)+1, 7, ENC_BIG_ENDIAN); break; case 5: /* LBT_CWCONFIG_REQ */ /* lbtHandle (16 bits) */ - proto_tree_add_item(oran_tree, hf_oran_lbtHandle, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtHandle, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* lbtCWConfig_H (8 bits) */ - proto_tree_add_item(oran_tree, hf_oran_lbtCWConfig_H, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtCWConfig_H, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; /* lbtCWConfig_T (8 bits) */ - proto_tree_add_item(oran_tree, hf_oran_lbtCWConfig_T, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtCWConfig_T, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; /* lbtMode (2 bits) */ - proto_tree_add_bits_item(oran_tree, hf_oran_lbtMode, tvb, offset*8, 2, ENC_BIG_ENDIAN); + proto_tree_add_bits_item(c_section_tree, hf_oran_lbtMode, tvb, offset*8, 2, ENC_BIG_ENDIAN); /* lbtTrafficClass (3 bits) */ - proto_tree_add_item(oran_tree, hf_oran_lbtTrafficClass, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtTrafficClass, tvb, offset, 1, ENC_BIG_ENDIAN); /* reserved (19 bits) */ - proto_tree_add_bits_item(oran_tree, hf_oran_reserved, tvb, (offset*8)+5, 19, ENC_BIG_ENDIAN); + proto_tree_add_bits_item(c_section_tree, hf_oran_reserved, tvb, (offset*8)+5, 19, ENC_BIG_ENDIAN); break; case 6: /* LBT_CWCONFIG_RSP */ /* lbtHandle (16 bits) */ - proto_tree_add_item(oran_tree, hf_oran_lbtHandle, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtHandle, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* lbtCWR_Rst (1 bit) */ - proto_tree_add_item(oran_tree, hf_oran_lbtCWR_Rst, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(c_section_tree, hf_oran_lbtCWR_Rst, tvb, offset, 1, ENC_BIG_ENDIAN); /* reserved (7 bits) */ - proto_tree_add_bits_item(oran_tree, hf_oran_reserved, tvb, (offset*8)+1, 7, ENC_BIG_ENDIAN); + proto_tree_add_bits_item(c_section_tree, hf_oran_reserved, tvb, (offset*8)+1, 7, ENC_BIG_ENDIAN); break; default: @@ -1504,7 +1505,7 @@ static int dissect_oran_c_section(tvbuff_t *tvb, proto_tree *tree, packet_info * gint extension_start_offset = offset; /* Create subtree for each extension (with summary) */ - proto_item *extension_ti = proto_tree_add_string_format(oran_tree, hf_oran_extension, + proto_item *extension_ti = proto_tree_add_string_format(c_section_tree, hf_oran_extension, tvb, offset, 0, "", "Extension"); proto_tree *extension_tree = proto_item_add_subtree(extension_ti, ett_oran_c_section_extension); @@ -1855,7 +1856,7 @@ static int dissect_oran_c_section(tvbuff_t *tvb, proto_tree *tree, packet_info * switch (beam_group_type) { case 0x0: /* common beam */ /* Reserved byte */ - proto_tree_add_item(oran_tree, hf_oran_rsvd8, tvb, offset, 1, ENC_NA); + proto_tree_add_item(extension_tree, hf_oran_rsvd8, tvb, offset, 1, ENC_NA); offset++; /* All entries are beamId... */ @@ -1866,7 +1867,7 @@ static int dissect_oran_c_section(tvbuff_t *tvb, proto_tree *tree, packet_info * case 0x1: /* beam matrix indication */ /* Reserved byte */ - proto_tree_add_item(oran_tree, hf_oran_rsvd8, tvb, offset, 1, ENC_NA); + proto_tree_add_item(extension_tree, hf_oran_rsvd8, tvb, offset, 1, ENC_NA); offset++; /* Entries inc from beamId... */ @@ -1886,7 +1887,7 @@ static int dissect_oran_c_section(tvbuff_t *tvb, proto_tree *tree, packet_info * /* port beam ID (or UEID) */ guint32 id; - proto_item *beamid_or_ueid_ti = proto_tree_add_item_ret_uint(oran_tree, hf_oran_beamId, + proto_item *beamid_or_ueid_ti = proto_tree_add_item_ret_uint(extension_tree, hf_oran_beamId, tvb, offset, 2, ENC_BIG_ENDIAN, &id); proto_item_append_text(beamid_or_ueid_ti, " port #%u beam ID (or UEId) %u", n, id); offset += 2; @@ -2472,7 +2473,7 @@ static int dissect_oran_c(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v proto_item *sectionHeading; - /* section subtree */ + /* Section subtree */ gint section_tree_offset = offset; proto_tree *section_tree = proto_tree_add_subtree(oran_tree, tvb, offset, 2, ett_oran_section_type, §ionHeading, "C-Plane Section Type "); @@ -2485,7 +2486,7 @@ static int dissect_oran_c(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v proto_tree_add_item(section_tree, hf_oran_filter_index, tvb, offset, 1, ENC_NA); offset += 1; - guint ref_a_offset = 0; + guint ref_a_offset = offset; /* frameId */ guint32 frameId = 0; proto_tree_add_item_ret_uint(section_tree, hf_oran_frame_id, tvb, offset, 1, ENC_NA, &frameId); @@ -2591,15 +2592,16 @@ static int dissect_oran_c(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v break; }; - /* Set actual length of section. */ - proto_item_set_len(section_tree, offset - section_tree_offset); - proto_item_append_text(sectionHeading, "%d, %s, Frame: %d, Subframe: %d, Slot: %d, StartSymbol: %d", sectionType, val_to_str_const(direction, data_direction_vals, "Unknown"), frameId, subframeId, slotId, startSymbolId); write_pdu_label_and_info(protocol_item, NULL, pinfo, ", Type: %d %s", sectionType, rval_to_str_const(sectionType, section_types_short, "Unknown")); + /* Set actual length of C-Plane section. */ + proto_item_set_len(section_tree, offset - section_tree_offset); + + /* Dissect each C section */ for (guint32 i = 0; i < nSections; ++i) { tvbuff_t *section_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, -1); @@ -2626,7 +2628,7 @@ dissect_oran_u(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ col_set_str(pinfo->cinfo, COL_PROTOCOL, "O-RAN-FH-U"); col_set_str(pinfo->cinfo, COL_INFO, "U-Plane"); - /* create display subtree for the protocol */ + /* Create display subtree for the protocol */ proto_item *protocol_item = proto_tree_add_item(tree, proto_oran, tvb, 0, -1, ENC_NA); proto_item_append_text(protocol_item, "-U"); proto_tree *oran_tree = proto_item_add_subtree(protocol_item, ett_oran); @@ -2714,8 +2716,9 @@ dissect_oran_u(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ guint nBytesPerPrb; do { + guint section_start_offet = offset; proto_item *sectionHeading; - proto_tree *section_tree = proto_tree_add_subtree(oran_tree, tvb, offset, 2, ett_oran_u_section, §ionHeading, "Section"); + proto_tree *section_tree = proto_tree_add_subtree(oran_tree, tvb, offset, 0, ett_oran_u_section, §ionHeading, "Section"); /* Section Header fields (darker green part) */ @@ -2825,7 +2828,8 @@ dissect_oran_u(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ offset += nBytesForSamples; - proto_item_set_len(sectionHeading, nBytesPerPrb * numPrbu + 4); /* 4 bytes for section header */ + /* Set length of overall section */ + proto_item_set_len(sectionHeading, offset-section_start_offet); } bytesLeft = tvb_captured_length(tvb) - offset; number_of_sections++; diff --git a/epan/dissectors/packet-ospf.c b/epan/dissectors/packet-ospf.c index 9d05ae5a64..9d08bd3f9f 100644 --- a/epan/dissectors/packet-ospf.c +++ b/epan/dissectors/packet-ospf.c @@ -3666,7 +3666,7 @@ dissect_ospf_v2_lsa(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *t guint8 ls_type; guint16 ls_length; int end_offset; - guint16 nr_links; + guint32 nr_links; guint16 nr_metric; /* router LSA */ @@ -3774,9 +3774,8 @@ dissect_ospf_v2_lsa(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *t case OSPF_LSTYPE_ROUTER: /* flags field in an router-lsa */ proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset, hf_ospf_v2_router_lsa_flag, ett_ospf_v2_router_lsa_flags, bf_v2_router_lsa_flags, ENC_BIG_ENDIAN); - - nr_links = tvb_get_ntohs(tvb, offset + 2); - proto_tree_add_item(ospf_lsa_tree, hf_ospf_lsa_number_of_links, tvb, offset + 2, 2, ENC_BIG_ENDIAN); + /* TODO: flags are only 1 byte, so there is an apparently unused byte here */ + proto_tree_add_item_ret_uint(ospf_lsa_tree, hf_ospf_lsa_number_of_links, tvb, offset + 2, 2, ENC_BIG_ENDIAN, &nr_links); offset += 4; diff --git a/epan/dissectors/packet-p22.c b/epan/dissectors/packet-p22.c index 9726274ddd..70f6c93ec1 100644 --- a/epan/dissectors/packet-p22.c +++ b/epan/dissectors/packet-p22.c @@ -1805,9 +1805,11 @@ dissect_p22_IPM(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_c const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 7; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + col_append_str(actx->pinfo->cinfo, COL_INFO, " Message"); offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset, @@ -1816,7 +1818,7 @@ dissect_p22_IPM(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_c - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -3522,12 +3524,14 @@ dissect_p22_IPMSynopsis(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 4; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset, IPMSynopsis_sequence_of, hf_index, ett_p22_IPMSynopsis); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -3988,12 +3992,14 @@ dissect_p22_BodyPartTokens(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 4; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset, BodyPartTokens_set_of, hf_index, ett_p22_BodyPartTokens); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -4044,12 +4050,14 @@ dissect_p22_ForwardedContentToken(bool implicit_tag _U_, tvbuff_t *tvb _U_, int const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 4; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset, ForwardedContentToken_set_of, hf_index, ett_p22_ForwardedContentToken); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-p7.c b/epan/dissectors/packet-p7.c index 31126a4b6e..a26670b083 100644 --- a/epan/dissectors/packet-p7.c +++ b/epan/dissectors/packet-p7.c @@ -1562,13 +1562,15 @@ dissect_p7_Filter(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1 const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 3; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_choice(actx, tree, tvb, offset, Filter_choice, hf_index, ett_p7_Filter, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-uds.c b/epan/dissectors/packet-uds.c index 1a18af8a82..e1eb3ef090 100644 --- a/epan/dissectors/packet-uds.c +++ b/epan/dissectors/packet-uds.c @@ -1487,6 +1487,22 @@ uds_proto_tree_add_address_name(proto_tree *tree, int hf, tvbuff_t *tvb, const g return ti; } +static void +uds_proto_item_append_address_text(proto_item *ti, guint8 address_length, const char *name, guint32 value) { + if (ti == NULL) { + return; + } + + switch (address_length) { + case 1: + proto_item_append_text(ti, ", %s: 0x%02x", name, value); + break; + case 2: + proto_item_append_text(ti, ", %s: 0x%04x", name, value); + break; + } +} + /*** Configuration End ***/ static gboolean @@ -2220,8 +2236,7 @@ dissect_uds_certificates_into_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree } static int -dissect_uds_internal(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 source_address, guint32 target_address, guint8 number_of_addresses_valid) -{ +dissect_uds_internal(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 source_address, guint16 target_address, guint8 number_of_addresses_valid, guint8 address_size) { proto_tree *uds_tree; proto_tree *subfunction_tree; proto_item *ti; @@ -2262,25 +2277,25 @@ dissect_uds_internal(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint3 ecu_address = G_MAXUINT32; break; case 1: - proto_item_append_text(ti, ", Address: 0x%04x", source_address); + uds_proto_item_append_address_text(ti, address_size, "Address", source_address); uds_proto_item_append_address_name(ti, source_address); - uds_proto_tree_add_address_item(uds_tree, hf_uds_diag_addr, tvb, 0, 0, source_address, false, false); + uds_proto_tree_add_address_item(uds_tree, hf_uds_diag_addr, tvb, 0, 0, source_address, true, false); uds_proto_tree_add_address_name(uds_tree, hf_uds_diag_addr_name, tvb, 0, 0, source_address); break; case 2: - proto_item_append_text(ti, ", Source: 0x%04x", source_address); + uds_proto_item_append_address_text(ti, address_size, "Source", source_address); uds_proto_item_append_address_name(ti, source_address); - proto_item_append_text(ti, ", Target: 0x%04x", target_address); + uds_proto_item_append_address_text(ti, address_size, "Target", target_address); uds_proto_item_append_address_name(ti, target_address); - uds_proto_tree_add_address_item(uds_tree, hf_uds_diag_source_addr, tvb, 0, 0, source_address, false, false); + uds_proto_tree_add_address_item(uds_tree, hf_uds_diag_source_addr, tvb, 0, 0, source_address, true, false); uds_proto_tree_add_address_name(uds_tree, hf_uds_diag_source_addr_name, tvb, 0, 0, source_address); uds_proto_tree_add_address_item(uds_tree, hf_uds_diag_addr, tvb, 0, 0, source_address, true, true); uds_proto_tree_add_address_name(uds_tree, hf_uds_diag_addr_name, tvb, 0, 0, source_address); - uds_proto_tree_add_address_item(uds_tree, hf_uds_diag_target_addr, tvb, 0, 0, target_address, false, false); + uds_proto_tree_add_address_item(uds_tree, hf_uds_diag_target_addr, tvb, 0, 0, target_address, true, false); uds_proto_tree_add_address_name(uds_tree, hf_uds_diag_target_addr_name, tvb, 0, 0, target_address); uds_proto_tree_add_address_item(uds_tree, hf_uds_diag_addr, tvb, 0, 0, target_address, true, true); @@ -3204,7 +3219,7 @@ dissect_uds_internal(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint3 static int dissect_uds_no_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - return dissect_uds_internal(tvb, pinfo, tree, 0, 0, 0); + return dissect_uds_internal(tvb, pinfo, tree, 0, 0, 0, 0); } static int @@ -3212,7 +3227,7 @@ dissect_uds_doip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data DISSECTOR_ASSERT(data); doip_info_t *doip_info = (doip_info_t *)data; - return dissect_uds_internal(tvb, pinfo, tree, doip_info->source_address, doip_info->target_address, 2); + return dissect_uds_internal(tvb, pinfo, tree, doip_info->source_address, doip_info->target_address, 2, 2); } static int @@ -3220,7 +3235,7 @@ dissect_uds_hsfz(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data DISSECTOR_ASSERT(data); hsfz_info_t *hsfz_info = (hsfz_info_t *)data; - return dissect_uds_internal(tvb, pinfo, tree, hsfz_info->source_address, hsfz_info->target_address, 2); + return dissect_uds_internal(tvb, pinfo, tree, hsfz_info->source_address, hsfz_info->target_address, 2, 1); } static int @@ -3228,7 +3243,7 @@ dissect_uds_iso15765(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * DISSECTOR_ASSERT(data); iso15765_info_t *info = (iso15765_info_t *)data; - return dissect_uds_internal(tvb, pinfo, tree, info->source_address, info->target_address, info->number_of_addresses_valid); + return dissect_uds_internal(tvb, pinfo, tree, info->source_address, info->target_address, info->number_of_addresses_valid, info->address_length); } static int @@ -3236,7 +3251,7 @@ dissect_uds_iso10681(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * DISSECTOR_ASSERT(data); iso10681_info_t *info = (iso10681_info_t *)data; - return dissect_uds_internal(tvb, pinfo, tree, info->source_address, info->target_address, 2); + return dissect_uds_internal(tvb, pinfo, tree, info->source_address, info->target_address, 2, 2); } static void diff --git a/epan/dissectors/packet-x509if.c b/epan/dissectors/packet-x509if.c index 8025d83671..b55d489182 100644 --- a/epan/dissectors/packet-x509if.c +++ b/epan/dissectors/packet-x509if.c @@ -1051,13 +1051,15 @@ dissect_x509if_Refinement(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 3; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_choice(actx, tree, tvb, offset, Refinement_choice, hf_index, ett_x509if_Refinement, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -1496,13 +1498,15 @@ dissect_x509if_ContextCombination(bool implicit_tag _U_, tvbuff_t *tvb _U_, int const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 3; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_choice(actx, tree, tvb, offset, ContextCombination_choice, hf_index, ett_x509if_ContextCombination, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -1621,13 +1625,15 @@ dissect_x509if_AttributeCombination(bool implicit_tag _U_, tvbuff_t *tvb _U_, in const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 3; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_choice(actx, tree, tvb, offset, AttributeCombination_choice, hf_index, ett_x509if_AttributeCombination, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-x509sat.c b/epan/dissectors/packet-x509sat.c index 58ce5bba81..bb67e6cbbf 100644 --- a/epan/dissectors/packet-x509sat.c +++ b/epan/dissectors/packet-x509sat.c @@ -436,13 +436,15 @@ dissect_x509sat_Criteria(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 3; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_choice(actx, tree, tvb, offset, Criteria_choice, hf_index, ett_x509sat_Criteria, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/epan/dissectors/packet-z3950.c b/epan/dissectors/packet-z3950.c index 2d1d4eebb1..9933765254 100644 --- a/epan/dissectors/packet-z3950.c +++ b/epan/dissectors/packet-z3950.c @@ -3035,13 +3035,15 @@ dissect_z3950_RPNStructure(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 3; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_choice(actx, tree, tvb, offset, RPNStructure_choice, hf_index, ett_z3950_RPNStructure, NULL); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -6546,12 +6548,14 @@ dissect_z3950_ElementInfo(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 4; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset, ElementInfo_sequence, hf_index, ett_z3950_ElementInfo); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } @@ -8027,12 +8031,14 @@ dissect_z3950_TaggedElement(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = 4; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset, TaggedElement_sequence, hf_index, ett_z3950_TaggedElement); - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); return offset; } diff --git a/plugins/epan/irda/packet-irda.c b/plugins/epan/irda/packet-irda.c index 1f8c266abd..6486aa797e 100644 --- a/plugins/epan/irda/packet-irda.c +++ b/plugins/epan/irda/packet-irda.c @@ -1496,6 +1496,7 @@ static void dissect_xid(tvbuff_t* tvb, packet_info* pinfo, proto_tree* root, pro if (lap_tree) { + /* Discovery flags */ ti = proto_tree_add_item(i_tree, hf_xid_flags, tvb, offset, 1, ENC_BIG_ENDIAN); flags_tree = proto_item_add_subtree(ti, ett_xid_flags); proto_tree_add_item(flags_tree, hf_xid_s, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -1517,6 +1518,7 @@ static void dissect_xid(tvbuff_t* tvb, packet_info* pinfo, proto_tree* root, pro proto_item_append_text(ti, " (final)"); } } + /* Skip (empty?) byte even if no command.. Have seen non-zero values in a capture */ offset++; if (lap_tree) diff --git a/tools/asn2wrs.py b/tools/asn2wrs.py index 8bd8608bcd..0411299892 100755 --- a/tools/asn2wrs.py +++ b/tools/asn2wrs.py @@ -1563,8 +1563,10 @@ def eth_type_fn_hdr(self, tname): const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers))); const unsigned cycle_size = {cycle_size}; unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size); + ''' if self.conform.get_fn_presence(self.eth_type[tname]['ref'][0]): @@ -1588,7 +1590,7 @@ def eth_type_fn_ftr(self, tname): if add_recursion_check: out += '''\ - p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size); + p_set_proto_depth(actx->pinfo, proto_id, recursion_depth); ''' if self.conform.get_fn_presence(self.eth_type[tname]['ref'][0]): diff --git a/ui/logray/logray_main.cpp b/ui/logray/logray_main.cpp index f97a3be2d9..473f396e93 100644 --- a/ui/logray/logray_main.cpp +++ b/ui/logray/logray_main.cpp @@ -871,20 +871,34 @@ int main(int argc, char *qt_argv[]) #endif /* _WIN32 */ /* Get the list of link-layer types for the capture devices. */ ret_val = EXIT_SUCCESS; + GList *if_cap_queries = NULL; + if_cap_query_t *if_cap_query; + GHashTable *capability_hash; for (i = 0; i < global_capture_opts.ifaces->len; i++) { interface_options *interface_opts; - if_capabilities_t *caps; - char *auth_str = NULL; interface_opts = &g_array_index(global_capture_opts.ifaces, interface_options, i); + if_cap_query = g_new(if_cap_query_t, 1); + if_cap_query->name = interface_opts->name; + if_cap_query->monitor_mode = interface_opts->monitor_mode; + if_cap_query->auth_username = NULL; + if_cap_query->auth_password = NULL; #ifdef HAVE_PCAP_REMOTE if (interface_opts->auth_type == CAPTURE_AUTH_PWD) { - auth_str = g_strdup_printf("%s:%s", interface_opts->auth_username, interface_opts->auth_password); + if_cap_query->auth_username = interface_opts->auth_username; + if_cap_query->auth_password = interface_opts->auth_password; } #endif - caps = capture_get_if_capabilities(interface_opts->name, interface_opts->monitor_mode, - auth_str, &err_str, &err_str_secondary, NULL); - g_free(auth_str); + if_cap_queries = g_list_prepend(if_cap_queries, if_cap_query); + } + if_cap_queries = g_list_reverse(if_cap_queries); + capability_hash = capture_get_if_list_capabilities(if_cap_queries, &err_str, &err_str_secondary, NULL); + g_list_free_full(if_cap_queries, g_free); + for (i = 0; i < global_capture_opts.ifaces->len; i++) { + interface_options *interface_opts; + if_capabilities_t *caps; + interface_opts = &g_array_index(global_capture_opts.ifaces, interface_options, i); + caps = static_cast(g_hash_table_lookup(capability_hash, interface_opts->name)); if (caps == NULL) { cmdarg_err("%s%s%s", err_str, err_str_secondary ? "\n" : "", err_str_secondary ? err_str_secondary : ""); g_free(err_str); @@ -894,7 +908,6 @@ int main(int argc, char *qt_argv[]) } ret_val = capture_opts_print_if_capabilities(caps, interface_opts, caps_queries); - free_if_capabilities(caps); if (ret_val != EXIT_SUCCESS) { break; } @@ -902,6 +915,7 @@ int main(int argc, char *qt_argv[]) #ifdef _WIN32 destroy_console(); #endif /* _WIN32 */ + g_hash_table_destroy(capability_hash); goto clean_exit; } diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index 6e8cf30859..44e3b7d253 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -929,20 +929,34 @@ int main(int argc, char *qt_argv[]) #endif /* _WIN32 */ /* Get the list of link-layer types for the capture devices. */ ret_val = EXIT_SUCCESS; + GList *if_cap_queries = NULL; + if_cap_query_t *if_cap_query; + GHashTable *capability_hash; for (i = 0; i < global_capture_opts.ifaces->len; i++) { interface_options *interface_opts; - if_capabilities_t *caps; - char *auth_str = NULL; interface_opts = &g_array_index(global_capture_opts.ifaces, interface_options, i); + if_cap_query = g_new(if_cap_query_t, 1); + if_cap_query->name = interface_opts->name; + if_cap_query->monitor_mode = interface_opts->monitor_mode; + if_cap_query->auth_username = NULL; + if_cap_query->auth_password = NULL; #ifdef HAVE_PCAP_REMOTE if (interface_opts->auth_type == CAPTURE_AUTH_PWD) { - auth_str = ws_strdup_printf("%s:%s", interface_opts->auth_username, interface_opts->auth_password); + if_cap_query->auth_username = interface_opts->auth_username; + if_cap_query->auth_password = interface_opts->auth_password; } #endif - caps = capture_get_if_capabilities(interface_opts->name, interface_opts->monitor_mode, - auth_str, &err_str, &err_str_secondary, NULL); - g_free(auth_str); + if_cap_queries = g_list_prepend(if_cap_queries, if_cap_query); + } + if_cap_queries = g_list_reverse(if_cap_queries); + capability_hash = capture_get_if_list_capabilities(if_cap_queries, &err_str, &err_str_secondary, NULL); + g_list_free_full(if_cap_queries, g_free); + for (i = 0; i < global_capture_opts.ifaces->len; i++) { + interface_options *interface_opts; + if_capabilities_t *caps; + interface_opts = &g_array_index(global_capture_opts.ifaces, interface_options, i); + caps = static_cast(g_hash_table_lookup(capability_hash, interface_opts->name)); if (caps == NULL) { cmdarg_err("%s%s%s", err_str, err_str_secondary ? "\n" : "", err_str_secondary ? err_str_secondary : ""); g_free(err_str); @@ -952,7 +966,6 @@ int main(int argc, char *qt_argv[]) } ret_val = capture_opts_print_if_capabilities(caps, interface_opts, caps_queries); - free_if_capabilities(caps); if (ret_val != EXIT_SUCCESS) { break; } @@ -960,6 +973,7 @@ int main(int argc, char *qt_argv[]) #ifdef _WIN32 destroy_console(); #endif /* _WIN32 */ + g_hash_table_destroy(capability_hash); goto clean_exit; }