Support 64-bit architectures
authoryoungman <yman.jung@samsung.com>
Fri, 28 Aug 2015 10:00:59 +0000 (19:00 +0900)
committeryoungman <yman.jung@samsung.com>
Tue, 3 Nov 2015 11:08:20 +0000 (20:08 +0900)
Change-Id: I49d3cfc4f6b5580fd9c075795f39ad3b3811cf3e
Signed-off-by: youngman <yman.jung@samsung.com>
19 files changed:
common/ic-dbus.xml
daemon/icd-dbus.c
daemon/icd-dbus.h
daemon/icd-ioty-ocprocess.c
daemon/icd-ioty-type.c
daemon/icd-ioty-type.h
daemon/icd-ioty.c
daemon/icd-ioty.h
lib/CMakeLists.txt
lib/icl-client-crud.c
lib/icl-client.c
lib/icl-client.h
lib/icl-dbus-type.c
lib/icl-presence.c
lib/icl-request.h
lib/icl-resource.c
lib/icl-resource.h
lib/icl-response.c
lib/icl-response.h

index 695a5e5..1e01ec2 100644 (file)
@@ -6,44 +6,44 @@
                        <arg type="i" name="ifaces" direction="in"/>
                        <arg type="y" name="properties" direction="in"/>
                        <arg type="u" name="signal_number" direction="in"/>
-                       <arg type="i" name="resource" direction="out"/>
+                       <arg type="x" name="resource" direction="out"/>
                </method>
                <method name="unregisterResource">
-                       <arg type="i" name="resource" direction="in"/>
+                       <arg type="x" name="resource" direction="in"/>
                        <arg type="i" name="ret" direction="out"/>
                </method>
                <method name="bindInterface">
-                       <arg type="i" name="resource" direction="in"/>
+                       <arg type="x" name="resource" direction="in"/>
                        <arg type="i" name="iface" direction="in"/>
                        <arg type="i" name="ret" direction="out"/>
                </method>
                <method name="bindType">
-                       <arg type="i" name="resource" direction="in"/>
+                       <arg type="x" name="resource" direction="in"/>
                        <arg type="s" name="type" direction="in"/>
                        <arg type="i" name="ret" direction="out"/>
                </method>
                <method name="bindResource">
-                       <arg type="i" name="parent" direction="in"/>
-                       <arg type="i" name="child" direction="in"/>
+                       <arg type="x" name="parent" direction="in"/>
+                       <arg type="x" name="child" direction="in"/>
                        <arg type="i" name="ret" direction="out"/>
                </method>
                <method name="unbindResource">
-                       <arg type="i" name="parent" direction="in"/>
-                       <arg type="i" name="child" direction="in"/>
+                       <arg type="x" name="parent" direction="in"/>
+                       <arg type="x" name="child" direction="in"/>
                        <arg type="i" name="ret" direction="out"/>
                </method>
                <method name="notifyListOfObservers">
-                       <arg type="i" name="resource" direction="in"/>
+                       <arg type="x" name="resource" direction="in"/>
                        <arg type="a(iv)" name="notify_msg" direction="in"/>
                        <arg type="ai" name="observers" direction="in"/>
                        <arg type="i" name="ret" direction="out"/>
                </method>
                <method name="notifyAll">
-                       <arg type="i" name="resource" direction="in"/>
+                       <arg type="x" name="resource" direction="in"/>
                        <arg type="i" name="ret" direction="out"/>
                </method>
                <method name="sendResponse">
-                       <arg type="(sia(qs)ivii)" name="response" direction="in"/>
+                       <arg type="(sia(qs)ivxx)" name="response" direction="in"/>
                        <arg type="i" name="ret" direction="out"/>
                </method>
                <method name="findResource">
                        <arg type="i" name="observe_type" direction="in"/>
                        <arg type="a(ss)" name="query" direction="in"/>
                        <arg type="u" name="signal_number" direction="in"/>
-                       <arg type="i" name="observe_h" direction="out"/>
+                       <arg type="x" name="observe_h" direction="out"/>
                </method>
                <method name="observerStop">
-                       <arg type="i" name="observe_h" direction="in"/>
+                       <arg type="x" name="observe_h" direction="in"/>
                        <arg type="a(qs)" name="options" direction="in"/>
                        <arg type="i" name="ret" direction="out"/>
                </method>
                        <arg type="s" name="host_address" direction="in"/>
                        <arg type="s" name="type" direction="in"/>
                        <arg type="u" name="signal_number" direction="in"/>
-                       <arg type="i" name="presence_h" direction="out"/>
+                       <arg type="x" name="presence_h" direction="out"/>
                </method>
                <method name="unsubscribePresence">
-                       <arg type="i" name="presence_h" direction="in"/>
+                       <arg type="x" name="presence_h" direction="in"/>
                        <arg type="i" name="ret" direction="out"/>
                </method>
                <method name="startPresence">
index 5c02938..3664818 100644 (file)
@@ -16,6 +16,8 @@
 #include <stdlib.h>
 #include <gio/gio.h>
 
+#include <octypes.h>
+
 #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);
 
index 9f896bf..a647bb8 100644 (file)
 #ifndef __IOT_CONNECTIVITY_MANAGER_DAEMON_DBUS_H__
 #define __IOT_CONNECTIVITY_MANAGER_DAEMON_DBUS_H__
 
+#include <stdint.h>
 #include <glib.h>
 #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);
index b230995..199a46a 100644 (file)
@@ -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);
index 59575bc..d37ae0b 100644 (file)
@@ -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;
+}
 
index 5fc1ecb..d124e39 100644 (file)
@@ -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__*/
index 5d2896e..3bb3ae8 100644 (file)
@@ -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();
 
index 60fa22a..3270b7d 100644 (file)
@@ -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);
index fc4ed83..5d704ad 100644 (file)
@@ -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})
index 88e26e6..3c7b7ee 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 #include <stdio.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <glib.h>
@@ -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;
index af420af..edb83cc 100644 (file)
@@ -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;
 }
index fb99042..16a5cab 100644 (file)
@@ -16,6 +16,7 @@
 #ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_CLIENT_H__
 #define __IOT_CONNECTIVITY_MANAGER_LIBRARY_CLIENT_H__
 
+#include <stdint.h>
 #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;
 };
 
index f964f3b..9f76f88 100644 (file)
@@ -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));
 
index 6bd31ba..22d70c8 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 #include <stdio.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
@@ -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;
 }
 
index ea0f7c2..b1c501e 100644 (file)
 #ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_REQUEST_H__
 #define __IOT_CONNECTIVITY_MANAGER_LIBRARY_REQUEST_H__
 
+#include <stdint.h>
 #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__ */
index 3001c9c..416fff5 100644 (file)
@@ -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;
 }
 
index 36c04e5..149ed6e 100644 (file)
@@ -16,6 +16,7 @@
 #ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESOURCE_H__
 #define __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESOURCE_H__
 
+#include <stdint.h>
 #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];
 };
 
index b2fac9e..6fa755f 100644 (file)
@@ -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;
index 8b566b0..d01ae5b 100644 (file)
 #ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESPONSE_H__
 #define __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESPONSE_H__
 
+#include <stdint.h>
 #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__ */