Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreadman committed Feb 28, 2025
2 parents e8f9492 + fd9b1fd commit 178fcbb
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 63 deletions.
7 changes: 1 addition & 6 deletions epan/dissectors/asn1/its/CPM-PDU-Descriptions.asn
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,7 @@ WrappedCpmContainer ::= SEQUENCE {
}


-- As per ASN.1 standard (ITU-T X.680 - 2021-02: Section 52.5)
-- ConstraintWrappedCpmContainers shall not be extensible, but the .c file generator does
-- not handle this correctly, so the extension marker is removed explicitly to be aligned with
-- the ASN.1 standard
--WrappedCpmContainers::= SEQUENCE SIZE(1..8,...) OF WrappedCpmContainer
WrappedCpmContainers::= SEQUENCE SIZE(1..8) OF WrappedCpmContainer
WrappedCpmContainers::= SEQUENCE SIZE(1..8,...) OF WrappedCpmContainer

ConstraintWrappedCpmContainers ::= WrappedCpmContainers
-- ((WITH COMPONENT (WITH COMPONENTS {..., containerId (ALL EXCEPT 1)})) |
Expand Down
50 changes: 48 additions & 2 deletions epan/dissectors/packet-bacapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7113,6 +7113,27 @@ static const fragment_items msg_frag_items = {
"Message fragments"
};

/* calculate an extended sequence number. The sequence number is an 8-bit
* counter, and can rollover with very large data length. */
static uint32_t
calculate_extended_seqno(uint32_t prev_seqno, uint8_t raw_seqno)
{
uint32_t seqno = (prev_seqno & 0xffffff00) | raw_seqno;
/* The Window Size must be in a range 1 to 127 (see ANSI/ASHRAE Std
* 135-2016 5.3), and this guarantees that, e.g., sequence number 128
* will not be transmitted unless a SegmentACK has been received for
* sequence number 0, so any subsequent sequence number 0 must actually
* be sequence number 256 after rollover.
*/
if (seqno + 0x80 < prev_seqno) {
seqno += 0x100;
} else if (prev_seqno + 0x80 < seqno) {
/* Unlikely, out-of-order packet backwards over the wrap boundary. */
seqno -= 0x100;
}
return seqno;
}

#if 0
/* if BACnet uses the reserved values, then patch the corresponding values here, maximum 16 values are defined */
/* FIXME: fGetMaxAPDUSize is commented out, as it is not used. It was used to set variables which were not later used. */
Expand Down Expand Up @@ -16772,15 +16793,40 @@ dissect_bacapp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _

if (fragment) { /* fragmented */
fragment_head *frag_msg;
uint32_t ext_seqno = bacapp_seqno;

pinfo->fragmented = true;

if (!PINFO_FD_VISITED(pinfo)) {
frag_msg = fragment_get(&msg_reassembly_table, pinfo, bacapp_invoke_id, NULL);
if (frag_msg && frag_msg->first_gap) {
/* If we have permanently lost segments then using the last
* contiguous sequence number isn't quite right - but we
* won't be able to defragment in that case anyway.
*/
uint32_t prev_seqno = frag_msg->first_gap->offset;
ext_seqno = calculate_extended_seqno(prev_seqno, bacapp_seqno);

if (ext_seqno != bacapp_seqno) {
p_add_proto_data(wmem_file_scope(), pinfo, proto_bacapp, bacapp_seqno, GUINT_TO_POINTER(ext_seqno));
}
}
} else {
/* This is not really necessary (because the fragment number is not
* used by fragment_add_seq_check on the second pass) but makes the
* fragment number in the Info column be the extended one.
*/
ext_seqno = GPOINTER_TO_UINT(p_get_proto_data(wmem_file_scope(), pinfo, proto_bacapp, bacapp_seqno));
if (ext_seqno == 0) {
ext_seqno = bacapp_seqno;
}
}
frag_msg = fragment_add_seq_check(&msg_reassembly_table,
tvb, data_offset,
pinfo,
bacapp_invoke_id, /* ID for fragments belonging together */
NULL,
bacapp_seqno, /* fragment sequence number */
ext_seqno, /* fragment sequence number */
tvb_reported_length_remaining(tvb, data_offset), /* fragment length - to the end */
flag & BACAPP_MORE_SEGMENTS); /* Last fragment reached? */
new_tvb = process_reassembled_data(tvb, data_offset, pinfo,
Expand All @@ -16792,7 +16838,7 @@ dissect_bacapp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _
" (Message Reassembled)");
} else { /* Not last packet of reassembled Short Message */
col_append_fstr(pinfo->cinfo, COL_INFO,
" (Message fragment %u)", bacapp_seqno);
" (Message fragment %u)", ext_seqno);
}
if (new_tvb) { /* take it all */
switch (bacapp_type) {
Expand Down
3 changes: 3 additions & 0 deletions epan/dissectors/packet-bgp.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ static dissector_handle_t bgp_handle;
#define BGP_CAPABILITY_BFD_STRICT 74 /* draft-ietf-idr-bgp-bfd-strict-mode */
#define BGP_CAPABILITY_SOFT_VERSION 75 /* draft-abraitis-bgp-version-capability */
#define BGP_CAPABILITY_PATHS_LIMIT 76 /* draft-abraitis-idr-addpath-paths-limit */
#define BGP_CAPABILITY_LINK_LOCAL_NEXT_HOP 77 /* draft-white-linklocal-capability */
#define BGP_CAPABILITY_ROUTE_REFRESH_CISCO 128 /* Cisco, RFC8810 */
#define BGP_CAPABILITY_RPD_CISCO 129 /* Cisco, RFC8810 */
#define BGP_CAPABILITY_ORF_CISCO 130 /* Cisco, RFC8810 */
Expand Down Expand Up @@ -2055,6 +2056,7 @@ static const value_string capability_vals[] = {
{ BGP_CAPABILITY_MULTISESSION_CISCO, "Multisession (Cisco)" },
{ BGP_CAPABILITY_FQDN_CISCO, "FQDN (Cisco)" },
{ BGP_CAPABILITY_OPERATIONAL_MSG_CISCO, "OPERATIONAL message (Cisco)" },
{ BGP_CAPABILITY_LINK_LOCAL_NEXT_HOP, "Link-Local Next Hop Capability" },
{ 0, NULL }
};

Expand Down Expand Up @@ -8726,6 +8728,7 @@ dissect_bgp_capability_item(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
}
break;

case BGP_CAPABILITY_LINK_LOCAL_NEXT_HOP:
case BGP_CAPABILITY_ENHANCED_ROUTE_REFRESH:
case BGP_CAPABILITY_ROUTE_REFRESH_CISCO:
case BGP_CAPABILITY_ROUTE_REFRESH:
Expand Down
2 changes: 1 addition & 1 deletion epan/dissectors/packet-its.c
Original file line number Diff line number Diff line change
Expand Up @@ -22189,7 +22189,7 @@ static int
dissect_cpm_WrappedCpmContainers(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_constrained_sequence_of(tvb, offset, actx, tree, hf_index,
ett_cpm_WrappedCpmContainers, cpm_WrappedCpmContainers_sequence_of,
1, 8, false);
1, 8, true);

return offset;
}
Expand Down
9 changes: 7 additions & 2 deletions epan/dissectors/packet-nas_5gs.c
Original file line number Diff line number Diff line change
Expand Up @@ -10452,7 +10452,10 @@ de_nas_5gs_ue_policies_andsp_wlansp_rule(tvbuff_t* tvb, packet_info* pinfo _U_,
offset += 6;
}
break;
case 2: /* preferred roaming partner list,*/
case 2: /* preferred roaming partner list*/
/* Length of sub entry {set type = preferred roaming partner list} */
proto_tree_add_item_ret_uint(sel_crit_set_sub_tree, hf_nas_5gs_wlansp_sub_ent_len, tvb, offset, 1, ENC_BIG_ENDIAN, &sub_ent_len);
offset++;
/* Priority */
proto_tree_add_item(sel_crit_set_sub_tree, hf_nas_5gs_wlansp_pref_roam_part_list_prio, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
Expand All @@ -10470,6 +10473,9 @@ de_nas_5gs_ue_policies_andsp_wlansp_rule(tvbuff_t* tvb, packet_info* pinfo _U_,
offset += country_len;
break;
case 3: /* Required protocol port tuple */
/* Length of sub entry {set type = Required protocol port tuple} */
proto_tree_add_item_ret_uint(sel_crit_set_sub_tree, hf_nas_5gs_wlansp_sub_ent_len, tvb, offset, 1, ENC_BIG_ENDIAN, &sub_ent_len);
offset++;
/* IP protocol */
proto_tree_add_item(sel_crit_set_sub_tree, hf_nas_5gs_wlansp_req_prot_ip_prot, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
Expand Down Expand Up @@ -10505,7 +10511,6 @@ de_nas_5gs_ue_policies_andsp_wlansp_rule(tvbuff_t* tvb, packet_info* pinfo _U_,
proto_tree_add_item(sel_crit_set_sub_tree, hf_nas_5gs_wlansp_sp_excl_list_ulb, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
offset += 5;
break;
default:
/* Skip over the list*/
Expand Down
41 changes: 26 additions & 15 deletions epan/dissectors/packet-protobuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1144,8 +1144,9 @@ dissect_one_protobuf_field(tvbuff_t *tvb, unsigned* offset, unsigned maxlen, pac
* 2. For bools, the default value is false.
* 3. For enums, the default value is the first defined enum value, which must be 0 in 'proto3' (but
* allowed to be other in 'proto2').
* 4. For numeric types, the default value is zero.
* There are no default values for fields 'repeated' or 'bytes' and 'string' without default value declared.
* 4. For numeric types, the default value is zero; for strings, the default value is the empty string;
* and for bytes, the default value is empty bytes.
* There are no default values for fields 'repeated'.
* If the missing field is 'required' in a 'proto2' file, an expert warning item will be added to the tree.
*
* Which fields will be displayed is controlled by 'add_default_value' option:
Expand Down Expand Up @@ -1199,14 +1200,11 @@ add_missing_fields_with_default_values(tvbuff_t* tvb, unsigned offset, packet_in
continue;
}

/* ignore repeated fields, or optional fields of message/group,
* or string/bytes fields without explicitly-declared default value.
/* ignore repeated fields, or optional fields of message/group.
*/
if (is_repeated || (!is_required && (field_type == PROTOBUF_TYPE_NONE
|| field_type == PROTOBUF_TYPE_MESSAGE
|| field_type == PROTOBUF_TYPE_GROUP
|| (field_type == PROTOBUF_TYPE_BYTES && !has_default_value)
|| (field_type == PROTOBUF_TYPE_STRING && !has_default_value)
))) {
continue;
}
Expand Down Expand Up @@ -1354,18 +1352,29 @@ add_missing_fields_with_default_values(tvbuff_t* tvb, unsigned offset, packet_in

case PROTOBUF_TYPE_BYTES:
string_value = pbw_FieldDescriptor_default_value_string(field_desc, &size);
DISSECTOR_ASSERT_HINT(has_default_value && string_value, "Bytes field must have default value!");
if (dumper) {
json_dumper_begin_base64(dumper);
json_dumper_write_base64(dumper, (const unsigned char *)string_value, size);
json_dumper_end_base64(dumper);
if (string_value == NULL) {
json_dumper_value_string(dumper, "");
} else {
json_dumper_begin_base64(dumper);
json_dumper_write_base64(dumper, (const unsigned char *)string_value, size);
json_dumper_end_base64(dumper);
}
}
if (!dissect_bytes_as_string) {
ti_value = proto_tree_add_bytes_with_length(field_tree, hf_protobuf_value_data, tvb, offset, 0, (const uint8_t*) string_value, size);
if (string_value == NULL) {
ti_value = proto_tree_add_bytes_format_value(field_tree, hf_protobuf_value_data, tvb, offset, 0, NULL, "%s", "");
} else {
ti_value = proto_tree_add_bytes_with_length(field_tree, hf_protobuf_value_data, tvb, offset, 0, (const uint8_t*)string_value, size);
}
proto_item_append_text(ti_field, " (%d bytes)", size);
/* the type of *hf_id_ptr MUST be FT_BYTES now */
if (hf_id_ptr) {
ti_pbf = proto_tree_add_bytes_with_length(pbf_tree, *hf_id_ptr, tvb, offset, 0, (const uint8_t*)string_value, size);
if (string_value == NULL) {
ti_pbf = proto_tree_add_bytes_format_value(pbf_tree, *hf_id_ptr, tvb, offset, 0, NULL, "%s", "");
} else {
ti_pbf = proto_tree_add_bytes_with_length(pbf_tree, *hf_id_ptr, tvb, offset, 0, (const uint8_t*)string_value, size);
}
}
break;
}
Expand All @@ -1375,7 +1384,9 @@ add_missing_fields_with_default_values(tvbuff_t* tvb, unsigned offset, packet_in
if (string_value == NULL) {
string_value = pbw_FieldDescriptor_default_value_string(field_desc, &size);
}
DISSECTOR_ASSERT_HINT(has_default_value && string_value, "String field must have default value!");
if (string_value == NULL) {
string_value = "";
}
ti_value = proto_tree_add_string(field_tree, hf_protobuf_value_string, tvb, offset, 0, string_value);
proto_item_append_text(ti_field, " %s", string_value);
if (hf_id_ptr) {
Expand Down Expand Up @@ -2442,8 +2453,8 @@ proto_register_protobuf(void)
" 1) The value of the 'default' option of an optional field defined in 'proto2' file. (explicitly-declared)\n"
" 2) False for bools.\n"
" 3) First defined enum value for enums.\n"
" 4) Zero for numeric types.\n"
"There are no default values for fields 'repeated' or 'bytes' and 'string' without default value declared.\n"
" 4) Zero for numeric types; empty string for 'string'; and empty bytes for 'bytes'.\n"
"There are no default values for fields 'repeated'.\n"
"If the missing field is 'required' in a 'proto2' file, a warning item will be added to the tree.",
&add_default_value, add_default_value_policy_vals, false);

Expand Down
Loading

0 comments on commit 178fcbb

Please sign in to comment.