aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Mathieson <martin.mathieson@keysight.com>2023-09-03 17:35:16 +0100
committerMartin Mathieson <martin.mathieson@keysight.com>2023-09-03 17:35:16 +0100
commitfc16c74e42a65f32c4d81c035b32b522c7d4c3f9 (patch)
treee2858be98c956c07538957100bd88cab4955497d
parent93a4164b50f336fb3fdf7204f775d20b2117310d (diff)
check_typed_item_calls.py: some updates
-rw-r--r--epan/dissectors/packet-dhcp-failover.c2
-rw-r--r--epan/dissectors/packet-mpeg-dsmcc.c2
-rw-r--r--epan/dissectors/packet-openwire.c2
-rw-r--r--epan/dissectors/packet-pfcp.c4
-rw-r--r--epan/dissectors/packet-tns.c2
-rw-r--r--epan/dissectors/packet-uavcan-dsdl.c4
-rwxr-xr-xtools/check_typed_item_calls.py43
7 files changed, 32 insertions, 27 deletions
diff --git a/epan/dissectors/packet-dhcp-failover.c b/epan/dissectors/packet-dhcp-failover.c
index 6f3f0eac1e..97f11f968e 100644
--- a/epan/dissectors/packet-dhcp-failover.c
+++ b/epan/dissectors/packet-dhcp-failover.c
@@ -1226,7 +1226,7 @@ proto_register_dhcpfo(void)
NULL, HFILL }
},
{&hf_dhcpfo_binding_status,
- {"Type", "dhcpfo.bindingstatus",
+ {"Status", "dhcpfo.bindingstatus",
FT_UINT32, BASE_DEC, VALS(binding_status_vals), 0,
NULL, HFILL }
},
diff --git a/epan/dissectors/packet-mpeg-dsmcc.c b/epan/dissectors/packet-mpeg-dsmcc.c
index c26f5924d2..ca5c412f8f 100644
--- a/epan/dissectors/packet-mpeg-dsmcc.c
+++ b/epan/dissectors/packet-mpeg-dsmcc.c
@@ -2822,7 +2822,7 @@ proto_register_dsmcc(void)
/* table 4-89 Q.922 Connection - start */
{ &hf_dsmcc_un_sess_rsrc_dlci_count, {
"DL CI Count", "mpeg_dsmcc.un_sess.rsrc_dlci_count",
- FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
+ FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL
} },
{ &hf_dsmcc_un_sess_rsrc_dlci, {
diff --git a/epan/dissectors/packet-openwire.c b/epan/dissectors/packet-openwire.c
index a0cbd3a1e8..a057d7d96c 100644
--- a/epan/dissectors/packet-openwire.c
+++ b/epan/dissectors/packet-openwire.c
@@ -1850,7 +1850,7 @@ proto_register_openwire(void)
{ "Value", "openwire.connectionid.value", FT_STRINGZ, BASE_NONE, NULL, 0x0, "Openwire ConnectionId Value", HFILL }},
{ &hf_openwire_sessionid_connectionid,
- { "Connection", "openwire.sessionid.connectionid", FT_STRINGZ, BASE_NONE, NULL, 0x0, "Openwire SessionId ConnectionId", HFILL }},
+ { "ConnectionId", "openwire.sessionid.connectionid", FT_STRINGZ, BASE_NONE, NULL, 0x0, "Openwire SessionId ConnectionId", HFILL }},
{ &hf_openwire_sessionid_value,
{ "Value", "openwire.sessionid.value", FT_INT64, BASE_DEC, NULL, 0x0, "Openwire SessionId Value", HFILL }},
diff --git a/epan/dissectors/packet-pfcp.c b/epan/dissectors/packet-pfcp.c
index 760a23fb4f..912e347ea0 100644
--- a/epan/dissectors/packet-pfcp.c
+++ b/epan/dissectors/packet-pfcp.c
@@ -11937,7 +11937,7 @@ proto_register_pfcp(void)
},
{ &hf_pfcp_msg_length,
{ "Length", "pfcp.length",
- FT_UINT8, BASE_DEC, NULL, 0x0,
+ FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_pfcp_hdr_flags,
@@ -12171,7 +12171,7 @@ proto_register_pfcp(void)
},
{ &hf_pfcp_precedence,
{ "Precedence", "pfcp.precedence",
- FT_UINT16, BASE_DEC, NULL, 0x0,
+ FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_pfcp_source_interface,
diff --git a/epan/dissectors/packet-tns.c b/epan/dissectors/packet-tns.c
index 0db20af0bf..aab3a62008 100644
--- a/epan/dissectors/packet-tns.c
+++ b/epan/dissectors/packet-tns.c
@@ -1275,7 +1275,7 @@ void proto_register_tns(void)
"Request", "tns.request", FT_BOOLEAN, BASE_NONE,
NULL, 0x0, "TRUE if TNS request", HFILL }},
{ &hf_tns_length, {
- "Packet Length", "tns.length", FT_UINT16, BASE_DEC,
+ "Packet Length", "tns.length", FT_UINT32, BASE_DEC,
NULL, 0x0, "Length of TNS packet", HFILL }},
{ &hf_tns_packet_checksum, {
"Packet Checksum", "tns.packet_checksum", FT_UINT16, BASE_HEX,
diff --git a/epan/dissectors/packet-uavcan-dsdl.c b/epan/dissectors/packet-uavcan-dsdl.c
index bf8339c689..1988a5ef1f 100644
--- a/epan/dissectors/packet-uavcan-dsdl.c
+++ b/epan/dissectors/packet-uavcan-dsdl.c
@@ -597,7 +597,7 @@ proto_register_dsdl(void)
{"Size", "uavcan_dsdl.file.GetInfo.size",
FT_UINT40, BASE_DEC, NULL, 0x0, NULL, HFILL}},
{&hf_uavcan_getinfo_timestamp,
- {"Path", "uavcan_dsdl.file.GetInfo.timestamp",
+ {"Timestamp", "uavcan_dsdl.file.GetInfo.timestamp",
FT_UINT40, BASE_DEC, NULL, 0x0, NULL, HFILL}},
{&hf_uavcan_getinfo_is_file_not_directory,
{"Is file not directory",
@@ -622,7 +622,7 @@ proto_register_dsdl(void)
{"Directory path", "uavcan_dsdl.file.list.directory_path",
FT_UINT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{&hf_uavcan_entry_base_name,
- {"Directory path", "uavcan_dsdl.file.list.entry_base_name",
+ {"Base name", "uavcan_dsdl.file.list.entry_base_name",
FT_UINT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{&hf_uavcan_modify_source_path,
{"Source", "uavcan_dsdl.file.Modify.source",
diff --git a/tools/check_typed_item_calls.py b/tools/check_typed_item_calls.py
index 398f800e21..7254e6a4cc 100755
--- a/tools/check_typed_item_calls.py
+++ b/tools/check_typed_item_calls.py
@@ -11,14 +11,8 @@ import argparse
import signal
import subprocess
-# This utility scans the dissector code for proto_tree_add_...() calls that constrain the type
-# or length of the item added, and checks that the used item is acceptable.
-#
-# - Note that this can only work where the hf_item variable or length is passed in directly - simple
-# macro substitution is now done in a limited way
-
+# This utility scans the dissector code for various issues.
# TODO:
-# - Attempt to check for allowed encoding types (most likely will be literal values |'d)?
# - Create maps from type -> display types for hf items (see display (FIELDDISPLAY)) in docs/README.dissector
@@ -640,7 +634,7 @@ class Item:
previousItem = None
- def __init__(self, filename, hf, filter, label, item_type, type_modifier, macros, mask=None,
+ def __init__(self, filename, hf, filter, label, item_type, display, strings, macros, mask=None,
check_mask=False, mask_exact_width=False, check_label=False, check_consecutive=False):
self.filename = filename
self.hf = hf
@@ -683,7 +677,7 @@ class Item:
warnings_found += 1
self.item_type = item_type
- self.type_modifier = type_modifier
+ self.display = display
# Optionally check that mask bits are contiguous
if check_mask:
@@ -692,9 +686,19 @@ class Item:
self.check_num_digits(self.mask)
self.check_digits_all_zeros(self.mask)
+ # N.B. these checks are already done by checkApis.pl
+ if strings.find('RVALS') != -1 and display.find('BASE_RANGE_STRING') == -1:
+ print('Warning: ' + filename, hf, 'filter "' + filter + ' strings has RVALS but display lacks BASE_RANGE_STRING')
+ warnings_found += 1
+
+ # For RVALS, is BASE_RANGE_STRING also set (checked by checkApis.pl)?
+ if strings.find('VALS_EXT_PTR') != -1 and display.find('BASE_EXT_STRING') == -1:
+ print('Warning: ' + filename, hf, 'filter "' + filter + ' strings has VALS_EXT_PTR but display lacks BASE_EXT_STRING')
+ warnings_found += 1
+
def __str__(self):
- return 'Item ({0} "{1}" {2} type={3}:{4} mask={5})'.format(self.filename, self.label, self.filter, self.item_type, self.type_modifier, self.mask)
+ return 'Item ({0} "{1}" {2} type={3}:{4} {5} mask={6})'.format(self.filename, self.label, self.filter, self.item_type, self.display, self.strings, self.mask)
@@ -790,16 +794,16 @@ class Item:
def get_field_width_in_bits(self):
if self.item_type == 'FT_BOOLEAN':
- if self.type_modifier == 'NULL':
+ if self.display == 'NULL':
return 8 # i.e. 1 byte
- elif self.type_modifier == 'BASE_NONE':
+ elif self.display == 'BASE_NONE':
return 8
- elif self.type_modifier == 'SEP_DOT': # from proto.h, only meant for FT_BYTES
+ elif self.display == 'SEP_DOT': # from proto.h, only meant for FT_BYTES
return 64
else:
try:
# For FT_BOOLEAN, modifier is just numerical number of bits. Round up to next nibble.
- return int((int(self.type_modifier) + 3)/4)*4
+ return int((int(self.display) + 3)/4)*4
except:
return None
else:
@@ -844,7 +848,7 @@ class Item:
ideal_mask_width = int(self.get_field_width_in_bits()/4)
if self.item_type == 'FT_BOOLEAN' and ideal_mask_width < 16 and len(mask)-2 != ideal_mask_width:
print('Warning:', self.filename, self.hf, 'filter=', self.filter, 'mask', self.mask, "with len", len(mask)-2,
- "but type", self.item_type, "|", self.type_modifier, " indicates should be", int(self.get_field_width_in_bits()/4))
+ "but type", self.item_type, "|", self.display, " indicates should be", int(self.get_field_width_in_bits()/4))
warnings_found += 1
else:
@@ -906,6 +910,7 @@ class Item:
label = label.replace('(', '')
label = label.replace(')', '')
label = label.replace('/', '')
+ label = label.replace("'", '')
# OK if filter is abbrev of label.
@@ -923,9 +928,8 @@ class Item:
filter_numbers = [int(n) for n in re.findall(r'\d+', last_filter_orig)]
if len(label_numbers) == len(filter_numbers) and label_numbers != filter_numbers:
if reportNumericalMismatch:
- print('Warning:', self.filename, self.hf, 'label="' + self.label + '" has different **numbers** from filter="' + self.filter + '"')
+ print('Note:', self.filename, self.hf, 'label="' + self.label + '" has different **numbers** from filter="' + self.filter + '"')
print(label_numbers, filter_numbers)
- warnings_found += 1
return False
# If they match after trimming number from filter, they should match.
@@ -1145,7 +1149,8 @@ def find_items(filename, macros, check_mask=False, mask_exact_width=False, check
# Store this item.
hf = m.group(1)
items[hf] = Item(filename, hf, filter=m.group(3), label=m.group(2), item_type=m.group(4),
- type_modifier=m.group(5),
+ display=m.group(5),
+ strings=m.group(6),
macros=macros,
mask=m.group(7),
check_mask=check_mask,
@@ -1330,7 +1335,7 @@ def checkFile(filename, check_mask=False, mask_exact_width=False, check_label=Fa
matches += 1
# Only checking if almost every field does match.
- checking = len(items_defined) and matches<len(items_defined) and ((matches / len(items_defined)) > 0.9)
+ checking = len(items_defined) and matches<len(items_defined) and ((matches / len(items_defined)) > 0.93)
if checking:
print(filename, ':', matches, 'label-vs-filter matches of out of', len(items_defined), 'so reporting mismatches')
for hf in items_defined: