diff options
author | Michael Mann <mmann78@netscape.net> | 2017-11-13 08:25:49 -0500 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-11-22 09:10:05 +0000 |
commit | 2f2c2b06e2f43c2a18bf1033253ee07c4b2b427e (patch) | |
tree | fb2c90e2a0ea020cd6994eb67f2a70abc2f73b37 /epan/dissectors | |
parent | 8d5726dccc6851aa99707f4ff3cf9d11128cd822 (diff) |
Add Zigbee encoding, ENC_ZIGBEE
Add the "special handling" of length = 0xFF for single byte or 0xFFFF
for uint16 value means size of field to follow is 0.
Ping-Bug: 14138
Change-Id: I0baa40f63152b9420a6569ca6cc5eba638fbc790
Reviewed-on: https://code.wireshark.org/review/24428
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Craig Jackson <cejackson51@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors')
-rw-r--r-- | epan/dissectors/packet-zbee-zcl-general.c | 25 | ||||
-rw-r--r-- | epan/dissectors/packet-zbee-zcl-se.c | 104 | ||||
-rw-r--r-- | epan/dissectors/packet-zbee-zcl.c | 51 |
3 files changed, 37 insertions, 143 deletions
diff --git a/epan/dissectors/packet-zbee-zcl-general.c b/epan/dissectors/packet-zbee-zcl-general.c index 6579929bcd..e48c0599f7 100644 --- a/epan/dissectors/packet-zbee-zcl-general.c +++ b/epan/dissectors/packet-zbee-zcl-general.c @@ -8712,7 +8712,6 @@ static int hf_zbee_zcl_part_opt_res = -1; static int hf_zbee_zcl_part_first_frame_id = -1; static int hf_zbee_zcl_part_part_indicator = -1; static int hf_zbee_zcl_part_part_frame = -1; -static int hf_zbee_zcl_part_part_frame_len = -1; static int hf_zbee_zcl_part_partitioned_cluster_id = -1; static int hf_zbee_zcl_part_ack_opt = -1; static int hf_zbee_zcl_part_ack_opt_nack_id_len = -1; @@ -8880,8 +8879,7 @@ static void dissect_zcl_part_trasfpartframe(tvbuff_t *tvb, proto_tree *tree, gui { guint8 options; - guint16 u16len; - guint8 frame_len; + gint frame_len; static const int * part_opt[] = { &hf_zbee_zcl_part_opt_first_block, @@ -8899,26 +8897,17 @@ static void dissect_zcl_part_trasfpartframe(tvbuff_t *tvb, proto_tree *tree, gui if ((options & ZBEE_ZCL_PART_OPT_INDIC_LEN) == 0) { /* 1-byte length */ - u16len = (guint16)tvb_get_guint8(tvb, *offset); - proto_tree_add_item(tree, hf_zbee_zcl_part_part_indicator, tvb, *offset, 1, (u16len & 0xFF)); + proto_tree_add_item(tree, hf_zbee_zcl_part_part_indicator, tvb, *offset, 1, ENC_NA); *offset += 1; } else { /* 2-bytes length */ - u16len = tvb_get_letohs(tvb, *offset); - proto_tree_add_item(tree, hf_zbee_zcl_part_part_indicator, tvb, *offset, 2, u16len); + proto_tree_add_item(tree, hf_zbee_zcl_part_part_indicator, tvb, *offset, 2, ENC_LITTLE_ENDIAN); *offset += 2; } - /* Retrieve PartitionedFrame length field */ - frame_len = tvb_get_guint8(tvb, *offset); /* string length */ - if (frame_len == ZBEE_ZCL_INVALID_STR_LENGTH) - frame_len = 0; - proto_tree_add_item(tree, hf_zbee_zcl_part_part_frame_len, tvb, *offset, 1, ENC_NA); - *offset += 1; - /* Retrieve "PartitionedFrame" field */ - proto_tree_add_item(tree, hf_zbee_zcl_part_part_frame, tvb, *offset, frame_len, ENC_NA); + proto_tree_add_item_ret_length(tree, hf_zbee_zcl_part_part_frame, tvb, *offset, 1, ENC_NA|ENC_ZIGBEE, &frame_len); *offset += frame_len; } /*dissect_zcl_part_trasfpartframe*/ @@ -9131,12 +9120,8 @@ void proto_register_zbee_zcl_part(void) { "Partition Indicator", "zbee_zcl_general.part.part_indicator", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL } }, - { &hf_zbee_zcl_part_part_frame_len, - { "Partition Frame Length", "zbee_zcl_general.part.part_frame_length", FT_UINT8, BASE_DEC, NULL, - 0x00, NULL, HFILL } }, - { &hf_zbee_zcl_part_part_frame, - { "Partition Frame", "zbee_zcl_general.part.part_frame", FT_BYTES, SEP_COLON, NULL, + { "Partition Frame", "zbee_zcl_general.part.part_frame", FT_UINT_BYTES, SEP_COLON, NULL, 0x00, NULL, HFILL } }, { &hf_zbee_zcl_part_partitioned_cluster_id, diff --git a/epan/dissectors/packet-zbee-zcl-se.c b/epan/dissectors/packet-zbee-zcl-se.c index 8298b1744b..2cf59dc1f2 100644 --- a/epan/dissectors/packet-zbee-zcl-se.c +++ b/epan/dissectors/packet-zbee-zcl-se.c @@ -50,41 +50,6 @@ static const value_string zbee_zcl_se_reporting_status_names[] = { { 0, NULL } }; -/** - *Dissect an octet string by adding a subtree showing length and octets - * - *@param tvb pointer to buffer containing raw packet. - *@param tree pointer to data tree Wireshark uses to display packet. - *@param offset pointer to buffer offset - *@param idx one of the ett_ array elements registered with proto_register_subtree_array() - *@param hfindex_len length field - *@param hfindex_data data field -*/ -static void dissect_zcl_octet_string(tvbuff_t *tvb, proto_tree *tree, guint *offset, - gint idx, int hfindex_len, int hfindex_data) -{ - guint8 octet_len; - proto_tree* subtree; - - /* Add subtree */ - subtree = proto_tree_add_subtree(tree, tvb, *offset, 0, idx, NULL, proto_registrar_get_name(hfindex_data)); - - /* Length */ - octet_len = tvb_get_guint8(tvb, *offset); - if (octet_len == ZBEE_ZCL_INVALID_STR_LENGTH) { - octet_len = 0; - } - proto_tree_add_item(subtree, hfindex_len, tvb, *offset, 1, ENC_NA); - *offset += 1; - - /* Data */ - proto_tree_add_item(subtree, hfindex_data, tvb, *offset, octet_len, ENC_NA); - *offset += octet_len; - - /* Set length of subtree */ - proto_item_set_end(proto_tree_get_parent(subtree), tvb, *offset); -} - /*************************/ /* Global Variables */ /*************************/ @@ -3673,7 +3638,6 @@ static int hf_zbee_zcl_pp_emergency_credit_setup_start_time = -1; static int hf_zbee_zcl_pp_emergency_credit_setup_emergency_credit_limit = -1; static int hf_zbee_zcl_pp_emergency_credit_setup_emergency_credit_threshold = -1; static int hf_zbee_zcl_pp_consumer_top_up_originating_device = -1; -static int hf_zbee_zcl_pp_consumer_top_up_top_up_code_len = -1; static int hf_zbee_zcl_pp_consumer_top_up_top_up_code = -1; static int hf_zbee_zcl_pp_credit_adjustment_issuer_event_id = -1; static int hf_zbee_zcl_pp_credit_adjustment_start_time = -1; @@ -3721,7 +3685,6 @@ static int hf_zbee_zcl_pp_consumer_top_up_response_source_of_top_up = -1; static int hf_zbee_zcl_pp_consumer_top_up_response_credit_remaining = -1; static int hf_zbee_zcl_pp_publish_top_up_log_command_index = -1; static int hf_zbee_zcl_pp_publish_top_up_log_total_number_of_commands = -1; -static int hf_zbee_zcl_pp_publish_top_up_log_top_up_code_len = -1; static int hf_zbee_zcl_pp_publish_top_up_log_top_up_code = -1; static int hf_zbee_zcl_pp_publish_top_up_log_top_up_amount = -1; static int hf_zbee_zcl_pp_publish_top_up_log_top_up_time = -1; @@ -3733,7 +3696,7 @@ static int hf_zbee_zcl_pp_publish_debt_log_debt_type = -1; static int hf_zbee_zcl_pp_publish_debt_log_outstanding_debt = -1; /* Initialize the subtree pointers */ -#define ZBEE_ZCL_SE_PP_NUM_INDIVIDUAL_ETT 3 +#define ZBEE_ZCL_SE_PP_NUM_INDIVIDUAL_ETT 1 #define ZBEE_ZCL_SE_PP_NUM_PUBLISH_TOP_UP_LOG_ETT 30 #define ZBEE_ZCL_SE_PP_NUM_PUBLISH_DEBT_LOG_ETT 30 #define ZBEE_ZCL_SE_PP_NUM_TOTAL_ETT (ZBEE_ZCL_SE_PP_NUM_INDIVIDUAL_ETT + \ @@ -3741,8 +3704,6 @@ static int hf_zbee_zcl_pp_publish_debt_log_outstanding_debt = -1; ZBEE_ZCL_SE_PP_NUM_PUBLISH_DEBT_LOG_ETT) static gint ett_zbee_zcl_pp = -1; -static gint ett_zbee_zcl_pp_consumer_top_up_top_up_code = -1; -static gint ett_zbee_zcl_pp_publish_top_up_log_top_up_code = -1; static gint ett_zbee_zcl_pp_publish_top_up_entry[ZBEE_ZCL_SE_PP_NUM_PUBLISH_TOP_UP_LOG_ETT]; static gint ett_zbee_zcl_pp_publish_debt_log_entry[ZBEE_ZCL_SE_PP_NUM_PUBLISH_DEBT_LOG_ETT]; @@ -4035,15 +3996,15 @@ dissect_zcl_pp_emergency_credit_setup(tvbuff_t *tvb, proto_tree *tree, guint *of static void dissect_zcl_pp_consumer_top_up(tvbuff_t *tvb, proto_tree *tree, guint *offset) { + int length; + /* Originating Device */ proto_tree_add_item(tree, hf_zbee_zcl_pp_consumer_top_up_originating_device, tvb, *offset, 1, ENC_NA); *offset += 1; /* TopUp Code */ - dissect_zcl_octet_string(tvb, tree, offset, - ett_zbee_zcl_pp_consumer_top_up_top_up_code, - hf_zbee_zcl_pp_consumer_top_up_top_up_code_len, - hf_zbee_zcl_pp_consumer_top_up_top_up_code); + proto_tree_add_item_ret_length(tree, hf_zbee_zcl_pp_consumer_top_up_top_up_code, tvb, *offset, 1, ENC_NA|ENC_ZIGBEE, &length); + *offset += length; } /*dissect_zcl_pp_consumer_top_up*/ /** @@ -4391,6 +4352,7 @@ static void dissect_zcl_pp_publish_top_up_log(tvbuff_t *tvb, proto_tree *tree, guint *offset) { guint i = 0; + gint length; nstime_t top_up_time; proto_tree *sub_tree; @@ -4409,10 +4371,8 @@ dissect_zcl_pp_publish_top_up_log(tvbuff_t *tvb, proto_tree *tree, guint *offset i++; /* Top Up Code */ - dissect_zcl_octet_string(tvb, sub_tree, offset, - ett_zbee_zcl_pp_publish_top_up_log_top_up_code, - hf_zbee_zcl_pp_publish_top_up_log_top_up_code_len, - hf_zbee_zcl_pp_publish_top_up_log_top_up_code); + proto_tree_add_item_ret_length(sub_tree, hf_zbee_zcl_pp_publish_top_up_log_top_up_code, tvb, *offset, 1, ENC_NA|ENC_ZIGBEE, &length); + *offset += length; /* Top Up Amount */ proto_tree_add_item(sub_tree, hf_zbee_zcl_pp_publish_top_up_log_top_up_amount, tvb, *offset, 4, ENC_LITTLE_ENDIAN); @@ -4570,12 +4530,8 @@ proto_register_zbee_zcl_pp(void) { "Originating Device", "zbee_zcl_se.pp.consumer_top_up.originating_device", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL } }, - { &hf_zbee_zcl_pp_consumer_top_up_top_up_code_len, - { "Length", "zbee_zcl_se.pp.consumer_top_up.top_up_code_len", FT_UINT8, BASE_DEC, NULL, - 0x00, NULL, HFILL } }, - { &hf_zbee_zcl_pp_consumer_top_up_top_up_code, - { "TopUp Code", "zbee_zcl_se.pp.consumer_top_up.top_up_code", FT_BYTES, SEP_COLON, NULL, + { "TopUp Code", "zbee_zcl_se.pp.consumer_top_up.top_up_code", FT_UINT_BYTES, SEP_COLON, NULL, 0x00, NULL, HFILL } }, { &hf_zbee_zcl_pp_credit_adjustment_issuer_event_id, @@ -4762,12 +4718,8 @@ proto_register_zbee_zcl_pp(void) { "Total Number of Commands", "zbee_zcl_se.pp.publish_top_up_log.total_number_of_commands", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL } }, - { &hf_zbee_zcl_pp_publish_top_up_log_top_up_code_len, - { "Length", "zbee_zcl_se.pp.publish_top_up_log.top_up_code_len", FT_UINT8, BASE_DEC, NULL, - 0x00, NULL, HFILL } }, - { &hf_zbee_zcl_pp_publish_top_up_log_top_up_code, - { "TopUp Code", "zbee_zcl_se.pp.publish_top_up_log.top_up_code", FT_BYTES, SEP_COLON, NULL, + { "TopUp Code", "zbee_zcl_se.pp.publish_top_up_log.top_up_code", FT_UINT_BYTES, SEP_COLON, NULL, 0x00, NULL, HFILL } }, { &hf_zbee_zcl_pp_publish_top_up_log_top_up_amount, @@ -4806,8 +4758,6 @@ proto_register_zbee_zcl_pp(void) /* ZCL Prepayment subtrees */ gint *ett[ZBEE_ZCL_SE_PP_NUM_TOTAL_ETT]; ett[0] = &ett_zbee_zcl_pp; - ett[1] = &ett_zbee_zcl_pp_consumer_top_up_top_up_code; - ett[2] = &ett_zbee_zcl_pp_publish_top_up_log_top_up_code; guint j = ZBEE_ZCL_SE_PP_NUM_INDIVIDUAL_ETT; @@ -5729,7 +5679,6 @@ static int hf_zbee_zcl_events_publish_event_log_id = -1; static int hf_zbee_zcl_events_publish_event_event_id = -1; static int hf_zbee_zcl_events_publish_event_event_time = -1; static int hf_zbee_zcl_events_publish_event_event_control = -1; -static int hf_zbee_zcl_events_publish_event_event_data_len = -1; static int hf_zbee_zcl_events_publish_event_event_data = -1; static int hf_zbee_zcl_events_publish_event_log_total_number_of_matching_events = -1; static int hf_zbee_zcl_events_publish_event_log_command_index = -1; @@ -5738,18 +5687,15 @@ static int hf_zbee_zcl_events_publish_event_log_number_of_events_log_payload_con static int hf_zbee_zcl_events_publish_event_log_log_id = -1; static int hf_zbee_zcl_events_publish_event_log_event_id = -1; static int hf_zbee_zcl_events_publish_event_log_event_time = -1; -static int hf_zbee_zcl_events_publish_event_log_event_data_len = -1; static int hf_zbee_zcl_events_publish_event_log_event_data = -1; static int hf_zbee_zcl_events_clear_event_log_response_cleared_event_logs = -1; /* Initialize the subtree pointers */ -#define ZBEE_ZCL_SE_EVENTS_NUM_INDIVIDUAL_ETT 3 +#define ZBEE_ZCL_SE_EVENTS_NUM_INDIVIDUAL_ETT 1 #define ZBEE_ZCL_SE_EVENTS_NUM_PUBLISH_EVENT_LOG_ETT 100 // The Great Britain Companion Specification (GBCS) allows up to 100 even though ZigBee only allows 15 #define ZBEE_ZCL_SE_EVENTS_NUM_TOTAL_ETT (ZBEE_ZCL_SE_EVENTS_NUM_INDIVIDUAL_ETT + ZBEE_ZCL_SE_EVENTS_NUM_PUBLISH_EVENT_LOG_ETT) static gint ett_zbee_zcl_events = -1; -static gint ett_zbee_zcl_events_publish_event_event_data = -1; -static gint ett_zbee_zcl_events_publish_event_log_event_data = -1; static gint ett_zbee_zcl_events_publish_event_log_entry[ZBEE_ZCL_SE_EVENTS_NUM_PUBLISH_EVENT_LOG_ETT]; /*************************/ @@ -5940,6 +5886,7 @@ static void dissect_zcl_events_publish_event(tvbuff_t *tvb, proto_tree *tree, guint *offset) { nstime_t event_time; + gint length; /* Log ID */ proto_tree_add_item(tree, hf_zbee_zcl_events_publish_event_log_id, tvb, *offset, 1, ENC_NA); @@ -5960,10 +5907,8 @@ dissect_zcl_events_publish_event(tvbuff_t *tvb, proto_tree *tree, guint *offset) *offset += 1; /* Event Data */ - dissect_zcl_octet_string(tvb, tree, offset, - ett_zbee_zcl_events_publish_event_event_data, - hf_zbee_zcl_events_publish_event_event_data_len, - hf_zbee_zcl_events_publish_event_event_data); + proto_tree_add_item_ret_length(tree, hf_zbee_zcl_events_publish_event_event_data, tvb, *offset, 1, ENC_NA|ENC_ZIGBEE, &length); + *offset += length; } /*dissect_zcl_events_publish_event*/ /** @@ -5978,6 +5923,7 @@ dissect_zcl_events_publish_event_log(tvbuff_t *tvb, proto_tree *tree, guint *off { proto_tree* event_log_tree; nstime_t event_time; + int length; /* Total Number of Matching Events */ proto_tree_add_item(tree, hf_zbee_zcl_events_publish_event_log_total_number_of_matching_events, tvb, *offset, 2, ENC_LITTLE_ENDIAN); @@ -6015,10 +5961,8 @@ dissect_zcl_events_publish_event_log(tvbuff_t *tvb, proto_tree *tree, guint *off *offset += 4; /* Event Data */ - dissect_zcl_octet_string(tvb, event_log_tree, offset, - ett_zbee_zcl_events_publish_event_log_event_data, - hf_zbee_zcl_events_publish_event_log_event_data_len, - hf_zbee_zcl_events_publish_event_log_event_data); + proto_tree_add_item_ret_length(event_log_tree, hf_zbee_zcl_events_publish_event_log_event_data, tvb, *offset, 1, ENC_NA|ENC_ZIGBEE, &length); + *offset += length; /* Set length of subtree */ proto_item_set_end(proto_tree_get_parent(event_log_tree), tvb, *offset); @@ -6109,12 +6053,8 @@ proto_register_zbee_zcl_events(void) { "Event Control", "zbee_zcl_se.events.publish_event.event_control", FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL } }, - { &hf_zbee_zcl_events_publish_event_event_data_len, - { "Length", "zbee_zcl_se.events.publish_event.event_data_len", FT_UINT8, BASE_DEC, NULL, - 0x00, NULL, HFILL } }, - { &hf_zbee_zcl_events_publish_event_event_data, - { "Event Data", "zbee_zcl_se.events.publish_event.event_data", FT_BYTES, SEP_COLON, NULL, + { "Event Data", "zbee_zcl_se.events.publish_event.event_data", FT_UINT_BYTES, SEP_COLON, NULL, 0x00, NULL, HFILL } }, { &hf_zbee_zcl_events_publish_event_log_total_number_of_matching_events, @@ -6145,12 +6085,8 @@ proto_register_zbee_zcl_events(void) { "Event Time", "zbee_zcl_se.events.publish_event_log.event_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x00, NULL, HFILL } }, - { &hf_zbee_zcl_events_publish_event_log_event_data_len, - { "Length", "zbee_zcl_se.events.publish_event_log.event_data_len", FT_UINT8, BASE_DEC, NULL, - 0x00, NULL, HFILL } }, - { &hf_zbee_zcl_events_publish_event_log_event_data, - { "Event Data", "zbee_zcl_se.events.publish_event_log.event_data", FT_BYTES, SEP_COLON, NULL, + { "Event Data", "zbee_zcl_se.events.publish_event_log.event_data", FT_UINT_BYTES, SEP_COLON, NULL, 0x00, NULL, HFILL } }, { &hf_zbee_zcl_events_clear_event_log_response_cleared_event_logs, @@ -6162,8 +6098,6 @@ proto_register_zbee_zcl_events(void) /* ZCL Events subtrees */ gint *ett[ZBEE_ZCL_SE_EVENTS_NUM_TOTAL_ETT]; ett[0] = &ett_zbee_zcl_events; - ett[1] = &ett_zbee_zcl_events_publish_event_event_data; - ett[2] = &ett_zbee_zcl_events_publish_event_log_event_data; guint j = ZBEE_ZCL_SE_EVENTS_NUM_INDIVIDUAL_ETT; diff --git a/epan/dissectors/packet-zbee-zcl.c b/epan/dissectors/packet-zbee-zcl.c index e2c2dbdcf8..ddb355316f 100644 --- a/epan/dissectors/packet-zbee-zcl.c +++ b/epan/dissectors/packet-zbee-zcl.c @@ -124,7 +124,6 @@ static int hf_zbee_zcl_attr_dir = -1; static int hf_zbee_zcl_attr_dis = -1; static int hf_zbee_zcl_attr_start = -1; static int hf_zbee_zcl_attr_maxnum = -1; -static int hf_zbee_zcl_attr_str_len = -1; static int hf_zbee_zcl_attr_str = -1; static int hf_zbee_zcl_attr_ostr = -1; static int hf_zbee_zcl_attr_array_elements_type = -1; @@ -1457,7 +1456,7 @@ void dissect_zcl_attr_data(tvbuff_t *tvb, proto_tree *tree, guint *offset, guint { guint attr_uint; gint attr_int; - guint8 *attr_string; + const guint8 *attr_string; guint8 attr_uint8[4]; guint8 elements_type; guint16 elements_num; @@ -1713,50 +1712,30 @@ void dissect_zcl_attr_data(tvbuff_t *tvb, proto_tree *tree, guint *offset, guint case ZBEE_ZCL_OCTET_STRING: /* Display octet string */ - attr_uint = tvb_get_guint8(tvb, *offset); /* string length */ - if (attr_uint == ZBEE_ZCL_INVALID_STR_LENGTH) attr_uint = 0; - proto_tree_add_uint(tree, hf_zbee_zcl_attr_str_len, tvb, *offset, 1, - attr_uint); - *offset += 1; - proto_tree_add_item(tree, hf_zbee_zcl_attr_ostr, tvb, *offset, attr_uint, ENC_NA); - proto_item_append_text(tree, ", Octets: %s", tvb_bytes_to_str_punct(wmem_packet_scope(), tvb, *offset, attr_uint, ':')); - *offset += attr_uint; + proto_tree_add_item_ret_length(tree, hf_zbee_zcl_attr_ostr, tvb, *offset, 1, ENC_NA|ENC_ZIGBEE, &attr_int); + proto_item_append_text(tree, ", Octets: %s", tvb_bytes_to_str_punct(wmem_packet_scope(), tvb, (*offset)+1, attr_int-1, ':')); + *offset += attr_int; break; case ZBEE_ZCL_CHAR_STRING: /* Display string */ - attr_uint = tvb_get_guint8(tvb, *offset); /* string length */ - if (attr_uint == ZBEE_ZCL_INVALID_STR_LENGTH) attr_uint = 0; - proto_tree_add_uint(tree, hf_zbee_zcl_attr_str_len, tvb, *offset, 1, attr_uint); - *offset += 1; - attr_string = tvb_get_string_enc(wmem_packet_scope(), tvb, *offset, attr_uint, ENC_ASCII); + proto_tree_add_item_ret_string_and_length(tree, hf_zbee_zcl_attr_str, tvb, *offset, 1, ENC_NA|ENC_ZIGBEE, wmem_packet_scope(), &attr_string, &attr_int); proto_item_append_text(tree, ", String: %s", attr_string); - proto_tree_add_string(tree, hf_zbee_zcl_attr_str, tvb, *offset, attr_uint, attr_string); - *offset += attr_uint; + *offset += attr_int; break; case ZBEE_ZCL_LONG_OCTET_STRING: /* Display long octet string */ - attr_uint = tvb_get_letohs(tvb, *offset); /* string length */ - if (attr_uint == ZBEE_ZCL_INVALID_LONG_STR_LENGTH) attr_uint = 0; - proto_tree_add_uint(tree, hf_zbee_zcl_attr_str_len, tvb, *offset, 2, attr_uint); - *offset += 2; - proto_tree_add_item(tree, hf_zbee_zcl_attr_ostr, tvb, *offset, attr_uint, ENC_NA); - proto_item_append_text(tree, ", Octets: %s", tvb_bytes_to_str_punct(wmem_packet_scope(), tvb, *offset, attr_uint, ':')); - *offset += attr_uint; + proto_tree_add_item_ret_length(tree, hf_zbee_zcl_attr_ostr, tvb, *offset, 2, ENC_LITTLE_ENDIAN|ENC_ZIGBEE, &attr_int); + proto_item_append_text(tree, ", Octets: %s", tvb_bytes_to_str_punct(wmem_packet_scope(), tvb, (*offset)+2, attr_int-2, ':')); + *offset += attr_int; break; case ZBEE_ZCL_LONG_CHAR_STRING: - /* Display long string */ - attr_uint = tvb_get_letohs(tvb, *offset); /* string length */ - if (attr_uint == ZBEE_ZCL_INVALID_LONG_STR_LENGTH) attr_uint = 0; - proto_tree_add_uint(tree, hf_zbee_zcl_attr_str_len, tvb, *offset, 2, attr_uint); - *offset += 2; - attr_string = tvb_get_string_enc(wmem_packet_scope(), tvb, *offset, attr_uint, ENC_ASCII); + proto_tree_add_item_ret_string_and_length(tree, hf_zbee_zcl_attr_str, tvb, *offset, 2, ENC_LITTLE_ENDIAN|ENC_ZIGBEE, wmem_packet_scope(), &attr_string, &attr_int); proto_item_append_text(tree, ", String: %s", attr_string); - proto_tree_add_string(tree, hf_zbee_zcl_attr_str, tvb, *offset, attr_uint, attr_string); - *offset += attr_uint; + *offset += attr_int; break; case ZBEE_ZCL_ARRAY: @@ -2230,16 +2209,12 @@ void proto_register_zbee_zcl(void) { "Maximum Number", "zbee_zcl.attr.maxnum", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_zbee_zcl_attr_str_len, - { "Length", "zbee_zcl.attr.str.len", FT_UINT8, BASE_DEC, NULL, 0x0, - NULL, HFILL }}, - { &hf_zbee_zcl_attr_str, - { "String", "zbee_zcl.attr.str", FT_STRING, BASE_NONE, NULL, 0x0, + { "String", "zbee_zcl.attr.str", FT_UINT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, { &hf_zbee_zcl_attr_ostr, - { "Octet String", "zbee_zcl.attr.ostr", FT_BYTES, SEP_COLON, NULL, 0x0, + { "Octet String", "zbee_zcl.attr.ostr", FT_UINT_BYTES, SEP_COLON, NULL, 0x0, NULL, HFILL }}, { &hf_zbee_zcl_attr_array_elements_type, |