ZigBee: Implement r21 APS commands Verify Key and Confirm Key

Introduced general APS command status, approproate field calles zbee_aps.cmd.status.
Changed zbee_aps.cmd.status field name of UPDATE-DEVICE to zbee_aps.cmd.update_status.

Change-Id: I0ad330e5d4a8948413aab428cac1e1475076c97b
Reviewed-on: https://code.wireshark.org/review/12864
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
dsrsupport 2015-12-25 15:18:23 +03:00 committed by Michael Mann
parent 88f01f8bcc
commit 503aea41e7
2 changed files with 134 additions and 1 deletions

View File

@ -55,6 +55,8 @@ static guint dissect_zbee_aps_switch_key (tvbuff_t *tvb, packet_info *pinf
static guint dissect_zbee_aps_auth_challenge (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
static guint dissect_zbee_aps_auth_data (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
static guint dissect_zbee_aps_tunnel (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, void *data);
static guint dissect_zbee_aps_verify_key (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
static guint dissect_zbee_aps_confirm_key (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset);
static guint dissect_zbee_t2 (tvbuff_t *tvb, proto_tree *tree, guint16 cluster_id);
/* Helper routine. */
@ -105,12 +107,14 @@ static int hf_zbee_aps_cmd_device = -1;
static int hf_zbee_aps_cmd_challenge = -1;
static int hf_zbee_aps_cmd_mac = -1;
static int hf_zbee_aps_cmd_key = -1;
static int hf_zbee_aps_cmd_key_hash = -1;
static int hf_zbee_aps_cmd_key_type = -1;
static int hf_zbee_aps_cmd_dst = -1;
static int hf_zbee_aps_cmd_src = -1;
static int hf_zbee_aps_cmd_seqno = -1;
static int hf_zbee_aps_cmd_short_addr = -1;
static int hf_zbee_aps_cmd_device_status = -1;
static int hf_zbee_aps_cmd_status = -1;
static int hf_zbee_aps_cmd_ea_key_type = -1;
static int hf_zbee_aps_cmd_ea_data = -1;
@ -240,6 +244,8 @@ static const value_string zbee_aps_cmd_names[] = {
{ ZBEE_APS_CMD_EA_INIT_MAC_DATA,"EA Initiator MAC" },
{ ZBEE_APS_CMD_EA_RESP_MAC_DATA,"EA Responder MAC" },
{ ZBEE_APS_CMD_TUNNEL, "Tunnel" },
{ ZBEE_APS_CMD_VERIFY_KEY, "Verify Key" },
{ ZBEE_APS_CMD_CONFIRM_KEY, "Confirm Key" },
{ 0, NULL }
};
@ -273,6 +279,31 @@ static const value_string zbee_aps_update_status_names[] = {
{ 0, NULL }
};
/* Update Device Status Names */
static const value_string zbee_aps_status_names[] = {
{ ZBEE_APP_STATUS_SUCCESS, "SUCCESS" },
{ ZBEE_APP_STATUS_ASDU_TOO_LONG, "ASDU_TOO_LONG" },
{ ZBEE_APP_STATUS_DEFRAG_DEFERRED, "DEFRAG_DEFERRED" },
{ ZBEE_APP_STATUS_DEFRAG_UNSUPPORTED, "DEFRAG_UNSUPPORTED" },
{ ZBEE_APP_STATUS_ILLEGAL_REQUEST, "ILLEGAL_REQUEST" },
{ ZBEE_APP_STATUS_INVALID_BINDING, "INVALID_BINDING" },
{ ZBEE_APP_STATUS_INVALID_GROUP, "INVALID_GROUP" },
{ ZBEE_APP_STATUS_INVALID_PARAMETER, "INVALID_PARAMETER" },
{ ZBEE_APP_STATUS_NO_ACK, "NO_ACK" },
{ ZBEE_APP_STATUS_NO_BOUND_DEVICE, "NO_BOUND_DEVICE" },
{ ZBEE_APP_STATUS_NO_SHORT_ADDRESS, "NO_SHORT_ADDRESS" },
{ ZBEE_APP_STATUS_NOT_SUPPORTED, "NOT_SUPPORTED" },
{ ZBEE_APP_STATUS_SECURED_LINK_KEY, "SECURED_LINK_KEY" },
{ ZBEE_APP_STATUS_SECURED_NWK_KEY, "SECURED_NWK_KEY" },
{ ZBEE_APP_STATUS_SECURITY_FAIL, "SECURITY_FAIL" },
{ ZBEE_APP_STATUS_TABLE_FULL, "TABLE_FULL" },
{ ZBEE_APP_STATUS_UNSECURED, "UNSECURED" },
{ ZBEE_APP_STATUS_UNSUPPORTED_ATTRIBUTE, "UNSUPPORTED_ATTRIBUTE" },
{ 0, NULL }
};
/* Outdated ZigBee 2004 Value Strings. */
static const value_string zbee_apf_type_names[] = {
{ ZBEE_APP_TYPE_KVP, "Key-Value Pair" },
@ -1143,6 +1174,16 @@ static void dissect_zbee_aps_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *
offset = dissect_zbee_aps_tunnel(tvb, pinfo, cmd_tree, offset, data);
break;
case ZBEE_APS_CMD_VERIFY_KEY:
/* Verify Key Command. */
offset = dissect_zbee_aps_verify_key(tvb, pinfo, cmd_tree, offset);
break;
case ZBEE_APS_CMD_CONFIRM_KEY:
/* Confirm Key Command. */
offset = dissect_zbee_aps_confirm_key(tvb, pinfo, cmd_tree, offset);
break;
default:
break;
} /* switch */
@ -1340,6 +1381,67 @@ dissect_zbee_aps_transport_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
return offset;
} /* dissect_zbee_aps_transport_key */
/**
*Helper dissector for the Verify Key Command.
*
*@param tvb pointer to buffer containing raw packet.
*@param pinfo pointer to packet information fields
*@param tree pointer to the command subtree.
*@param offset into the tvb to begin dissection.
*@return offset after command dissection.
*/
static guint
dissect_zbee_aps_verify_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset)
{
/* display the key type. */
proto_tree_add_item(tree, hf_zbee_aps_cmd_key_type, tvb, offset, 1, ENC_NA);
offset += 1;
/* Get and display the source address. */
proto_tree_add_item(tree, hf_zbee_aps_cmd_src, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* This value is the outcome of executing the specialized keyed hash
* function specified in section B.1.4 using a key with the 1-octet string
* 03 as the input string.
*/
proto_tree_add_item(tree, hf_zbee_aps_cmd_key_hash, tvb, offset, ZBEE_APS_CMD_KEY_LENGTH, ENC_NA);
offset += ZBEE_APS_CMD_KEY_LENGTH;
/* Done */
return offset;
} /* dissect_zbee_aps_verify_key */
/**
*Helper dissector for the Confirm Key command.
*
*@param tvb pointer to buffer containing raw packet.
*@param pinfo pointer to packet information fields
*@param tree pointer to the command subtree.
*@param offset into the tvb to begin dissection.
*@return offset after command dissection.
*/
static guint
dissect_zbee_aps_confirm_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset)
{
/* display status. */
guint status = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_zbee_aps_cmd_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* display the key type. */
proto_tree_add_item(tree, hf_zbee_aps_cmd_key_type, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_zbee_aps_cmd_dst, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_item_append_text(tree, ", %s", val_to_str_const(status, zbee_aps_status_names, "Unknown Status"));
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", val_to_str_const(status, zbee_aps_status_names, "Unknown Status"));
/* Done */
return offset;
} /* dissect_zbee_aps_confirm_key */
/**
*Helper dissector for the Update Device command.
*
@ -1878,6 +1980,10 @@ void proto_register_zbee_aps(void)
{ "Key", "zbee_aps.cmd.key", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_zbee_aps_cmd_key_hash,
{ "Key Hash", "zbee_aps.cmd.key_hash", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_zbee_aps_cmd_key_type,
{ "Key Type", "zbee_aps.cmd.key_type", FT_UINT8, BASE_HEX,
VALS(zbee_aps_key_names), 0x0, NULL, HFILL }},
@ -1899,10 +2005,15 @@ void proto_register_zbee_aps(void)
"The device whose status is being updated.", HFILL }},
{ &hf_zbee_aps_cmd_device_status,
{ "Device Status", "zbee_aps.cmd.status", FT_UINT8, BASE_HEX,
{ "Device Status", "zbee_aps.cmd.update_status", FT_UINT8, BASE_HEX,
VALS(zbee_aps_update_status_names), 0x0,
"Update device status.", HFILL }},
{ &hf_zbee_aps_cmd_status,
{ "Status", "zbee_aps.cmd.status", FT_UINT8, BASE_HEX,
VALS(zbee_aps_status_names), 0x0,
"APS status.", HFILL }},
{ &hf_zbee_aps_cmd_ea_key_type,
{ "Key Type", "zbee_aps.cmd.ea.key_type", FT_UINT8, BASE_HEX,
VALS(zbee_aps_ea_key_names), 0x0,

View File

@ -62,6 +62,8 @@
#define ZBEE_APS_CMD_EA_INIT_MAC_DATA 0x0c
#define ZBEE_APS_CMD_EA_RESP_MAC_DATA 0x0d
#define ZBEE_APS_CMD_TUNNEL 0x0e
#define ZBEE_APS_CMD_VERIFY_KEY 0x0f
#define ZBEE_APS_CMD_CONFIRM_KEY 0x10
#define ZBEE_APS_CMD_KEY_TC_MASTER 0x00
#define ZBEE_APS_CMD_KEY_STANDARD_NWK 0x01
@ -246,6 +248,26 @@
#define ZBEE_APS_T2_CID_BTARXOWIDR 0xf00a
#define ZBEE_APS_T2_CID_BTARACR 0xf00e
#define ZBEE_APP_STATUS_SUCCESS 0x00 /*A request has been executed successfully.*/
#define ZBEE_APP_STATUS_ASDU_TOO_LONG 0xa0 /*A transmit request failed since the ASDU is too large and fragmentation is not supported.*/
#define ZBEE_APP_STATUS_DEFRAG_DEFERRED 0xa1 /*A received fragmented frame could not be defragmented at the current time.*/
#define ZBEE_APP_STATUS_DEFRAG_UNSUPPORTED 0xa2 /*A received fragmented frame could not be defragmented since the device does not support fragmentation.*/
#define ZBEE_APP_STATUS_ILLEGAL_REQUEST 0xa3 /*A parameter value was out of range.*/
#define ZBEE_APP_STATUS_INVALID_BINDING 0xa4 /*An APSME-UNBIND.request failed due to the requested binding link not existing in the binding table.*/
#define ZBEE_APP_STATUS_INVALID_GROUP 0xa5 /*An APSME-REMOVE-GROUP.request has been issued with a group identifier that does not appear in the group table.*/
#define ZBEE_APP_STATUS_INVALID_PARAMETER 0xa6 /*A parameter value was invalid or out of range.*/
#define ZBEE_APP_STATUS_NO_ACK 0xa7 /*An APSDE-DATA.request requesting acknowledged trans-mission failed due to no acknowledgement being received.*/
#define ZBEE_APP_STATUS_NO_BOUND_DEVICE 0xa8 /*An APSDE-DATA.request with a destination addressing mode set to 0x00 failed due to there being no devices bound to this device.*/
#define ZBEE_APP_STATUS_NO_SHORT_ADDRESS 0xa9 /*An APSDE-DATA.request with a destination addressing mode set to 0x03 failed due to no corresponding short address found*/
#define ZBEE_APP_STATUS_NOT_SUPPORTED 0xaa /*An APSDE-DATA.request with a destination addressing mode set to 0x00 failed due to a binding table not being supported on the device.*/
#define ZBEE_APP_STATUS_SECURED_LINK_KEY 0xab /*An ASDU was received that was secured using a link key.*/
#define ZBEE_APP_STATUS_SECURED_NWK_KEY 0xac /*An ASDU was received that was secured using a network key.*/
#define ZBEE_APP_STATUS_SECURITY_FAIL 0xad /*An APSDE-DATA.request requesting security has resulted in an error during the corresponding security processing.*/
#define ZBEE_APP_STATUS_TABLE_FULL 0xae /*An APSME-BIND.request or APSME.ADD-GROUP.request issued when the binding or group tables, respectively, were full.*/
#define ZBEE_APP_STATUS_UNSECURED 0xaf /*An ASDU was received without any security.*/
#define ZBEE_APP_STATUS_UNSUPPORTED_ATTRIBUTE 0xb0 /*An APSME-GET.request or APSME-SET.request has been issued with an unknown attribute identifier.*/
/* Structure to contain the APS frame information */
typedef struct{
gboolean indirect_mode; /* ZigBee 2004 and Earlier */