From dda66065df2c6c71bde1bd87ad776b998dfda876 Mon Sep 17 00:00:00 2001 From: youngman Date: Fri, 28 Aug 2015 19:00:59 +0900 Subject: [PATCH] Support 64-bit architectures Change-Id: I49d3cfc4f6b5580fd9c075795f39ad3b3811cf3e Signed-off-by: youngman --- common/ic-dbus.xml | 30 ++++++++-------- daemon/icd-dbus.c | 67 ++++++++++++++++++---------------- daemon/icd-dbus.h | 4 +++ daemon/icd-ioty-ocprocess.c | 6 ++-- daemon/icd-ioty-type.c | 28 +++++++++++++++ daemon/icd-ioty-type.h | 3 ++ daemon/icd-ioty.c | 88 ++++++++++++++++++++++++++++++--------------- daemon/icd-ioty.h | 2 +- lib/CMakeLists.txt | 2 +- lib/icl-client-crud.c | 3 +- lib/icl-client.c | 2 +- lib/icl-client.h | 3 +- lib/icl-dbus-type.c | 6 ++-- lib/icl-presence.c | 14 +++++--- lib/icl-request.h | 8 ++--- lib/icl-resource.c | 26 +++++++------- lib/icl-resource.h | 3 +- lib/icl-response.c | 4 +-- lib/icl-response.h | 7 ++-- 19 files changed, 192 insertions(+), 114 deletions(-) diff --git a/common/ic-dbus.xml b/common/ic-dbus.xml index 695a5e5..1e01ec2 100644 --- a/common/ic-dbus.xml +++ b/common/ic-dbus.xml @@ -6,44 +6,44 @@ - + - + - + - + - - + + - - + + - + - + - + @@ -78,10 +78,10 @@ - + - + @@ -107,10 +107,10 @@ - + - + diff --git a/daemon/icd-dbus.c b/daemon/icd-dbus.c index 5c02938..3664818 100644 --- a/daemon/icd-dbus.c +++ b/daemon/icd-dbus.c @@ -16,6 +16,8 @@ #include #include +#include + #include "iotcon.h" #include "ic-common.h" #include "ic-utils.h" @@ -36,7 +38,7 @@ typedef struct _icd_dbus_client_s { } icd_dbus_client_s; typedef struct _icd_resource_handle { - void *handle; + OCResourceHandle handle; unsigned int number; } icd_resource_handle_s; @@ -47,7 +49,7 @@ icDbus* icd_dbus_get_object() } -static void _icd_dbus_resource_handle_free(void *handle) +static void _icd_dbus_resource_handle_free(OCResourceHandle handle) { icd_dbus_client_s *client; GList *cur_client, *cur_hd; @@ -85,7 +87,8 @@ static void _icd_dbus_resource_handle_free(void *handle) return; } -int icd_dbus_client_list_get_info(void *handle, unsigned int *sig_num, gchar **bus_name) +int icd_dbus_client_list_get_info(OCResourceHandle handle, unsigned int *sig_num, + gchar **bus_name) { FN_CALL; icd_dbus_client_s *client; @@ -161,7 +164,7 @@ int icd_dbus_emit_signal(const char *dest, const char *signal_name, GVariant *va return IOTCON_ERROR_NONE; } -static void _icd_dbus_cleanup_handle(void *data) +static void _icd_dbus_cleanup_handle(OCResourceHandle data) { int ret; icd_resource_handle_s *rsrc_handle = data; @@ -283,8 +286,8 @@ static int _icd_dbus_subscribe_name_owner_changed(GDBusConnection *conn) return IOTCON_ERROR_NONE; } -static int _icd_dbus_resource_list_append_handle(const gchar *bus_name, void *handle, - unsigned int signal_number) +static int _icd_dbus_resource_list_append_handle(const gchar *bus_name, + OCResourceHandle handle, unsigned int signal_number) { FN_CALL; GList *cur_client, *cur_hd; @@ -385,7 +388,7 @@ static gboolean _dbus_handle_register_resource(icDbus *object, FN_CALL; int ret; const gchar *sender; - void *handle = NULL; + OCResourceHandle handle = NULL; handle = icd_ioty_register_resource(uri_path, resource_types, ifaces, properties); if (handle) { @@ -401,24 +404,24 @@ static gboolean _dbus_handle_register_resource(icDbus *object, } } - ic_dbus_complete_register_resource(object, invocation, GPOINTER_TO_INT(handle)); + ic_dbus_complete_register_resource(object, invocation, ICD_POINTER_TO_INT64(handle)); return TRUE; } static gboolean _dbus_handle_unregister_resource(icDbus *object, - GDBusMethodInvocation *invocation, gint resource) + GDBusMethodInvocation *invocation, gint64 resource) { int ret; - ret = icd_ioty_unregister_resource(GINT_TO_POINTER(resource)); + ret = icd_ioty_unregister_resource(ICD_INT64_TO_POINTER(resource)); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_unregister_resource(%u) Fail(%d)", resource, ret); else DBG("handle(%u) deregistered", resource); - _icd_dbus_resource_handle_free(GINT_TO_POINTER(resource)); + _icd_dbus_resource_handle_free(ICD_INT64_TO_POINTER(resource)); ic_dbus_complete_unregister_resource(object, invocation, ret); @@ -427,11 +430,11 @@ static gboolean _dbus_handle_unregister_resource(icDbus *object, static gboolean _dbus_handle_bind_interface(icDbus *object, - GDBusMethodInvocation *invocation, gint resource, gint iface) + GDBusMethodInvocation *invocation, gint64 resource, gint iface) { int ret; - ret = icd_ioty_bind_interface(GINT_TO_POINTER(resource), iface); + ret = icd_ioty_bind_interface(ICD_INT64_TO_POINTER(resource), iface); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_bind_interface() Fail(%d)", ret); @@ -442,11 +445,11 @@ static gboolean _dbus_handle_bind_interface(icDbus *object, static gboolean _dbus_handle_bind_type(icDbus *object, - GDBusMethodInvocation *invocation, gint resource, const gchar *type) + GDBusMethodInvocation *invocation, gint64 resource, const gchar *type) { int ret; - ret = icd_ioty_bind_type(GINT_TO_POINTER(resource), type); + ret = icd_ioty_bind_type(ICD_INT64_TO_POINTER(resource), type); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_bind_type() Fail(%d)", ret); @@ -457,11 +460,11 @@ static gboolean _dbus_handle_bind_type(icDbus *object, static gboolean _dbus_handle_bind_resource(icDbus *object, - GDBusMethodInvocation *invocation, gint parent, gint child) + GDBusMethodInvocation *invocation, gint64 parent, gint64 child) { int ret; - ret = icd_ioty_bind_resource(GINT_TO_POINTER(parent), GINT_TO_POINTER(child)); + ret = icd_ioty_bind_resource(ICD_INT64_TO_POINTER(parent), ICD_INT64_TO_POINTER(child)); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_bind_resource() Fail(%d)", ret); @@ -472,11 +475,12 @@ static gboolean _dbus_handle_bind_resource(icDbus *object, static gboolean _dbus_handle_unbind_resource(icDbus *object, - GDBusMethodInvocation *invocation, gint parent, gint child) + GDBusMethodInvocation *invocation, gint64 parent, gint64 child) { int ret; - ret = icd_ioty_unbind_resource(GINT_TO_POINTER(parent), GINT_TO_POINTER(child)); + ret = icd_ioty_unbind_resource(ICD_INT64_TO_POINTER(parent), + ICD_INT64_TO_POINTER(child)); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_unbind_resource() Fail(%d)", ret); @@ -513,7 +517,7 @@ static gboolean _dbus_handle_observer_start(icDbus *object, GVariant *query, guint signal_number) { - void *observe_h; + OCDoHandle observe_h; const gchar *sender; sender = g_dbus_method_invocation_get_sender(invocation); @@ -522,7 +526,7 @@ static gboolean _dbus_handle_observer_start(icDbus *object, if (NULL == observe_h) ERR("icd_ioty_observer_start() Fail"); - ic_dbus_complete_observer_start(object, invocation, GPOINTER_TO_INT(observe_h)); + ic_dbus_complete_observer_start(object, invocation, ICD_POINTER_TO_INT64(observe_h)); /* observe_h will be freed in _dbus_handle_observer_stop() */ return TRUE; @@ -531,12 +535,12 @@ static gboolean _dbus_handle_observer_start(icDbus *object, static gboolean _dbus_handle_observer_stop(icDbus *object, GDBusMethodInvocation *invocation, - gint observe_h, + gint64 observe_h, GVariant *options) { int ret; - ret = icd_ioty_observer_stop(GINT_TO_POINTER(observe_h), options); + ret = icd_ioty_observer_stop(ICD_INT64_TO_POINTER(observe_h), options); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_observer_stop() Fail(%d)", ret); @@ -548,13 +552,13 @@ static gboolean _dbus_handle_observer_stop(icDbus *object, static gboolean _dbus_handle_notify_list_of_observers(icDbus *object, GDBusMethodInvocation *invocation, - gint resource, + gint64 resource, GVariant *notify_msg, GVariant *observers) { int ret; - ret = icd_ioty_notify_list_of_observers(GINT_TO_POINTER(resource), notify_msg, + ret = icd_ioty_notify_list_of_observers(ICD_INT64_TO_POINTER(resource), notify_msg, observers); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_notify_list_of_observers() Fail(%d)", ret); @@ -566,11 +570,11 @@ static gboolean _dbus_handle_notify_list_of_observers(icDbus *object, static gboolean _dbus_handle_notify_all(icDbus *object, GDBusMethodInvocation *invocation, - gint resource) + gint64 resource) { int ret; - ret = icd_ioty_notify_all(GINT_TO_POINTER(resource)); + ret = icd_ioty_notify_all(ICD_INT64_TO_POINTER(resource)); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_notify_all() Fail(%d)", ret); @@ -700,7 +704,7 @@ static gboolean _dbus_handle_subscribe_presence(icDbus *object, const gchar *type, guint signal_number) { - void *presence_h; + OCDoHandle presence_h; const gchar *sender; sender = g_dbus_method_invocation_get_sender(invocation); @@ -708,7 +712,8 @@ static gboolean _dbus_handle_subscribe_presence(icDbus *object, if (NULL == presence_h) ERR("icd_ioty_subscribe_presence() Fail"); - ic_dbus_complete_subscribe_presence(object, invocation, GPOINTER_TO_INT(presence_h)); + ic_dbus_complete_subscribe_presence(object, invocation, + ICD_POINTER_TO_INT64(presence_h)); return TRUE; } @@ -716,11 +721,11 @@ static gboolean _dbus_handle_subscribe_presence(icDbus *object, static gboolean _dbus_handle_unsubscribe_presence(icDbus *object, GDBusMethodInvocation *invocation, - gint presence_h) + gint64 presence_h) { int ret; - ret = icd_ioty_unsubscribe_presence(GINT_TO_POINTER(presence_h)); + ret = icd_ioty_unsubscribe_presence(ICD_INT64_TO_POINTER(presence_h)); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_unsubscribe_presence() Fail(%d)", ret); diff --git a/daemon/icd-dbus.h b/daemon/icd-dbus.h index 9f896bf..a647bb8 100644 --- a/daemon/icd-dbus.h +++ b/daemon/icd-dbus.h @@ -16,9 +16,13 @@ #ifndef __IOT_CONNECTIVITY_MANAGER_DAEMON_DBUS_H__ #define __IOT_CONNECTIVITY_MANAGER_DAEMON_DBUS_H__ +#include #include #include "ic-dbus.h" +#define ICD_INT64_TO_POINTER(i) ((void*)(intptr_t)(i)) +#define ICD_POINTER_TO_INT64(p) ((int64_t)(intptr_t)(p)) + icDbus* icd_dbus_get_object(); int icd_dbus_client_list_get_info(void *handle, unsigned int *sig_num, gchar **bus_name); int icd_dbus_emit_signal(const char *dest, const char *sig_name, GVariant *value); diff --git a/daemon/icd-ioty-ocprocess.c b/daemon/icd-ioty-ocprocess.c index b230995..199a46a 100644 --- a/daemon/icd-ioty-ocprocess.c +++ b/daemon/icd-ioty-ocprocess.c @@ -214,15 +214,15 @@ static int _worker_req_handler(void *context) if (ctx->payload) g_variant_builder_add(&payload_builder, "v", ctx->payload); - value = g_variant_new("(ia(qs)a(ss)iiavii)", + value = g_variant_new("(ia(qs)a(ss)iiavxx)", ctx->types, ctx->options, ctx->query, ctx->observe_action, ctx->observer_id, &payload_builder, - GPOINTER_TO_INT(ctx->request_h), - GPOINTER_TO_INT(ctx->resource_h)); + ICD_POINTER_TO_INT64(ctx->request_h), + ICD_POINTER_TO_INT64(ctx->resource_h)); ret = _ocprocess_response_signal(ctx->bus_name, IC_DBUS_SIGNAL_REQUEST_HANDLER, ctx->signum, value); diff --git a/daemon/icd-ioty-type.c b/daemon/icd-ioty-type.c index 59575bc..d37ae0b 100644 --- a/daemon/icd-ioty-type.c +++ b/daemon/icd-ioty-type.c @@ -72,4 +72,32 @@ int icd_ioty_transport_flag_to_conn_type(OCTransportAdapter adapter, } +int icd_ioty_conn_type_to_oic_transport_type(int conn_type, OCTransportAdapter *adapter, + OCTransportFlags *flag) +{ + switch (conn_type) { + case IOTCON_CONNECTIVITY_IPV4: + *adapter = OC_ADAPTER_IP; + *flag = OC_IP_USE_V4; + break; + case IOTCON_CONNECTIVITY_IPV6: + *adapter = OC_ADAPTER_IP; + *flag = OC_IP_USE_V6; + break; + case IOTCON_CONNECTIVITY_EDR: + *adapter = OC_ADAPTER_RFCOMM_BTEDR; + *flag = OC_DEFAULT_FLAGS; + break; + case IOTCON_CONNECTIVITY_LE: + *adapter = OC_ADAPTER_GATT_BTLE; + *flag = OC_DEFAULT_FLAGS; + break; + case IOTCON_CONNECTIVITY_ALL: + default: + *adapter = OC_DEFAULT_ADAPTER; + *flag = OC_DEFAULT_FLAGS; + } + + return IOTCON_ERROR_NONE; +} diff --git a/daemon/icd-ioty-type.h b/daemon/icd-ioty-type.h index 5fc1ecb..d124e39 100644 --- a/daemon/icd-ioty-type.h +++ b/daemon/icd-ioty-type.h @@ -25,4 +25,7 @@ OCConnectivityType icd_ioty_conn_type_to_oic_conn_type(int conn_type); int icd_ioty_transport_flag_to_conn_type(OCTransportAdapter adapter, OCTransportFlags flag); +int icd_ioty_conn_type_to_oic_transport_type(int conn_type, OCTransportAdapter *adapter, + OCTransportFlags *flag); + #endif /*__IOT_CONNECTIVITY_MANAGER_DAEMON_IOTIVITY_TYPE_H__*/ diff --git a/daemon/icd-ioty.c b/daemon/icd-ioty.c index 5d2896e..3bb3ae8 100644 --- a/daemon/icd-ioty.c +++ b/daemon/icd-ioty.c @@ -319,15 +319,15 @@ static int _ioty_get_header_options(GVariantIter *src, int src_size, int icd_ioty_send_response(GVariant *resp) { - int result, error_code, options_size; - int request_handle, resource_handle; char *new_uri_path; GVariant *repr_gvar; GVariantIter *options; OCStackResult ret; OCEntityHandlerResponse response = {0}; + int result, error_code, options_size; + int64_t request_handle, resource_handle; - g_variant_get(resp, "(&sia(qs)ivii)", + g_variant_get(resp, "(&sia(qs)ivxx)", &new_uri_path, &error_code, &options, @@ -336,8 +336,8 @@ int icd_ioty_send_response(GVariant *resp) &request_handle, &resource_handle); - response.requestHandle = GINT_TO_POINTER(request_handle); - response.resourceHandle = GINT_TO_POINTER(resource_handle); + response.requestHandle = ICD_INT64_TO_POINTER(request_handle); + response.resourceHandle = ICD_INT64_TO_POINTER(resource_handle); response.ehResult = (OCEntityHandlerResult)result; if (OC_EH_RESOURCE_CREATED == response.ehResult) @@ -444,8 +444,7 @@ int icd_ioty_find_resource(const char *host_address, const char *resource_type, /* * returned string SHOULD be released by you */ -static char* _icd_ioty_resource_generate_uri(char *host, bool is_secure, char *uri_path, - GVariant *query) +static char* _icd_ioty_resource_generate_uri(char *uri_path, GVariant *query) { int len; bool loop_first = true; @@ -453,10 +452,7 @@ static char* _icd_ioty_resource_generate_uri(char *host, bool is_secure, char *u GVariantIter query_iter; char uri_buf[PATH_MAX] = {0}; - if (is_secure) - len = snprintf(uri_buf, sizeof(uri_buf), ICD_IOTY_COAPS"%s%s", host, uri_path); - else - len = snprintf(uri_buf, sizeof(uri_buf), ICD_IOTY_COAP"%s%s", host, uri_path); + len = snprintf(uri_buf, sizeof(uri_buf), "%s", uri_path); /* remove suffix '/' */ if ('/' == uri_buf[strlen(uri_buf) - 1]) { @@ -538,12 +534,12 @@ static gboolean _icd_ioty_crud(int type, icDbus *object, GDBusMethodInvocation * GVariantIter *options; OCCallbackData cbdata = {0}; int conn_type, options_size; - char *uri_path, *host, *uri; - char uri_buf[PATH_MAX] = {0}; + char *uri_path, *host, *uri, *dev_host, *ptr; OCHeaderOption oic_options[MAX_HEADER_OPTIONS]; OCHeaderOption *oic_options_ptr = NULL; OCPayload *payload = NULL; OCConnectivityType oic_conn_type; + OCDevAddr dev_addr = {0}; switch (type) { case ICD_CRUD_GET: @@ -567,14 +563,14 @@ static gboolean _icd_ioty_crud(int type, icDbus *object, GDBusMethodInvocation * return FALSE; } - g_variant_get(resource, "(&s&sba(qs)i)", &uri_path, &host, &is_secure, &options, + g_variant_get(resource, "(&s&sba(qs)i)", &uri_path, &host, &is_secure, &options, &conn_type); switch (type) { case ICD_CRUD_GET: case ICD_CRUD_PUT: case ICD_CRUD_POST: - uri = _icd_ioty_resource_generate_uri(host, is_secure, uri_path, query); + uri = _icd_ioty_resource_generate_uri(uri_path, query); if (NULL == uri) { ERR("_icd_ioty_resource_generate_uri() Fail"); g_variant_iter_free(options); @@ -583,8 +579,7 @@ static gboolean _icd_ioty_crud(int type, icDbus *object, GDBusMethodInvocation * } break; case ICD_CRUD_DELETE: - snprintf(uri_buf, sizeof(uri_buf), "%s%s", host, uri_path); - uri = strdup(uri_buf); + uri = strdup(uri_path); break; } @@ -610,10 +605,30 @@ static gboolean _icd_ioty_crud(int type, icDbus *object, GDBusMethodInvocation * oic_conn_type = icd_ioty_conn_type_to_oic_conn_type(conn_type); + icd_ioty_conn_type_to_oic_transport_type(conn_type, &dev_addr.adapter, + &dev_addr.flags); + + switch (conn_type) { + case IOTCON_CONNECTIVITY_IPV4: + dev_host = strtok_r(host, ":", &ptr); + snprintf(dev_addr.addr, sizeof(dev_addr.addr), "%s", dev_host); + dev_addr.port = atoi(strtok_r(NULL, ":", &ptr)); + break; + case IOTCON_CONNECTIVITY_IPV6: + dev_host = strtok_r(host, "]", &ptr); + snprintf(dev_addr.addr, sizeof(dev_addr.addr), "%s", dev_host); + dev_addr.port = atoi(strtok_r(NULL, "]", &ptr)); + break; + default: + ERR("Invalid Connectivitiy Type"); + icd_ioty_complete_error(type, invocation, IOTCON_ERROR_IOTIVITY); + return TRUE; + } + icd_ioty_csdk_lock(); /* TODO : QoS is come from lib. And user can set QoS to client structure. */ - result = OCDoResource(NULL, rest_type, uri, NULL, payload, oic_conn_type, OC_LOW_QOS, - &cbdata, oic_options_ptr, options_size); + result = OCDoResource(NULL, rest_type, uri, &dev_addr, payload, oic_conn_type, + OC_LOW_QOS, &cbdata, oic_options_ptr, options_size); icd_ioty_csdk_unlock(); free(uri); @@ -666,15 +681,16 @@ OCDoHandle icd_ioty_observer_start(GVariant *resource, int observe_type, GVarian icd_sig_ctx_s *context; OCCallbackData cbdata = {0}; int conn_type, options_size; - char *uri_path, *host, *uri; + char *uri_path, *host, *uri, *dev_host, *ptr; OCHeaderOption oic_options[MAX_HEADER_OPTIONS]; OCHeaderOption *oic_options_ptr = NULL; OCConnectivityType oic_conn_type; + OCDevAddr dev_addr = {0}; g_variant_get(resource, "(&s&sba(qs)i)", &uri_path, &host, &is_secure, &options, &conn_type); - uri = _icd_ioty_resource_generate_uri(host, is_secure, uri_path, query); + uri = _icd_ioty_resource_generate_uri(uri_path, query); if (NULL == uri) { ERR("_icd_ioty_resource_generate_uri() Fail"); g_variant_iter_free(options); @@ -718,10 +734,29 @@ OCDoHandle icd_ioty_observer_start(GVariant *resource, int observe_type, GVarian oic_conn_type = icd_ioty_conn_type_to_oic_conn_type(conn_type); + icd_ioty_conn_type_to_oic_transport_type(conn_type, &dev_addr.adapter, + &dev_addr.flags); + + switch (conn_type) { + case IOTCON_CONNECTIVITY_IPV4: + dev_host = strtok_r(host, ":", &ptr); + snprintf(dev_addr.addr, sizeof(dev_addr.addr), "%s", dev_host); + dev_addr.port = atoi(strtok_r(NULL, ":", &ptr)); + break; + case IOTCON_CONNECTIVITY_IPV6: + dev_host = strtok_r(host, "]", &ptr); + snprintf(dev_addr.addr, sizeof(dev_addr.addr), "%s", dev_host); + dev_addr.port = atoi(strtok_r(NULL, "]", &ptr)); + break; + default: + ERR("Invalid Connectivitiy Type"); + return NULL; + } + icd_ioty_csdk_lock(); /* TODO : QoS is come from lib. And user can set QoS to client structure. */ - result = OCDoResource(&handle, method, uri, NULL, NULL, oic_conn_type, OC_LOW_QOS, - &cbdata, oic_options_ptr, options_size); + result = OCDoResource(&handle, method, uri, &dev_addr, NULL, oic_conn_type, + OC_LOW_QOS, &cbdata, oic_options_ptr, options_size); icd_ioty_csdk_unlock(); free(uri); if (OC_STACK_OK != result) { @@ -882,8 +917,6 @@ OCDoHandle icd_ioty_subscribe_presence(const char *host_address, char uri[PATH_MAX] = {0}; OCCallbackData cbdata = {0}; icd_sig_ctx_s *context; - iotcon_connectivity_type_e conn_type = IOTCON_CONNECTIVITY_IPV4; - OCConnectivityType oic_conn_type; len = snprintf(uri, sizeof(uri), "%s%s", host_address, OC_RSRVD_PRESENCE_URI); if (len <= 0 || sizeof(uri) <= len) { @@ -906,10 +939,9 @@ OCDoHandle icd_ioty_subscribe_presence(const char *host_address, cbdata.cb = icd_ioty_ocprocess_presence_cb; cbdata.cd = _ioty_free_signal_context; - oic_conn_type = icd_ioty_conn_type_to_oic_conn_type(conn_type); - + /* In case of IPV4 or IPV6, connectivity type is CT_ADAPTER_IP in iotivity 0.9.2 */ icd_ioty_csdk_lock(); - result = OCDoResource(&handle, OC_REST_PRESENCE, uri, NULL, NULL, oic_conn_type, + result = OCDoResource(&handle, OC_REST_PRESENCE, uri, NULL, NULL, CT_ADAPTER_IP, OC_LOW_QOS, &cbdata, NULL, 0); icd_ioty_csdk_unlock(); diff --git a/daemon/icd-ioty.h b/daemon/icd-ioty.h index 60fa22a..3270b7d 100644 --- a/daemon/icd-ioty.h +++ b/daemon/icd-ioty.h @@ -47,7 +47,7 @@ void icd_ioty_csdk_unlock(); GThread* icd_ioty_init(const char *addr, unsigned short port); -void icd_ioty_deinit(); +void icd_ioty_deinit(GThread *thread); OCResourceHandle icd_ioty_register_resource(const char *uri_path, const char* const* res_types, int ifaces, uint8_t properties); diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index fc4ed83..5d704ad 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -22,7 +22,7 @@ INSTALL(TARGETS ${CLIENT} DESTINATION ${LIB_INSTALL_DIR}) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) CONFIGURE_FILE(${CLIENT}.pc.in ${CLIENT}.pc @ONLY) -INSTALL(FILES ${CLIENT}.pc DESTINATION lib/pkgconfig) +INSTALL(FILES ${CLIENT}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) FILE(GLOB CLIENT_HEADER include/*.h) INSTALL(FILES ${CLIENT_HEADER} DESTINATION ${INCLUDE_INSTALL_DIR}/${CLIENT}) diff --git a/lib/icl-client-crud.c b/lib/icl-client-crud.c index 88e26e6..3c7b7ee 100644 --- a/lib/icl-client-crud.c +++ b/lib/icl-client-crud.c @@ -14,6 +14,7 @@ * limitations under the License. */ #include +#include #include #include #include @@ -431,7 +432,7 @@ API int iotcon_observer_start(iotcon_client_h resource, iotcon_on_observe_cb cb, void *user_data) { - int observe_handle; + int64_t observe_handle; GError *error = NULL; unsigned int sub_id; int signal_number; diff --git a/lib/icl-client.c b/lib/icl-client.c index af420af..edb83cc 100644 --- a/lib/icl-client.c +++ b/lib/icl-client.c @@ -326,7 +326,7 @@ static iotcon_client_h _icl_client_from_gvariant(GVariant *payload, return NULL; } client->conn_type = conn_type; - client->is_secure = true; + client->is_secure = is_secure; return client; } diff --git a/lib/icl-client.h b/lib/icl-client.h index fb99042..16a5cab 100644 --- a/lib/icl-client.h +++ b/lib/icl-client.h @@ -16,6 +16,7 @@ #ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_CLIENT_H__ #define __IOT_CONNECTIVITY_MANAGER_LIBRARY_CLIENT_H__ +#include #include "iotcon-struct.h" #include "icl-options.h" @@ -30,7 +31,7 @@ struct icl_remote_resource { iotcon_resource_types_h types; int ifaces; iotcon_connectivity_type_e conn_type; - int observe_handle; + int64_t observe_handle; unsigned int observe_sub_id; }; diff --git a/lib/icl-dbus-type.c b/lib/icl-dbus-type.c index f964f3b..9f76f88 100644 --- a/lib/icl-dbus-type.c +++ b/lib/icl-dbus-type.c @@ -98,14 +98,14 @@ GVariant* icl_dbus_response_to_gvariant(struct icl_resource_response *response) return NULL; } - value = g_variant_new("(sia(qs)ivii)", + value = g_variant_new("(sia(qs)ivxx)", ic_utils_dbus_encode_str(response->new_uri_path), response->error_code, &options, response->result, repr_gvar, - GPOINTER_TO_INT(response->request_handle), - GPOINTER_TO_INT(response->resource_handle)); + response->oic_request_h, + response->oic_resource_h); DBG("response : %s", g_variant_print(value, FALSE)); diff --git a/lib/icl-presence.c b/lib/icl-presence.c index 6bd31ba..22d70c8 100644 --- a/lib/icl-presence.c +++ b/lib/icl-presence.c @@ -14,6 +14,7 @@ * limitations under the License. */ #include +#include #include #include #include @@ -28,7 +29,7 @@ typedef struct icl_presence { iotcon_presence_cb cb; void *user_data; unsigned int id; - int handle; + int64_t handle; } icl_presence_s; API int iotcon_start_presence(unsigned int time_to_live) @@ -107,7 +108,13 @@ static void _icl_presence_cb(GDBusConnection *connection, static void _icl_presence_conn_cleanup(icl_presence_s *presence) { presence->id = 0; - presence->handle = 0; + + if (presence->handle) { + presence->handle = 0; + return; + } + + free(presence); } @@ -202,11 +209,10 @@ API int iotcon_unsubscribe_presence(iotcon_presence_h presence) ERR("iotcon-daemon Fail(%d)", ret); return icl_dbus_convert_daemon_error(ret); } + presence->handle = 0; icl_dbus_unsubscribe_signal(presence->id); - free(presence); - return IOTCON_ERROR_NONE; } diff --git a/lib/icl-request.h b/lib/icl-request.h index ea0f7c2..b1c501e 100644 --- a/lib/icl-request.h +++ b/lib/icl-request.h @@ -16,12 +16,10 @@ #ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_REQUEST_H__ #define __IOT_CONNECTIVITY_MANAGER_LIBRARY_REQUEST_H__ +#include #include "iotcon-struct.h" #include "iotcon-constant.h" -typedef void* oc_request_h; -typedef void* oc_resource_h; - struct icl_observe_info { iotcon_observe_action_e action; int observer_id; @@ -34,8 +32,8 @@ struct icl_resource_request { iotcon_query_h query; struct icl_observe_info observation_info; iotcon_repr_h repr; - oc_request_h request_handle; - oc_resource_h resource_handle; + int64_t oic_request_h; + int64_t oic_resource_h; }; #endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_REQUEST_H__ */ diff --git a/lib/icl-resource.c b/lib/icl-resource.c index 3001c9c..416fff5 100644 --- a/lib/icl-resource.c +++ b/lib/icl-resource.c @@ -48,22 +48,20 @@ static void _icl_request_handler(GDBusConnection *connection, GVariantIter *repr_iter; char *key = NULL; char *value = NULL; - int request_handle; - int resource_handle; struct icl_resource_request request = {0}; iotcon_resource_h resource = user_data; iotcon_request_handler_cb cb = resource->cb; GVariant *repr_gvar; - g_variant_get(parameters, "(ia(qs)a(ss)iiavii)", + g_variant_get(parameters, "(ia(qs)a(ss)iiavxx)", &request.types, &options, &query, &request.observation_info.action, &request.observation_info.observer_id, &repr_iter, - &request_handle, - &resource_handle); + &request.oic_request_h, + &request.oic_resource_h); if (g_variant_iter_n_children(options)) { request.header_options = iotcon_options_new(); @@ -79,9 +77,6 @@ static void _icl_request_handler(GDBusConnection *connection, } g_variant_iter_free(query); - request.request_handle = GINT_TO_POINTER(request_handle); - request.resource_handle = GINT_TO_POINTER(resource_handle); - if (g_variant_iter_loop(repr_iter, "v", &repr_gvar)) { request.repr = icl_repr_from_gvariant(repr_gvar); if (NULL == request.repr) { @@ -113,7 +108,15 @@ static void _icl_request_handler(GDBusConnection *connection, static void _icl_resource_conn_cleanup(iotcon_resource_h resource) { resource->sub_id = 0; - resource->handle = 0; + + if (resource->handle) { + resource->handle = 0; + return; + } + + iotcon_resource_types_free(resource->types); + free(resource->uri_path); + free(resource); } @@ -225,13 +228,10 @@ API int iotcon_unregister_resource(iotcon_resource_h resource) ERR("iotcon-daemon Fail(%d)", ret); return icl_dbus_convert_daemon_error(ret); } + resource->handle = 0; icl_dbus_unsubscribe_signal(resource->sub_id); - iotcon_resource_types_free(resource->types); - free(resource->uri_path); - free(resource); - return IOTCON_ERROR_NONE; } diff --git a/lib/icl-resource.h b/lib/icl-resource.h index 36c04e5..149ed6e 100644 --- a/lib/icl-resource.h +++ b/lib/icl-resource.h @@ -16,6 +16,7 @@ #ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESOURCE_H__ #define __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESOURCE_H__ +#include #include "iotcon.h" #include "icl-dbus.h" @@ -33,7 +34,7 @@ struct icl_resource { iotcon_request_handler_cb cb; void *user_data; unsigned int sub_id; - int handle; + int64_t handle; iotcon_resource_h children[IOTCON_CONTAINED_RESOURCES_MAX]; }; diff --git a/lib/icl-response.c b/lib/icl-response.c index b2fac9e..6fa755f 100644 --- a/lib/icl-response.c +++ b/lib/icl-response.c @@ -40,8 +40,8 @@ API iotcon_response_h iotcon_response_new(iotcon_request_h request_h) return NULL; } - resp->request_handle = request_h->request_handle; - resp->resource_handle = request_h->resource_handle; + resp->oic_request_h = request_h->oic_request_h; + resp->oic_resource_h = request_h->oic_resource_h; resp->error_code = 200; return resp; diff --git a/lib/icl-response.h b/lib/icl-response.h index 8b566b0..d01ae5b 100644 --- a/lib/icl-response.h +++ b/lib/icl-response.h @@ -16,10 +16,9 @@ #ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESPONSE_H__ #define __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESPONSE_H__ +#include #include "iotcon-struct.h" #include "iotcon-constant.h" -#include "icl-request.h" - typedef enum { ICL_VISIBILITY_NONE = 0, @@ -35,8 +34,8 @@ struct icl_resource_response { iotcon_interface_e iface; iotcon_response_result_e result; iotcon_repr_h repr; - oc_request_h request_handle; - oc_resource_h resource_handle; + int64_t oic_request_h; + int64_t oic_resource_h; }; #endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESPONSE_H__ */ -- 2.7.4