#include "credresource.h"
#include "utlist.h"
#include "aclresource.h" //Note: SRM internal header
+#include "pconfresource.h"
#define TAG "OCPMAPI"
*/
OCStackResult OCDiscoverUnownedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
{
- if( ppList == NULL || *ppList != NULL)
+ if( ppList == NULL || *ppList != NULL || 0 == timeout)
{
return OC_STACK_INVALID_PARAM;
}
*/
OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList)
{
- if( ppList == NULL || *ppList != NULL)
+ if( ppList == NULL || *ppList != NULL || 0 == timeout)
{
return OC_STACK_INVALID_PARAM;
}
{
if(NULL == callbackData)
{
- return OC_STACK_INVALID_PARAM;
+ return OC_STACK_INVALID_CALLBACK ;
}
return OTMSetOwnershipTransferCallbackData(oxm, callbackData);
{
return OC_STACK_INVALID_PARAM;
}
-
+ if (!resultCallback)
+ {
+ OIC_LOG(INFO, TAG, "OCDoOwnershipTransfer : NULL Callback");
+ return OC_STACK_INVALID_CALLBACK;
+ }
return OTMDoOwnershipTransfer(ctx, targetDevices, resultCallback);
}
}
+/**
+ * this function sends Direct-Pairing Configuration to a device.
+ *
+ * @param[in] ctx Application context would be returned in result callback.
+ * @param[in] selectedDeviceInfo Selected target device.
+ * @param[in] pconf PCONF pointer.
+ * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
+ request recieves a response from resource server.
+ * @return OC_STACK_OK in case of success and other value otherwise.
+ */
+OCStackResult OCProvisionDirectPairing(void* ctx, const OCProvisionDev_t *selectedDeviceInfo, OicSecPconf_t *pconf,
+ OCProvisionResultCB resultCallback)
+{
+ return SRPProvisionDirectPairing(ctx, selectedDeviceInfo, pconf, resultCallback);
+}
+
/*
* Function to unlink devices.
* This function will remove the credential & relationship between the two devices.
OCUuidList_t* idList = NULL;
size_t numOfDev = 0;
- if (!pTargetDev1 || !pTargetDev2 || !resultCallback)
+ if (!pTargetDev1 || !pTargetDev2 || !pTargetDev1->doxm || !pTargetDev2->doxm)
{
OIC_LOG(ERROR, TAG, "OCUnlinkDevices : NULL parameters");
return OC_STACK_INVALID_PARAM;
}
+ if (!resultCallback)
+ {
+ OIC_LOG(INFO, TAG, "OCUnlinkDevices : NULL Callback");
+ return OC_STACK_INVALID_CALLBACK;
+ }
+ if (0 == memcmp(&pTargetDev1->doxm->deviceID, &pTargetDev2->doxm->deviceID, sizeof(OicUuid_t)))
+ {
+ OIC_LOG(INFO, TAG, "OCUnlinkDevices : Same device ID");
+ return OC_STACK_INVALID_PARAM;
+ }
// Get linked devices with the first device.
OCStackResult res = PDMGetLinkedDevices(&(pTargetDev1->doxm->deviceID), &idList, &numOfDev);
{
OIC_LOG(INFO, TAG, "IN OCRemoveDevice");
OCStackResult res = OC_STACK_ERROR;
- if (!pTargetDev || !resultCallback || 0 == waitTimeForOwnedDeviceDiscovery)
+ if (!pTargetDev || 0 == waitTimeForOwnedDeviceDiscovery)
{
OIC_LOG(INFO, TAG, "OCRemoveDevice : Invalied parameters");
return OC_STACK_INVALID_PARAM;
}
+ if (!resultCallback)
+ {
+ OIC_LOG(INFO, TAG, "OCRemoveDevice : NULL Callback");
+ return OC_STACK_INVALID_CALLBACK;
+ }
// Send DELETE requests to linked devices
OCStackResult resReq = OC_STACK_ERROR; // Check that we have to wait callback or not.
OCProvisionResultCB resultCallback)
{
- if (!pDev1 || !pDev2 || !resultCallback)
+ if (!pDev1 || !pDev2 || !pDev1->doxm || !pDev2->doxm)
{
OIC_LOG(ERROR, TAG, "OCProvisionPairwiseDevices : Invalid parameters");
return OC_STACK_INVALID_PARAM;
}
+ if (!resultCallback)
+ {
+ OIC_LOG(INFO, TAG, "OCProvisionPairwiseDevices : NULL Callback");
+ return OC_STACK_INVALID_CALLBACK;
+ }
if (!(keySize == OWNER_PSK_LENGTH_128 || keySize == OWNER_PSK_LENGTH_256))
{
OIC_LOG(INFO, TAG, "OCProvisionPairwiseDevices : Invalid key size");
return OC_STACK_INVALID_PARAM;
}
+ if (0 == memcmp(&pDev1->doxm->deviceID, &pDev2->doxm->deviceID, sizeof(OicUuid_t)))
+ {
+ OIC_LOG(INFO, TAG, "OCProvisionPairwiseDevices : Same device ID");
+ return OC_STACK_INVALID_PARAM;
+ }
OIC_LOG(DEBUG, TAG, "Checking link in DB");
bool linkExists = true;
{
//TODO will be replaced by more efficient logic
if (pOwnedDevList == NULL || *pOwnedDevList != NULL || pUnownedDevList == NULL
- || *pUnownedDevList != NULL)
+ || *pUnownedDevList != NULL || 0 == waittime)
{
return OC_STACK_INVALID_PARAM;
}
DeleteACLList(pAcl);
}
+/**
+ * This function deletes PDACL data.
+ *
+ * @param pPdAcl Pointer to OicSecPdAcl_t structure.
+ */
+void OCDeletePdAclList(OicSecPdAcl_t* pPdAcl)
+{
+ FreePdAclList(pPdAcl);
+}
+
#ifdef __WITH_X509__
/**