diff options
-rw-r--r-- | epan/dissectors/packet-cisco-erspan.c | 8 | ||||
-rw-r--r-- | epan/dissectors/packet-hci_mon.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-iso7816.c | 8 | ||||
-rw-r--r-- | epan/dissectors/packet-mplstp-oam.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-mswsp.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-ppcap.c | 12 | ||||
-rw-r--r-- | epan/dissectors/packet-pw-oam.c | 2 | ||||
-rw-r--r-- | plugins/epan/ethercat/packet-ecatmb.c | 6 | ||||
-rw-r--r-- | plugins/epan/profinet/packet-pn-dcp.c | 16 | ||||
-rwxr-xr-x | tools/check_typed_item_calls.py | 44 |
10 files changed, 60 insertions, 42 deletions
diff --git a/epan/dissectors/packet-cisco-erspan.c b/epan/dissectors/packet-cisco-erspan.c index 987fa60aa8..1e8c15d4d0 100644 --- a/epan/dissectors/packet-cisco-erspan.c +++ b/epan/dissectors/packet-cisco-erspan.c @@ -519,7 +519,7 @@ proto_register_erspan(void) 0x03fff000, NULL, HFILL }}, { &hf_erspan_pid1_domain_id, - { "VSM Domain ID", "erspan.pid1.vsmid", FT_UINT16, BASE_DEC, NULL, + { "VSM Domain ID", "erspan.pid1.vsmid", FT_UINT32, BASE_DEC, NULL, 0x00000fff, NULL, HFILL }}, { &hf_erspan_pid1_port_index, @@ -532,7 +532,7 @@ proto_register_erspan(void) 0x03ffc000, NULL, HFILL }}, { &hf_erspan_pid3_port_index, - { "Port ID/Index", "erspan.pid3.port_index", FT_UINT16, BASE_DEC, NULL, + { "Port ID/Index", "erspan.pid3.port_index", FT_UINT32, BASE_DEC, NULL, 0x00003fff, NULL, HFILL }}, { &hf_erspan_pid3_timestamp, @@ -554,11 +554,11 @@ proto_register_erspan(void) /* ID = 5 or 6 */ { &hf_erspan_pid5_switchid, - { "Switch ID", "erspan.pid5.switchid", FT_UINT16, BASE_DEC, NULL, + { "Switch ID", "erspan.pid5.switchid", FT_UINT32, BASE_DEC, NULL, 0x03ff0000, NULL, HFILL }}, { &hf_erspan_pid5_port_index, - { "Port ID/Index", "erspan.pid5.port_index", FT_UINT16, BASE_DEC, NULL, + { "Port ID/Index", "erspan.pid5.port_index", FT_UINT32, BASE_DEC, NULL, 0x0000ffff, NULL, HFILL }}, { &hf_erspan_pid5_timestamp, diff --git a/epan/dissectors/packet-hci_mon.c b/epan/dissectors/packet-hci_mon.c index cff727ce08..e9a8b07bae 100644 --- a/epan/dissectors/packet-hci_mon.c +++ b/epan/dissectors/packet-hci_mon.c @@ -535,7 +535,7 @@ proto_register_hci_mon(void) }, { &hf_manufacturer, { "Manufacturer", "hci_mon.manufacturer", - FT_UINT16, BASE_HEX, NULL, 0x000, + FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } }, { &hf_system_note, diff --git a/epan/dissectors/packet-iso7816.c b/epan/dissectors/packet-iso7816.c index 066c5538c4..2361ad0519 100644 --- a/epan/dissectors/packet-iso7816.c +++ b/epan/dissectors/packet-iso7816.c @@ -840,19 +840,19 @@ proto_register_iso7816(void) }, { &hf_iso7816_atr_next_ta_present, { "TA(i+1) present", "iso7816.atr.next_ta_present", - FT_BOOLEAN, BASE_HEX, NULL, 0x10, NULL, HFILL } + FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL } }, { &hf_iso7816_atr_next_tb_present, { "TB(i+1) present", "iso7816.atr.next_tb_present", - FT_BOOLEAN, BASE_HEX, NULL, 0x20, NULL, HFILL } + FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL } }, { &hf_iso7816_atr_next_tc_present, { "TC(i+1) present", "iso7816.atr.next_tc_present", - FT_BOOLEAN, BASE_HEX, NULL, 0x40, NULL, HFILL } + FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL } }, { &hf_iso7816_atr_next_td_present, { "TD(i+1) present", "iso7816.atr.next_td_present", - FT_BOOLEAN, BASE_HEX, NULL, 0x80, NULL, HFILL } + FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL } }, { &hf_iso7816_atr_k, { "Number K of historical bytes", "iso7816.atr.k", diff --git a/epan/dissectors/packet-mplstp-oam.c b/epan/dissectors/packet-mplstp-oam.c index baad281cef..934aa56173 100644 --- a/epan/dissectors/packet-mplstp-oam.c +++ b/epan/dissectors/packet-mplstp-oam.c @@ -298,7 +298,7 @@ proto_register_mplstp_fm(void) { &hf_mplstp_fm_flags, { "FM Flags", "mplstp_oam.flags", - FT_UINT8, BASE_HEX, NULL, 0x0000, "MPLS-TP FM Flags", HFILL} + FT_UINT8, BASE_HEX, NULL, 0x0, "MPLS-TP FM Flags", HFILL} }, { &hf_mplstp_fm_flags_l, diff --git a/epan/dissectors/packet-mswsp.c b/epan/dissectors/packet-mswsp.c index 38bcefd072..f414b5b137 100644 --- a/epan/dissectors/packet-mswsp.c +++ b/epan/dissectors/packet-mswsp.c @@ -6452,7 +6452,7 @@ proto_register_mswsp(void) &hf_mswsp_bool_options_cursor, { "Cursor", "mswsp.CPMCreateQuery.RowSetProperties.uBooleanOptions.cursor", FT_UINT32, - BASE_HEX, VALS(cursor_vals), 0x0000000007, "Cursor Type", HFILL + BASE_HEX, VALS(cursor_vals), 0x00000007, "Cursor Type", HFILL } }, { diff --git a/epan/dissectors/packet-ppcap.c b/epan/dissectors/packet-ppcap.c index 12a583825a..0b99ef3420 100644 --- a/epan/dissectors/packet-ppcap.c +++ b/epan/dissectors/packet-ppcap.c @@ -631,22 +631,22 @@ module_t *ppcap_module; BASE_DEC, NULL, 0x00, NULL, HFILL}}, { &hf_ppcap_destination_ip_address1, { "Destination IP Address", "ppcap.destination_ip_address1", FT_IPv4, - BASE_NONE, NULL, 0x00, NULL, HFILL}}, + BASE_NONE, NULL, 0x0, NULL, HFILL}}, { &hf_ppcap_destination_ip_address2, { "Destination IP Address", "ppcap.destination_ip_address2", FT_IPv6, - BASE_NONE, NULL, 0x00, NULL, HFILL}}, + BASE_NONE, NULL, 0x0, NULL, HFILL}}, { &hf_ppcap_source_nodeid, { "Source Node ID", "ppcap.source_nodeid", FT_STRING, - BASE_NONE, NULL, 0x00, NULL, HFILL}}, + BASE_NONE, NULL, 0x0, NULL, HFILL}}, { &hf_ppcap_destination_nodeid, { "Destination Node ID", "ppcap.destination_address", FT_STRING, - BASE_NONE, NULL, 0x00, NULL, HFILL}}, + BASE_NONE, NULL, 0x0, NULL, HFILL}}, { &hf_ppcap_info, { "Info", "ppcap.info", FT_STRING, - BASE_NONE, NULL, 0x0000, NULL, HFILL}}, + BASE_NONE, NULL, 0x0, NULL, HFILL}}, { &hf_ppcap_payload_data, { "Payload Data", "ppcap.payload_data", FT_BYTES, - BASE_NONE, NULL, 0x0000, NULL, HFILL}}, + BASE_NONE, NULL, 0x0, NULL, HFILL}}, { &hf_ppcap_local_port, { "Local Port", "ppcap.local_port", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL}}, diff --git a/epan/dissectors/packet-pw-oam.c b/epan/dissectors/packet-pw-oam.c index 3dcc115ffb..61908df83f 100644 --- a/epan/dissectors/packet-pw-oam.c +++ b/epan/dissectors/packet-pw-oam.c @@ -146,7 +146,7 @@ proto_register_pw_oam(void) {&hf_pw_oam_flags, {"Flags", "pw_oam.flags", FT_UINT8, - BASE_HEX, NULL, 0x0000, "OAM Flags", HFILL }}, + BASE_HEX, NULL, 0x0, "OAM Flags", HFILL }}, {&hf_pw_oam_flags_a, {"Acknowledgement", "pw_oam.flags_a", diff --git a/plugins/epan/ethercat/packet-ecatmb.c b/plugins/epan/ethercat/packet-ecatmb.c index 696a681db0..d3e2fde551 100644 --- a/plugins/epan/ethercat/packet-ecatmb.c +++ b/plugins/epan/ethercat/packet-ecatmb.c @@ -1855,11 +1855,11 @@ void proto_register_ecat_mailbox(void) }, { &hf_ecat_mailbox_soe_header_opcode, { "SoE OpCode", "ecat_mailbox.soe_opcode", - FT_UINT16, BASE_DEC, VALS(SoeOpcode), 0x00000007, NULL, HFILL } + FT_UINT16, BASE_DEC, VALS(SoeOpcode), 0x0007, NULL, HFILL } }, { &hf_ecat_mailbox_soe_header_incomplete, { "More Follows...", "ecat_mailbox.soe_header_incomplete", - FT_BOOLEAN, 16, TFS(&flags_set_truth), 0x00000008, NULL, HFILL } + FT_BOOLEAN, 16, TFS(&flags_set_truth), 0x0008, NULL, HFILL } }, { &hf_ecat_mailbox_soe_header_error, { "Error", "ecat_mailbox.soe_header_error", @@ -1868,7 +1868,7 @@ void proto_register_ecat_mailbox(void) }, { &hf_ecat_mailbox_soe_header_driveno, { "Drive No", "ecat_mailbox.soe_header_driveno", - FT_UINT16, BASE_DEC, NULL, 0x000000e0, NULL, HFILL } + FT_UINT16, BASE_DEC, NULL, 0x00e0, NULL, HFILL } }, { &hf_ecat_mailbox_soe_header_datastate, { "Datastate", "ecat_mailbox.soe_header_datastate", diff --git a/plugins/epan/profinet/packet-pn-dcp.c b/plugins/epan/profinet/packet-pn-dcp.c index 6a306a938c..1392eb8405 100644 --- a/plugins/epan/profinet/packet-pn-dcp.c +++ b/plugins/epan/profinet/packet-pn-dcp.c @@ -285,8 +285,8 @@ static const value_string pn_dcp_suboption_device[] = { { 0, NULL } }; -static const true_false_string pn_dcp_rsi_properties_value_bit[] = - { { "Available", "Not available" } }; +static const true_false_string pn_dcp_rsi_properties_value_bit = + { "Available", "Not available" }; #define PNDCP_SUBOPTION_DHCP_CLIENT_ID 61 #define PNDCP_SUBOPTION_DHCP_CONTROL_FOR_ADDRESS_RES 255 @@ -1622,32 +1622,32 @@ proto_register_pn_dcp (void) { &hf_pn_dcp_rsi_properties_value_bit0, { "IP Stack", "pn_dcp.suboption_device_rsi_properties_value.bit0", - FT_BOOLEAN, 16, TFS(pn_dcp_rsi_properties_value_bit), 0x0001, + FT_BOOLEAN, 16, TFS(&pn_dcp_rsi_properties_value_bit), 0x0001, NULL, HFILL } }, { &hf_pn_dcp_rsi_properties_value_bit1, { "CLRPC Interface", "pn_dcp.suboption_device_rsi_properties_value.bit1", - FT_BOOLEAN, 16, TFS(pn_dcp_rsi_properties_value_bit), 0x0002, + FT_BOOLEAN, 16, TFS(&pn_dcp_rsi_properties_value_bit), 0x0002, NULL, HFILL } }, { &hf_pn_dcp_rsi_properties_value_bit2, { "RSI AR Interface", "pn_dcp.suboption_device_rsi_properties_value.bit2", - FT_BOOLEAN, 16, TFS(pn_dcp_rsi_properties_value_bit), 0x0004, + FT_BOOLEAN, 16, TFS(&pn_dcp_rsi_properties_value_bit), 0x0004, NULL, HFILL } }, { &hf_pn_dcp_rsi_properties_value_bit3, { "RSI AR Read Implicit Interface", "pn_dcp.suboption_device_rsi_properties_value.bit3", - FT_BOOLEAN, 16, TFS(pn_dcp_rsi_properties_value_bit), 0x0008, + FT_BOOLEAN, 16, TFS(&pn_dcp_rsi_properties_value_bit), 0x0008, NULL, HFILL } }, { &hf_pn_dcp_rsi_properties_value_bit4, { "RSI CIM Interface", "pn_dcp.suboption_device_rsi_properties_value.bit4", - FT_BOOLEAN, 16, TFS(pn_dcp_rsi_properties_value_bit), 0x0010, + FT_BOOLEAN, 16, TFS(&pn_dcp_rsi_properties_value_bit), 0x0010, NULL, HFILL } }, { &hf_pn_dcp_rsi_properties_value_bit5, { "RSI CIM Read Implicit Interface", "pn_dcp.suboption_device_rsi_properties_value.bit5", - FT_BOOLEAN, 16, TFS(pn_dcp_rsi_properties_value_bit), 0x0020, + FT_BOOLEAN, 16, TFS(&pn_dcp_rsi_properties_value_bit), 0x0020, NULL, HFILL } }, { &hf_pn_dcp_rsi_properties_value_otherbits, diff --git a/tools/check_typed_item_calls.py b/tools/check_typed_item_calls.py index 760010a352..706466dc83 100755 --- a/tools/check_typed_item_calls.py +++ b/tools/check_typed_item_calls.py @@ -134,7 +134,7 @@ class ProtoTreeAddItemCheck(APICheck): if call.hf_name in items: if call.length and items[call.hf_name].item_type in self.lengths: if self.lengths[items[call.hf_name].item_type] < call.length: - print(self.file + ':' + str(call.line_number), + print('Warning:'. self.file + ':' + str(call.line_number), 'proto_tree_add_item called for', call.hf_name, ' - ', 'item type is', items[call.hf_name].item_type, 'but call has len', call.length) @@ -156,7 +156,10 @@ known_non_contiguous_fields = { 'wlan.fixed.capabilities.cfpoll.sta', 'zbee_zcl_se.pp.attr.payment_control_configuration.reserved', # matches other fields in same sequence 'zbee_zcl_se.pp.snapshot_payload_cause.reserved', # matches other fields in same sequence 'ebhscr.eth.rsv', # matches other fields in same sequence - 'v120.lli' # non-contiguous field (http://www.acacia-net.com/wwwcla/protocol/v120_l2.htm) + 'v120.lli', # non-contiguous field (http://www.acacia-net.com/wwwcla/protocol/v120_l2.htm) + 'stun.type.class', + 'bssgp.csg_id' + } ################################################################################################## @@ -187,7 +190,7 @@ class Item: previousItem = None - def __init__(self, filename, filter, label, item_type, mask=None, check_mask=False, check_label=False, check_consecutive=False): + def __init__(self, filename, filter, label, item_type, type_modifier, mask=None, check_mask=False, check_label=False, check_consecutive=False): self.filename = filename self.filter = filter self.label = label @@ -215,6 +218,7 @@ class Item: print('Warning: ' + filename + 'filter=' + filter + ' \"' + label + '\" begins or ends with a space') self.item_type = item_type + self.type_modifier = type_modifier # Optionally check that mask bits are contiguous if check_mask: @@ -271,7 +275,7 @@ class Item: print('unexpected item_type is ', self.item_type) field_width = 64 else: - field_width = field_widths[self.item_type] + field_width = self.get_field_width_in_bits() # Its a problem is the mask_width is > field_width - some of the bits won't get looked at!? @@ -284,7 +288,7 @@ class Item: issues_found += 1 # Now, any more zero set bits are an error! - if self.filter in known_non_contiguous_fields: + if self.filter in known_non_contiguous_fields or self.filter.startswith('rtpmidi'): # Don't report if we know this one is Ok. return while n <= 63: @@ -293,6 +297,17 @@ class Item: return n += 1 + def get_field_width_in_bits(self): + if self.item_type == 'FT_BOOLEAN': + if self.type_modifier == 'NULL': + return 8 # i.e. 1 byte + elif self.type_modifier == 'BASE_NONE': + return 8 + else: + return int(self.type_modifier) + else: + return field_widths[self.item_type] + def check_mask_too_long(self, mask): if not self.mask_value: return @@ -300,23 +315,25 @@ class Item: # There may be good reasons for having a wider field/mask, e.g. if there are 32 related flags, showing them # all lined up as part of the same word may make it clearer. But some cases have been found # where the grouping does not seem to be natural.. - print('Warning: ', self.filename, 'filter=', self.filter, ' - mask seems to be wider than necessary?', mask) + print('Warning: ', self.filename, 'filter=', self.filter, ' - mask with leading or trailing 0 bytes suggests field', self.item_type, 'may be wider than necessary?', mask) global issues_found issues_found += 1 def check_num_digits(self, mask): - if mask.startswith('0x'): + if mask.startswith('0x') and len(mask) > 3: global issues_found if len(mask) % 2: - print('Warning: ', self.filename, 'filter=', self.filter, ' - mask has odd number of digits', mask, int(field_widths[self.item_type]/8)) + print('Warning: ', self.filename, 'filter=', self.filter, ' - mask has odd number of digits', mask, + 'expected max for', self.item_type, 'is', int(self.get_field_width_in_bits()/4)) issues_found += 1 if self.item_type in field_widths: - if len(mask)-2 > int(field_widths[self.item_type]/4): - print('Warning: ', self.filename, 'filter=', self.filter, self.mask, "with len is", len(mask)-2, "but type", self.item_type, " indicates max of", int(field_widths[self.item_type]/4)) + if len(mask)-2 > self.get_field_width_in_bits()/4: + print('Warning: ', self.filename, 'filter=', self.filter, self.mask, "with len is", len(mask)-2, + "but type", self.item_type, " indicates max of", int(self.get_field_width_in_bits()/4)) issues_found += 1 else: - print('Warning: ', self.filename, 'filter=', self.filter, ' - mask has type', self.item_type, 'but mask set:', mask) + print('Warning: ', self.filename, 'filter=', self.filter, ' - item has type', self.item_type, 'but mask set:', mask) issues_found += 1 @@ -416,11 +433,12 @@ def find_items(filename, check_mask=False, check_label=False, check_consecutive= contents = f.read() # Remove comments so as not to trip up RE. contents = removeComments(contents) - matches = re.finditer(r'.*\{\s*\&(hf_.*),\s*{\s*\"(.+)\",\s*\"([a-zA-Z0-9_\-\.]+)\",\s*([A-Z0-9_]*),\s*.*,\s*([A-Za-z0-9x_\(\)]*),\s*([a-z0-9x_]*),', contents) + matches = re.finditer(r'.*\{\s*\&(hf_.*),\s*{\s*\"(.+)\",\s*\"([a-zA-Z0-9_\-\.]+)\",\s*([A-Z0-9_]*),\s*(.*),\s*([A-Za-z0-9x_\(\)]*),\s*([a-z0-9x_]*),', contents) for m in matches: # Store this item. hf = m.group(1) - items[hf] = Item(filename, filter=m.group(3), label=m.group(2), item_type=m.group(4), mask=m.group(6), + items[hf] = Item(filename, filter=m.group(3), label=m.group(2), item_type=m.group(4), mask=m.group(7), + type_modifier=m.group(5), check_mask=check_mask, check_label=check_label, check_consecutive=(not is_generated and check_consecutive)) |