More value_string fixes

This commit is contained in:
Martin Mathieson 2023-09-28 15:29:30 +01:00
parent 3f3ef7f463
commit 10e312fde1
6 changed files with 42 additions and 39 deletions

View file

@ -223,9 +223,9 @@ static const value_string rt_flow_control_vals[] = {
static const value_string rt_services_vals[] = {
{0x00, "none"},
{0x04, "segment request count"},
{0x08, "Session control message request count"},
{0x0c, "reserved"},
{0x01, "segment request count"},
{0x02, "Session control message request count"},
{0x03, "reserved"},
{0x0, NULL}
};

View file

@ -250,9 +250,9 @@ static const value_string devicenet_group_select_vals[] = {
static const value_string devicenet_fragmented_message_type_vals[] = {
{ 0, "First Fragment" },
{ 0x40, "Middle fragment" },
{ 0x80, "Last fragment" },
{ 0xC0, "Fragment Acknowledge" },
{ 1, "Middle fragment" },
{ 2, "Last fragment" },
{ 3, "Fragment Acknowledge" },
{ 0, NULL }
};

View file

@ -464,9 +464,9 @@ static const value_string bssmap_field_element_ids[] = {
};
static const value_string bssap_cc_values[] = {
{ 0x00, "not further specified" },
{ 0x80, "FACCH or SDCCH" },
{ 0xc0, "SACCH" },
{ 0x0, "not further specified" },
{ 0x2, "FACCH or SDCCH" },
{ 0x3, "SACCH" },
{ 0, NULL } };
static const value_string bssap_sapi_values[] = {

View file

@ -722,16 +722,16 @@ static const value_string q931_l1_intermediate_rate_vals[] = {
};
static const value_string q931_l1_stop_bits_vals[] = {
{ 0x20, "1" },
{ 0x40, "1.5" },
{ 0x60, "2" },
{ 0x01, "1" },
{ 0x02, "1.5" },
{ 0x03, "2" },
{ 0, NULL }
};
static const value_string q931_l1_data_bits_vals[] = {
{ 0x08, "5" },
{ 0x10, "7" },
{ 0x18, "8" },
{ 0x1, "5" },
{ 0x2, "7" },
{ 0x3, "8" },
{ 0, NULL }
};
@ -766,8 +766,8 @@ static const value_string q931_uil2_vals[] = {
static value_string_ext q931_uil2_vals_ext = VALUE_STRING_EXT_INIT(q931_uil2_vals);
static const value_string q931_mode_vals[] = {
{ 0x20, "Normal mode" },
{ 0x40, "Extended mode" },
{ 0x1, "Normal mode" },
{ 0x2, "Extended mode" },
{ 0, NULL }
};
@ -1664,9 +1664,9 @@ dissect_q931_progress_indicator_ie(tvbuff_t *tvb, int offset, int len,
* information element.
*/
static const value_string q931_netid_type_vals[] = {
{ 0x00, "User specified" },
{ 0x20, "National network identification" },
{ 0x30, "International network identification" },
{ 0x0, "User specified" },
{ 0x2, "National network identification" },
{ 0x3, "International network identification" },
{ 0, NULL }
};
@ -1956,10 +1956,10 @@ dissect_q931_td_selection_and_int_ie(tvbuff_t *tvb, packet_info *pinfo, int offs
* Dissect a Packet layer binary parameters information element.
*/
static const value_string q931_fast_selected_vals[] = {
{ 0x00, "Fast select not requested" },
{ 0x08, "Fast select not requested" },
{ 0x10, "Fast select requested with no restriction of response" },
{ 0x18, "Fast select requested with restrictions of response" },
{ 0x0, "Fast select not requested" },
{ 0x1, "Fast select not requested" },
{ 0x2, "Fast select requested with no restriction of response" },
{ 0x3, "Fast select requested with restrictions of response" },
{ 0x00, NULL }
};
@ -2176,14 +2176,14 @@ dissect_q931_number_ie(packet_info *pinfo, tvbuff_t *tvb, int offset, int len,
* Dissect a party subaddress information element.
*/
static const value_string q931_subaddress_type_vals[] = {
{ 0x00, "X.213/ISO 8348 Add.2 NSAP" },
{ 0x20, "User-specified" },
{ 0x0, "X.213/ISO 8348 Add.2 NSAP" },
{ 0x2, "User-specified" },
{ 0, NULL }
};
static const value_string q931_odd_even_indicator_vals[] = {
{ 0x00, "Even number of address signals" },
{ 0x08, "Odd number of address signals" },
{ 0x0, "Even number of address signals" },
{ 0x1, "Odd number of address signals" },
{ 0, NULL }
};

View file

@ -3841,9 +3841,9 @@ static const value_string mu_resv0_strings[] =
static const value_string mu_action_field_strings[] =
{
{ 0x0000, "SSID" },
{ 0x2000, "Redirect With Vlan ID" },
{ 0x3000, "Vlan ID" },
{ 0x0, "SSID" },
{ 0x2, "Redirect With Vlan ID" },
{ 0x3, "Vlan ID" },
{ 0, NULL }
};

View file

@ -767,22 +767,25 @@ class Item:
self.mask_value = 0
def check_value_string_range(self, vs_min, vs_max):
# N,B, this doesn't reduce bit count when a mask is set!
item_width = self.get_field_width_in_bits()
if self.mask_value > 0:
# Have mask, so count number of bits set.
item_width = 0
for n in range(0,63):
item_width += 1 if self.check_bit(self.mask_value, n) else 0
if item_width is None:
# Type field defined by macro?
return
item_max = (2 ** item_width) - 1
if self.mask_value > 0:
# Distance between first and last '1'
bitBools = bin(self.mask_value)[2:]
mask_width = bitBools.rfind('1') - bitBools.find('1') + 1
else:
# No mask is effectively a full mask..
mask_width = item_width
item_max = (2 ** mask_width)
if vs_max > item_max:
global warnings_found
print('Warning:', self.filename, self.hf, 'filter=', self.filter,
self.strings, "has max value", vs_max, '(' + hex(vs_max) + ')', "which doesn't fit into", item_width, 'bits',
self.strings, "has max value", vs_max, '(' + hex(vs_max) + ')', "which doesn't fit into", mask_width, 'bits',
'( mask is', hex(self.mask_value), ')')
warnings_found += 1