From 00318b3267c22528134ffefa026f9a46abc3f5f9 Mon Sep 17 00:00:00 2001 From: nbertin Date: Wed, 6 Feb 2019 15:09:09 +0100 Subject: noe: updated decoding of messages display True/False if a property is of type "bool" display string if a property is of type "utf-8" Change-Id: I3655b401298fc4cca9bcf5388707c90c4c1540bb Reviewed-on: https://code.wireshark.org/review/31934 Petri-Dish: Alexis La Goutte Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/dissectors/packet-noe.c | 232 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 195 insertions(+), 37 deletions(-) (limited to 'epan/dissectors/packet-noe.c') diff --git a/epan/dissectors/packet-noe.c b/epan/dissectors/packet-noe.c index 29422ad744..e32b25e605 100644 --- a/epan/dissectors/packet-noe.c +++ b/epan/dissectors/packet-noe.c @@ -10,6 +10,8 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ +#include + #include "config.h" #include "epan/packet.h" @@ -98,7 +100,6 @@ static const value_string val_str_class[] = { {OPCODE_C_ime_context , "ime_context"}, {0, NULL} }; - static value_string_ext val_str_class_ext = VALUE_STRING_EXT_INIT(val_str_class); #define OPCODE_P_B_objectid 0 @@ -399,7 +400,6 @@ static const value_string val_str_props[] = { {OPCODE_P_A_end_date , "end_date"}, {0, NULL} }; - static value_string_ext val_str_props_ext = VALUE_STRING_EXT_INIT(val_str_props); #define OPCODE_EVT_CONTEXT_SWITCH 0 @@ -548,7 +548,6 @@ static const value_string val_str_event[] = { {OPCODE_EVT_ACTLISTBOX_DISMISSED , "EVT_ACTLISTBOX_DISMISSED"}, {0, NULL} }; - static value_string_ext val_str_event_ext = VALUE_STRING_EXT_INIT(val_str_event); #define P_BASIC 0 @@ -560,6 +559,119 @@ static value_string_ext val_str_event_ext = VALUE_STRING_EXT_INIT(val_str_event) #define C_INVALID 255 #define E_INVALID 255 +static guint utf8_properties[] = { + ((OPCODE_C_security << 8) | OPCODE_P_B_login ), + ((OPCODE_C_security << 8) | OPCODE_P_A_pem_data ), + ((OPCODE_C_security << 8) | OPCODE_P_A_serial_number), + ((OPCODE_C_security << 8) | OPCODE_P_A_owner_name ), + ((OPCODE_C_security << 8) | OPCODE_P_A_issuer_name ), + ((OPCODE_C_security << 8) | OPCODE_P_A_end_date ), + ((OPCODE_C_date << 8) | OPCODE_P_A_today ), + ((OPCODE_C_date << 8) | OPCODE_P_A_tomorrow ), + ((OPCODE_C_AOMV << 8) | OPCODE_P_A_label ), + ((OPCODE_C_AOMV << 8) | OPCODE_P_A_value ), + ((OPCODE_C_bluetooth << 8) | OPCODE_P_B_address ), + ((OPCODE_C_bluetooth << 8) | OPCODE_P_B_name ), + ((OPCODE_C_callstate << 8) | OPCODE_P_A_name ), + ((OPCODE_C_callstate << 8) | OPCODE_P_A_number ), + ((OPCODE_C_tabbox << 8) | OPCODE_P_A_label ), + ((OPCODE_C_tabbox << 8) | OPCODE_P_A_value ), + ((OPCODE_C_listbox << 8) | OPCODE_P_A_label ), + ((OPCODE_C_listbox << 8) | OPCODE_P_A_value ), + ((OPCODE_C_actionlistbox << 8) | OPCODE_P_A_label ), + ((OPCODE_C_actionlistbox << 8) | OPCODE_P_A_value ), + ((OPCODE_C_textbox << 8) | OPCODE_P_B_label ), + ((OPCODE_C_textbox << 8) | OPCODE_P_B_append ), + ((OPCODE_C_textbox << 8) | OPCODE_P_B_overwrite ), + ((OPCODE_C_actionbox << 8) | OPCODE_P_B_label ), + ((OPCODE_C_actionbox << 8) | OPCODE_P_B_value ), + ((OPCODE_C_inputbox << 8) | OPCODE_P_B_label ), + ((OPCODE_C_inputbox << 8) | OPCODE_P_B_value ), + ((OPCODE_C_inputbox << 8) | OPCODE_P_B_mask ), + ((OPCODE_C_inputbox << 8) | OPCODE_P_B_append ), + ((OPCODE_C_checkbox << 8) | OPCODE_P_B_label ), + ((OPCODE_C_datebox << 8) | OPCODE_P_B_format ), + ((OPCODE_C_timerbox << 8) | OPCODE_P_B_label ), + ((OPCODE_C_timerbox << 8) | OPCODE_P_B_format ), + ((OPCODE_C_dialogbox << 8) | OPCODE_P_B_label ), + ((OPCODE_C_dialogbox << 8) | OPCODE_P_A_action_label ), + ((OPCODE_C_dialogbox << 8) | OPCODE_P_A_action_value ), + ((OPCODE_C_sliderbar << 8) | OPCODE_P_B_label ), + ((OPCODE_C_progressbar << 8) | OPCODE_P_B_label ), + ((OPCODE_C_imagebox << 8) | OPCODE_P_B_URI ), + ((OPCODE_C_AOMEL << 8) | OPCODE_P_A_label ), + ((OPCODE_C_telephonicboxitem << 8) | OPCODE_P_B_label ), + ((OPCODE_C_bluetooth_device << 8) | OPCODE_P_B_address ), + ((OPCODE_C_bluetooth_device << 8) | OPCODE_P_B_name ), + ((OPCODE_C_bluetooth_device << 8) | OPCODE_P_B_pin ), + ((OPCODE_C_headerbox << 8) | OPCODE_P_B_label ), + ((OPCODE_C_ime_context << 8) | OPCODE_P_A_name ) +}; + +static guint bool_properties[] = { + ((OPCODE_C_terminal << 8) | OPCODE_P_B_negative_ack ), + ((OPCODE_C_terminal << 8) | OPCODE_P_B_CS_idle_state ), + ((OPCODE_C_terminal << 8) | OPCODE_P_B_PS_idle_state ), + ((OPCODE_C_terminal << 8) | OPCODE_P_B_use_customisation), + ((OPCODE_C_terminal << 8) | OPCODE_P_B_ime_lock ), + ((OPCODE_C_audioconfig << 8) | OPCODE_P_B_enable ), + ((OPCODE_C_audioconfig << 8) | OPCODE_P_B_qos_ticket ), + ((OPCODE_C_leds << 8) | OPCODE_P_B_onoff ), + ((OPCODE_C_screen << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_screen << 8) | OPCODE_P_B_clearscreen ), + ((OPCODE_C_AOMV << 8) | OPCODE_P_B_all_icons_off ), + ((OPCODE_C_AOMV << 8) | OPCODE_P_A_enable ), + ((OPCODE_C_bluetooth << 8) | OPCODE_P_B_bth_ringing ), + ((OPCODE_C_bluetooth << 8) | OPCODE_P_B_bonded_devices ), + ((OPCODE_C_callstate << 8) | OPCODE_P_B_enable ), + ((OPCODE_C_framebox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_framebox << 8) | OPCODE_P_B_autospread ), + ((OPCODE_C_framebox << 8) | OPCODE_P_B_cycling ), + ((OPCODE_C_tabbox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_listbox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_listbox << 8) | OPCODE_P_B_showevent ), + ((OPCODE_C_listbox << 8) | OPCODE_P_B_showactive ), + ((OPCODE_C_listbox << 8) | OPCODE_P_B_circular ), + ((OPCODE_C_listbox << 8) | OPCODE_P_B_disablelongpress ), + ((OPCODE_C_actionlistbox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_textbox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_actionbox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_inputbox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_inputbox << 8) | OPCODE_P_B_enable ), + ((OPCODE_C_inputbox << 8) | OPCODE_P_B_password ), + ((OPCODE_C_inputbox << 8) | OPCODE_P_B_focus ), + ((OPCODE_C_inputbox << 8) | OPCODE_P_B_inputborder ), + ((OPCODE_C_checkbox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_checkbox << 8) | OPCODE_P_B_enable ), + ((OPCODE_C_checkbox << 8) | OPCODE_P_B_state ), + ((OPCODE_C_datebox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_timerbox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_popupbox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_popupbox << 8) | OPCODE_P_B_modal ), + ((OPCODE_C_dialogbox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_dialogbox << 8) | OPCODE_P_B_modal ), + ((OPCODE_C_sliderbar << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_progressbar << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_imagebox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_iconbox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_AOMVbox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_telephonicbox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_telephonicbox << 8) | OPCODE_P_B_enable ), + ((OPCODE_C_AOMEL << 8) | OPCODE_P_B_all_icons_off ), + ((OPCODE_C_AOMEL << 8) | OPCODE_P_B_all_labels_off ), + ((OPCODE_C_AOM10 << 8) | OPCODE_P_B_all_icons_off ), + ((OPCODE_C_AOM40 << 8) | OPCODE_P_B_all_icons_off ), + ((OPCODE_C_telephonicboxitem << 8) | OPCODE_P_B_focus ), + ((OPCODE_C_bluetooth_device << 8) | OPCODE_P_B_enable ), + ((OPCODE_C_bluetooth_device << 8) | OPCODE_P_B_bonded ), + ((OPCODE_C_headerbox << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_ime_context << 8) | OPCODE_P_B_enable ), + ((OPCODE_C_ime_context << 8) | OPCODE_P_B_visible ), + ((OPCODE_C_ime_context << 8) | OPCODE_P_A_mode ), + ((OPCODE_C_ime_context << 8) | OPCODE_P_A_state ), + ((OPCODE_C_ime_context << 8) | OPCODE_P_A_enable ) +}; + /*----------------------------------------------------------------------------- globals ---------------------------------------------------------------------------*/ @@ -585,11 +697,13 @@ static int hf_noe_value = -1; static int hf_noe_message = -1; static int hf_noe_key_name = -1; static int hf_noe_bonded = -1; +static int hf_noe_property_item_bool = -1; static int hf_noe_property_item_u8 = -1; static int hf_noe_property_item_u16 = -1; static int hf_noe_property_item_u24 = -1; static int hf_noe_property_item_u32 = -1; static int hf_noe_property_item_bytes = -1; +static int hf_noe_property_item_utf8 = -1; static int hf_event_bt_key = -1; static int hf_event_context_switch = -1; static int hf_evt_locappl_enable = -1; @@ -934,6 +1048,25 @@ static void decode_evt_error(proto_tree *tree, proto_tree_add_item(tree, hf_noe_message, tvb, offset, length, ENC_NA); } +static int compcp(const void *pcp1, const void *pcp2) +{ + guint cp1 = *((guint *)pcp1); + guint cp2 = *((guint *)pcp2); + + return (cp1 - cp2); +} + +static gboolean property_is_bool(guint8 noe_class, guint8 property_code) +{ + guint key = ((noe_class << 8) | property_code); + return (bsearch(&key, bool_properties, (sizeof(bool_properties)/sizeof(guint16)), sizeof(guint16), compcp) != NULL); +} + +static gboolean property_is_utf8(guint8 noe_class, guint8 property_code) +{ + guint key = ((noe_class << 8) | property_code); + return (bsearch(&key, utf8_properties, (sizeof(utf8_properties)/sizeof(guint16)), sizeof(guint16), compcp) != NULL); +} /*----------------------------------------------------------------------------- MESSAGE BODY DECODER @@ -941,11 +1074,12 @@ static void decode_evt_error(proto_tree *tree, ---------------------------------------------------------------------------*/ static void decode_tlv(proto_tree *tree, tvbuff_t *tvb, + guint8 noe_class, guint offset, guint length) { proto_tree *property_tree; - guint8 property_type; + guint8 property_code; guint16 property_length; /* guint64 property_index;*/ @@ -958,12 +1092,12 @@ static void decode_tlv(proto_tree *tree, while(length > 0) { - property_type = tvb_get_guint8(tvb, offset); + property_code = tvb_get_guint8(tvb, offset); proto_tree_add_item(property_tree, hf_noe_pcode, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; length -= 1; - if (property_type >= P_ARRAY) + if (property_code >= P_ARRAY) { proto_tree_add_item(property_tree, hf_noe_aindx, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; @@ -986,38 +1120,38 @@ static void decode_tlv(proto_tree *tree, length -= 1; } - switch(property_length) + if (property_is_utf8(noe_class, property_code)) + { + proto_tree_add_item(property_tree, hf_noe_property_item_utf8, tvb, offset, property_length, ENC_STRING); + } + else { - case 0: + switch(property_length) { - break; + case 0: + break; + case 1: + if (property_is_bool(noe_class, property_code)) + proto_tree_add_item(property_tree, hf_noe_property_item_bool, tvb, offset, 1, ENC_BIG_ENDIAN); + else + proto_tree_add_item(property_tree, hf_noe_property_item_u8, tvb, offset, 1, ENC_BIG_ENDIAN); + break; + case 2: + proto_tree_add_item(property_tree, hf_noe_property_item_u16, tvb, offset, 2, ENC_BIG_ENDIAN); + break; + case 3: + proto_tree_add_item(property_tree, hf_noe_property_item_u24, tvb, offset, 3, ENC_BIG_ENDIAN); + break; + case 4: + proto_tree_add_item(property_tree, hf_noe_property_item_u32, tvb, offset, 4, ENC_BIG_ENDIAN); + break; + default: + proto_tree_add_item(property_tree, hf_noe_property_item_bytes, tvb, offset, property_length, ENC_NA); + break; } - case 1: - proto_tree_add_item(property_tree, hf_noe_property_item_u8, tvb, offset, 1, ENC_BIG_ENDIAN); - offset += 1; - length -= 1; - break; - case 2: - proto_tree_add_item(property_tree, hf_noe_property_item_u16, tvb, offset, 2, ENC_BIG_ENDIAN); - offset += 2; - length -= 2; - break; - case 3: - proto_tree_add_item(property_tree, hf_noe_property_item_u24, tvb, offset, 3, ENC_BIG_ENDIAN); - offset += 3; - length -= 3; - break; - case 4: - proto_tree_add_item(property_tree, hf_noe_property_item_u32, tvb, offset, 4, ENC_BIG_ENDIAN); - offset += 4; - length -= 4; - break; - default: - proto_tree_add_item(property_tree, hf_noe_property_item_bytes, tvb, offset, property_length, ENC_NA); - offset += property_length; - length -= property_length; - break; } + offset += property_length; + length -= property_length; } } @@ -1199,7 +1333,7 @@ static void decode_evt(proto_tree *tree, length -= 2; if (length > 0) - decode_tlv(tree, tvb, offset, length); + decode_tlv(tree, tvb, C_INVALID, offset, length); break; } } @@ -1246,7 +1380,7 @@ static void decode_mtd(proto_tree *tree, offset += 1; length -= 1; if (length > 0) - decode_tlv(tree, tvb, offset, length); + decode_tlv(tree, tvb, noe_class, offset, length); break; } case METHOD_DELETE_ITEM: @@ -1262,7 +1396,7 @@ static void decode_mtd(proto_tree *tree, default: { if (length > 0) - decode_tlv(tree, tvb, offset, length); + decode_tlv(tree, tvb, noe_class, offset, length); break; } } @@ -1540,6 +1674,18 @@ void proto_register_noe(void) HFILL } }, + { &hf_noe_property_item_bool, + { + "Value", + "noe.property_item.bool", + FT_UINT8, + BASE_DEC, + VALS(noe_true_false_str_vals), + 0x0, + NULL, + HFILL + } + }, { &hf_noe_property_item_u8, { "Value", @@ -1600,6 +1746,18 @@ void proto_register_noe(void) HFILL } }, + { &hf_noe_property_item_utf8, + { + "Value", + "noe.property_item.utf8", + FT_STRING, + BASE_NONE, + NULL, + 0x0, + NULL, + HFILL + } + }, { &hf_event_bt_key, { "Value", -- cgit v1.2.3