diff options
author | Ivan Ermakov <iermakov@yahoo.com> | 2017-10-31 17:13:58 +0300 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-11-22 19:02:37 +0000 |
commit | bceae3cff2c8a635ef112b3ac11f36679d77ed20 (patch) | |
tree | 30ac607cfc335ce1c01579e9805c7370fe682b47 | |
parent | b993c6f05c3a9c3bd8748ffe57928a8d790371f7 (diff) |
ZigBee ZCL Calendar Cluster dissector
Added dissectors for payloads of Calendar cluster.
Change-Id: I5c71078714521e25ad4db82b7ffe5166965d5280
Reviewed-on: https://code.wireshark.org/review/24201
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r-- | epan/dissectors/packet-zbee-zcl-se.c | 776 |
1 files changed, 756 insertions, 20 deletions
diff --git a/epan/dissectors/packet-zbee-zcl-se.c b/epan/dissectors/packet-zbee-zcl-se.c index 2cf59dc1f2..0223d31e89 100644 --- a/epan/dissectors/packet-zbee-zcl-se.c +++ b/epan/dissectors/packet-zbee-zcl-se.c @@ -50,6 +50,47 @@ static const value_string zbee_zcl_se_reporting_status_names[] = { { 0, NULL } }; +/** + *Dissect a ZigBee Date + * + *@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 subtree_name name for the subtree + *@param idx one of the ett_ array elements registered with proto_register_subtree_array() + *@param hfindex_yy year field + *@param hfindex_mm month field + *@param hfindex_md month day field + *@param hfindex_wd week day field +*/ +static void dissect_zcl_date(tvbuff_t *tvb, proto_tree *tree, guint *offset, + gint idx, const char* subtree_name, int hfindex_yy, int hfindex_mm, int hfindex_md, + int hfindex_wd) +{ + guint8 yy; + proto_tree* subtree; + + /* Add subtree */ + subtree = proto_tree_add_subtree(tree, tvb, *offset, 4, idx, NULL, subtree_name); + + /* Year */ + yy = tvb_get_guint8(tvb, *offset); + proto_tree_add_uint(subtree, hfindex_yy, tvb, *offset, 1, yy + 1900); + *offset += 1; + + /* Month */ + proto_tree_add_item(subtree, hfindex_mm, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Month Day */ + proto_tree_add_item(subtree, hfindex_md, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Week Day */ + proto_tree_add_item(subtree, hfindex_wd, tvb, *offset, 1, ENC_NA); + *offset += 1; +} /*dissect_zcl_date*/ + /*************************/ /* Global Variables */ /*************************/ @@ -5085,6 +5126,19 @@ void proto_reg_handoff_zbee_zcl_calendar(void); /* Attribute Dissector Helpers */ static void dissect_zcl_calendar_attr_data (proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type); +/* Command Dissector Helpers */ +static void dissect_zcl_calendar_get_calendar (tvbuff_t *tvb, proto_tree *tree, guint *offset); +static void dissect_zcl_calendar_get_day_profiles(tvbuff_t *tvb, proto_tree *tree, guint *offset); +static void dissect_zcl_calendar_get_week_profiles(tvbuff_t *tvb, proto_tree *tree, guint *offset); +static void dissect_zcl_calendar_get_seasons(tvbuff_t *tvb, proto_tree *tree, guint *offset); +static void dissect_zcl_calendar_get_special_days(tvbuff_t *tvb, proto_tree *tree, guint *offset); +static void dissect_zcl_calendar_publish_calendar(tvbuff_t *tvb, proto_tree *tree, guint *offset); +static void dissect_zcl_calendar_publish_day_profile(tvbuff_t *tvb, proto_tree *tree, guint *offset); +static void dissect_zcl_calendar_publish_week_profile(tvbuff_t *tvb, proto_tree *tree, guint *offset); +static void dissect_zcl_calendar_publish_seasons(tvbuff_t *tvb, proto_tree *tree, guint *offset); +static void dissect_zcl_calendar_publish_special_days(tvbuff_t *tvb, proto_tree *tree, guint *offset); +static void dissect_zcl_calendar_cancel(tvbuff_t *tvb, proto_tree *tree, guint *offset); + /*************************/ /* Global Variables */ /*************************/ @@ -5098,9 +5152,70 @@ static int hf_zbee_zcl_calendar_srv_tx_cmd_id = -1; static int hf_zbee_zcl_calendar_srv_rx_cmd_id = -1; static int hf_zbee_zcl_calendar_attr_id = -1; static int hf_zbee_zcl_calendar_attr_reporting_status = -1; +static int hf_zbee_zcl_calendar_type = -1; +static int hf_zbee_zcl_calendar_start_time = -1; +static int hf_zbee_zcl_calendar_earliest_start_time = -1; +static int hf_zbee_zcl_calendar_time_reference = -1; +static int hf_zbee_zcl_calendar_name = -1; +static int hf_zbee_zcl_calendar_command_index = -1; +static int hf_zbee_zcl_calendar_date_year = -1; +static int hf_zbee_zcl_calendar_date_month = -1; +static int hf_zbee_zcl_calendar_date_month_day = -1; +static int hf_zbee_zcl_calendar_date_week_day = -1; +static int hf_zbee_zcl_calendar_provider_id = -1; +static int hf_zbee_zcl_calendar_issuer_event_id = -1; +static int hf_zbee_zcl_calendar_min_issuer_event_id = -1; +static int hf_zbee_zcl_calendar_issuer_calendar_id = -1; +static int hf_zbee_zcl_calendar_day_id = -1; +static int hf_zbee_zcl_calendar_day_id_ref = -1; +static int hf_zbee_zcl_calendar_day_id_ref_monday = -1; +static int hf_zbee_zcl_calendar_day_id_ref_tuesday = -1; +static int hf_zbee_zcl_calendar_day_id_ref_wednesday = -1; +static int hf_zbee_zcl_calendar_day_id_ref_thursday = -1; +static int hf_zbee_zcl_calendar_day_id_ref_friday = -1; +static int hf_zbee_zcl_calendar_day_id_ref_saturday = -1; +static int hf_zbee_zcl_calendar_day_id_ref_sunday = -1; +static int hf_zbee_zcl_calendar_week_id = -1; +static int hf_zbee_zcl_calendar_week_id_ref = -1; +static int hf_zbee_zcl_calendar_start_day_id = -1; +static int hf_zbee_zcl_calendar_start_week_id = -1; +static int hf_zbee_zcl_calendar_number_of_calendars = -1; +static int hf_zbee_zcl_calendar_number_of_events = -1; +static int hf_zbee_zcl_calendar_number_of_days = -1; +static int hf_zbee_zcl_calendar_number_of_weeks = -1; +static int hf_zbee_zcl_calendar_number_of_seasons = -1; +static int hf_zbee_zcl_calendar_number_of_day_profiles = -1; +static int hf_zbee_zcl_calendar_number_of_week_profiles = -1; +static int hf_zbee_zcl_calendar_total_number_of_schedule_entries = -1; +static int hf_zbee_zcl_calendar_total_number_of_special_days = -1; +static int hf_zbee_zcl_calendar_total_number_of_commands = -1; +static int hf_zbee_zcl_calendar_schedule_entry_start_time = -1; +static int hf_zbee_zcl_calendar_schedule_entry_price_tier = -1; +static int hf_zbee_zcl_calendar_schedule_entry_friendly_credit_enable = -1; +static int hf_zbee_zcl_calendar_schedule_entry_auxilary_load_switch_state = -1; /* Initialize the subtree pointers */ static gint ett_zbee_zcl_calendar = -1; +static gint ett_zbee_zcl_calendar_special_day_date = -1; +static gint ett_zbee_zcl_calendar_season_start_date = -1; + +#define zbee_zcl_calendar_type_names_VALUE_STRING_LIST(XXX) \ + XXX(ZBEE_ZCL_CALENDAR_TYPE_DELIVERED, 0x00, "Delivered Calendar" ) \ + XXX(ZBEE_ZCL_CALENDAR_TYPE_RECEIVED, 0x01, "Received Calendar" ) \ + XXX(ZBEE_ZCL_CALENDAR_TYPE_DELIVERED_AND_RECEIVED, 0x02, "Delivered and Received Calendar" ) \ + XXX(ZBEE_ZCL_CALENDAR_TYPE_FRIENDLY_CREDIT, 0x03, "Friendly Credit Calendar" ) \ + XXX(ZBEE_ZCL_CALENDAR_TYPE_AUXILARY_LOAD_SWITCH, 0x04, "Auxilary Load Switch Calendar" ) + +VALUE_STRING_ENUM(zbee_zcl_calendar_type_names); +VALUE_STRING_ARRAY(zbee_zcl_calendar_type_names); + +#define zbee_zcl_calendar_time_reference_names_VALUE_STRING_LIST(XXX) \ + XXX(ZBEE_ZCL_CALENDAR_TIME_REFERENCE_UTC_TIME, 0x00, "UTC Time" ) \ + XXX(ZBEE_ZCL_CALENDAR_TIME_REFERENCE_STANDARD_TIME, 0x01, "Standard Time" ) \ + XXX(ZBEE_ZCL_CALENDAR_TIME_REFERENCE_LOCAL_TIME, 0x02, "Local Time" ) + +VALUE_STRING_ENUM(zbee_zcl_calendar_time_reference_names); +VALUE_STRING_ARRAY(zbee_zcl_calendar_time_reference_names); /*************************/ /* Function Bodies */ @@ -5114,7 +5229,7 @@ static gint ett_zbee_zcl_calendar = -1; *@param offset pointer to buffer offset *@param attr_id attribute identifier *@param data_type attribute data type -*/ + */ static void dissect_zcl_calendar_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type) { @@ -5137,10 +5252,11 @@ dissect_zcl_calendar_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, g *@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_calendar(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; @@ -5156,8 +5272,8 @@ dissect_zbee_zcl_calendar(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v 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_calendar_srv_rx_cmd_names, "Unknown Command"), - zcl->tran_seqno); + val_to_str_const(cmd_id, zbee_zcl_calendar_srv_rx_cmd_names, "Unknown Command"), + zcl->tran_seqno); /* Add the command ID. */ proto_tree_add_uint(tree, hf_zbee_zcl_calendar_srv_rx_cmd_id, tvb, offset, 1, cmd_id); @@ -5165,33 +5281,33 @@ dissect_zbee_zcl_calendar(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v /* 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_calendar, NULL, "Payload"); + payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_calendar, NULL, "Payload"); /* Call the appropriate command dissector */ switch (cmd_id) { case ZBEE_ZCL_CMD_ID_CAL_GET_CALENDAR: - /* Add function to dissect payload */ + dissect_zcl_calendar_get_calendar(tvb, payload_tree, &offset); break; case ZBEE_ZCL_CMD_ID_CAL_GET_DAY_PROFILES: - /* Add function to dissect payload */ + dissect_zcl_calendar_get_day_profiles(tvb, payload_tree, &offset); break; case ZBEE_ZCL_CMD_ID_CAL_GET_WEEK_PROFILES: - /* Add function to dissect payload */ + dissect_zcl_calendar_get_week_profiles(tvb, payload_tree, &offset); break; case ZBEE_ZCL_CMD_ID_CAL_GET_SEASONS: - /* Add function to dissect payload */ + dissect_zcl_calendar_get_seasons(tvb, payload_tree, &offset); break; case ZBEE_ZCL_CMD_ID_CAL_GET_SPECIAL_DAYS: - /* Add function to dissect payload */ + dissect_zcl_calendar_get_special_days(tvb, payload_tree, &offset); break; case ZBEE_ZCL_CMD_ID_CAL_GET_CALENDAR_CANCELLATION: - /* Add function to dissect payload */ + /* No Payload */ break; default: @@ -5202,8 +5318,8 @@ dissect_zbee_zcl_calendar(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v 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_calendar_srv_tx_cmd_names, "Unknown Command"), - zcl->tran_seqno); + val_to_str_const(cmd_id, zbee_zcl_calendar_srv_tx_cmd_names, "Unknown Command"), + zcl->tran_seqno); /* Add the command ID. */ proto_tree_add_uint(tree, hf_zbee_zcl_calendar_srv_tx_cmd_id, tvb, offset, 1, cmd_id); @@ -5211,33 +5327,33 @@ dissect_zbee_zcl_calendar(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v /* 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_calendar, NULL, "Payload"); + payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_calendar, NULL, "Payload"); /* Call the appropriate command dissector */ switch (cmd_id) { case ZBEE_ZCL_CMD_ID_CAL_PUBLISH_CALENDAR: - /* Add function to dissect payload */ + dissect_zcl_calendar_publish_calendar(tvb, payload_tree, &offset); break; case ZBEE_ZCL_CMD_ID_CAL_PUBLISH_DAY_PROFILE: - /* Add function to dissect payload */ + dissect_zcl_calendar_publish_day_profile(tvb, payload_tree, &offset); break; case ZBEE_ZCL_CMD_ID_CAL_PUBLISH_WEEK_PROFILE: - /* Add function to dissect payload */ + dissect_zcl_calendar_publish_week_profile(tvb, payload_tree, &offset); break; case ZBEE_ZCL_CMD_ID_CAL_PUBLISH_SEASONS: - /* Add function to dissect payload */ + dissect_zcl_calendar_publish_seasons(tvb, payload_tree, &offset); break; case ZBEE_ZCL_CMD_ID_CAL_PUBLISH_SPECIAL_DAYS: - /* Add function to dissect payload */ + dissect_zcl_calendar_publish_special_days(tvb, payload_tree, &offset); break; case ZBEE_ZCL_CMD_ID_CAL_CANCEL_CALENDAR: - /* Add function to dissect payload */ + dissect_zcl_calendar_cancel(tvb, payload_tree, &offset); break; default: @@ -5250,6 +5366,460 @@ dissect_zbee_zcl_calendar(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v } /*dissect_zbee_zcl_calendar*/ /** + *This function manages the Get Calendar 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_calendar_get_calendar(tvbuff_t *tvb, proto_tree *tree, guint *offset) +{ + nstime_t earliest_start_time; + + /* Earliest Start Time */ + earliest_start_time.secs = (time_t)tvb_get_letohl(tvb, *offset) + ZBEE_ZCL_NSTIME_UTC_OFFSET; + earliest_start_time.nsecs = 0; + proto_tree_add_time(tree, hf_zbee_zcl_calendar_earliest_start_time, tvb, *offset, 4, &earliest_start_time); + *offset += 4; + + /* Min Issuer Event ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_min_issuer_event_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Number of Calendars */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_number_of_calendars, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Calendar Type */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_type, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Provider Id */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_provider_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; +} /*dissect_zcl_calendar_get_calendar*/ + +/** + *This function manages the Get Day Profiles 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_calendar_get_day_profiles(tvbuff_t *tvb, proto_tree *tree, guint *offset) +{ + /* Provider Id */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_provider_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Issuer Calendar ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_issuer_calendar_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Start Day Id */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_start_day_id, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Number of Days */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_number_of_days, tvb, *offset, 1, ENC_NA); + *offset += 1; +} /*dissect_zcl_calendar_get_day_profiles*/ + +/** + *This function manages the Get Week Profiles 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_calendar_get_week_profiles(tvbuff_t *tvb, proto_tree *tree, guint *offset) +{ + /* Provider Id */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_provider_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Issuer Calendar ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_issuer_calendar_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Start Week Id */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_start_week_id, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Number of Weeks */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_number_of_weeks, tvb, *offset, 1, ENC_NA); + *offset += 1; +} /*dissect_zcl_calendar_get_week_profiles*/ + +/** + *This function manages the Get Seasons 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_calendar_get_seasons(tvbuff_t *tvb, proto_tree *tree, guint *offset) +{ + /* Provider Id */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_provider_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Issuer Calendar ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_issuer_calendar_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; +} /*dissect_zcl_calendar_get_seasons*/ + +/** + *This function manages the Get Special Days 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_calendar_get_special_days(tvbuff_t *tvb, proto_tree *tree, guint *offset) +{ + nstime_t start_time; + + /* Start Time */ + start_time.secs = (time_t)tvb_get_letohl(tvb, *offset) + ZBEE_ZCL_NSTIME_UTC_OFFSET; + start_time.nsecs = 0; + proto_tree_add_time(tree, hf_zbee_zcl_calendar_start_time, tvb, *offset, 4, &start_time); + *offset += 4; + + /* Number of Events */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_number_of_events, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Calendar Type */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_type, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Provider Id */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_provider_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Issuer Calendar ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_issuer_calendar_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; +} /*dissect_zcl_calendar_get_special_days*/ + +/** + *This function manages the Publish Calendar 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_calendar_publish_calendar(tvbuff_t *tvb, proto_tree *tree, guint *offset) +{ + nstime_t start_time; + int length; + + /* Provider Id */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_provider_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Issuer Event ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_issuer_event_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Issuer Calendar ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_issuer_calendar_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Start Time */ + start_time.secs = (time_t)tvb_get_letohl(tvb, *offset) + ZBEE_ZCL_NSTIME_UTC_OFFSET; + start_time.nsecs = 0; + proto_tree_add_time(tree, hf_zbee_zcl_calendar_start_time, tvb, *offset, 4, &start_time); + *offset += 4; + + /* Calendar Type */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_type, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Calendar Time Reference */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_time_reference, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Calendar Name */ + proto_tree_add_item_ret_length(tree, hf_zbee_zcl_calendar_name, tvb, *offset, 1, ENC_NA|ENC_ZIGBEE, &length); + *offset += length; + + /* Number of Seasons */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_number_of_seasons, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Number of Week Profiles */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_number_of_week_profiles, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Number of Day Profiles */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_number_of_day_profiles, tvb, *offset, 1, ENC_NA); + *offset += 1; +} /*dissect_zcl_calendar_publish_calendar*/ + +/** + *This function manages the Publish Day Profile 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_calendar_publish_day_profile(tvbuff_t *tvb, proto_tree *tree, guint *offset) +{ + guint8 schedule_entries_count; + guint8 calendar_type; + + /* Provider Id */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_provider_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Issuer Event ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_issuer_event_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Issuer Calendar ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_issuer_calendar_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Day ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_day_id, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Total Number of Schedule Entries */ + schedule_entries_count = tvb_get_guint8(tvb, *offset); + proto_tree_add_item(tree, hf_zbee_zcl_calendar_total_number_of_schedule_entries, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Command Index */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_command_index, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Total Number of Commands */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_total_number_of_commands, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Calendar Type */ + calendar_type = tvb_get_guint8(tvb, *offset); + proto_tree_add_item(tree, hf_zbee_zcl_calendar_type, tvb, *offset, 1, ENC_NA); + *offset += 1; + + for (gint i = 0; tvb_reported_length_remaining(tvb, *offset) >= 3 && i < schedule_entries_count; i++) { + /* Start Time */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_schedule_entry_start_time, tvb, *offset, 2, ENC_LITTLE_ENDIAN); + *offset += 2; + + switch (calendar_type) { + /* Rate Start Time */ + case ZBEE_ZCL_CALENDAR_TYPE_DELIVERED: + case ZBEE_ZCL_CALENDAR_TYPE_RECEIVED: + case ZBEE_ZCL_CALENDAR_TYPE_DELIVERED_AND_RECEIVED: + /* Price Tier */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_schedule_entry_price_tier, tvb, *offset, 1, ENC_NA); + *offset += 1; + break; + + /* Friendly Credit Start Time */ + case ZBEE_ZCL_CALENDAR_TYPE_FRIENDLY_CREDIT: + /* Price Tier */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_schedule_entry_friendly_credit_enable, tvb, *offset, 1, ENC_NA); + *offset += 1; + break; + + /* Auxilary Load Start Time */ + case ZBEE_ZCL_CALENDAR_TYPE_AUXILARY_LOAD_SWITCH: + /* Price Tier */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_schedule_entry_auxilary_load_switch_state, tvb, *offset, 1, ENC_NA); + *offset += 1; + break; + } + } +} /*dissect_zcl_calendar_publish_day_profile*/ + +/** + *This function manages the Publish Week Profile 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_calendar_publish_week_profile(tvbuff_t *tvb, proto_tree *tree, guint *offset) +{ + /* Provider Id */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_provider_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Issuer Event ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_issuer_event_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Issuer Calendar ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_issuer_calendar_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Week ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_week_id, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Day ID Ref Monday */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_day_id_ref_monday, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Day ID Ref Tuesday */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_day_id_ref_tuesday, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Day ID Ref Wednesday */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_day_id_ref_wednesday, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Day ID Ref Thursday */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_day_id_ref_thursday, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Day ID Ref Friday */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_day_id_ref_friday, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Day ID Ref Saturday */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_day_id_ref_saturday, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Day ID Ref Sunday */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_day_id_ref_sunday, tvb, *offset, 1, ENC_NA); + *offset += 1; +} /*dissect_zcl_calendar_publish_week_profile*/ + +/** + *This function manages the Publish Season Profile 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_calendar_publish_seasons(tvbuff_t *tvb, proto_tree *tree, guint *offset) +{ + /* Provider Id */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_provider_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Issuer Event ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_issuer_event_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Issuer Calendar ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_issuer_calendar_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Command Index */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_command_index, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Total Number of Commands */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_total_number_of_commands, tvb, *offset, 1, ENC_NA); + *offset += 1; + + for (gint i = 0; tvb_reported_length_remaining(tvb, *offset) >= 5; i++) { + /* Season Start Date */ + dissect_zcl_date(tvb, tree, offset, ett_zbee_zcl_calendar_season_start_date, "Season Start Date", hf_zbee_zcl_calendar_date_year, hf_zbee_zcl_calendar_date_month, hf_zbee_zcl_calendar_date_month_day, hf_zbee_zcl_calendar_date_week_day); + + /* Week ID Ref */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_week_id_ref, tvb, *offset, 1, ENC_NA); + *offset += 1; + } +} /*dissect_zcl_calendar_publish_seasons*/ + +/** + *This function manages the Publish Special Days 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_calendar_publish_special_days(tvbuff_t *tvb, proto_tree *tree, guint *offset) +{ + guint8 total_special_days_count; + nstime_t start_time; + + /* Provider Id */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_provider_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Issuer Event ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_issuer_event_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Issuer Calendar ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_issuer_calendar_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Start Time */ + start_time.secs = (time_t)tvb_get_letohl(tvb, *offset) + ZBEE_ZCL_NSTIME_UTC_OFFSET; + start_time.nsecs = 0; + proto_tree_add_time(tree, hf_zbee_zcl_calendar_start_time, tvb, *offset, 4, &start_time); + *offset += 4; + + /* Calendar Type */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_type, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Total Number of Special Days */ + total_special_days_count = tvb_get_guint8(tvb, *offset); + proto_tree_add_item(tree, hf_zbee_zcl_calendar_total_number_of_special_days, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Command Index */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_command_index, tvb, *offset, 1, ENC_NA); + *offset += 1; + + /* Total Number of Commands */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_total_number_of_commands, tvb, *offset, 1, ENC_NA); + *offset += 1; + + for (gint i = 0; tvb_reported_length_remaining(tvb, *offset) >= 5 && i < total_special_days_count; i++) { + /* Special Day Date */ + dissect_zcl_date(tvb, tree, offset, ett_zbee_zcl_calendar_special_day_date, "Special Day Date", hf_zbee_zcl_calendar_date_year, hf_zbee_zcl_calendar_date_month, hf_zbee_zcl_calendar_date_month_day, hf_zbee_zcl_calendar_date_week_day); + + /* Day ID Ref */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_day_id_ref, tvb, *offset, 1, ENC_NA); + *offset += 1; + } +} /*dissect_zcl_calendar_publish_special_days*/ + +/** + *This function manages the Cancel Calendar 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_calendar_cancel(tvbuff_t *tvb, proto_tree *tree, guint *offset) +{ + /* Provider Id */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_provider_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Issuer Calendar ID */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_issuer_calendar_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); + *offset += 4; + + /* Calendar Type */ + proto_tree_add_item(tree, hf_zbee_zcl_calendar_type, tvb, *offset, 1, ENC_NA); + *offset += 1; +} /*dissect_zcl_calendar_cancel*/ + +/** *This function registers the ZCL Calendar dissector * */ @@ -5274,11 +5844,177 @@ proto_register_zbee_zcl_calendar(void) { "Command", "zbee_zcl_se.calendar.cmd.srv_rx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_calendar_srv_rx_cmd_names), 0x00, NULL, HFILL } }, + { &hf_zbee_zcl_calendar_type, + { "Calendar Type", "zbee_zcl_se.calendar.type", FT_UINT8, BASE_HEX, VALS(zbee_zcl_calendar_type_names), + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_start_time, + { "Start Time", "zbee_zcl_se.calendar.start_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_earliest_start_time, + { "Earliest Start Time", "zbee_zcl_se.calendar.earliest_start_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_time_reference, + { "Calendar Time Reference", "zbee_zcl_se.calendar.time_reference", FT_UINT8, BASE_HEX, VALS(zbee_zcl_calendar_time_reference_names), + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_name, + { "Calendar Name", "zbee_zcl_se.calendar.name", FT_STRING, BASE_NONE, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_command_index, + { "Command Index", "zbee_zcl_se.calendar.command_index", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_date_year, + { "Year", "zbee_zcl_se.calendar.date.year", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_date_month, + { "Month", "zbee_zcl_se.calendar.date.month", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_date_month_day, + { "Month Day", "zbee_zcl_se.calendar.date.month_day", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_date_week_day, + { "Week Day", "zbee_zcl_se.calendar.date.week_day", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_provider_id, + { "Provider ID", "zbee_zcl_se.calendar.provider_id", FT_UINT32, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_issuer_event_id, + { "Issuer Event ID", "zbee_zcl_se.calendar.issuer_event_id", FT_UINT32, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_min_issuer_event_id, + { "Min. Issuer Event ID", "zbee_zcl_se.calendar.min_issuer_event_id", FT_UINT32, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_issuer_calendar_id, + { "Issuer Calendar ID", "zbee_zcl_se.calendar.issuer_calendar_id", FT_UINT32, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_day_id, + { "Day ID", "zbee_zcl_se.calendar.day_id", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_day_id_ref, + { "Day ID Ref", "zbee_zcl_se.calendar.day_id_ref", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_day_id_ref_monday, + { "Day ID Ref Monday", "zbee_zcl_se.calendar.day_id_ref_monday", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_day_id_ref_tuesday, + { "Day ID Ref Tuesday", "zbee_zcl_se.calendar.day_id_ref_tuesday", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_day_id_ref_wednesday, + { "Day ID Ref Wednesday", "zbee_zcl_se.calendar.day_id_ref_wednesday", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_day_id_ref_thursday, + { "Day ID Ref Thursday", "zbee_zcl_se.calendar.day_id_ref_thursday", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_day_id_ref_friday, + { "Day ID Ref Friday", "zbee_zcl_se.calendar.day_id_ref_friday", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_day_id_ref_saturday, + { "Day ID Ref Saturday", "zbee_zcl_se.calendar.day_id_ref_saturday", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_day_id_ref_sunday, + { "Day ID Ref Sunday", "zbee_zcl_se.calendar.day_id_ref_sunday", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_week_id, + { "Week ID", "zbee_zcl_se.calendar.week_id", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_week_id_ref, + { "Week ID Ref", "zbee_zcl_se.calendar.week_id_ref", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_start_day_id, + { "Start Day ID", "zbee_zcl_se.calendar.start_day_id", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_start_week_id, + { "Start Week ID", "zbee_zcl_se.calendar.start_week_id", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_number_of_calendars, + { "Number of Calendars", "zbee_zcl_se.calendar.number_of_calendars", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_number_of_events, + { "Number of Events", "zbee_zcl_se.calendar.number_of_events", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_number_of_days, + { "Number of Days", "zbee_zcl_se.calendar.number_of_days", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_number_of_weeks, + { "Number of Weeks", "zbee_zcl_se.calendar.number_of_weeks", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_number_of_seasons, + { "Number of Seasons", "zbee_zcl_se.calendar.number_of_seasons", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_number_of_day_profiles, + { "Number of Day Profiles", "zbee_zcl_se.calendar.number_of_day_profiles", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_number_of_week_profiles, + { "Number of Week Profiles", "zbee_zcl_se.calendar.number_of_week_profiles", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_total_number_of_schedule_entries, + { "Total Number of Schedule Entries", "zbee_zcl_se.calendar.total_number_of_schedule_entries", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_total_number_of_special_days, + { "Total Number of Special Days", "zbee_zcl_se.calendar.total_number_of_special_days", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_total_number_of_commands, + { "Total Number of Commands", "zbee_zcl_se.calendar.total_number_of_commands", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_schedule_entry_start_time, + { "Start Time", "zbee_zcl_se.calendar.schedule_entry.start_time", FT_UINT16, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_schedule_entry_price_tier, + { "Price Tier", "zbee_zcl_se.calendar.schedule_entry.price_tier", FT_UINT8, BASE_DEC, NULL, + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_schedule_entry_friendly_credit_enable, + { "Friendly Credit Enable", "zbee_zcl_se.calendar.schedule_entry.friendly_credit_enable", FT_BOOLEAN, 8, TFS(&tfs_enabled_disabled), + 0x00, NULL, HFILL } }, + + { &hf_zbee_zcl_calendar_schedule_entry_auxilary_load_switch_state, + { "Auxilary Load Switch State", "zbee_zcl_se.calendar.schedule_entry.auxilary_load_switch_state", FT_UINT8, BASE_HEX, NULL, + 0x00, NULL, HFILL } }, + }; /* ZCL Calendar subtrees */ gint *ett[] = { &ett_zbee_zcl_calendar, + &ett_zbee_zcl_calendar_special_day_date, + &ett_zbee_zcl_calendar_season_start_date, }; /* Register the ZigBee ZCL Calendar cluster protocol name and description */ |