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 SP_PROVISION_API_H
22 #define SP_PROVISION_API_H
25 #include "securevirtualresourcetypes.h"
37 SP_RESULT_SUCCESS = 0,
38 SP_RESULT_INVALID_PARAM,
39 SP_RESULT_MEM_ALLOCATION_FAIL,
40 SP_RESULT_INTERNAL_ERROR,
42 SP_RESULT_CONN_INVALID_PARAM,
43 SP_RESULT_CONN_ADAPTER_NOT_ENABLED,
44 SP_RESULT_CONN_SERVER_STARTED_ALREADY,
45 SP_RESULT_CONN_SERVER_NOT_STARTED,
46 SP_RESULT_CONN_DESTINATION_NOT_REACHABLE,
47 SP_RESULT_CONN_SOCKET_OPERATION_FAILED,
48 SP_RESULT_CONN_SEND_FAILED,
49 SP_RESULT_CONN_RECEIVE_FAILED,
50 SP_RESULT_CONN_MEMORY_ALLOC_FAILED,
51 SP_RESULT_CONN_REQUEST_TIMEOUT,
52 SP_RESULT_CONN_DESTINATION_DISCONNECTED,
53 SP_RESULT_CONN_STATUS_FAILED,
54 SP_RESULT_CONN_NOT_SUPPORTED
58 typedef struct SPTargetDeviceInfo SPTargetDeviceInfo_t;
59 typedef struct SPDevInfo SPDevInfo_t;
62 * Device Info structure.
64 struct SPTargetDeviceInfo
66 OCDevAddr endpoint; /**< target address **/
67 OicSecPstat_t *pstat; /**< Pointer to target's pstat resource. **/
68 OicSecDoxm_t *doxm; /**< Pointer to target's doxm resource. **/
69 uint16_t securePort; /**< Secure port **/
70 SPTargetDeviceInfo_t *next; /**< Next pointer. **/
74 * Owned target device info
78 OCDevAddr endpoint; /**< target address **/
79 OicUuid_t deviceId; /**< Device ID. **/
80 SPDevInfo_t *next; /**< Next pointer. **/
84 * The function is responsible for discovery of device is current subnet. It will list
85 * all the device in subnet which are not yet owned. Please call OCInit with OC_CLIENT_SERVER as
88 * @param[in] timeout Timeout in seconds, value till which function will listen to responses from
89 * client before returning the list of devices.
90 * @param[out] list List of provision candidate devices.
91 * @return SP_SUCCESS in case of success and other value otherwise.
93 SPResult SPProvisioningDiscovery(unsigned short timeout,
94 SPTargetDeviceInfo_t **list);
97 * The function is reponsible for following activities:
98 * - Send post to /oic/sec/doxm resource with selected ownership transfer method
99 * - Get pstat resource of target device to enumerate supported operation modes.
100 * - Select and let the target device know the selected methods.
101 * - Initiate anon handshake and save owner PSK
102 * - Update doxm resource of target device with ownership info.
104 * @param[in] timeout Timeout value in secs till which call REST request will wait before
105 * returning error in case of 0 function will wait till success.
106 * @param[in] selectedDeviceInfo Device information.
107 * @return SP_SUCCESS in case of success and other value otherwise.
109 SPResult SPInitProvisionContext(unsigned short timeout,
110 SPTargetDeviceInfo_t *selectedDeviceInfo);
113 * Function to send ACL information to resource.
115 * @param[in] timeout Timeout value in secs till which call to REST request will wait before
116 * returning error in case of 0 function will wait till success.
117 * @param[in] selectedDeviceInfo Selected target device.
118 * @param[in] acl ACL to provision
119 * @return SP_SUCCESS in case of success and other value otherwise.
121 SPResult SPProvisionACL(unsigned short timeout, const SPTargetDeviceInfo_t *selectedDeviceInfo,
125 * Function to send credential information to list of resources.
127 * @param[in] timeout Timeout value in secs till which call to REST request will wait before
128 * returning error in case of 0 function will wait till success.
129 * @param[in] type Type of credentials to be provisioned to the device.
130 * @param[in] pDevList List of devices to be provisioned with the specified credential.
132 * @return SP_SUCCESS in case of success and other value otherwise.
134 SPResult SPProvisionCredentials(unsigned short timeout, OicSecCredType_t type,
135 const SPDevInfo_t *pDevList);
138 * Function to confirm the ACL post request to check whether its updated at
139 * resource server end properly or not.
141 * @param[in] timeout Timeout value in seconds till which call REST request will wait
142 * before returning error in case of 0 function will wait till success.
143 * @param[in] context Provisioning context
144 * @return SP_SUCCESS on success
146 SPResult SPFinalizeProvisioning(unsigned short timeout,
147 SPTargetDeviceInfo_t *selectedDeviceInfo);
150 * Function to end Provisioning session.
152 * @return SP_SUCCESS on success
154 SPResult SPTerminateProvisioning();
159 #endif //SP_PROVISION_API_H