Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / resource / csdk / security / include / internal / secureresourcemanager.h
1 //******************************************************************
2 //
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef SECURITYRESOURCEMANAGER_H_
22 #define SECURITYRESOURCEMANAGER_H_
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 /**
29  * @brief   Register Persistent storage callback.
30  * @param   persistentStorageHandler [IN] Pointers to open, read, write, close & unlink handlers.
31  * @return
32  *     OC_STACK_OK    - No errors; Success
33  *     OC_STACK_INVALID_PARAM - Invalid parameter
34  */
35 OCStackResult SRMRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler);
36
37 /**
38  * @brief   Get Persistent storage handler pointer.
39  * @return
40  *     The pointer to Persistent Storage callback handler
41  */
42 OCPersistentStorage* SRMGetPersistentStorageHandler();
43
44 /**
45  * @brief   Register request and response callbacks.
46  *          Requests and responses are delivered in these callbacks.
47  * @param   reqHandler   [IN] Request handler callback ( for GET,PUT ..etc)
48  * @param   respHandler  [IN] Response handler callback.
49  * @param   errHandler   [IN] Error handler callback.
50  * @return
51  *     OC_STACK_OK    - No errors; Success
52  *     OC_STACK_INVALID_PARAM - Invalid parameter
53  */
54 OCStackResult SRMRegisterHandler(CARequestCallback reqHandler,
55                                  CAResponseCallback respHandler,
56                                  CAErrorCallback errHandler);
57
58 /**
59  * @brief   Initialize all secure resources ( /oic/sec/cred, /oic/sec/acl, /oic/sec/pstat etc).
60  * @return  OC_STACK_OK for Success, otherwise some error value
61  */
62 OCStackResult SRMInitSecureResources();
63
64 /**
65  * @brief   Perform cleanup for secure resources ( /oic/sec/cred, /oic/sec/acl, /oic/sec/pstat etc).
66  * @return  none
67  */
68 void SRMDeInitSecureResources();
69
70 /**
71  * @brief   Initialize Policy Engine context.
72  * @return  OC_STACK_OK for Success, otherwise some error value.
73  */
74 OCStackResult SRMInitPolicyEngine();
75
76 /**
77  * @brief   Cleanup Policy Engine context.
78  * @return  none
79  */
80 void SRMDeInitPolicyEngine();
81
82 /**
83  * @brief   Provisioning API response callback.
84  * @param object[IN]       endpoint instance.
85  * @param responseInfo[IN] instance of CAResponseInfo_t structure.
86  * @return true if received response is for provisioning API false otherwise.
87  */
88 typedef bool (*SPResponseCallback) (const CAEndpoint_t *object,
89                                     const CAResponseInfo_t *responseInfo);
90
91 /**
92  * @brief function to register provisoning API's response callback.
93  * @param respHandler response handler callback.
94  */
95 void SRMRegisterProvisioningResponseHandler(SPResponseCallback respHandler);
96
97 #ifdef __cplusplus
98 }
99 #endif
100
101 #endif /* SECURITYRESOURCEMANAGER_H_ */