GVariant *payload;
GVariantBuilder *options;
GVariantBuilder *query;
+ OCDevAddr *dev_addr;
};
GVariant *value;
struct icd_req_context *ctx = context;
GVariantBuilder payload_builder;
+ char addr[PATH_MAX] = {0};
RETV_IF(NULL == ctx, IOTCON_ERROR_INVALID_PARAMETER);
if (ctx->payload)
g_variant_builder_add(&payload_builder, "v", ctx->payload);
- value = g_variant_new("(ia(qs)a(ss)iiavxx)",
+ if (ctx->dev_addr->addr && *ctx->dev_addr->addr)
+ snprintf(addr, sizeof(addr), "%s:%d", ctx->dev_addr->addr, ctx->dev_addr->port);
+
+ value = g_variant_new("(sia(qs)a(ss)iiavxx)",
+ addr,
ctx->types,
ctx->options,
ctx->query,
free(ctx->bus_name);
g_variant_builder_unref(ctx->options);
g_variant_builder_unref(ctx->query);
+ free(ctx->dev_addr);
free(ctx);
return ret;
char *token, *save_ptr1, *save_ptr2;
char *bus_name = NULL;
struct icd_req_context *req_ctx;
+ OCDevAddr *dev_addr;
RETV_IF(NULL == request, OC_EH_ERROR);
req_ctx->signum = signal_number;
req_ctx->bus_name = bus_name;
+ dev_addr = calloc(1, sizeof(OCDevAddr));
+ if (NULL == dev_addr) {
+ ERR("calloc() Fail(%d)", errno);
+ free(req_ctx);
+ return OC_EH_ERROR;
+ }
+ memcpy(dev_addr, &request->devAddr, sizeof(OCDevAddr));
+ req_ctx->dev_addr = dev_addr;
+
/* request type */
if (OC_REQUEST_FLAG & flag) {
switch (request->method) {
g_variant_unref(req_ctx->payload);
g_variant_builder_unref(req_ctx->options);
g_variant_builder_unref(req_ctx->query);
+ free(req_ctx->dev_addr);
free(req_ctx);
return OC_EH_ERROR;
}
#include "icl.h"
#include "icl-request.h"
+API int iotcon_request_get_host_address(iotcon_request_h request,
+ char **host_address)
+{
+ RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == host_address, IOTCON_ERROR_INVALID_PARAMETER);
+
+ *host_address = request->host_address;
+
+ return IOTCON_ERROR_NONE;
+}
+
+
/* The content of the request should not be freed by user. */
API int iotcon_request_get_representation(iotcon_request_h request,
iotcon_representation_h *repr)
};
struct icl_resource_request {
+ char *host_address;
int types;
iotcon_options_h header_options;
iotcon_query_h query;
iotcon_resource_h resource = user_data;
iotcon_request_handler_cb cb = resource->cb;
- g_variant_get(parameters, "(ia(qs)a(ss)iiavxx)",
+ g_variant_get(parameters, "(sia(qs)a(ss)iiavxx)",
+ &request.host_address,
&request.types,
&options,
&query,
typedef struct icl_resource_request* iotcon_request_h;
/**
+ * @brief Gets host address of the request
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] request The handle of the request
+ * @param[out] host_address The host address of the request
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see iotcon_request_get_representation()
+ * @see iotcon_request_get_types()
+ * @see iotcon_request_get_options()
+ * @see iotcon_request_get_query()
+ * @see iotcon_request_get_observer_action()
+ * @see iotcon_request_get_observer_id()
+ */
+int iotcon_request_get_host_address(iotcon_request_h request,
+ char **host_address);
+
+
+/**
* @brief Gets an representation of the request
*
* @since_tizen 3.0
* @retval #IOTCON_ERROR_NONE Successful
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
+ * @see iotcon_request_get_host_address()
* @see iotcon_request_get_types()
* @see iotcon_request_get_options()
* @see iotcon_request_get_query()
* @retval #IOTCON_ERROR_NONE Successful
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
+ * @see iotcon_request_get_host_address()
* @see iotcon_request_get_representation()
* @see iotcon_request_get_options()
* @see iotcon_request_get_query()
* @retval #IOTCON_ERROR_NONE Successful
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
+ * @see iotcon_request_get_host_address()
* @see iotcon_request_get_representation()
* @see iotcon_request_get_types()
* @see iotcon_request_get_query()
* @retval #IOTCON_ERROR_NONE Successful
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
+ * @see iotcon_request_get_host_address()
* @see iotcon_request_get_representation()
* @see iotcon_request_get_types()
* @see iotcon_request_get_options()
* @retval #IOTCON_ERROR_NONE Successful
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
+ * @see iotcon_request_get_host_address()
* @see iotcon_request_get_representation()
* @see iotcon_request_get_types()
* @see iotcon_request_get_options()
* @retval #IOTCON_ERROR_NONE Successful
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
+ * @see iotcon_request_get_host_address()
* @see iotcon_request_get_representation()
* @see iotcon_request_get_types()
* @see iotcon_request_get_options()
iotcon_query_h query;
iotcon_response_h response = NULL;
int ret, types, observer_id, observer_action;
+ char *host_address;
RET_IF(NULL == request);
iotcon_response_destroy(response);
+ ret = iotcon_request_get_host_address(request, &host_address);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_request_get_host_address() Fail(%d)", ret);
+ return;
+ }
+ INFO("host_address : %s", host_address);
+
if (IOTCON_REQUEST_OBSERVE & types) {
ret = iotcon_request_get_observer_action(request, &observer_action);
if (IOTCON_ERROR_NONE != ret) {
return;
}
+
if (IOTCON_OBSERVE_REGISTER == observer_action) {
ret = iotcon_request_get_observer_id(request, &observer_id);
if (IOTCON_ERROR_NONE != ret) {