summaryrefslogtreecommitdiff
path: root/digital/beacon/src/Bitcloud_stack/Components/APS/include/private/apsTransportKey.h
blob: 989f5dd627bedadd61c7134cdba7d4ffc5f26cbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**************************************************************************//**
  \file apsTransportKey.h

  \brief Private interface of transport key implementation.

  \author
    Atmel Corporation: http://www.atmel.com \n
    Support email: avr@atmel.com

  Copyright (c) 2008 , Atmel Corporation. All rights reserved.
  Licensed under Atmel's Limited License Agreement (BitCloudTM).

  \internal
   History:
    2011-05-05 Max Gekk - Created.
   Last change:
    $Id: apsTransportKey.h 18405 2011-08-31 15:42:23Z mgekk $
 ******************************************************************************/
#if !defined _APS_TRANSPORT_KEY_H
#define _APS_TRANSPORT_KEY_H

/******************************************************************************
                               Includes section
 ******************************************************************************/
#include <apsCommand.h>
#include <apsmeTransportKey.h>

#if defined _SECURITY_
/******************************************************************************
                               Definitions section
 ******************************************************************************/
/* The macro checks the source is trusted - himself or Trust Center. */
#define IS_SOURCE_TRUSTED(commandInd) ((commandInd)->nwkDataInd->boomerang \
  || (APS_SECURED_HASH_OF_TRUST_CENTER_LINK_KEY_STATUS == (commandInd)->securityStatus) \
  || (APS_SECURED_TRUST_CENTER_LINK_KEY_STATUS == (commandInd)->securityStatus))

/******************************************************************************
                                 Types section
 ******************************************************************************/
/* Type of function for preparing and sending a transport key command. */
typedef void (* ApsTransportKeyCommand_t)(APS_TransportKeyReq_t *const req);
BEGIN_PACK
/* Type of common part of APS Transport Key command. */
typedef struct PACK _ApsTransportKeyCommonFrame_t
{
  /** An APS header, which comprises frame control and addressing information. */
  ApduCommandHeader_t header;
  /** This field describes the type of key being transported. The different
   * types of keys are enumerated in Table 4.12 of ZigBee spec r19. */
  uint8_t keyType;
} ApsTransportKeyCommonFrame_t;
END_PACK

/******************************************************************************
                               Prototypes section
 ******************************************************************************/
/**************************************************************************//**
  \brief Main task handler of APS Transport Key component.
 ******************************************************************************/
APS_PRIVATE void apsTransportKeyTaskHandler(void);

#if defined _TRUST_CENTRE_
/**************************************************************************//**
  \brief Process confirmation of APS transport key command transmission.

  \param[in] commandReq - pointer to APS command request.
  \param[in] status - command transmission status.

  \return None.
 ******************************************************************************/
APS_PRIVATE void apsConfirmTransportKeyCommand(ApsCommandReq_t *const commandReq,
  const APS_Status_t status);

/**************************************************************************//**
  \brief Initialization of common fields of APS Transport key command frame.

  \param[in] commonFields - common sub-frame of transport key frame.
  \param[in] keyType - type of key in the transport key command frame.

  \return None.
 ******************************************************************************/
APS_PRIVATE void
apsInitCommonTransportKeyFields(ApsTransportKeyCommonFrame_t *const commonFields,
  const APS_TransportKeyType_t keyType);
#endif /* _TRUST_CENTRE_ */

/**************************************************************************//**
  \brief Process an incoming transport key command frame.

  \param[in] commandInd - pointer to received command descriptor.
  \return 'true' if NWK_DataInd_t structure is not used otherwise return 'false'.
 ******************************************************************************/
APS_PRIVATE bool apsTransportKeyInd(const ApsCommandInd_t *const commandInd);

/**************************************************************************//**
  \brief Forward a transport key command to unauthenticated child.

  \param[in] commandInd - pointer to received command descriptor.
  \param[in] dstExtAddr - pointer to raw extended address from received frame.
  \param[in] apsSendKeyToChildConf - NLDE-DATA confirm callback function's pointer.

  \return 'true' if NWK_DataInd_t structure is not used otherwise return 'false'.
 ******************************************************************************/
APS_PRIVATE bool apsForwardKeyToChild(const ApsCommandInd_t *const commandInd,
  const uint8_t *const dstExtAddr,
  void (* apsSendKeyToChildConf)(NWK_DataConf_t *conf));

/**************************************************************************//**
  \brief Reset the internal queue and variables of Transport Key component.
 ******************************************************************************/
APS_PRIVATE void apsTransportKeyReset(void);

#else
#define apsTransportKeyTaskHandler NULL
#define apsTransportKeyReset() (void)0
#endif /* _SECURITY_ */
#endif /* _APS_TRANSPORT_KEY_H */
/** eof apsTransportKey.h */