check_typed_item_calls.py: Flag bits set outside mask
Current errors are: Error: epan/dissectors/packet-asterix.c filter= asterix.021_161_TN 0x0fff with len is 4 but type FT_UINT8 indicates max of 2 and extra digits are non-zero (0f) Error: epan/dissectors/packet-capwap.c filter= capwap.control.message_element.ieee80211_station_session_key.flags_a 0x2000 with len is 4 but type FT_BOOLEAN indicates max of 1 and extra digits are non-zero (200) Error: epan/dissectors/packet-capwap.c filter= capwap.control.message_element.ieee80211_station_session_key.flags_c 0x1000 with len is 4 but type FT_BOOLEAN indicates max of 1 and extra digits are non-zero (100) Error: epan/dissectors/packet-cfdp.c filter= cfdp.trans_stat_2_b 0x6000 with len is 4 but type FT_UINT8 indicates max of 2 and extra digits are non-zero (60) Error: epan/dissectors/packet-cfdp.c filter= cfdp.suspension_ind_b 0x8000 with len is 4 but type FT_UINT8 indicates max of 2 and extra digits are non-zero (80) Error: epan/dissectors/packet-ixveriwave.c filter= ixveriwave.tx.factorydebug 0x7f80 with len is 4 but type FT_UINT8 indicates max of 2 and extra digits are non-zero (7f) Error: epan/dissectors/packet-opa-snc.c filter= opa.snc.rhf.eccerr 0x200000000 with len is 9 but type FT_BOOLEAN indicates max of 8 and extra digits are non-zero (2) Error: plugins/epan/ethercat/packet-ethercat-datagram.c filter= ecat.reg.ctrlstat.rdacc 0x0100 with len is 4 but type FT_BOOLEAN indicates max of 2 and extra digits are non-zero (01) Error: plugins/epan/ethercat/packet-ethercat-datagram.c filter= ecat.reg.ctrlstat.wracc 0x0200 with len is 4 but type FT_BOOLEAN indicates max of 2 and extra digits are non-zero (02) Error: plugins/epan/ethercat/packet-ethercat-datagram.c filter= ecat.reg.ctrlstat.reloadacc 0x0400 with len is 4 but type FT_BOOLEAN indicates max of 2 and extra digits are non-zero (04) Error: plugins/epan/ethercat/packet-ethercat-datagram.c filter= ecat.reg.ctrlstat.crcerr 0x0800 with len is 4 but type FT_BOOLEAN indicates max of 2 and extra digits are non-zero (08) Error: plugins/epan/ethercat/packet-ethercat-datagram.c filter= ecat.reg.ctrlstat.lderr 0x1000 with len is 4 but type FT_BOOLEAN indicates max of 2 and extra digits are non-zero (10) Error: plugins/epan/ethercat/packet-ethercat-datagram.c filter= ecat.reg.ctrlstat.cmderr 0x2000 with len is 4 but type FT_BOOLEAN indicates max of 2 and extra digits are non-zero (20) Error: plugins/epan/ethercat/packet-ethercat-datagram.c filter= ecat.reg.ctrlstat.wrerr 0x4000 with len is 4 but type FT_BOOLEAN indicates max of 2 and extra digits are non-zero (40) Error: plugins/epan/ethercat/packet-ethercat-datagram.c filter= ecat.reg.ctrlstat.busy 0x8000 with len is 4 but type FT_BOOLEAN indicates max of 2 and extra digits are non-zero (80)
This commit is contained in:
parent
9bf24deb2d
commit
ef2468662b
|
@ -334,7 +334,8 @@ class Item:
|
|||
elif self.type_modifier == 'SEP_DOT':
|
||||
return 64
|
||||
else:
|
||||
return int(self.type_modifier)
|
||||
# Round up to next nibble.
|
||||
return int(self.type_modifier)+3
|
||||
else:
|
||||
return field_widths[self.item_type]
|
||||
|
||||
|
@ -352,16 +353,27 @@ class Item:
|
|||
def check_num_digits(self, mask):
|
||||
if mask.startswith('0x') and len(mask) > 3:
|
||||
global warnings_found
|
||||
global errors_found
|
||||
if len(mask) % 2:
|
||||
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))
|
||||
'expected max for', self.item_type, 'is', int((self.get_field_width_in_bits())/4))
|
||||
warnings_found += 1
|
||||
|
||||
if self.item_type in field_widths:
|
||||
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))
|
||||
warnings_found += 1
|
||||
extra_digits = mask[2:2+(len(mask)-2 - int(self.get_field_width_in_bits()/4))]
|
||||
# Its an error if any of these are non-zero, as they won't have any effect!
|
||||
if extra_digits != '0'*len(extra_digits):
|
||||
print('Error:', 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),
|
||||
"and extra digits are non-zero (" + extra_digits + ")")
|
||||
errors_found += 1
|
||||
else:
|
||||
# If has leading zeros, still confusing, so warn.
|
||||
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))
|
||||
warnings_found += 1
|
||||
|
||||
else:
|
||||
print('Warning:', self.filename, 'filter=', self.filter, ' - item has type', self.item_type, 'but mask set:', mask)
|
||||
warnings_found += 1
|
||||
|
|
Loading…
Reference in New Issue