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
25 #ifdef _ENABLE_MULTIPLE_OWNER_
27 #endif //_ENABLE_MULTIPLE_OWNER_
34 * Initialize DOXM resource by loading data from persistent storage.
36 * @return ::OC_STACK_OK for Success, otherwise some error value.
38 OCStackResult InitDoxmResource();
41 * Perform cleanup for DOXM resources.
43 * @return ::OC_STACK_OK for Success, otherwise some error value.
45 OCStackResult DeInitDoxmResource();
48 * This method is used by SRM to retrieve DOXM resource data..
50 * @return reference to @ref OicSecDoxm_t, binary format of Doxm resource data.
52 const OicSecDoxm_t* GetDoxmResourceData();
55 * This method converts CBOR DOXM into binary DOXM.
56 * The CBOR DOXM can be from persistent database or
57 * or received as PUT/POST request.
59 * @param cborPayload is a doxm data in cbor.
60 * @note Caller needs to invoke OCFree after done using the return pointer.
61 * @param doxm is the pointer to @ref OicSecDoxm_t.
62 * @param size of the cborPayload. In case value is 0, CBOR_SIZE value is assigned.
64 * @return ::OC_STACK_OK for Success, otherwise some error value.
66 OCStackResult CBORPayloadToDoxm(const uint8_t *cborPayload, size_t size,
70 * This method converts DOXM data into CBOR format.
71 * Caller needs to invoke 'free' when finished done using
74 * @param doxm Pointer to @ref OicSecDoxm_t.
75 * @note Caller needs to invoke OCFree after done using the return pointer.
76 * @param cborPayload is the payload of the cbor.
77 * @param cborSize is the size of the cbor payload. Passed parameter should not be NULL.
78 * @param rwOnly indicates whether convertingpayload has all properties or read-write properties only.
80 * @return ::OC_STACK_OK for Success, otherwise some error value.
82 OCStackResult DoxmToCBORPayload(const OicSecDoxm_t * doxm, uint8_t **cborPayload,
83 size_t *cborSize, bool rwOnly);
86 * This method returns the SRM device ID for this device.
88 * @return ::OC_STACK_OK for Success, otherwise some error value.
90 OCStackResult GetDoxmDeviceID(OicUuid_t *deviceID);
93 * This method changes the SRM device ID for this device.
94 * This api will update device Id iff device is in unowned state.
95 * @return ::OC_STACK_OK for Success, otherwise some error value.
97 OCStackResult SetDoxmDeviceID(const OicUuid_t *deviceID);
101 * Gets the OicUuid_t value for the owner of this device.
103 * @param devownerid a pointer to be assigned to the devownerid property
104 * @return ::OC_STACK_OK if devownerid is assigned correctly, else ::OC_STACK_ERROR.
106 OCStackResult GetDoxmDevOwnerId(OicUuid_t *devownerid);
109 * Gets the bool state of "isOwned" property on the doxm resource.
111 * @param isOwned a pointer to be assigned to isOwned property
112 * @return ::OC_STACK_OK if isOwned is assigned correctly, else ::OC_STACK_ERROR.
114 OCStackResult GetDoxmIsOwned(bool *isOwned);
117 * Gets the OicUuid_t value for the rowneruuid of the doxm resource.
119 * @param rowneruuid a pointer to be assigned to the rowneruuid property
120 * @return ::OC_STACK_OK if rowneruuid is assigned correctly, else ::OC_STACK_ERROR.
122 OCStackResult GetDoxmRownerId(OicUuid_t *rowneruuid);
124 #ifdef _ENABLE_MULTIPLE_OWNER_
126 * Compare the UUID to SubOwner.
128 * @param[in] uuid device UUID
130 * @return true if uuid exists in the SubOwner list of doxm, else false.
132 bool IsSubOwner(const OicUuid_t* uuid);
133 #endif //_ENABLE_MULTIPLE_OWNER_
135 /** This function deallocates the memory for OicSecDoxm_t .
137 * @param doxm is the pointer to @ref OicSecDoxm_t.
139 void DeleteDoxmBinData(OicSecDoxm_t* doxm);
142 * Function to restore doxm resurce to initial status.
143 * This function will use in case of error while ownership transfer
145 void RestoreDoxmToInitState();
147 #if defined(__WITH_DTLS__) && defined(_ENABLE_MULTIPLE_OWNER_)
149 * Callback function to handle MOT DTLS handshake result.
150 * @param[out] object remote device information.
151 * @param[out] errorInfo CA Error information.
153 void MultipleOwnerDTLSHandshakeCB(const CAEndpoint_t *object,
154 const CAErrorInfo_t *errorInfo);
155 #endif //__WITH_DTLS__ && _ENABLE_MULTIPLE_OWNER_
161 #endif //IOTVT_SRM_DOXMR_H