diff options
author | Ivan Ermakov <iermakov@yahoo.com> | 2017-10-31 17:06:52 +0300 |
---|---|---|
committer | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2017-11-01 08:54:46 +0000 |
commit | 062ca10cff8203330dc8c56e99a52e0b8e4155ee (patch) | |
tree | bfca479c5540882efa5fa7507e0e60725d0d56d2 /epan | |
parent | 93c358cb5d2a6620d997862ef39e1082e47e8329 (diff) |
ZigBee ZCL MDU Pariring Cluster dissector
Added dissectors for commands and payloads of MDU Pairing cluster.
Change-Id: I842ddf50f91d0ecc46605325048971d1eeba6df6
Reviewed-on: https://code.wireshark.org/review/24200
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-zbee-zcl-se.c | 316 | ||||
-rw-r--r-- | epan/dissectors/packet-zbee.h | 1 |
2 files changed, 317 insertions, 0 deletions
diff --git a/epan/dissectors/packet-zbee-zcl-se.c b/epan/dissectors/packet-zbee-zcl-se.c index d53cf83b02..a23fc4fb70 100644 --- a/epan/dissectors/packet-zbee-zcl-se.c +++ b/epan/dissectors/packet-zbee-zcl-se.c @@ -5281,6 +5281,322 @@ proto_reg_handoff_zbee_zcl_events(void) } /*proto_reg_handoff_zbee_zcl_events*/ /* ########################################################################## */ +/* #### (0x070A) MDU PAIRING CLUSTER ############################################ */ +/* ########################################################################## */ + +/* Attributes */ +#define zbee_zcl_mdu_pairing_attr_names_VALUE_STRING_LIST(XXX) \ + XXX(ZBEE_ZCL_ATTR_ID_SE_ATTR_REPORT_STATUS_MDU_PAIRING, 0xFFFE, "Attribute Reporting Status" ) + +VALUE_STRING_ENUM(zbee_zcl_mdu_pairing_attr_names); +VALUE_STRING_ARRAY(zbee_zcl_mdu_pairing_attr_names); +static value_string_ext zbee_zcl_mdu_pairing_attr_names_ext = VALUE_STRING_EXT_INIT(zbee_zcl_mdu_pairing_attr_names); + +/* Server Commands Received */ +#define zbee_zcl_mdu_pairing_srv_rx_cmd_names_VALUE_STRING_LIST(XXX) \ + XXX(ZBEE_ZCL_CMD_ID_MDU_PAIRING_REQUEST, 0x00, "Pairing Request" ) + +VALUE_STRING_ENUM(zbee_zcl_mdu_pairing_srv_rx_cmd_names); +VALUE_STRING_ARRAY(zbee_zcl_mdu_pairing_srv_rx_cmd_names); + +/* Server Commands Generated */ +#define zbee_zcl_mdu_pairing_srv_tx_cmd_names_VALUE_STRING_LIST(XXX) \ + XXX(ZBEE_ZCL_CMD_ID_MDU_PAIRING_RESPONSE, 0x00, "Pairing Response" ) + +VALUE_STRING_ENUM(zbee_zcl_mdu_pairing_srv_tx_cmd_names); +VALUE_STRING_ARRAY(zbee_zcl_mdu_pairing_srv_tx_cmd_names); + +/*************************/ +/* Function Declarations */ +/*************************/ +void proto_register_zbee_zcl_mdu_pairing(void); +void proto_reg_handoff_zbee_zcl_mdu_pairing(void); + +/* Attribute Dissector Helpers */ +static void dissect_zcl_mdu_pairing_attr_data (proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type); + +/* Command Dissector Helpers */ +static void dissect_zcl_mdu_pairing_request (tvbuff_t *tvb, proto_tree *tree, guint *offset); +static void dissect_zcl_mdu_pairing_response(tvbuff_t *tvb, proto_tree *tree, guint *offset); + +/*************************/ +/* Global Variables */ +/*************************/ + +static dissector_handle_t mdu_pairing_handle; + +/* Initialize the protocol and registered fields */ +static int proto_zbee_zcl_mdu_pairing = -1; + +static int hf_zbee_zcl_mdu_pairing_srv_tx_cmd_id = -1; +static int hf_zbee_zcl_mdu_pairing_srv_rx_cmd_id = -1; +static int hf_zbee_zcl_mdu_pairing_attr_id = -1; +static int hf_zbee_zcl_mdu_pairing_attr_reporting_status = -1; +static int hf_zbee_zcl_mdu_pairing_info_version = -1; +static int hf_zbee_zcl_mdu_pairing_total_devices_number = -1; +static int hf_zbee_zcl_mdu_pairing_cmd_id = -1; +static int hf_zbee_zcl_mdu_pairing_total_commands_number = -1; +static int hf_zbee_zcl_mdu_pairing_device_eui64 = -1; +static int hf_zbee_zcl_mdu_pairing_local_info_version = -1; +static int hf_zbee_zcl_mdu_pairing_requesting_device_eui64 = -1; + +/* Initialize the subtree pointers */ +static gint ett_zbee_zcl_mdu_pairing = -1; + +/*************************/ +/* Function Bodies */ +/*************************/ + +/** + *This function is called by ZCL foundation dissector in order to decode + * + *@param tree pointer to data tree Wireshark uses to display packet. + *@param tvb pointer to buffer containing raw packet. + *@param offset pointer to buffer offset + *@param attr_id attribute identifier + *@param data_type attribute data type +*/ +static void +dissect_zcl_mdu_pairing_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type) +{ + /* Dissect attribute data type and data */ + switch (attr_id) { + /* applies to all SE clusters */ + case ZBEE_ZCL_ATTR_ID_SE_ATTR_REPORT_STATUS_MDU_PAIRING: + proto_tree_add_item(tree, hf_zbee_zcl_mdu_pairing_attr_reporting_status, tvb, *offset, 1, ENC_NA); + *offset += 1; + break; + + default: /* Catch all */ + dissect_zcl_attr_data(tvb, tree, offset, data_type); + break; + } +} /*dissect_zcl_mdu_pairing_attr_data*/ + +/** + *ZigBee ZCL MDU Pairing cluster dissector for wireshark. + * + *@param tvb pointer to buffer containing raw packet. + *@param pinfo pointer to packet information fields + *@param tree pointer to data tree Wireshark uses to display packet. +*/ +static int +dissect_zbee_zcl_mdu_pairing(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) +{ + proto_tree *payload_tree; + zbee_zcl_packet *zcl; + guint offset = 0; + guint8 cmd_id; + gint rem_len; + + /* Reject the packet if data is NULL */ + if (data == NULL) + return 0; + zcl = (zbee_zcl_packet *)data; + cmd_id = zcl->cmd_id; + + /* Create a subtree for the ZCL Command frame, and add the command ID to it. */ + if (zcl->direction == ZBEE_ZCL_FCF_TO_SERVER) { + /* Append the command name to the info column. */ + col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u", + val_to_str_const(cmd_id, zbee_zcl_mdu_pairing_srv_rx_cmd_names, "Unknown Command"), + zcl->tran_seqno); + + /* Add the command ID. */ + proto_tree_add_uint(tree, hf_zbee_zcl_mdu_pairing_srv_rx_cmd_id, tvb, offset, 1, cmd_id); + + /* Check is this command has a payload, than add the payload tree */ + rem_len = tvb_reported_length_remaining(tvb, ++offset); + if (rem_len > 0) { + payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_mdu_pairing, NULL, "Payload"); + + /* Call the appropriate command dissector */ + switch (cmd_id) { + + case ZBEE_ZCL_CMD_ID_MDU_PAIRING_REQUEST: + dissect_zcl_mdu_pairing_request(tvb, payload_tree, &offset); + break; + + default: + break; + } + } + } + else { /* ZBEE_ZCL_FCF_TO_CLIENT */ + /* Append the command name to the info column. */ + col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u", + val_to_str_const(cmd_id, zbee_zcl_mdu_pairing_srv_tx_cmd_names, "Unknown Command"), + zcl->tran_seqno); + + /* Add the command ID. */ + proto_tree_add_uint(tree, hf_zbee_zcl_mdu_pairing_srv_tx_cmd_id, tvb, offset, 1, cmd_id); + + /* Check is this command has a payload, than add the payload tree */ + rem_len = tvb_reported_length_remaining(tvb, ++offset); + if (rem_len > 0) { + payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_mdu_pairing, NULL, "Payload"); + + /* Call the appropriate command dissector */ + switch (cmd_id) { + + case ZBEE_ZCL_CMD_ID_MDU_PAIRING_RESPONSE: + dissect_zcl_mdu_pairing_response(tvb, payload_tree, &offset); + break; + + default: + break; + } + } + } + + return tvb_captured_length(tvb); +} /*dissect_zbee_zcl_mdu_pairing*/ + +/** + *This function manages the Pairing Request payload + * + *@param tvb pointer to buffer containing raw packet. + *@param tree pointer to data tree Wireshark uses to display packet. + *@param offset pointer to offset from caller +*/ +static void +dissect_zcl_mdu_pairing_request(tvbuff_t *tvb, proto_tree *tree, guint *offset) +{ + /* Local pairing information version */ + proto_tree_add_item(tree, hf_zbee_zcl_mdu_pairing_local_info_version, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* EUI64 of Requesting Device */ + proto_tree_add_item(tree, hf_zbee_zcl_mdu_pairing_requesting_device_eui64, tvb, *offset, 8, ENC_LITTLE_ENDIAN); + *offset += 8; +} /*dissect_zcl_mdu_pairing_request*/ + +/** + *This function manages the Pairing Response payload + * + *@param tvb pointer to buffer containing raw packet. + *@param tree pointer to data tree Wireshark uses to display packet. + *@param offset pointer to offset from caller +*/ +static void +dissect_zcl_mdu_pairing_response(tvbuff_t *tvb, proto_tree *tree, guint *offset) +{ + guint8 devices_num; + + /* Pairing information version */ + proto_tree_add_item(tree, hf_zbee_zcl_mdu_pairing_info_version, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Total Number of Devices */ + devices_num = tvb_get_guint8(tvb, *offset); + proto_tree_add_item(tree, hf_zbee_zcl_mdu_pairing_total_devices_number, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Command index */ + proto_tree_add_item(tree, hf_zbee_zcl_mdu_pairing_cmd_id, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Total Number of Commands */ + proto_tree_add_item(tree, hf_zbee_zcl_mdu_pairing_total_commands_number, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* EUI64 of Devices */ + for (gint i = 0; tvb_reported_length_remaining(tvb, *offset) >= 8 && i < devices_num; i++) { + /* EUI64 of Device i */ + proto_tree_add_item(tree, hf_zbee_zcl_mdu_pairing_device_eui64, tvb, *offset, 8, ENC_LITTLE_ENDIAN); + *offset += 8; + } +} /*dissect_zcl_mdu_pairing_response*/ + +/** + *This function registers the ZCL MDU Pairing dissector + * +*/ +void +proto_register_zbee_zcl_mdu_pairing(void) +{ + static hf_register_info hf[] = { + + { &hf_zbee_zcl_mdu_pairing_attr_id, + { "Attribute", "zbee_zcl_se.mdu_pairing.attr_id", FT_UINT16, BASE_HEX | BASE_EXT_STRING, &zbee_zcl_mdu_pairing_attr_names_ext, + 0x0, NULL, HFILL } }, + + { &hf_zbee_zcl_mdu_pairing_attr_reporting_status, /* common to all SE clusters */ + { "Attribute Reporting Status", "zbee_zcl_se.mdu_pairing.attr.attr_reporting_status", + FT_UINT8, BASE_HEX, VALS(zbee_zcl_se_reporting_status_names), 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_mdu_pairing_srv_tx_cmd_id, + { "Command", "zbee_zcl_se.mdu_pairing.cmd.srv_tx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_mdu_pairing_srv_tx_cmd_names), + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_mdu_pairing_srv_rx_cmd_id, + { "Command", "zbee_zcl_se.mdu_pairing.cmd.srv_rx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_mdu_pairing_srv_rx_cmd_names), + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_mdu_pairing_info_version, + { "Pairing information version", "zbee_zcl_se.mdu_pairing.info_version", FT_UINT32, BASE_DEC, NULL, + 0x0, NULL, HFILL } }, + + { &hf_zbee_zcl_mdu_pairing_total_devices_number, + { "Total Number of Devices", "zbee_zcl_se.mdu_pairing.total_devices_number", FT_UINT8, BASE_DEC, NULL, + 0x0, NULL, HFILL } }, + + { &hf_zbee_zcl_mdu_pairing_cmd_id, + { "Command Index", "zbee_zcl_se.mdu_pairing.command_index", FT_UINT8, BASE_HEX, NULL, + 0x0, NULL, HFILL } }, + + { &hf_zbee_zcl_mdu_pairing_total_commands_number, + { "Total Number of Commands", "zbee_zcl_se.mdu_pairing.total_commands_number", FT_UINT8, BASE_DEC, NULL, + 0x0, NULL, HFILL } }, + + { &hf_zbee_zcl_mdu_pairing_device_eui64, + { "Device EUI64", "zbee_zcl_se.mdu_pairing.device_eui64", FT_EUI64, BASE_NONE, NULL, + 0x0, NULL, HFILL } }, + + { &hf_zbee_zcl_mdu_pairing_local_info_version, + { "Local Pairing Information Version", "zbee_zcl_se.mdu_pairing.local_info_version", FT_UINT32, BASE_DEC, NULL, + 0x0, NULL, HFILL } }, + + { &hf_zbee_zcl_mdu_pairing_requesting_device_eui64, + { "EUI64 of Requesting Device", "zbee_zcl_se.mdu_pairing.requesting_device_eui64", FT_EUI64, BASE_NONE, NULL, + 0x0, NULL, HFILL } }, + }; + + /* ZCL MDU Pairing subtrees */ + gint *ett[] = { + &ett_zbee_zcl_mdu_pairing + }; + + /* Register the ZigBee ZCL MDU Pairing cluster protocol name and description */ + proto_zbee_zcl_mdu_pairing = proto_register_protocol("ZigBee ZCL MDU Pairing", "ZCL MDU Pairing", ZBEE_PROTOABBREV_ZCL_MDU_PAIRING); + proto_register_field_array(proto_zbee_zcl_mdu_pairing, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + + /* Register the ZigBee ZCL MDU Pairing dissector. */ + mdu_pairing_handle = register_dissector(ZBEE_PROTOABBREV_ZCL_MDU_PAIRING, dissect_zbee_zcl_mdu_pairing, proto_zbee_zcl_mdu_pairing); +} /*proto_register_zbee_zcl_mdu_pairing*/ + +/** + *Hands off the ZCL MDU Pairing dissector. + * +*/ +void +proto_reg_handoff_zbee_zcl_mdu_pairing(void) +{ + /* Register our dissector with the ZigBee application dissectors. */ + dissector_add_uint("zbee.zcl.cluster", ZBEE_ZCL_CID_MDU_PAIRING, mdu_pairing_handle); + + zbee_zcl_init_cluster( proto_zbee_zcl_mdu_pairing, + ett_zbee_zcl_mdu_pairing, + ZBEE_ZCL_CID_MDU_PAIRING, + hf_zbee_zcl_mdu_pairing_attr_id, + hf_zbee_zcl_mdu_pairing_srv_rx_cmd_id, + hf_zbee_zcl_mdu_pairing_srv_tx_cmd_id, + (zbee_zcl_fn_attr_data)dissect_zcl_mdu_pairing_attr_data + ); +} /*proto_reg_handoff_zbee_zcl_mdu_pairing*/ + +/* ########################################################################## */ /* #### (0x0800) KEY ESTABLISHMENT ########################################## */ /* ########################################################################## */ diff --git a/epan/dissectors/packet-zbee.h b/epan/dissectors/packet-zbee.h index 2ea9328e63..2199045148 100644 --- a/epan/dissectors/packet-zbee.h +++ b/epan/dissectors/packet-zbee.h @@ -1177,6 +1177,7 @@ #define ZBEE_PROTOABBREV_ZCL_PRE_PAYMENT "zbee_zcl_se.pp" #define ZBEE_PROTOABBREV_ZCL_CALENDAR "zbee_zcl_se.calendar" #define ZBEE_PROTOABBREV_ZCL_EVENTS "zbee_zcl_se.events" +#define ZBEE_PROTOABBREV_ZCL_MDU_PAIRING "zbee_zcl_se.mdu_pairing" #define ZBEE_PROTOABBREV_ZCL_SHADE_CONFIG "zbee_zcl_closures.shade_config" #define ZBEE_PROTOABBREV_ZCL_DOOR_LOCK "zbee_zcl_closures.door_lock" #define ZBEE_PROTOABBREV_ZCL_COLOR_CONTROL "zbee_zcl_lighting.color_ctrl" |