1 /* *****************************************************************
\r
3 * Copyright 2016 Samsung Electronics All Rights Reserved.
\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
11 * http://www.apache.org/licenses/LICENSE-2.0
\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
19 * *****************************************************************/
\r
21 #ifndef IOTVT_SRM_PCONF_H
\r
22 #define IOTVT_SRM_PCONF_H
\r
24 #include "octypes.h"
\r
31 * Initialize PCONF resource by loading data from persistent storage.
\r
33 * @retval OC_STACK_OK for Success, otherwise some error value
\r
35 OCStackResult InitPconfResource();
\r
38 * Perform cleanup for PCONF resources.
\r
40 * @retval OC_STACK_OK for Success, otherwise some error value
\r
42 OCStackResult DeInitPconfResource();
\r
45 * This method is used by SRM to retrieve PCONF resource data..
\r
47 * @retval reference to @ref OicSecPconf_t, binary format of Pconf resource data
\r
49 const OicSecPconf_t* GetPconfResourceData();
\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
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
61 * @note Caller needs to invoke OCFree after done
\r
62 * using the return pointer
\r
64 OCStackResult CBORPayloadToPconf(const uint8_t *cborPayload, size_t size, OicSecPconf_t **secPconf);
\r
67 * This method converts PCONF data into CBOR format.
\r
68 * Caller needs to invoke 'free' when finished done using
\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
76 * @note Caller needs to invoke OCFree after done
\r
77 * using the return pointer
\r
79 OCStackResult PconfToCBORPayload(const OicSecPconf_t *pconf,uint8_t **payload,size_t *size);
\r
82 * This method might be used to add a paired device id after direct-pairing process complete.
\r
84 * @param pdeviceId ID of the paired device.
\r
86 * @retval OC_STACK_OK for Success, otherwise some error value
\r
88 OCStackResult AddPairedDevice(OicUuid_t *pdeviceId);
\r
91 * This method might be used by PolicyEngine to retrieve PDACL for a Subject.
\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
97 * @retval reference to @ref OicSecPdAcl_t if PDACL is found, else NULL
\r
99 const OicSecPdAcl_t* GetPdAclData(const OicUuid_t* subjectId, OicSecPdAcl_t **savePtr);
\r
102 * This method return whether device is paired or not.
\r
104 * @param pdeviceId Target device ID to find in paired list.
\r
105 * @retval ture if device is already paired, else false
\r
107 bool IsPairedDevice(const OicUuid_t* pdeviceId);
\r
109 /** This function deallocates the memory for OicSecPconf_t .
\r
111 * @param[in] pconf Pointer to OicSecPconf_t.
\r
113 void DeletePconfBinData(OicSecPconf_t* pconf);
\r
116 * This function frees OicSecPdAcl_t object's fields and object itself.
\r
118 void FreePdAclList(OicSecPdAcl_t* pdacls);
\r
121 * Internal function to update resource owner
\r
123 * @param newROwner new owner
\r
125 * @retval ::OC_STACK_OK for Success, otherwise some error value
\r
127 OCStackResult SetPconfRownerId(const OicUuid_t* newROwner);
\r
130 * Gets the OicUuid_t value for the rownerid of the pconf resource.
\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
135 OCStackResult GetPconfRownerId(OicUuid_t *rowneruuid);
\r
141 #endif //IOTVT_SRM_PCONF_H
\r