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_DOXM_H
22 #define IOTVT_SRM_DOXM_H
31 * Initialize DOXM resource by loading data from persistent storage.
33 * @return ::OC_STACK_OK for Success, otherwise some error value.
35 OCStackResult InitDoxmResource();
38 * Perform cleanup for DOXM resources.
40 * @return ::OC_STACK_OK for Success, otherwise some error value.
42 OCStackResult DeInitDoxmResource();
45 * This method is used by SRM to retrieve DOXM resource data..
47 * @return reference to @ref OicSecDoxm_t, binary format of Doxm resource data.
49 const OicSecDoxm_t* GetDoxmResourceData();
52 * This method converts CBOR DOXM into binary DOXM.
53 * The CBOR DOXM can be from persistent database or
54 * or received as PUT/POST request.
56 * @param cborPayload is a doxm data in cbor.
57 * @note Caller needs to invoke OCFree after done using the return pointer.
58 * @param doxm is the pointer to @ref OicSecDoxm_t.
59 * @param size of the cborPayload. In case value is 0, CBOR_SIZE value is assigned.
61 * @return ::OC_STACK_OK for Success, otherwise some error value.
63 OCStackResult CBORPayloadToDoxm(const uint8_t *cborPayload, size_t size,
67 * This method converts DOXM data into CBOR format.
68 * Caller needs to invoke 'free' when finished done using
71 * @param doxm Pointer to @ref OicSecDoxm_t.
72 * @note Caller needs to invoke OCFree after done using the return pointer.
73 * @param cborPayload is the payload of the cbor.
74 * @param cborSize is the size of the cbor payload. Passed parameter should not be NULL.
75 * @param rwOnly indicates whether convertingpayload has all properties or read-write properties only.
77 * @return ::OC_STACK_OK for Success, otherwise some error value.
79 OCStackResult DoxmToCBORPayload(const OicSecDoxm_t * doxm, uint8_t **cborPayload,
80 size_t *cborSize, bool rwOnly);
83 * This method returns the SRM device ID for this device.
85 * @return ::OC_STACK_OK for Success, otherwise some error value.
87 OCStackResult GetDoxmDeviceID(OicUuid_t *deviceID);
90 * This method changes the SRM device ID for this device.
91 * This api will update device Id iff device is in unowned state.
92 * @return ::OC_STACK_OK for Success, otherwise some error value.
94 OCStackResult SetDoxmDeviceID(const OicUuid_t *deviceID);
98 * Gets the OicUuid_t value for the owner of this device.
100 * @param devownerid a pointer to be assigned to the devownerid property
101 * @return ::OC_STACK_OK if devownerid is assigned correctly, else ::OC_STACK_ERROR.
103 OCStackResult GetDoxmDevOwnerId(OicUuid_t *devownerid);
106 * Gets the bool state of "isOwned" property on the doxm resource.
108 * @param isOwned a pointer to be assigned to isOwned property
109 * @return ::OC_STACK_OK if isOwned is assigned correctly, else ::OC_STACK_ERROR.
111 OCStackResult GetDoxmIsOwned(bool *isOwned);
114 * Gets the OicUuid_t value for the rowneruuid of the doxm resource.
116 * @param rowneruuid a pointer to be assigned to the rowneruuid property
117 * @return ::OC_STACK_OK if rowneruuid is assigned correctly, else ::OC_STACK_ERROR.
119 OCStackResult GetDoxmRownerId(OicUuid_t *rowneruuid);
121 /** This function deallocates the memory for OicSecDoxm_t .
123 * @param doxm is the pointer to @ref OicSecDoxm_t.
125 void DeleteDoxmBinData(OicSecDoxm_t* doxm);
128 * Function to restore doxm resurce to initial status.
129 * This function will use in case of error while ownership transfer
131 void RestoreDoxmToInitState();
137 #endif //IOTVT_SRM_DOXMR_H