return TRUE;
}
+static gboolean __asp_manager_gdbus_bound_port(AspSession *object,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters,
+ const gboolean *user_data)
+{
+ __ASP_LOG_FUNC_ENTER__;
+ GVariantIter *iter = NULL;
+ gchar *key = NULL;
+ GVariant *var = NULL;
+ asp_s *asp = NULL;
+
+ const gchar *session_mac = NULL;
+ guint32 session_id = 0;
+ const gchar *ip_address = NULL;
+ gint32 port = 0;
+ gint32 proto = 0;
+ guint8 mac_addr[MAC_LEN] = {0,};
+ gboolean res;
+
+ asp = (asp_s *)user_data;
+ if (!asp) {
+ ASP_LOGE("Failed to get memory for asp structure");
+ ASP_RETURN_SESSION_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
+ goto out;
+ }
+ DEBUG_PARAMS(parameters);
+
+ g_variant_get(parameters, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+ if (!g_strcmp0(key, "session_mac"))
+ g_variant_get(var, "&s", &session_mac);
+ else if (!g_strcmp0(key, "session_id"))
+ g_variant_get(var, "u", &session_id);
+ else if (!g_strcmp0(key, "ip_address"))
+ g_variant_get(var, "&s", &ip_address);
+ else if (!g_strcmp0(key, "port"))
+ g_variant_get(var, "i", &port);
+ else if (!g_strcmp0(key, "proto"))
+ g_variant_get(var, "i", &proto);
+ else
+ ;/* Do Nothing */
+ }
+
+ if (session_mac == NULL) {
+ ASP_LOGE("Invalid parameter");
+ ASP_RETURN_SESSION_ERR(invocation, -ASP_ERROR_INVALIED_PARAMS);
+ goto out;
+ }
+
+ if (strlen(session_mac) != 17) {
+ ASP_LOGE("Invalid parameter");
+ ASP_RETURN_SESSION_ERR(invocation, -ASP_ERROR_INVALIED_PARAMS);
+ goto out;
+ }
+ ASP_LOGD("session ID [%u] session mac [%s]", session_id, session_mac);
+
+ macaddr_atoe(session_mac, mac_addr);
+ res = asp_session_bound_port(mac_addr, session_id, ip_address,
+ port, proto);
+ if (!res) {
+ ASP_LOGE("Operation Failed");
+ ASP_RETURN_SESSION_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
+ goto out;
+ }
+
+ asp_session_complete_bound_port(object, invocation, ASP_ERROR_NONE);
+
+out:
+ __ASP_LOG_FUNC_EXIT__;
+ return TRUE;
+}
+
+static gboolean __asp_manager_gdbus_release_port(AspSession *object,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters,
+ const gboolean *user_data)
+{
+ __ASP_LOG_FUNC_ENTER__;
+ GVariantIter *iter = NULL;
+ gchar *key = NULL;
+ GVariant *var = NULL;
+ asp_s *asp = NULL;
+
+ const gchar *session_mac = NULL;
+ guint32 session_id = 0;
+ const gchar *ip_address = NULL;
+ gint32 port = 0;
+ gint32 proto = 0;
+ guint8 mac_addr[MAC_LEN] = {0,};
+ gboolean res = TRUE;
+
+ asp = (asp_s *)user_data;
+ if (!asp) {
+ ASP_LOGE("Failed to get memory for asp structure");
+ ASP_RETURN_SESSION_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
+ goto out;
+ }
+ DEBUG_PARAMS(parameters);
+
+ g_variant_get(parameters, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+ if (!g_strcmp0(key, "session_mac"))
+ g_variant_get(var, "&s", &session_mac);
+ else if (!g_strcmp0(key, "session_id"))
+ g_variant_get(var, "u", &session_id);
+ else if (!g_strcmp0(key, "ip_address"))
+ g_variant_get(var, "&s", &ip_address);
+ else if (!g_strcmp0(key, "port"))
+ g_variant_get(var, "i", &port);
+ else if (!g_strcmp0(key, "proto"))
+ g_variant_get(var, "i", &proto);
+ else
+ ;/* Do Nothing */
+ }
+
+ if (session_mac == NULL) {
+ ASP_LOGE("Invalid parameter");
+ ASP_RETURN_SESSION_ERR(invocation, -ASP_ERROR_INVALIED_PARAMS);
+ goto out;
+ }
+
+ if (strlen(session_mac) != 17) {
+ ASP_LOGE("Invalid parameter");
+ ASP_RETURN_SESSION_ERR(invocation, -ASP_ERROR_INVALIED_PARAMS);
+ goto out;
+ }
+ ASP_LOGD("session ID [%u] session mac [%s]", session_id, session_mac);
+
+ macaddr_atoe(session_mac, mac_addr);
+ if (!res) {
+ ASP_LOGE("Operation Failed");
+ ASP_RETURN_SESSION_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
+ goto out;
+ }
+
+ asp_session_complete_release_port(object, invocation, ASP_ERROR_NONE);
+
+out:
+ __ASP_LOG_FUNC_EXIT__;
+ return TRUE;
+}
+
static gboolean __asp_manager_gdbus_session_init(asp_s *asp)
{
__ASP_LOG_FUNC_ENTER__;
G_CALLBACK(__asp_manager_gdbus_close_session),
asp);
+ g_signal_connect(
+ session,
+ "handle-bound-port",
+ G_CALLBACK(__asp_manager_gdbus_bound_port),
+ asp);
+
+ g_signal_connect(
+ session,
+ "handle-release-port",
+ G_CALLBACK(__asp_manager_gdbus_release_port),
+ asp);
+
/* Export the object (@manager takes its own reference to @object) */
g_dbus_object_manager_server_export(asp->obj_mgr, G_DBUS_OBJECT_SKELETON(object));
g_object_unref(object);
return;
}
- if(session->over_p2p && session->sock_addr == NULL) {
+ if (session->over_p2p && session->sock_addr == NULL) {
ASP_LOGD("IpAssigned signal isn't yet received, discard event");
return;
}
{
gchar buffer[256];
va_list args;
- va_start (args, format);
- g_vsnprintf (buffer, 255, format, args);
- va_end (args);
+ va_start(args, format);
+ g_vsnprintf(buffer, 255, format, args);
+ va_end(args);
ASP_LOGD("%s", buffer);
ASP_LOGD("peer IP %s", p_ip_assigned_param->peer_ip_addr);
_store_peer_ip_addr(session, p_ip_assigned_param->peer_ip_addr,
p_ip_assigned_param->length);
- if (session->asp_role == ASP_ROLE_SEEKER) {
+ if (session->asp_role == ASP_ROLE_SEEKER)
ret_state = SESSION_STATE_REQUEST_SESSION_SENT;
- } else {
+ else
ret_state = SESSION_STATE_REQUEST_SESSION_RECEIVED;
- }
return ret_state;
}
asp_session_s *session = (asp_session_s *)p_context_data;
- if(!session->over_p2p)
+ if (!session->over_p2p)
_call_connect_status_cb(0, session->session_mac, session->session_id,
ASP_SESSION_CONNECT_STATUS_SESSION_REQUEST_SENT);
}
asp_session_s *session = (asp_session_s *)p_context_data;
g_assert(session);
if (session->over_p2p && session->confirmed &&
- session->asp_role == ASP_ROLE_ADVERTIZER ) {
- /* TODO: Set Session should done after this event*/
+ session->asp_role == ASP_ROLE_ADVERTIZER) {
+ /* TODO: Set Session should done after this event */
} else {
/* session_request_cb */
/* what is user data ? */