summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Soerensen <knnthsrnsn@gmail.com>2017-05-15 14:08:46 +0200
committerMichael Mann <mmann78@netscape.net>2017-05-22 16:28:56 +0000
commitdd914364c7b93faf2bf3992a076908cb624f5cfb (patch)
tree9870cfac8bc19e57e9b34a4b42caf1252ba9a9b2
parentfc1c8e139bcf885497138cccf05b2d2b543aefc9 (diff)
downloadwireshark-dd914364c7b93faf2bf3992a076908cb624f5cfb.tar.gz
ZigBee: Add attribute and command names from Events cluster
Bug: 13360 Change-Id: Ie6c5cb4d592490716204ff56dea11e92e071f740 Reviewed-on: https://code.wireshark.org/review/21662 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--epan/dissectors/packet-zbee-zcl-se.c234
-rw-r--r--epan/dissectors/packet-zbee.h1
2 files changed, 235 insertions, 0 deletions
diff --git a/epan/dissectors/packet-zbee-zcl-se.c b/epan/dissectors/packet-zbee-zcl-se.c
index 681afa2cc4..be882aaa02 100644
--- a/epan/dissectors/packet-zbee-zcl-se.c
+++ b/epan/dissectors/packet-zbee-zcl-se.c
@@ -1981,6 +1981,240 @@ proto_reg_handoff_zbee_zcl_pp(void)
);
} /*proto_reg_handoff_zbee_zcl_pp*/
+/* ########################################################################## */
+/* #### (0x0709) EVENTS CLUSTER ############################################# */
+/* ########################################################################## */
+
+/* Attributes */
+#define zbee_zcl_events_attr_names_VALUE_STRING_LIST(XXX) \
+/* Smart Energy */ \
+ XXX(ZBEE_ZCL_ATTR_ID_SE_ATTR_REPORT_STATUS_EVENTS, 0xFFFE, "Attribute Reporting Status" )
+
+VALUE_STRING_ENUM(zbee_zcl_events_attr_names);
+VALUE_STRING_ARRAY(zbee_zcl_events_attr_names);
+
+/* Server Commands Received */
+#define zbee_zcl_events_srv_rx_cmd_names_VALUE_STRING_LIST(XXX) \
+ XXX(ZBEE_ZCL_CMD_ID_EVENTS_GET_EVENT_LOG, 0x00, "Get Event Log" ) \
+ XXX(ZBEE_ZCL_CMD_ID_EVENTS_CLEAR_EVENT_LOG_REQUEST, 0x01, "Clear Event Log Request" )
+
+VALUE_STRING_ENUM(zbee_zcl_events_srv_rx_cmd_names);
+VALUE_STRING_ARRAY(zbee_zcl_events_srv_rx_cmd_names);
+
+/* Server Commands Generated */
+#define zbee_zcl_events_srv_tx_cmd_names_VALUE_STRING_LIST(XXX) \
+ XXX(ZBEE_ZCL_CMD_ID_EVENTS_PUBLISH_EVENT, 0x00, "Publish Event" ) \
+ XXX(ZBEE_ZCL_CMD_ID_EVENTS_PUBLISH_EVENT_LOG, 0x01, "Publish Event Log" ) \
+ XXX(ZBEE_ZCL_CMD_ID_EVENTS_CLEAR_EVENT_LOG_RESPONSE, 0x02, "Clear Event Log Response" )
+
+VALUE_STRING_ENUM(zbee_zcl_events_srv_tx_cmd_names);
+VALUE_STRING_ARRAY(zbee_zcl_events_srv_tx_cmd_names);
+
+/*************************/
+/* Function Declarations */
+/*************************/
+void proto_register_zbee_zcl_events(void);
+void proto_reg_handoff_zbee_zcl_events(void);
+
+/* Attribute Dissector Helpers */
+static void dissect_zcl_events_attr_data (proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type);
+
+/*************************/
+/* Global Variables */
+/*************************/
+
+static dissector_handle_t events_handle;
+
+/* Initialize the protocol and registered fields */
+static int proto_zbee_zcl_events = -1;
+
+static int hf_zbee_zcl_events_srv_tx_cmd_id = -1;
+static int hf_zbee_zcl_events_srv_rx_cmd_id = -1;
+static int hf_zbee_zcl_events_attr_id = -1;
+static int hf_zbee_zcl_events_attr_reporting_status = -1;
+
+/* Initialize the subtree pointers */
+static gint ett_zbee_zcl_events = -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_events_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type)
+{
+ switch (attr_id) {
+ /* applies to all SE clusters */
+ case ZBEE_ZCL_ATTR_ID_SE_ATTR_REPORT_STATUS_EVENTS:
+ proto_tree_add_item(tree, hf_zbee_zcl_events_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_events_attr_data*/
+
+/**
+ *ZigBee ZCL Events 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_events(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
+{
+ 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_events_srv_rx_cmd_names, "Unknown Command"),
+ zcl->tran_seqno);
+
+ /* Add the command ID. */
+ proto_tree_add_uint(tree, hf_zbee_zcl_events_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) {
+ proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_events, NULL, "Payload");
+
+ /* Call the appropriate command dissector */
+ switch (cmd_id) {
+
+ case ZBEE_ZCL_CMD_ID_EVENTS_GET_EVENT_LOG:
+ /* Add function to dissect payload */
+ break;
+
+ case ZBEE_ZCL_CMD_ID_EVENTS_CLEAR_EVENT_LOG_REQUEST:
+ /* Add function to dissect payload */
+ 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_events_srv_tx_cmd_names, "Unknown Command"),
+ zcl->tran_seqno);
+
+ /* Add the command ID. */
+ proto_tree_add_uint(tree, hf_zbee_zcl_events_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) {
+ proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_events, NULL, "Payload");
+
+ /* Call the appropriate command dissector */
+ switch (cmd_id) {
+
+ case ZBEE_ZCL_CMD_ID_EVENTS_PUBLISH_EVENT:
+ /* Add function to dissect payload */
+ break;
+
+ case ZBEE_ZCL_CMD_ID_EVENTS_PUBLISH_EVENT_LOG:
+ /* Add function to dissect payload */
+ break;
+
+ case ZBEE_ZCL_CMD_ID_EVENTS_CLEAR_EVENT_LOG_RESPONSE:
+ /* Add function to dissect payload */
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ return tvb_captured_length(tvb);
+} /*dissect_zbee_zcl_events*/
+
+/**
+ *This function registers the ZCL Events dissector
+ *
+*/
+void
+proto_register_zbee_zcl_events(void)
+{
+ static hf_register_info hf[] = {
+
+ { &hf_zbee_zcl_events_attr_id,
+ { "Attribute", "zbee_zcl_se.events.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_events_attr_names),
+ 0x0, NULL, HFILL } },
+
+ { &hf_zbee_zcl_events_attr_reporting_status, /* common to all SE clusters */
+ { "Attribute Reporting Status", "zbee_zcl_se.events.attr.attr_reporting_status",
+ FT_UINT8, BASE_HEX, VALS(zbee_zcl_se_reporting_status_names), 0x00, NULL, HFILL } },
+
+ { &hf_zbee_zcl_events_srv_tx_cmd_id,
+ { "Command", "zbee_zcl_se.events.cmd.srv_tx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_events_srv_tx_cmd_names),
+ 0x00, NULL, HFILL } },
+
+ { &hf_zbee_zcl_events_srv_rx_cmd_id,
+ { "Command", "zbee_zcl_se.events.cmd.srv_rx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_events_srv_rx_cmd_names),
+ 0x00, NULL, HFILL } },
+
+ };
+
+ /* ZCL Events subtrees */
+ gint *ett[] = {
+ &ett_zbee_zcl_events,
+ };
+
+ /* Register the ZigBee ZCL Events cluster protocol name and description */
+ proto_zbee_zcl_events = proto_register_protocol("ZigBee ZCL Events", "ZCL Events", ZBEE_PROTOABBREV_ZCL_EVENTS);
+ proto_register_field_array(proto_zbee_zcl_events, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+
+ /* Register the ZigBee ZCL Events dissector. */
+ events_handle = register_dissector(ZBEE_PROTOABBREV_ZCL_EVENTS, dissect_zbee_zcl_events, proto_zbee_zcl_events);
+} /*proto_register_zbee_zcl_events*/
+
+/**
+ *Hands off the Zcl Events dissector.
+ *
+*/
+void
+proto_reg_handoff_zbee_zcl_events(void)
+{
+ /* Register our dissector with the ZigBee application dissectors. */
+ dissector_add_uint("zbee.zcl.cluster", ZBEE_ZCL_CID_EVENTS, events_handle);
+
+ zbee_zcl_init_cluster( proto_zbee_zcl_events,
+ ett_zbee_zcl_events,
+ ZBEE_ZCL_CID_EVENTS,
+ hf_zbee_zcl_events_attr_id,
+ hf_zbee_zcl_events_srv_rx_cmd_id,
+ hf_zbee_zcl_events_srv_tx_cmd_id,
+ (zbee_zcl_fn_attr_data)dissect_zcl_events_attr_data
+ );
+} /*proto_reg_handoff_zbee_zcl_events*/
/* ########################################################################## */
/* #### (0x0800) KEY ESTABLISHMENT ########################################## */
diff --git a/epan/dissectors/packet-zbee.h b/epan/dissectors/packet-zbee.h
index 83eb19109c..a91d3fa2c8 100644
--- a/epan/dissectors/packet-zbee.h
+++ b/epan/dissectors/packet-zbee.h
@@ -1175,6 +1175,7 @@
#define ZBEE_PROTOABBREV_ZCL_MSG "zbee_zcl_se.msg"
#define ZBEE_PROTOABBREV_ZCL_TUN "zbee_zcl_se.tun"
#define ZBEE_PROTOABBREV_ZCL_PRE_PAYMENT "zbee_zcl_se.pp"
+#define ZBEE_PROTOABBREV_ZCL_EVENTS "zbee_zcl_se.events"
#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"