Mistake on this page?
Report an issue in GitHub or email us
atts_main.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief ATT server main module.
6  *
7  * Copyright (c) 2009-2019 Arm Ltd. All Rights Reserved.
8  *
9  * Copyright (c) 2019-2020 Packetcraft, Inc.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 /*************************************************************************************************/
24 #ifndef ATTS_MAIN_H
25 #define ATTS_MAIN_H
26 
27 #include "wsf_queue.h"
28 #include "wsf_timer.h"
29 #include "att_api.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /**************************************************************************************************
36  Data Types
37 **************************************************************************************************/
38 
39 /* ATTS event handler messages */
40 enum
41 {
42  ATTS_MSG_IDLE_TIMEOUT = ATTS_MSG_START,
43  ATTS_MSG_API_VALUE_IND_NTF,
44  ATTS_MSG_IND_TIMEOUT,
45  ATTS_MSG_SIGN_CMAC_CMPL,
46  ATTS_MSG_DBH_CMAC_CMPL
47 };
48 
49 /*!
50  * Data buffer format for API request messages:
51  *
52  * | attsPktParam_t | ATT request data |
53  * | bytes 0 to 7 | bytes 8 - |
54  */
55 
56 /* API parameters */
57 typedef struct
58 {
59  uint16_t len;
60  uint16_t handle;
62 
63 /* verify attsPktParam_t will work in data buffer format described above */
65 
66 /* API message structure */
67 typedef struct
68 {
69  wsfMsgHdr_t hdr;
70  attsPktParam_t *pPkt;
71  uint8_t slot;
72 } attsApiMsg_t;
73 
74 /* ATTS connection control block */
75 typedef struct
76 {
77  wsfTimer_t outIndTimer; /* Outstanding indication timer */
78  attCcb_t *pMainCcb; /* Pointer to ATT main CCB */
79  wsfTimer_t idleTimer; /* service discovery idle timer */
80  dmConnId_t connId; /* DM connection ID */
81  uint8_t slot; /* ATT/EATT slot ID */
82  uint16_t outIndHandle; /* Waiting for confirm from peer for this indication handle */
83  uint16_t pendIndHandle; /* Callback to application pending for this indication handle */
84  uint16_t pendNtfHandle[ATT_NUM_SIMUL_NTF]; /* Callback to application pending for this notification handle */
85 } attsCcb_t;
86 
87 /* Client characteristic configuration descriptor callback type
88  *
89  * \param connId DM connection ID.
90  * \param method Read or write.
91  * \param handle Attribute handle of the descriptor.
92  * \param pValue Pointer to the attribute value of the descriptor.
93  *
94  * \return ATT_SUCCESS if successful otherwise error.
95  */
96 typedef uint8_t (*attsCccFcn_t)(dmConnId_t connId, uint8_t method, uint16_t handle, uint8_t *pValue);
97 
98 /* Main control block of the ATTS subsystem */
99 typedef struct
100 {
101  attsCcb_t ccb[DM_CONN_MAX][ATT_BEARER_MAX]; /* Connection slot control block */
102  wsfQueue_t prepWriteQueue[DM_CONN_MAX]; /* Connection prepare write queue */
103  wsfQueue_t groupQueue; /* Queue of attribute groups */
104  attFcnIf_t const *pInd; /* Indication callback interface */
105  attMsgHandler_t signMsgCback; /* Signed data callback interface */
106  attsAuthorCback_t authorCback; /* Authorization callback */
107  attsCccFcn_t cccCback; /* CCC callback */
108 } attsCb_t;
109 
110 /* PDU processing function type */
111 typedef void (*attsProcFcn_t)(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
112 
113 /* CSF Control block */
114 typedef struct
115 {
116  attsCsfRec_t attsCsfTable[DM_CONN_MAX]; /* connected clients' supported features record table. */
117  attsCsfWriteCback_t writeCback; /* Write callback. */
118  uint8_t isHashUpdating; /* Database hash update status. */
119 } attsCsfCb_t;
120 
121 /**************************************************************************************************
122  Global Variables
123 **************************************************************************************************/
124 
125 /* PDU processing function lookup table, indexed by method */
126 extern attsProcFcn_t attsProcFcnTbl[ATT_METHOD_SIGNED_WRITE_CMD+1];
127 
128 /* Control block */
129 extern attsCb_t attsCb;
130 
131 /**************************************************************************************************
132  Function Declarations
133 **************************************************************************************************/
134 
135 attsCcb_t *attsCcbByConnId(dmConnId_t connId, uint8_t slot);
136 attsCcb_t *attsCcbByHandle(uint16_t handle, uint8_t slot);
137 
138 void attsErrRsp(attCcb_t *pCcb, uint8_t slot, uint8_t opcode, uint16_t attHandle, uint8_t reason);
139 void attsClearPrepWrites(attsCcb_t *pCcb);
140 bool_t attsUuidCmp(attsAttr_t *pAttr, uint8_t uuidLen, uint8_t *pUuid);
141 bool_t attsUuid16Cmp(uint8_t *pUuid16, uint8_t uuidLen, uint8_t *pUuid);
142 attsAttr_t *attsFindByHandle(uint16_t handle, attsGroup_t **pAttrGroup);
143 uint16_t attsFindInRange(uint16_t startHandle, uint16_t endHandle, attsAttr_t **pAttr);
144 uint16_t attsFindUuidInRange(uint16_t startHandle, uint16_t endHandle, uint8_t uuidLen,
145  uint8_t *pUuid, attsAttr_t **pAttr, attsGroup_t **pAttrGroup);
146 uint8_t attsPermissions(dmConnId_t connId, uint8_t permit, uint16_t handle, uint8_t permissions);
147 void attsDiscBusy(attsCcb_t *pCcb);
148 void attsCheckPendDbHashReadRsp(void);
149 void attsProcessDatabaseHashUpdate(secCmacMsg_t *pMsg);
150 uint16_t attsIsHashableAttr(attsAttr_t *pAttr);
151 void attsMsgCback(wsfMsgHdr_t *pMsg);
152 
153 void attsProcMtuReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
154 void attsProcFindInfoReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
155 void attsProcFindTypeReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
156 void attsProcReadTypeReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
157 void attsProcReadReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
158 void attsProcReadBlobReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
159 void attsProcReadMultReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
160 void attsProcReadGroupTypeReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
161 void attsProcWrite(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
162 void attsProcPrepWriteReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
163 void attsProcExecWriteReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
164 void attsProcValueCnf(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
165 void attsProcReadMultiVarReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
166 
167 uint8_t attsCsfActClientState(uint16_t handle, uint8_t opcode, uint8_t *pPacket);
168 uint8_t attsCsfIsClientChangeAware(dmConnId_t connId, uint16_t handle);
169 void attsCsfSetHashUpdateStatus(bool_t isUpdating);
170 uint8_t attsCsfGetHashUpdateStatus(void);
171 
172 void attsIndNtfCallback(dmConnId_t connId, attsCcb_t *pCcb, uint8_t status);
173 void attsHandleValueIndNtf(dmConnId_t connId, uint16_t handle, uint8_t slot, uint16_t valueLen,
174  uint8_t *pValue, uint8_t opcode, bool_t zeroCpy);
175 
176 #ifdef __cplusplus
177 };
178 #endif
179 
180 #endif /* ATTS_MAIN_H */
uint8_t dmConnId_t
Connection identifier.
Definition: dm_api.h:588
WSF_CT_ASSERT(((int) LCTR_EXT_INIT_MSG_INITIATE_CANCEL==(int) LCTR_INIT_MSG_INITIATE_CANCEL))
LCTR_EXT_INIT_MSG_INITIATE_CANCEL and LCTR_INIT_MSG_INITIATE_CANCEL shall be aligned.
CMAC Security callback parameters structure.
Definition: sec_api.h:77
Attribute group.
Definition: att_api.h:312
uint8_t(* attsAuthorCback_t)(dmConnId_t connId, uint8_t permit, uint16_t handle)
ATTS authorization callback type.
Definition: att_api.h:290
#define ATT_NUM_SIMUL_NTF
Maximum number of simultaneous ATT notifications.
Definition: cfg_stack.h:159
Queue structure.
Definition: wsf_queue.h:46
#define L2C_PAYLOAD_START
Start of L2CAP payload in an HCI ACL packet buffer.
Definition: l2c_defs.h:52
Attribute structure.
Definition: att_api.h:214
Timer structure.
Definition: wsf_timer.h:53
General purpose queue service.
#define DM_CONN_MAX
Maximum number of connections.
Definition: cfg_stack.h:81
Client supported features record structure.
Definition: att_api.h:225
Timer service.
void(* attsCsfWriteCback_t)(dmConnId_t connId, uint8_t changeAwareState, uint8_t *pCsf)
ATTS client supported features write callback type.
Definition: att_api.h:303
Attribute protocol client and server API.
Common message structure passed to event handler.
Definition: wsf_os.h:106
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.