Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / resource / csdk / security / include / internal / pconfresource.h
1 /* *****************************************************************\r
2  *\r
3  * Copyright 2016 Samsung Electronics All Rights Reserved.\r
4  *\r
5  *\r
6  *\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  *\r
11  *     http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  *\r
19  * *****************************************************************/\r
20 \r
21 #ifndef IOTVT_SRM_PCONF_H\r
22 #define IOTVT_SRM_PCONF_H\r
23 \r
24 #include "octypes.h"\r
25 \r
26 #ifdef __cplusplus\r
27 extern "C" {\r
28 #endif\r
29 \r
30 /**\r
31  * Initialize PCONF resource by loading data from persistent storage.\r
32  *\r
33  * @retval  OC_STACK_OK for Success, otherwise some error value\r
34  */\r
35 OCStackResult InitPconfResource();\r
36 \r
37 /**\r
38  * Perform cleanup for PCONF resources.\r
39  *\r
40  * @retval  OC_STACK_OK for Success, otherwise some error value\r
41  */\r
42 OCStackResult DeInitPconfResource();\r
43 \r
44 /**\r
45  * This method is used by SRM to retrieve PCONF resource data..\r
46  *\r
47  * @retval  reference to @ref OicSecPconf_t, binary format of Pconf resource data\r
48  */\r
49 const OicSecPconf_t* GetPconfResourceData();\r
50 \r
51 /**\r
52  * This method converts CBOR PCONF into binary PCONF.\r
53  * The JSON PCONF can be from persistent database or\r
54  * or received as PUT request.\r
55  *\r
56  * @param cborPayload  pconf data in cbor format.\r
57  * @param size cbor payload size\r
58  * @param secPconf converted pconf\r
59  * @return OC_STACK_OK for success.\r
60  *\r
61  * @note Caller needs to invoke OCFree after done\r
62  *       using the return pointer\r
63  */\r
64 OCStackResult CBORPayloadToPconf(const uint8_t *cborPayload, size_t size, OicSecPconf_t **secPconf);\r
65 \r
66 /**\r
67  * This method converts PCONF data into CBOR format.\r
68  * Caller needs to invoke 'free' when finished done using\r
69  * return string\r
70  *\r
71  * @param pconf  Pointer to OicSecPconf_t.\r
72  * @param payload pconf converted in cbor format\r
73  * @param size size of the converted payload\r
74  * @return OC_STACK_OK for success.\r
75  *\r
76  * @note Caller needs to invoke OCFree after done\r
77  *       using the return pointer\r
78  */\r
79 OCStackResult PconfToCBORPayload(const OicSecPconf_t *pconf,uint8_t **payload,size_t *size);\r
80 \r
81 /**\r
82  * This method might be used to add a paired device id after direct-pairing process complete.\r
83  *\r
84  * @param pdeviceId ID of the paired device.\r
85  *\r
86  * @retval  OC_STACK_OK for Success, otherwise some error value\r
87  */\r
88 OCStackResult AddPairedDevice(OicUuid_t *pdeviceId);\r
89 \r
90 /**\r
91  * This method might be used by PolicyEngine to retrieve PDACL for a Subject.\r
92  *\r
93  * @param subjectId ID of the subject for which PDACL is required.\r
94  * @param savePtr is used internally by @ref GetACLResourceData to maintain index between\r
95  *                successive calls for same subjectId.\r
96  *\r
97  * @retval  reference to @ref OicSecPdAcl_t if PDACL is found, else NULL\r
98  */\r
99 const OicSecPdAcl_t* GetPdAclData(const OicUuid_t* subjectId, OicSecPdAcl_t **savePtr);\r
100 \r
101 /**\r
102  * This method return whether device is paired or not.\r
103  *\r
104  * @param pdeviceId Target device ID to find in paired list.\r
105  * @retval  ture if device is already paired, else false\r
106  */\r
107 bool IsPairedDevice(const OicUuid_t* pdeviceId);\r
108 \r
109 /** This function deallocates the memory for OicSecPconf_t .\r
110  *\r
111  * @param[in] pconf  Pointer to OicSecPconf_t.\r
112  */\r
113 void DeletePconfBinData(OicSecPconf_t* pconf);\r
114 \r
115 /**\r
116  * This function frees OicSecPdAcl_t object's fields and object itself.\r
117  */\r
118 void FreePdAclList(OicSecPdAcl_t* pdacls);\r
119 \r
120 /**\r
121  * Internal function to update resource owner\r
122  *\r
123  * @param newROwner new owner\r
124  *\r
125  * @retval ::OC_STACK_OK for Success, otherwise some error value\r
126  */\r
127 OCStackResult SetPconfRownerId(const OicUuid_t* newROwner);\r
128 \r
129 /**\r
130  * Gets the OicUuid_t value for the rownerid of the pconf resource.\r
131  *\r
132  * @param rowneruuid a pointer to be assigned to the rowneruuid property\r
133  * @return ::OC_STACK_OK if rowneruuid is assigned correctly, else ::OC_STACK_ERROR.\r
134  */\r
135 OCStackResult GetPconfRownerId(OicUuid_t *rowneruuid);\r
136 \r
137 #ifdef __cplusplus\r
138 }\r
139 #endif\r
140 \r
141 #endif //IOTVT_SRM_PCONF_H\r
142 \r
143 \r
144 \r