1 /* *****************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * *****************************************************************/
21 #ifndef OC_PROVISIONING_TYPES_H
22 #define OC_PROVISIONING_TYPES_H
25 #include "experimental/securevirtualresourcetypes.h"
32 * Node to construct list of UUID pair list.
34 typedef struct OCPairList OCPairList_t;
43 * Node to construct UUID linked list.
45 typedef struct OCUuidList OCUuidList_t;
53 * Device's power on/off state.
56 DEV_STATUS_ON = (1 << 0),
57 DEV_STATUS_OFF = (1 << 1)
61 * Device Information of discoverd unowned/owned device(s) for provisioning.
63 typedef struct OCProvisionDev
65 OCDevAddr endpoint; /**< target address **/
66 OicSecPstat_t *pstat; /**< Pointer to target's pstat resource. **/
67 OicSecDoxm_t *doxm; /**< Pointer to target's doxm resource. **/
68 OCConnectivityType connType; /**< Connectivity type of endpoint */
69 uint16_t securePort; /**< secure port **/
71 uint16_t tcpPort; /**< tcp port **/
72 uint16_t tcpSecurePort; /**< secure tcp port **/
74 char specVer[SPEC_MAX_VER_LEN]; /**< spec version **/
75 DeviceStatus devStatus; /**< status of device **/
77 bool ownerAclUnauthorizedRequest; /**< true if the provisioning client has already re-tried posting the Owner ACE **/
78 struct OCProvisionDev *next; /**< Next pointer. **/
82 * Result information for each target device.
84 typedef struct OCPMResult{
89 typedef struct OCPMGetCsrResult
95 OicEncodingType_t encoding; /* Determines contents of csr; either OIC_ENCODING_DER or OIC_ENCODING_PEM */
98 typedef struct OCPMGetSpResult
105 typedef struct OCPMRoleCertChain
107 uint64_t credId; /**< credential ID */
108 OicSecKey_t certificate; /**< certificate chain including leaf and intermediate CA certificates */
109 } OCPMRoleCertChain_t;
111 typedef struct OCPMGetRolesResult
113 OicUuid_t deviceId; /**< responding device ID */
114 OCStackResult res; /**< result for this device */
115 OCPMRoleCertChain_t *chains; /**< cert chains (if res is OC_STACK_OK) */
116 size_t chainsLength; /**< length of chains array (if res is OC_STACK_OK */
117 } OCPMGetRolesResult_t;
122 typedef enum OwnerType{
128 * Index value to access OxM allow table
130 typedef enum OxmAllowTableIdx {
131 OXM_IDX_JUST_WORKS = 0,
132 OXM_IDX_MV_JUST_WORKS,
133 #ifdef MULTIPLE_OWNER
134 OXM_IDX_PRECONFIG_PIN,
136 OXM_IDX_RANDOM_DEVICE_PIN,
137 OXM_IDX_MANUFACTURER_CERTIFICATE,
138 OXM_IDX_CON_MFG_CERT,
139 OXM_IDX_DECENTRALIZED_PUBLIC_KEY,
145 * Callback function definition of provisioning API
147 * @param[in] ctx - If user set his/her context, it will be returned here.
148 * @param[in] nOfRes - total number of results, it depends on using which provisioning API.
149 * @param[in] arr - Array of OCPMResult_t, each OCPMResult_t contains result for target Device.
150 * @param[in] hasError - If there is no error, it's returned with 'false' but if there is a single
151 * or more error is/are occured during operation, it will be 'true'.
153 typedef void (*OCProvisionResultCB)(void* ctx, size_t nOfRes, OCProvisionResult_t *arr, bool hasError);
156 * Callback function definition of CSR retrieve API
158 * @param[out] ctx - If user set a context, it will be returned here.
159 * @param[out] nOfRes - total number of results
160 * @param[out] arr - Array of OCPMGetCsrResult_t, containing one entry for each target device. If an entry's res
161 * member is OC_STACK_OK, then csr and csrLen are valid; otherwise they should not be used.
162 * This memory is only valid while the callback is executing; callers must make copies if the data
163 * needs to be kept longer.
164 * @param[out] hasError - If all calls succeded, this will be false. One or more errors, and this will
165 * be true. Examine the elements of arr to discover which failed.
167 typedef void (*OCGetCSRResultCB)(void* ctx, size_t nOfRes, OCPMGetCsrResult_t *arr, bool hasError);
170 * Callback function definition of SP retrieve API
172 * @param[out] ctx - If user set a context, it will be returned here.
173 * @param[out] nOfRes - total number of results
174 * @param[out] arr - Array of OCPMGetSpResult_t, containing one entry for each target device. If an entry's res
175 * member is OC_STACK_OK, This memory is only valid while the callback is executing;
176 * callers must make copies if the data needs to be kept longer.
177 * @param[out] hasError - If all calls succeded, this will be false. One or more errors, and this will
178 * be true. Examine the elements of arr to discover which failed.
180 typedef void (*OCGetSpResultCB)(void* ctx, size_t nOfRes, OCPMGetSpResult_t *arr, bool hasError);
183 * Callback function definition of roles retrieve API
185 * @param[out] ctx - If user set a context, it will be returned here.
186 * @param[out] nOfRes - total number of results
187 * @param[out] arr - Array of OCPMGetRolesResult_t, containing one entry for each target device. If an entry's res
188 * member is OC_STACK_OK, then chains and chainsLength are valid; otherwise they should not be used.
189 * This memory is only valid while the callback is executing; callers must make copies if the data
190 * needs to be kept longer.
191 * @param[out] hasError - If all calls succeeded, this will be false. One or more errors, and this will
192 * be true. Examine the elements of arr to discover which failed.
194 typedef void (*OCGetRolesResultCB)(void* ctx, size_t nOfRes, OCPMGetRolesResult_t *arr, bool hasError);
200 #endif //OC_PROVISIONING_TYPES_H