Commit 7c69843c authored by Andreas Zisowsky's avatar Andreas Zisowsky

Added oc_obt_is_owned()

Made the previously static function is_owned() public.

Change-Id: I604142d5aa075c9b51356fb9b7f423bbc53276ca
Signed-off-by: default avatarAndreas Zisowsky <zisowsky@lynxtechnology.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/26791Tested-by: default avatarIoTivity Jenkins <jenkins-daemon@iotivity.org>
parent 7bf1d413
......@@ -68,6 +68,18 @@ int oc_obt_discover_owned_devices(oc_obt_devicelist_cb_t cb, void *data);
int oc_obt_get_ownership(oc_endpoint_t *ep,
oc_obt_devicelist_cb_t cb, void *data);
/**
@brief Checks whether a specific UUID is owned.
The function checks via the credential store whether the
specified di is owned. This is independent of the discovery
of owned devices and available already right after initialization.
@param uuid UUID of the device to check
@return true if owned, false if unowned or uuid is NULL
@see oc_sec_get_creds
*/
bool oc_obt_is_owned_device(oc_uuid_t *uuid);
/* Perform ownership transfer */
int oc_obt_perform_just_works_otm(oc_device_t *device, oc_obt_status_cb_t cb,
void *data);
......
......@@ -129,9 +129,11 @@ get_secure_endpoint(oc_endpoint_t *endpoint)
return endpoint;
}
static bool
owned_device(oc_uuid_t *uuid)
bool
oc_obt_is_owned_device(oc_uuid_t *uuid)
{
if (!uuid)
return false;
/* Check if we already own this device by querying our creds */
oc_sec_creds_t *creds = oc_sec_get_creds(0);
oc_sec_cred_t *c = (oc_sec_cred_t *)oc_list_head(creds->creds);
......@@ -820,7 +822,7 @@ oc_obt_perform_just_works_otm(oc_device_t *device, oc_obt_status_cb_t cb,
{
OC_DBG("In oc_obt_perform_just_works_otm");
if (owned_device(&device->uuid)) {
if (oc_obt_is_owned_device(&device->uuid)) {
return -1;
}
......@@ -938,7 +940,7 @@ get_endpoints(oc_client_response_t *data)
}
if (device->ctx) {
// See oc_obt_rediscover_owned_device() and obt_check_owned().
// See oc_obt_get_ownership() and oc_obt_check_owned().
trigger_get_ownership(device, device->ctx);
device->ctx = NULL;
}
......@@ -997,7 +999,7 @@ obt_check_owned(oc_client_response_t *data)
new_device = cache_device_if_not_known(oc_cache, &uuid, data->endpoint);
} else {
/* Device is owned by somebody else */
if (!owned_device(&uuid)) {
if (!oc_obt_is_owned_device(&uuid)) {
trigger_get_ownership(NULL, cb);
return;
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment