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 OCPROVISIONINGMANAGER_H_
22 #define OCPROVISIONINGMANAGER_H_
26 #include "ownershiptransfermanager.h"
28 #include "securevirtualresourcetypes.h"
29 #endif //MULTIPLE_OWNER
36 * The function is responsible for initializaton of the provisioning manager. It will load
37 * provisioning database which have owned device's list and their linked status.
38 * TODO: In addition, if there is a device(s) which has not up-to-date credentials, this function will
39 * automatically try to update the deivce(s).
41 * @param[in] dbPath file path of the sqlite3 db
43 * @return OC_STACK_OK in case of success and other value otherwise.
45 OCStackResult OCInitPM(const char* dbPath);
48 * API to cleanup PDM in case of timeout.
49 * It will remove the PDM_DEVICE_INIT state devices from PDM.
51 * @return OC_STACK_OK in case of success and other value otherwise.
53 OCStackResult OCPDMCleanupForTimeout();
56 * The function is responsible for discovery of owned/unowned device is specified endpoint/deviceID.
57 * It will return the found device even though timeout is not exceeded.
59 * @param[in] timeout Timeout in seconds, value till which function will listen to responses from
60 * server before returning the device.
61 * @param[in] deviceID deviceID of target device.
62 * @param[out] ppFoundDevice OCProvisionDev_t of found device
63 * @return OTM_SUCCESS in case of success and other value otherwise.
65 OCStackResult OCDiscoverSingleDevice(unsigned short timeout, const OicUuid_t* deviceID,
66 OCProvisionDev_t **ppFoundDevice);
69 * The function is responsible for discovery of owned/unowned device is specified endpoint/MAC
71 * It will return the found device even though timeout is not exceeded.
73 * @param[in] timeout Timeout in seconds, value till which function will listen to responses from
74 * server before returning the device.
75 * @param[in] deviceID deviceID of target device.
76 * @param[in] hostAddress MAC address of target device.
77 * @param[in] connType ConnectivityType for discovery.
78 * @param[out] ppFoundDevice OCProvisionDev_t of found device.
79 * @return OTM_SUCCESS in case of success and other value otherwise.
81 OCStackResult OCDiscoverSingleDeviceInUnicast(unsigned short timeout, const OicUuid_t* deviceID,
82 const char* hostAddress, OCConnectivityType connType,
83 OCProvisionDev_t **ppFoundDevice);
86 * The function is responsible for discovery of device is current subnet. It will list
87 * all the device in subnet which are not yet owned. Please call OCInit with OC_CLIENT_SERVER as
90 * @param[in] waittime Timeout in seconds, value till which function will listen to responses from
91 * server before returning the list of devices.
92 * @param[out] ppList List of candidate devices to be provisioned
93 * @return OTM_SUCCESS in case of success and other value otherwise.
95 OCStackResult OCDiscoverUnownedDevices(unsigned short waittime, OCProvisionDev_t **ppList);
98 * Do ownership transfer for un-owned device.
100 * @param[in] ctx Application context would be returned in result callback
101 * @param[in] targetDevices List of devices to perform ownership transfer.
102 * @param[in] resultCallback Result callback function to be invoked when ownership transfer finished.
103 * @return OC_STACK_OK in case of success and other value otherwise.
105 OCStackResult OCDoOwnershipTransfer(void* ctx,
106 OCProvisionDev_t *targetDevices,
107 OCProvisionResultCB resultCallback);
110 * API to set a allow status of OxM
112 * @param[in] oxm Owership transfer method (ref. OicSecOxm_t)
113 * @param[in] allowStatus allow status (true = allow, false = not allow)
115 * @return OC_STACK_OK in case of success and other value otherwise.
117 OCStackResult OCSetOxmAllowStatus(const OicSecOxm_t oxm, const bool allowStatus);
119 #ifdef MULTIPLE_OWNER
121 * API to perfrom multiple ownership transfer for MOT enabled device.
123 * @param[in] ctx Application context would be returned in result callback
124 * @param[in] targetDevices List of devices to perform ownership transfer.
125 * @param[in] resultCallback Result callback function to be invoked when ownership transfer finished.
126 * @return OC_STACK_OK in case of success and other value otherwise.
128 OCStackResult OCDoMultipleOwnershipTransfer(void* ctx,
129 OCProvisionDev_t *targetDevices,
130 OCProvisionResultCB resultCallback);
131 #endif //MULTIPLE_OWNER
134 * API to register for particular OxM.
136 * @param[in] oxm transfer method.
137 * @param[in] callbackData of callback functions for owership transfer.
138 * @return OC_STACK_OK in case of success and other value otherwise.
140 OCStackResult OCSetOwnerTransferCallbackData(OicSecOxm_t oxm, OTMCallbackData_t* callbackData);
143 * The function is responsible for discovery of owned device is current subnet. It will list
144 * all the device in subnet which are owned by calling provisioning client.
146 * @param[in] timeout Timeout in seconds, value till which function will listen to responses from
147 * server before returning the list of devices.
148 * @param[out] ppList List of device owned by provisioning tool.
149 * @return OTM_SUCCESS in case of success and other value otherwise.
151 OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList);
153 #ifdef MULTIPLE_OWNER
155 * The function is responsible for the discovery of an MOT-enabled device with the specified deviceID.
156 * The function will return when security information for device with deviceID has been obtained or the
157 * timeout has been exceeded.
159 * @param[in] timeoutSeconds Maximum time, in seconds, this function will listen for responses from
160 * servers before returning.
161 * @param[in] deviceID deviceID of target device.
162 * @param[out] ppFoundDevice OCProvisionDev_t of discovered device. Caller should use
163 * OCDeleteDiscoveredDevices to delete the device.
164 * @return OC_STACK_OK in case of success and other values otherwise.
166 OCStackResult OCDiscoverMultipleOwnerEnabledSingleDevice(unsigned short timeoutSeconds,
167 const OicUuid_t *deviceID,
168 OCProvisionDev_t **ppFoundDevice);
171 * The function is responsible for discovery of MOT enabled device is current subnet.
173 * @param[in] timeout Timeout in seconds, value till which function will listen to responses from
174 * server before returning the list of devices.
175 * @param[out] ppList List of MOT enabled devices.
176 * @return OC_STACK_OK in case of success and other value otherwise.
178 OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList);
181 * The function is responsible for discovery of Multiple Owned device is current subnet.
183 * @param[in] timeout Timeout in seconds, value till which function will listen to responses from
184 * server before returning the list of devices.
185 * @param[out] ppList List of Multiple Owned devices.
186 * @return OC_STACK_OK in case of success and other value otherwise.
188 OCStackResult OCDiscoverMultipleOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList);
191 * The function is responsible for determining if the caller is a subowner of the specified device.
193 * @param[in] device MOT enabled device that contains a list of subowners.
194 * @param[out] isSubowner Bool indicating whether the caller is a subowner of device.
195 * @return OC_STACK_OK in case of success and other value otherwise.
197 OCStackResult OCIsSubownerOfDevice(OCProvisionDev_t *device, bool *isSubowner);
198 #endif //MULTIPLE_OWNER
201 * API to provision credentials between two devices and ACLs for the devices who act as a server.
203 * @param[in] ctx Application context returned in the result callback.
204 * @param[in] type Type of credentials to be provisioned to the device.
205 * @param[in] keySize size of key
206 * @param[in] pDev1 Pointer to OCProvisionDev_t instance,respresenting device to be provisioned.
207 * @param[in] pDev1Acl ACL for device 1. If this is not required set NULL.
208 * @param[in] pDev2 Pointer to OCProvisionDev_t instance,respresenting device to be provisioned.
209 * @param[in] pDev2Acl ACL for device 2. If this is not required set NULL.
210 * @param[in] resultCallback callback provided by API user, callback will be called when
211 * provisioning request recieves a response from first resource server.
212 * @return OC_STACK_OK in case of success and other value otherwise.
214 OCStackResult OCProvisionPairwiseDevices(void* ctx, OicSecCredType_t type, size_t keySize,
215 const OCProvisionDev_t *pDev1, OicSecAcl_t *pDev1Acl,
216 const OCProvisionDev_t *pDev2, OicSecAcl_t *pDev2Acl,
217 OCProvisionResultCB resultCallback);
220 * API to send version 1 ACL information to device.
222 * @param[in] ctx Application context returned in the result callback.
223 * @param[in] selectedDeviceInfo Selected target device.
224 * @param[in] acl ACL to provision.
225 * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
226 request recieves a response from resource server.
227 * @return OC_STACK_OK in case of success and other value otherwise.
229 OCStackResult OCProvisionACL(void *ctx, const OCProvisionDev_t *selectedDeviceInfo, OicSecAcl_t *acl,
230 OCProvisionResultCB resultCallback);
233 * API to send version 2 ACL information to device.
235 * @param[in] ctx Application context returned in the result callback.
236 * @param[in] selectedDeviceInfo Selected target device.
237 * @param[in] acl ACL to provision.
238 * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
239 request recieves a response from resource server.
240 * @return OC_STACK_OK in case of success and other value otherwise.
242 OCStackResult OCProvisionACL2(void *ctx, const OCProvisionDev_t *selectedDeviceInfo, OicSecAcl_t *acl,
243 OCProvisionResultCB resultCallback);
246 * function to save ACL which has several ACE into Acl of SVR.
248 * @param acl ACL to be saved in Acl of SVR.
249 * @return OC_STACK_OK in case of success and other value otherwise.
251 OCStackResult OCSaveACL(const OicSecAcl_t* acl);
254 * this function requests CRED information to resource.
256 * @param[in] ctx Application context returned in the result callback.
257 * @param[in] selectedDeviceInfo Selected target device.
258 * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
259 request recieves a response from resource server.
260 * @return OC_STACK_OK in case of success and other value otherwise.
262 OCStackResult OCGetCredResource(void* ctx, const OCProvisionDev_t *selectedDeviceInfo,
263 OCProvisionResultCB resultCallback);
266 * this function requests version 1 ACL information to resource.
268 * @param[in] ctx Application context returned in the result callback.
269 * @param[in] selectedDeviceInfo Selected target device.
270 * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
271 request recieves a response from resource server.
272 * @return OC_STACK_OK in case of success and other value otherwise.
274 OCStackResult OCGetACLResource(void* ctx, const OCProvisionDev_t *selectedDeviceInfo,
275 OCProvisionResultCB resultCallback);
278 * this function requests version 2 ACL information to resource.
280 * @param[in] ctx Application context returned in the result callback.
281 * @param[in] selectedDeviceInfo Selected target device.
282 * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
283 request recieves a response from resource server.
284 * @return OC_STACK_OK in case of success and other value otherwise.
286 OCStackResult OCGetACL2Resource(void* ctx, const OCProvisionDev_t *selectedDeviceInfo,
287 OCProvisionResultCB resultCallback);
290 * This function requests the device provide its Certificate Signing Request (CSR).
292 * @param[in] ctx Application context returned in the result callback.
293 * @param[in] selectedDeviceInfo Selected target device.
294 * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
295 request recieves a response from resource server.
296 * @return OC_STACK_OK in case of success and other value otherwise.
298 OCStackResult OCGetCSRResource(void* ctx, const OCProvisionDev_t *selectedDeviceInfo,
299 OCGetCSRResultCB resultCallback);
302 * This function requests the device provide its roles resource, listing the role certificates
303 * it has for the local requestor.
305 * @param[in] ctx Application context that is returned in the result callback.
306 * @param[in] selectedDeviceInfo Selected target device.
307 * @param[in] resultCallback callback provided by the API user. Callback will be called when provisioning
308 * request receives a response from the resource server.
309 * @return OC_STACK_OK in case of success, and error value otherwise.
311 OCStackResult OCGetRolesResource(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
312 OCGetRolesResultCB resultCallback);
315 * This function requests the device delete a particular role certificate by credId.
317 * @param[in] ctx Application context that is returned in the result callback.
318 * @param[in] selectedDeviceInfo Selected target device.
319 * @param[in] resultCallback callback provided by the API user. Callback will be called when request receives
320 * a response from the resource server.
321 * @param[in] credId credId to request be deleted. If 0, delete all role certificates for this peer.
323 * @return OC_STACK_OK in case of success, and error value otherwise.
325 OCStackResult OCDeleteRoleCertificateByCredId(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
326 OCProvisionResultCB resultCallback, uint32_t credId);
329 * this function sends Direct-Pairing Configuration to a device.
331 * @param[in] ctx Application context returned in the result callback.
332 * @param[in] selectedDeviceInfo Selected target device.
333 * @param[in] pconf PCONF pointer.
334 * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
335 request recieves a response from resource server.
336 * @return OC_STACK_OK in case of success and other value otherwise.
338 OCStackResult OCProvisionDirectPairing(void* ctx, const OCProvisionDev_t *selectedDeviceInfo, OicSecPconf_t *pconf,
339 OCProvisionResultCB resultCallback);
342 * API to provision credential to devices.
344 * @param[in] ctx Application context returned in the result callback.
345 * @param[in] type Type of credentials to be provisioned to the device.
346 * @param[in] keySize size of key
347 * @param[in] pDev1 Pointer to OCProvisionDev_t instance, representing the resource to be provisioned.
348 * @param[in] pDev2 Pointer to OCProvisionDev_t instance, representing the resource to be provisioned.
349 * @param[in] resultCallback callback provided by API user, callback will be called when
350 * provisioning request recieves a response from first resource server.
351 * @return OC_STACK_OK in case of success and other value otherwise.
353 OCStackResult OCProvisionCredentials(void *ctx, OicSecCredType_t type, size_t keySize,
354 const OCProvisionDev_t *pDev1,
355 const OCProvisionDev_t *pDev2,
356 OCProvisionResultCB resultCallback);
359 * API to provision symmetric pair-wise key credentials to devices that grant a role.
361 * @param[in] ctx Application context returned in the result callback.
362 * @param[in] type Type of credentials to be provisioned to the device.
363 * @param[in] keySize size of key
364 * @param[in] pDev1 Pointer to OCProvisionDev_t instance, representing the resource to be provisioned.
365 * @param[in] pDev2 Pointer to OCProvisionDev_t instance, representing the resource to be provisioned.
366 * Use NULL to indicate the local device.
367 * @param[in] role1 The role which the device indicated by pDev1 will have when communicating with pDev2.
368 * Use NULL to associate no role with this credential.
369 * @param[in] role2 The role which the device indicated by pDev2 will have when communicating with pDev1.
370 * Use NULL to associate no role with this credential.
371 * @param[in] resultCallback callback provided by API user, callback will be called when
372 * provisioning request receives a response from first resource server.
373 * @return OC_STACK_OK in case of success and other value otherwise.
375 OCStackResult OCProvisionSymmetricRoleCredentials(void *ctx, OicSecCredType_t type, size_t keySize,
376 const OCProvisionDev_t *pDev1,
377 const OCProvisionDev_t *pDev2,
378 const OicSecRole_t *role1,
379 const OicSecRole_t *role2,
380 OCProvisionResultCB resultCallback);
383 * API to provision a certificate to a device.
385 * @param[in] ctx Application context returned in result callback.
386 * @param[in] pDev Pointer to OCProvisionDev_t instance, respresenting the device to be provsioned.
387 * @param[in] pemCert Certificate to provision, encoded as PEM
388 * @param[in] resultCallback callback provided by API user, callback will be called when
389 * provisioning request receives a response from first resource server.
390 * @return OC_STACK_OK in case of success and other value otherwise.
392 OCStackResult OCProvisionCertificate(void *ctx,
393 const OCProvisionDev_t *pDev,
395 OCProvisionResultCB resultCallback);
397 #ifdef MULTIPLE_OWNER
399 * API to provision preconfigured PIN to device(NOT LIST).
400 * If device does not support the Preconfigured PIN OxM,
401 * OCProvisionPreconfigPin API will update the device's Doxm
402 * and then try preconfigured PIN provisioning once again.
404 * @param[in] ctx Application context returned in the result callback.
405 * @param[in] targetDeviceInfo Selected target device.
406 * @param[in] preconfigPin string of preconfigured PIN.
407 * @param[in] preconfigPinLen string length of 'preconfigPin'.
408 * @param[in] resultCallback callback provided by API user, callback will be called when
409 * provisioning request recieves a response from first resource server.
410 * @return OC_STACK_OK in case of success and other value otherwise.
412 OCStackResult OCProvisionPreconfigPin(void *ctx,
413 OCProvisionDev_t *targetDeviceInfo,
414 const char *preconfigPin,
415 size_t preconfigPinLen,
416 OCProvisionResultCB resultCallback);
419 * API to add preconfigured PIN to local SVR DB.
421 * @param[in] targetDeviceInfo Selected target device.
422 * @param[in] preconfigPin Preconfig PIN which is used while multiple owner authentication
423 * @param[in] preconfigPinLen Byte length of preconfigPin
424 * @return OC_STACK_OK in case of success and other value otherwise.
426 OCStackResult OCAddPreconfigPin(const OCProvisionDev_t *targetDeviceInfo,
427 const char *preconfigPin,
428 size_t preconfigPinLen);
431 * API to update 'doxm.mom' to resource server.
433 * @param[in] targetDeviceInfo Selected target device.
434 * @param[in] momType Mode of multiple ownership transfer (ref. oic.sec.mom)
435 * @param[in] resultCallback callback provided by API user, callback will be called when
436 * POST 'mom' request recieves a response from resource server.
437 * @return OC_STACK_OK in case of success and other value otherwise.
439 OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo,
440 const OicSecMomType_t momType, OCProvisionResultCB resultCallback);
443 * API to update 'doxm.oxmsel' to resource server.
445 * @param[in] targetDeviceInfo Selected target device.
446 * @param[in] oxmSelValue Method of multiple ownership transfer (ref. oic.sec.doxmtype)
447 * @param[in] resultCallback callback provided by API user, callback will be called when
448 * POST 'oxmsel' request recieves a response from resource server.
449 * @return OC_STACK_OK in case of success and other value otherwise.
451 OCStackResult OCSelectMOTMethod(void *ctx, const OCProvisionDev_t *targetDeviceInfo,
452 const OicSecOxm_t oxmSelValue, OCProvisionResultCB resultCallback);
453 #endif //MULTIPLE_OWNER
456 * Function to unlink devices.
457 * This function will remove the credential & relasionship between the two devices.
459 * @param[in] ctx Application context would be returned in result callback
460 * @param[in] pTargetDev1 fitst device information to be unlinked.
461 * @param[in] pTargetDev2 second device information to be unlinked.
462 * @param[in] resultCallback callback provided by API user, callback will be called when
463 * device unlink is finished.
464 * @return OC_STACK_OK in case of success and other value otherwise.
466 OCStackResult OCUnlinkDevices(void* ctx,
467 const OCProvisionDev_t* pTargetDev1,
468 const OCProvisionDev_t* pTargetDev2,
469 OCProvisionResultCB resultCallback);
472 * Function for device revocation
473 * This function will remove credential of target device from all devices in subnet.
475 * @param[in] ctx Application context would be returned in result callback
476 * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
477 * @param[in] pTargetDev Device information to be revoked.
478 * @param[in] resultCallback callback provided by API user, callback will be called when
479 * credential revocation is finished.
480 * @return OC_STACK_OK in case of success and other value otherwise.
481 * if OC_STACK_OK is returned, the caller of this API should wait for callback.
482 * OC_STACK_CONTINUE means operation is success but no need to wait for callback.
484 OCStackResult OCRemoveDevice(void* ctx,
485 unsigned short waitTimeForOwnedDeviceDiscovery,
486 const OCProvisionDev_t* pTargetDev,
487 OCProvisionResultCB resultCallback);
490 * Function to device revocation
491 * This function will remove credential of target device from all devices in subnet.
493 * @param[in] ctx Application context would be returned in result callback
494 * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
495 * @param[in] pTargetUuid Device information to be revoked.
496 * @param[in] resultCallback callback provided by API user, callback will be called when
497 * credential revocation is finished.
498 * @return OC_STACK_OK in case of success and other value otherwise.
500 OCStackResult OCRemoveDeviceWithUuid(void* ctx,
501 unsigned short waitTimeForOwnedDeviceDiscovery,
502 const OicUuid_t* pTargetUuid,
503 OCProvisionResultCB resultCallback);
506 * Function to reset the target device.
507 * This function will remove credential and ACL of target device from all devices in subnet.
509 * @param[in] ctx Application context would be returned in result callback
510 * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
511 * @param[in] pTargetDev Device information to be revoked.
512 * @param[in] resultCallback callback provided by API user, callback will be called when
513 * credential revocation is finished.
514 * @return OC_STACK_OK in case of success and other value otherwise.
516 OCStackResult OCResetDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDiscovery,
517 const OCProvisionDev_t* pTargetDev,
518 OCProvisionResultCB resultCallback);
521 * This function resets SVR DB to its factory setting.
523 *@return OC_STACK_OK in case of successful reset and other value otherwise.
525 OCStackResult OCResetSVRDB(void);
528 * This function configures SVR DB as self-ownership.
530 *@return OC_STACK_OK in case of successful configue and other value otherwise.
532 OCStackResult OCConfigSelfOwnership(void);
535 * API to get status of all the devices in current subnet. The status include endpoint information
536 * and doxm information which can be extracted duing owned and unowned discovery. Along with this
537 * information. The API will provide information about devices' status
538 * Device can have following states
539 * - ON/OFF: Device is switched on or off.
541 * NOTE: Caller need to call OCDeleteDiscoveredDevices to delete memory allocated by this API for out
542 * variables pOwnedDevList and pUnownedDevList.
544 * @param[in] waittime Wait time for the API. The wait time will be divided by 2, and half of wait time
545 * will be used for unowned discovery and remaining half for owned discovery. So the wait time should be
546 * equal to or more than 2.
547 * @param[out] pOwnedDevList list of owned devices.
548 * @param[out] pUnownedDevList list of unowned devices.
549 * @return OC_STACK_OK in case of success and other value otherwise.
551 OCStackResult OCGetDevInfoFromNetwork(unsigned short waittime,
552 OCProvisionDev_t** pOwnedDevList,
553 OCProvisionDev_t** pUnownedDevList);
555 * This method is used to get linked devices' IDs.
557 * @param[in] uuidOfDevice a target device's uuid.
558 * @param[out] uuidList information about the list of linked devices' uuids.
559 * @param[out] numOfDevices total number of linked devices.
560 * @return OC_STACK_OK in case of success and other value otherwise.
562 OCStackResult OCGetLinkedStatus(const OicUuid_t* uuidOfDevice,
563 OCUuidList_t** uuidList,
564 size_t* numOfDevices);
567 * Remove locally stored credentials with the specified subject UUID.
569 * @param[in] subjectUuid The subject UUID of the credentials to remove
571 * @return OC_STACK_RESOURCE_DELETED if credentials were removed, or
572 * OC_STACK_ERROR if no credentials were removed.
574 OCStackResult OCRemoveCredential(const OicUuid_t* subjectUuid);
577 * API to delete memory allocated to linked list created by OCDiscover_XXX_Devices API.
579 * @param[in] pList Pointer to OCProvisionDev_t which should be deleted.
581 void OCDeleteDiscoveredDevices(OCProvisionDev_t *pList);
584 * API to delete memory allocated to OicUuid_t list.
586 * @param[in] pList Pointer to OicUuid_t list which should be deleted.
588 void OCDeleteUuidList(OCUuidList_t* pList);
591 * This function deletes ACL data.
593 * @param pAcl Pointer to OicSecAcl_t structure.
595 void OCDeleteACLList(OicSecAcl_t* pAcl);
598 * This function deletes PDACL data.
600 * @param pPdAcl Pointer to OicSecPdAcl_t structure.
602 void OCDeletePdAclList(OicSecPdAcl_t* pPdAcl);
604 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
606 * function to provision Trust certificate chain to devices.
608 * @param[in] ctx Application context returned in the result callback.
609 * @param[in] type Type of credentials to be provisioned to the device.
610 * @param[in] credId CredId of trust certificate chain to be provisioned to the device.
611 * @param[in] selectedDeviceInfo Pointer to OCProvisionDev_t instance,respresenting resource to be provsioned.
612 * @param[in] resultCallback callback provided by API user, callback will be called when
613 * provisioning request recieves a response from first resource server.
614 * @return OC_STACK_OK in case of success and other value otherwise.
616 OCStackResult OCProvisionTrustCertChain(void *ctx, OicSecCredType_t type, uint16_t credId,
617 const OCProvisionDev_t *selectedDeviceInfo,
618 OCProvisionResultCB resultCallback);
620 * function to save Trust certificate chain into Cred of SVR.
622 * @param[in] trustCertChain Trust certificate chain to be saved in Cred of SVR.
623 * @param[in] chainSize Size of trust certificate chain to be saved in Cred of SVR
624 * @param[in] encodingType Encoding type of trust certificate chain to be saved in Cred of SVR
625 * @param[out] credId CredId of saved trust certificate chain in Cred of SVR.
626 * @return OC_STACK_OK in case of success and other value otherwise.
628 OCStackResult OCSaveTrustCertChain(const uint8_t *trustCertChain, size_t chainSize,
629 OicEncodingType_t encodingType, uint16_t *credId);
632 * Function to save an identity certificate chain into Cred of SVR.
634 * @param[in] cert Certificate chain to be saved in Cred of SVR, PEM encoded, null terminated
635 * @param[in] key private key corresponding to the certificate, PEM encoded, null terminated
636 * @param[out] credId CredId of saved certificate chain in Cred of SVR.
637 * @return OC_STACK_OK in case of success and other value otherwise.
639 OCStackResult OCSaveOwnCertChain(const char* cert, const char* key, uint16_t *credId);
642 * Function to save own role certificate into Cred of SVR.
644 * @param[in] cert Certificate chain to be saved in Cred of SVR, PEM encoded, null terminated
645 * @param[out] credId CredId of saved trust certificate chain in Cred of SVR.
646 * @return OC_STACK_OK in case of success and other value otherwise.
648 * @note The certificate public key must be the same as public key in the identity
649 * certificate (installed by OCSaveOwnCertChain).
651 OCStackResult OCSaveOwnRoleCert(const char* cert, uint16_t *credId);
654 * function to register callback, for getting notification for TrustCertChain change.
656 * @param[in] TrustCertChainChangeCB notifier callback function
657 * @return OC_STACK_OK in case of success and other value otherwise.
659 OCStackResult OCRegisterTrustCertChainNotifier(void *cb, TrustCertChainChangeCB CB);
662 * function to de-register TrustCertChain notification callback.
664 void OCRemoveTrustCertChainNotifier(void);
667 * Function to read Trust certificate chain from SVR.
668 * Caller must free when done using the returned trust certificate
669 * @param[in] credId CredId of trust certificate chain in SVR.
670 * @param[out] trustCertChain Trust certificate chain.
671 * @param[out] chainSize Size of trust certificate chain
672 * @return OC_STACK_OK in case of success and other value otherwise.
674 OCStackResult OCReadTrustCertChain(uint16_t credId, uint8_t **trustCertChain,
678 * Function to select appropriate security provisioning method.
680 * @param[in] supportedMethods Array of supported methods
681 * @param[in] numberOfMethods number of supported methods
682 * @param[out] selectedMethod Selected methods
683 * @param[in] ownerType type of owner device (SUPER_OWNER or SUB_OWNER)
684 * @return OC_STACK_OK on success
686 OCStackResult OCSelectOwnershipTransferMethod(const OicSecOxm_t *supportedMethods,
687 size_t numberOfMethods, OicSecOxm_t *selectedMethod, OwnerType_t ownerType);
689 #endif // __WITH_DTLS__ || __WITH_TLS__
694 #endif // __cplusplus
696 #endif /* OCPROVISIONINGMANAGER_H_ */