1 //******************************************************************
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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 IOTVT_SRM_PSTATR_H
22 #define IOTVT_SRM_PSTATR_H
29 * Initialize Pstat resource by loading data from persistent storage.
31 * @return ::OC_STACK_OK for Success, otherwise some error value.
33 OCStackResult InitPstatResource();
36 * Perform cleanup for Pstat resources.
38 * @return ::OC_STACK_OK for Success, otherwise some error value.
40 OCStackResult DeInitPstatResource();
43 * This method converts PSTAT into the cbor payload.
45 * @param pstat pointer to the initialized pstat structure.
46 * @param cborPayload pointer to pstat cbor payload.
47 * @param size of the cbor payload converted. It is 0 in case of error,
48 * else a positive value if succcessful.
50 * @return ::OC_STACK_OK for Success, otherwise some error value.
52 OCStackResult PstatToCBORPayload(const OicSecPstat_t *pstat, uint8_t **cborPayload,
53 size_t *cborSize, bool writableOnly);
56 * This method converts cbor into PSTAT data.
58 * @param cborPayload is the pstat data in cbor format.
59 * @param size of the cborPayload. In case 0 is provided it assigns CBOR_SIZE (255) value.
60 * @param pstat pointer to @ref OicSecPstat_t.
62 * @return ::OC_STACK_OK for Success, otherwise some error value.
64 OCStackResult CBORPayloadToPstat(const uint8_t *cborPayload, const size_t cborSize,
65 OicSecPstat_t **pstat);
69 * Function to check the pstat access of SubOwner
71 * @param[in] cborPayload CBOR payload of pstat
72 * @param[in] size Byte length of cborPayload
74 * @return ::true for valid access, otherwise invalid access
76 bool IsValidPstatAccessForSubOwner(const uint8_t *cborPayload, size_t size);
80 /** This function deallocates the memory for OicSecPstat_t.
82 * @param pstat is the pointer to @ref OicSecPstat_t.
84 void DeletePstatBinData(OicSecPstat_t* pstat);
87 * Function to restore pstat resurce to initial status.
88 * This function will use in case of error while ownership transfer
90 void RestorePstatToInitState();
93 * Internal function to update resource owner
95 * @param newROwner new owner
97 * @retval ::OC_STACK_OK for Success, otherwise some error value
99 OCStackResult SetPstatRownerId(const OicUuid_t* newROwner);
102 * Gets the OicUuid_t value for the rownerid of the pstat resource.
104 * @param rowneruuid a pointer to be assigned to the rowneruuid property
105 * @return ::OC_STACK_OK if rowneruuid is assigned correctly, else ::OC_STACK_ERROR.
107 OCStackResult GetPstatRownerId(OicUuid_t *rowneruuid);
110 * This function returns the "isop" status of the device.
112 * @return true iff pstat.isop == 1, else false
117 * Internal function to change pastat resource to Ready for Normal Operation.
119 * @param newROwner new owner
121 * @retval ::OC_STACK_OK for Success, otherwise some error value
123 OCStackResult SetPstatSelfOwnership(const OicUuid_t* newROwner);
129 #endif //IOTVT_SRM_PSTATR_H