From 8b50f320a5668681df6fafbd88f9029c3707e8e4 Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Wed, 10 Jan 2018 20:49:53 +0900 Subject: [PATCH] d2d-subowner: fix memory leak and change signal name Signed-off-by: saerome.kim --- src/d2d-subowner/d2ds-service-interface.c | 16 +- src/d2d-subowner/d2ds-subowner.c | 369 ++++++++++++++++-------------- src/d2d-subowner/introspection/d2ds.xml | 57 +++-- src/fn-manager/src/comp_mot_agent.c | 13 +- 4 files changed, 244 insertions(+), 211 deletions(-) diff --git a/src/d2d-subowner/d2ds-service-interface.c b/src/d2d-subowner/d2ds-service-interface.c index 164e93b..2acc0d8 100644 --- a/src/d2d-subowner/d2ds-service-interface.c +++ b/src/d2d-subowner/d2ds-service-interface.c @@ -205,7 +205,7 @@ static gboolean _d2ds_dbus_handle_remove_mo(NetD2ds *object, } -static gboolean _d2ds_dbus_handle_prov_acl(NetD2ds *object, +static gboolean _d2ds_dbus_handle_acl(NetD2ds *object, GDBusMethodInvocation *invocation, gchar *arg_target, gchar *arg_subject, gchar *arg_uri, gchar *arg_rt, gchar *arg_interface, gint arg_permission, gpointer user_data) { @@ -219,12 +219,12 @@ static gboolean _d2ds_dbus_handle_prov_acl(NetD2ds *object, if (D2DS_ERROR_NONE != ret) D2DS_LOGE("Failed to d2ds_request_prov_acl !"); - net_d2ds_complete_prov_acl(object, invocation, ret); + net_d2ds_complete_acl(object, invocation, ret); return TRUE; } -static gboolean _d2ds_dbus_handle_prov_cred(NetD2ds *object, +static gboolean _d2ds_dbus_handle_cred(NetD2ds *object, GDBusMethodInvocation *invocation, gchar *arg_dev1, gchar *arg_dev2, gpointer user_data) { int ret = D2DS_ERROR_NONE; @@ -237,7 +237,7 @@ static gboolean _d2ds_dbus_handle_prov_cred(NetD2ds *object, if (D2DS_ERROR_NONE != ret) D2DS_LOGE("Failed to d2ds_request_prov_cred !"); - net_d2ds_complete_prov_cred(object, invocation, ret); + net_d2ds_complete_cred(object, invocation, ret); return TRUE; } @@ -328,10 +328,10 @@ static void _d2ds_dbus_on_bus_acquired(GDBusConnection *conn, const gchar *name, G_CALLBACK(_d2ds_dbus_handle_mot), service); g_signal_connect(d2ds_dbus_object, "handle-remove-mo", G_CALLBACK(_d2ds_dbus_handle_remove_mo), service); - g_signal_connect(d2ds_dbus_object, "handle-prov-acl", - G_CALLBACK(_d2ds_dbus_handle_prov_acl), service); - g_signal_connect(d2ds_dbus_object, "handle-prov-cred", - G_CALLBACK(_d2ds_dbus_handle_prov_cred), service); + g_signal_connect(d2ds_dbus_object, "handle-acl", + G_CALLBACK(_d2ds_dbus_handle_acl), service); + g_signal_connect(d2ds_dbus_object, "handle-cred", + G_CALLBACK(_d2ds_dbus_handle_cred), service); g_signal_connect(d2ds_dbus_object, "handle-get-ownerid", G_CALLBACK(_d2ds_dbus_handle_get_ownerid), service); g_signal_connect(d2ds_dbus_object, "handle-pairwise", diff --git a/src/d2d-subowner/d2ds-subowner.c b/src/d2d-subowner/d2ds-subowner.c index 90e9f2b..2ab5c88 100644 --- a/src/d2d-subowner/d2ds-subowner.c +++ b/src/d2d-subowner/d2ds-subowner.c @@ -61,8 +61,10 @@ #define ACL_RESRC_ARRAY_SIZE 3 #define DISCOVERY_TIMEOUT 3 /**< 3 sec */ -#define CALLBACK_TIMEOUT_S 10 * 1000 /**< 10 sec = 100ms * 1000 */ -#define CALLBACK_TIMEOUT_MS 10 * 500 /**< 5sec = 100ms * 500 */ +#define CALLBACK_TIMEOUT_10S 10 * 1000 /**< 10 sec = 10 * 1000 * 1ms */ +#define CALLBACK_TIMEOUT_5S 5 * 1000 /**< 5sec = 5 * 1000 * 1ms */ + +#define TIMEOUT_USED /* '_' for separaing from the same constant variable in srmresourcestrings.c */ static const char* SVR_DB_FILE_NAME = "oic_svr_db_d2ds.dat"; @@ -100,25 +102,23 @@ typedef struct { gchar *uuid_dev1; /**< 1st device for CRED provisiong */ gchar *uuid_dev2; /**< 2nd device for CRED provisiong */ - /* For Pairwaise linking */ - OCProvisionDev_t *target_1; /**< Target device 1*/ - OCProvisionDev_t *target_2; /**< Target device 1*/ + /* For Pairwaise linking */ + gchar *target_1; /**< Target device 1*/ + gchar *target_2; /**< Target device 1*/ - OCProvisionDev_t *subject_1; /**< Target device for ACL */ + gchar *subject_1; /**< Target device for ACL */ gchar *rsrc_uri_1; /**< Resource URI */ gchar *rsrc_type_1; /**< Resouce Type */ gchar *rsrc_interface_1; /**< Resource Interface Array To-Do : Make this as array */ int permission_1;/**< Permision */ - OCProvisionDev_t *subject_2; /**< Target device for ACL */ + gchar *subject_2; /**< Target device for ACL */ gchar *rsrc_uri_2; /**< Resource URI */ gchar *rsrc_type_2; /**< Resouce Type */ gchar *rsrc_interface_2; /**< Resource Interface Array To-Do : Make this as array */ int permission_2;/**< Permision */ - OCProvisionDev_t *dev1; /**< 1st device for CRED provisiong */ - OCProvisionDev_t *dev2; /**< 2nd device for CRED provisiong */ - /* For unpair */ - OCProvisionDev_t *target; /**< Target device */ + /* For unpair */ + gchar *target_to_revoke; /**< Target device to revoke */ } d2ds_req_cb_s; @@ -589,12 +589,55 @@ static void _request_cleanup(gpointer data) } if (con->uuid_target_str) { g_free(con->uuid_target_str); + con->uuid_target_str = NULL; } if (con->uuid_dev1) { g_free(con->uuid_dev1); + con->uuid_dev1 = NULL; } if (con->uuid_dev2) { g_free(con->uuid_dev2); + con->uuid_dev2 = NULL; + } + if (con->target_1) { + g_free(con->target_1); + con->target_1 = NULL; + } + if (con->subject_1) { + g_free(con->subject_1); + con->subject_1 = NULL; + } + if (con->rsrc_uri_1) { + g_free(con->rsrc_uri_1); + con->rsrc_uri_1 = NULL; + } + if (con->rsrc_type_1) { + g_free(con->rsrc_type_1); + con->rsrc_type_1 = NULL; + } + if (con->rsrc_interface_1) { + g_free(con->rsrc_interface_1); + con->rsrc_interface_1 = NULL; + } + if (con->target_2) { + g_free(con->target_1); + con->target_1 = NULL; + } + if (con->subject_2) { + g_free(con->subject_1); + con->subject_1 = NULL; + } + if (con->rsrc_uri_2) { + g_free(con->rsrc_uri_2); + con->rsrc_uri_2 = NULL; + } + if (con->rsrc_type_2) { + g_free(con->rsrc_type_2); + con->rsrc_type_2 = NULL; + } + if (con->rsrc_interface_2) { + g_free(con->rsrc_interface_2); + con->rsrc_interface_2 = NULL; } /* Set d2ds status 'pending' */ @@ -606,49 +649,6 @@ static void _request_cleanup(gpointer data) } } -#ifdef TEST -static gboolean _d2ds_timeout_cb(gpointer data) -{ - d2ds_req_cb_s *con = (d2ds_req_cb_s *)data; - d2ds_check_null_ret("con", con); - - if (NULL == con) { - D2DS_LOGE("container is NULL"); - return G_SOURCE_REMOVE; - } - if (con->found) { - D2DS_LOGE("cb was alreay handled"); - return G_SOURCE_REMOVE; - } - - if(OC_STACK_OK != OCProcess()) { - D2DS_LOGE( "OCStack process error"); - return G_SOURCE_REMOVE; - } - - OCPDMCleanupForTimeout(); - - switch (con->cid) { - case D2DS_DISC_MOT_ENB_DEVS: - D2DS_LOGE("Discovered Multiple Ownership Transfer Enabled Devices\n"); - g_client->g_motdev_cnt = _print_dev_list(g_client->g_motdev_list); - break; - case D2DS_DISC_MOWNED_DEVS: - D2DS_LOGE("Discovered Multiple Ownership Transfer Enabled Devices\n"); - g_client->g_mowndev_cnt = _print_dev_list(g_client->g_mowned_list); - break; - case D2DS_MOT: - case D2DS_PROV_ACL: - case D2DS_PROV_CRED: - break; - } - - _request_cleanup((gpointer)con); - - return G_SOURCE_REMOVE; -} -#endif - static void __notify_found_devs(void *data) { GVariantBuilder builder; @@ -739,8 +739,62 @@ static void __notify_found_devs(void *data) g_variant_unref(devices); } +#ifdef TIMEOUT_USED +static gboolean _d2ds_timeout_cb(gpointer data) +{ + d2ds_req_cb_s *con = (d2ds_req_cb_s *)data; + d2ds_check_null_ret_error("con", con, G_SOURCE_REMOVE); + + if (NULL == con) { + D2DS_LOGE("container is NULL"); + return G_SOURCE_REMOVE; + } + if (con->found) { + D2DS_LOGE("cb was alreay handled"); + return G_SOURCE_REMOVE; + } + + if(OC_STACK_OK != OCProcess()) { + D2DS_LOGE( "OCStack process error"); + return G_SOURCE_REMOVE; + } + + OCPDMCleanupForTimeout(); + switch (con->cid) { + case D2DS_DISC_MOT_ENB_DEVS: + D2DS_LOGE("Discovered Multiple Ownership Transfer Enabled Devices"); + __notify_found_devs(con); + break; + case D2DS_DISC_MOWNED_DEVS: + D2DS_LOGE("Discovered Multiple Ownership Transfer Enabled Devices"); + __notify_found_devs(con); + break; + case D2DS_MOT: + net_d2ds_emit_mot_done(d2ds_dbus_get_object(), D2DS_ERROR_OPERATION_FAILED); + break; + case D2DS_PROV_ACL: + net_d2ds_emit_acl_done(d2ds_dbus_get_object(), D2DS_ERROR_OPERATION_FAILED); + break; + case D2DS_PROV_CRED: + net_d2ds_emit_cred_done(d2ds_dbus_get_object(), D2DS_ERROR_OPERATION_FAILED); + break; + case D2DS_REMOVE_MOT: + net_d2ds_emit_remove_mo_done(d2ds_dbus_get_object(), D2DS_ERROR_OPERATION_FAILED); + break; + case D2DS_UNPAIR: + net_d2ds_emit_unpair_done(d2ds_dbus_get_object(), D2DS_ERROR_OPERATION_FAILED); + break; + case D2DS_PROV_PAIRWISE: + net_d2ds_emit_pairwise_done(d2ds_dbus_get_object(), D2DS_ERROR_OPERATION_FAILED); + break; + } + _request_cleanup((gpointer)con); + + return G_SOURCE_REMOVE; +} +#endif static gpointer _disc_mot_env_devs_func(gpointer data) { d2ds_req_cb_s *con = (d2ds_req_cb_s *)data; @@ -871,12 +925,9 @@ static gpointer _mot_func(gpointer data) D2DS_LOGE("We can't find in MOT dev list"); goto MOT_ENDED; } - /* To MOT only one device */ - src_dev->next = NULL; g_client->g_doneCB = false; -#ifdef MULTIPLE_OWNER OCProvisionDev_t* dev = NULL; LL_FOREACH(src_dev, dev) { if(OIC_PRECONFIG_PIN == dev->doxm->oxmSel) { @@ -890,14 +941,14 @@ static gpointer _mot_func(gpointer data) } } } -#endif + ret = OCDoMultipleOwnershipTransfer(g_client, src_dev, _mot_cb); if (OC_STACK_OK != ret ) { D2DS_LOGE( "OCDoMultipleOwnershipTransfer: ret = %d (%s)", ret, _error_to_string(ret)); goto MOT_ENDED; } - ret = _wait_cb_ret(CALLBACK_TIMEOUT_S); + ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); if(ret) { D2DS_LOGE( "OCDoMultipleOwnershipTransfer callback error = %d (%s)", ret, _error_to_string(ret)); goto MOT_ENDED; @@ -951,7 +1002,7 @@ static int _d2ds_mot(d2ds_service *service, gchar *uuid_str, gchar *pin) g_thread_unref(con->thread); #ifdef TIMEOUT_USED - con->tid = g_timeout_add_seconds(CALLBACK_TIMEOUT_S + 1, _d2ds_timeout_cb, con); + con->tid = g_timeout_add_seconds(CALLBACK_TIMEOUT_5S + 1, _d2ds_timeout_cb, con); #endif return D2DS_ERROR_NONE; } @@ -1004,7 +1055,7 @@ static gpointer _remove_mo_func(gpointer data) goto MOT_ENDED; } - ret = _wait_cb_ret(CALLBACK_TIMEOUT_S); + ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); if(ret) { D2DS_LOGE( "OCRemoveSubOwner callback error = %d (%s)", ret, _error_to_string(ret)); goto MOT_ENDED; @@ -1048,7 +1099,7 @@ static int _d2ds_remove_mo(d2ds_service *service, gchar *uuid_str) g_thread_unref(con->thread); #ifdef TIMEOUT_USED - con->tid = g_timeout_add_seconds(CALLBACK_TIMEOUT_S + 1, _d2ds_timeout_cb, con); + con->tid = g_timeout_add_seconds(CALLBACK_TIMEOUT_5S + 1, _d2ds_timeout_cb, con); #endif return D2DS_ERROR_NONE; } @@ -1327,9 +1378,6 @@ static gpointer _provisioning_acl_func(gpointer data) } g_free(uuid); - /* To do ACL provisioning only one */ - target_dev->next = NULL; - uuid = _convert_uuid(con->uuid_subject_str); subject_dev = _get_dev_by_uuid(g_client->g_mowned_list, uuid); if (!subject_dev) { @@ -1338,9 +1386,6 @@ static gpointer _provisioning_acl_func(gpointer data) } g_free(uuid); - /* To do ACL provisioning only one */ - subject_dev->next = NULL; - g_client->g_doneCB = false; D2DS_LOGI(" Provisioning Selected ACL.."); @@ -1357,7 +1402,7 @@ static gpointer _provisioning_acl_func(gpointer data) goto PVACL_ERROR; } - ret = _wait_cb_ret(CALLBACK_TIMEOUT_S); + ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); if (ret) { D2DS_LOGE( "OCProvisionCredentials Faild = %d", errno); goto PVACL_ERROR; @@ -1367,7 +1412,7 @@ static gpointer _provisioning_acl_func(gpointer data) PVACL_ERROR: /* Notify ACL result */ - net_d2ds_emit_prov_acl_done(d2ds_dbus_get_object(), (int)ret); + net_d2ds_emit_acl_done(d2ds_dbus_get_object(), (int)ret); if (acl) OCDeleteACLList(acl); @@ -1406,7 +1451,7 @@ static int _provisioning_acl(d2ds_service *service, gchar *target, gchar *subjec } g_thread_unref(con->thread); #ifdef TIMEOUT_USED - con->tid = g_timeout_add_seconds(CALLBACK_TIMEOUT_S + 1, _d2ds_timeout_cb, con); + con->tid = g_timeout_add_seconds(CALLBACK_TIMEOUT_5S + 1, _d2ds_timeout_cb, con); #endif return D2DS_ERROR_NONE; } @@ -1415,8 +1460,17 @@ static gpointer _provisioning_pairwise_func(gpointer data) { OCStackResult ret = OC_STACK_OK; d2ds_req_cb_s *con = (d2ds_req_cb_s *)data; + + OicUuid_t *uuid_1 = NULL; + OicUuid_t *uuid_2 = NULL; + OicSecAcl_t* acl_1 = NULL; - OicSecAcl_t* acl_2 = NULL; + OicSecAcl_t* acl_2 = NULL; + + OCProvisionDev_t *target_dev_1 = NULL; + OCProvisionDev_t *target_dev_2 = NULL; + OCProvisionDev_t *subject_dev_1 = NULL; + OCProvisionDev_t *subject_dev_2 = NULL; if (!con->subject_1 || !con->rsrc_uri_1 || !con->rsrc_type_1 || !con->rsrc_interface_1 || !con->subject_2 || !con->rsrc_uri_2 || !con->rsrc_type_2 || !con->rsrc_interface_2) { @@ -1433,11 +1487,43 @@ static gpointer _provisioning_pairwise_func(gpointer data) goto PVACL_ERROR; } + uuid_1 = _convert_uuid(con->target_1); + target_dev_1 = _get_dev_by_uuid(g_client->g_mowned_list, uuid_1); + if (!target_dev_1) { + D2DS_LOGE("We can't find target in MOWNED dev list"); + goto PVACL_ERROR; + } + g_free(uuid_1); + + uuid_2 = _convert_uuid(con->target_2); + target_dev_2 = _get_dev_by_uuid(g_client->g_mowned_list, uuid_2); + if (!target_dev_2) { + D2DS_LOGE("We can't find target in MOWNED dev list"); + goto PVACL_ERROR; + } + g_free(uuid_2); + + uuid_1 = _convert_uuid(con->subject_1); + subject_dev_1 = _get_dev_by_uuid(g_client->g_mowned_list, uuid_1); + if (!subject_dev_1) { + D2DS_LOGE("We can't find subject in MOWNED dev list"); + goto PVACL_ERROR; + } + g_free(uuid_1); + + uuid_2 = _convert_uuid(con->subject_2); + subject_dev_2 = _get_dev_by_uuid(g_client->g_mowned_list, uuid_2); + if (!subject_dev_2) { + D2DS_LOGE("We can't find subject in MOWNED dev list"); + goto PVACL_ERROR; + } + g_free(uuid_2); + g_client->g_doneCB = false; D2DS_LOGI(" Provisioning Selected Pairwise.."); - acl_1 = _create_target_acl(&con->target_1->doxm->deviceID, - &con->subject_1->doxm->deviceID, con->rsrc_uri_1, + acl_1 = _create_target_acl(&target_dev_1->doxm->deviceID, + &subject_dev_1->doxm->deviceID, con->rsrc_uri_1, con->rsrc_type_1, con->rsrc_interface_1, con->permission_1); if (NULL == acl_1) { @@ -1445,8 +1531,8 @@ static gpointer _provisioning_pairwise_func(gpointer data) goto PVACL_ERROR; } - acl_2 = _create_target_acl(&con->target_2->doxm->deviceID, - &con->subject_2->doxm->deviceID, con->rsrc_uri_2, + acl_2 = _create_target_acl(&target_dev_2->doxm->deviceID, + &subject_dev_2->doxm->deviceID, con->rsrc_uri_2, con->rsrc_type_2, con->rsrc_interface_2, con->permission_2); if (NULL == acl_2) { @@ -1455,15 +1541,15 @@ static gpointer _provisioning_pairwise_func(gpointer data) } ret = OCProvisionPairwiseDevices((void*) g_client, SYMMETRIC_PAIR_WISE_KEY, - OWNER_PSK_LENGTH_256, con->target_1, acl_1, - con->target_2, acl_2, _provisioning_pairwise_cb); + OWNER_PSK_LENGTH_256, target_dev_1, acl_1, + target_dev_2, acl_2, _provisioning_pairwise_cb); if (OC_STACK_OK != ret) { D2DS_LOGD( "OCProvisionPairwiseDevices API error: %d (%s)", ret, _error_to_string(ret)); goto PVACL_ERROR; } - ret = _wait_cb_ret(CALLBACK_TIMEOUT_S); + ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); if (ret) { D2DS_LOGE( "OCProvisionPairwise Faild = %d", errno); goto PVACL_ERROR; @@ -1473,13 +1559,13 @@ static gpointer _provisioning_pairwise_func(gpointer data) PVACL_ERROR: /* Notify ACL result */ - net_d2ds_emit_prov_acl_done(d2ds_dbus_get_object(), (int)ret); + net_d2ds_emit_pairwise_done(d2ds_dbus_get_object(), (int)ret); if (acl_1) { OCDeleteACLList(acl_1); acl_1 = NULL; } - if (acl_2) { + if (acl_2) { OCDeleteACLList(acl_2); acl_2 = NULL; } @@ -1493,22 +1579,26 @@ static gpointer _unpair_func(gpointer data) OCStackResult ret = OC_STACK_OK; d2ds_req_cb_s *con = (d2ds_req_cb_s *)data; - if (!con->target) { + OicUuid_t *uuid = NULL; + + if (!con->target_to_revoke) { D2DS_LOGE("Some parameters are wrong"); - D2DS_LOGE("%p", con->target ); + D2DS_LOGE("%s", con->target_to_revoke ); goto PVACL_ERROR; } + uuid = _convert_uuid(con->target_to_revoke); + g_client->g_doneCB = false; D2DS_LOGI(" unpair device.."); - ret = OCRemoveDevice((void*) g_client,DISCOVERY_TIMEOUT,con->target,_unpair_cb ); + ret = OCRemoveDeviceWithUuid((void*) g_client, CALLBACK_TIMEOUT_5S, uuid, _unpair_cb ); if (OC_STACK_OK != ret) { D2DS_LOGD( "OCRemoveDevice API error: %d (%s)", ret, _error_to_string(ret)); goto PVACL_ERROR; } - ret = _wait_cb_ret(CALLBACK_TIMEOUT_S); + ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); if (ret) { D2DS_LOGE( "OCRemoveDevice Faild = %d", errno); goto PVACL_ERROR; @@ -1518,8 +1608,9 @@ static gpointer _unpair_func(gpointer data) PVACL_ERROR: /* Notify ACL result */ - net_d2ds_emit_prov_acl_done(d2ds_dbus_get_object(), (int)ret); - + net_d2ds_emit_unpair_done(d2ds_dbus_get_object(), (int)ret); + if (uuid) + g_free(uuid); _request_cleanup(con); g_thread_exit(GINT_TO_POINTER (1)); return NULL; @@ -1527,9 +1618,8 @@ PVACL_ERROR: static int _provisioning_unpair(d2ds_service *service, gchar *target) { - OicUuid_t *uuid = NULL; - OCProvisionDev_t *target_dev = NULL; + OCProvisionDev_t *target_dev = NULL; d2ds_req_cb_s *con = NULL; con = g_malloc0(sizeof(d2ds_req_cb_s)); @@ -1543,22 +1633,7 @@ static int _provisioning_unpair(d2ds_service *service, gchar *target) con->userdata = service; con->cid = D2DS_UNPAIR; - uuid = _convert_uuid(target); - - target_dev = _get_dev_by_uuid(g_client->g_mowned_list, uuid); - if (!target_dev) { - D2DS_LOGE("We can't find target in MOWNED dev list"); - _request_cleanup(con); - return D2DS_ERROR_NO_DATA; - } - g_free(uuid); - - - /* Copy subject device and related information */ - con->target = PMCloneOCProvisionDev(target_dev); - /* To do ACL provisioning only one */ - con->target->next = NULL; - + con->target_to_revoke = g_strdup(target); con->thread = g_thread_try_new("unpair_device", _unpair_func, con, NULL); if (!con->thread) { @@ -1568,7 +1643,7 @@ static int _provisioning_unpair(d2ds_service *service, gchar *target) } g_thread_unref(con->thread); #ifdef TIMEOUT_USED - con->tid = g_timeout_add_seconds(CALLBACK_TIMEOUT_S + 1, _d2ds_timeout_cb, con); + con->tid = g_timeout_add_seconds(CALLBACK_TIMEOUT_5S + 1, _d2ds_timeout_cb, con); #endif return D2DS_ERROR_NONE; } @@ -1577,14 +1652,6 @@ static int _provisioning_pairwise_link(d2ds_service *service, gchar *target_1, g gchar *rsrc_uri_1, gchar *rsrc_type_1, gchar *rsrc_interface_1, int permission_1, gchar *target_2, gchar *subject_2,gchar *rsrc_uri_2, gchar *rsrc_type_2, gchar *rsrc_interface_2, int permission_2) { - - OicUuid_t *uuid_1 = NULL; - OicUuid_t *uuid_2 = NULL; - OCProvisionDev_t *target_dev_1 = NULL; - OCProvisionDev_t *subject_dev_1 = NULL; - OCProvisionDev_t *target_dev_2 = NULL; - OCProvisionDev_t *subject_dev_2 = NULL; - d2ds_req_cb_s *con = NULL; con = g_malloc0(sizeof(d2ds_req_cb_s)); if (NULL == con) { @@ -1597,69 +1664,15 @@ static int _provisioning_pairwise_link(d2ds_service *service, gchar *target_1, g con->userdata = service; con->cid = D2DS_PROV_PAIRWISE; - uuid_1 = _convert_uuid(target_1); - uuid_2 = _convert_uuid(target_2); - - target_dev_1 = _get_dev_by_uuid(g_client->g_mowned_list, uuid_1); - if (!target_dev_1) { - D2DS_LOGE("We can't find target in MOWNED dev list"); - _request_cleanup(con); - return D2DS_ERROR_NO_DATA; - } - g_free(uuid_1); - - target_dev_2 = _get_dev_by_uuid(g_client->g_mowned_list, uuid_2); - if (!target_dev_2) { - D2DS_LOGE("We can't find target in MOWNED dev list"); - _request_cleanup(con); - return D2DS_ERROR_NO_DATA; - } - g_free(uuid_2); - - /* Copy subject device and related information */ - con->target_1 = PMCloneOCProvisionDev(target_dev_1); - /* To do ACL provisioning only one */ - con->target_1->next = NULL; - - - /* Copy subject device and related information */ - con->target_2 = PMCloneOCProvisionDev(target_dev_2); - /* To do ACL provisioning only one */ - con->target_2->next = NULL; - - uuid_1 = _convert_uuid(subject_1); - subject_dev_1 = _get_dev_by_uuid(g_client->g_mowned_list, uuid_1); - if (!subject_dev_1) { - D2DS_LOGE("We can't find subject in MOWNED dev list"); - _request_cleanup(con); - return D2DS_ERROR_NO_DATA; - } - g_free(uuid_1); - - uuid_2 = _convert_uuid(subject_2); - subject_dev_2 = _get_dev_by_uuid(g_client->g_mowned_list, uuid_2); - if (!subject_dev_2) { - D2DS_LOGE("We can't find subject in MOWNED dev list"); - _request_cleanup(con); - return D2DS_ERROR_NO_DATA; - } - g_free(uuid_2); - - /* Copy subject device and related information */ - con->subject_1 = PMCloneOCProvisionDev(subject_dev_1); - /* To do ACL provisioning only one */ - con->subject_1->next = NULL; - - /* Copy subject device and related information */ - con->subject_2 = PMCloneOCProvisionDev(subject_dev_2); - /* To do ACL provisioning only one */ - con->subject_2->next = NULL; - + con->target_1 = g_strdup(target_1); + con->subject_1 = g_strdup(target_1); con->rsrc_uri_1 = OICStrdup(rsrc_uri_1); con->rsrc_type_1 = OICStrdup(rsrc_type_1); con->rsrc_interface_1 = OICStrdup(rsrc_interface_1); - con->rsrc_uri_2 = OICStrdup(rsrc_uri_2); + con->target_2 = g_strdup(target_1); + con->subject_2 = g_strdup(target_1); + con->rsrc_uri_2 = OICStrdup(rsrc_uri_2); con->rsrc_type_2 = OICStrdup(rsrc_type_2); con->rsrc_interface_2 = OICStrdup(rsrc_interface_2); @@ -1672,7 +1685,7 @@ static int _provisioning_pairwise_link(d2ds_service *service, gchar *target_1, g } g_thread_unref(con->thread); #ifdef TIMEOUT_USED - con->tid = g_timeout_add_seconds(CALLBACK_TIMEOUT_S + 1, _d2ds_timeout_cb, + con->tid = g_timeout_add_seconds(CALLBACK_TIMEOUT_5S + 1, _d2ds_timeout_cb, con); #endif return D2DS_ERROR_NONE; @@ -1736,14 +1749,14 @@ static gpointer _cred_provisioning_func(gpointer data) D2DS_LOGI("Provisioning Selected Pairwise Devices.."); ret = OCProvisionCredentials((void*) g_client, - SYMMETRIC_PAIR_WISE_KEY, OWNER_PSK_LENGTH_128, + SYMMETRIC_PAIR_WISE_KEY, OWNER_PSK_LENGTH_256, dev1, dev2, _provision_cred_cb); if (OC_STACK_OK != ret) { D2DS_LOGD( "OCProvisionPairwiseDevices API error: %d (%s)", ret, _error_to_string(ret)); goto PVPWS_ERROR; } - ret = _wait_cb_ret(CALLBACK_TIMEOUT_S); + ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); if (ret) { D2DS_LOGE( "OCProvisionCredentials Faild = %d", errno); goto PVPWS_ERROR; @@ -1756,7 +1769,7 @@ static gpointer _cred_provisioning_func(gpointer data) PVPWS_ERROR: /* Notify ACL result */ - net_d2ds_emit_prov_cred_done(d2ds_dbus_get_object(), (int)ret); + net_d2ds_emit_cred_done(d2ds_dbus_get_object(), (int)ret); if (uuid) g_free(uuid); @@ -1799,7 +1812,7 @@ static int _provisioning_cred(d2ds_service *service, } g_thread_unref(con->thread); #ifdef TIMEOUT_USED - con->tid = g_timeout_add_seconds(CALLBACK_TIMEOUT_S + 1, _d2ds_timeout_cb, con); + con->tid = g_timeout_add_seconds(CALLBACK_TIMEOUT_5S + 1, _d2ds_timeout_cb, con); #endif return D2DS_ERROR_NONE; } diff --git a/src/d2d-subowner/introspection/d2ds.xml b/src/d2d-subowner/introspection/d2ds.xml index ddd130e..e6858a5 100644 --- a/src/d2d-subowner/introspection/d2ds.xml +++ b/src/d2d-subowner/introspection/d2ds.xml @@ -22,7 +22,7 @@ - + @@ -31,7 +31,7 @@ - + @@ -40,27 +40,27 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + @@ -73,10 +73,19 @@ - + + + + + + + + + + - + diff --git a/src/fn-manager/src/comp_mot_agent.c b/src/fn-manager/src/comp_mot_agent.c index 1f80b55..104e23a 100644 --- a/src/fn-manager/src/comp_mot_agent.c +++ b/src/fn-manager/src/comp_mot_agent.c @@ -433,13 +433,24 @@ static void _agent_signal_handler(GDBusConnection *connection, g_variant_iter_free(iter_row); } g_variant_iter_free(iter); - + } else if (0 == g_strcmp0(signal_name, "acl_done")) { + g_variant_get(parameters, "(i)", &result); + LOG_DEBUG("Result : %d", result); + } else if (0 == g_strcmp0(signal_name, "cred_done")) { + g_variant_get(parameters, "(i)", &result); + LOG_DEBUG("Result : %d", result); } else if (0 == g_strcmp0(signal_name, "mot_done")) { g_variant_get(parameters, "(i)", &result); LOG_DEBUG("Result : %d", result); } else if (0 == g_strcmp0(signal_name, "remove_mo_done")) { g_variant_get(parameters, "(i)", &result); LOG_DEBUG("Result : %d", result); + } else if (0 == g_strcmp0(signal_name, "pairwise_done")) { + g_variant_get(parameters, "(i)", &result); + LOG_DEBUG("Result : %d", result); + } else if (0 == g_strcmp0(signal_name, "unpair_done")) { + g_variant_get(parameters, "(i)", &result); + LOG_DEBUG("Result : %d", result); } } static int _subscribe_event() -- 2.7.4