Add peer ip assigned signal handler and fix dbus issues
[platform/core/connectivity/asp-manager.git] / src / tech / asp-tech-p2p.c
index 42345cb..e0dba81 100755 (executable)
@@ -92,6 +92,10 @@ void asp_tech_p2p_process_session_config_request(GDBusConnection *connection,
 
 void asp_tech_p2p_process_connect_status(GDBusConnection *connection,
                const gchar *object_path, GVariant *parameters);
+
+void asp_tech_p2p_process_session_peer_ip(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters);
+
 /*****************************************************************************
  * Global Variables
  *****************************************************************************/
@@ -137,6 +141,11 @@ static struct {
                                asp_tech_p2p_process_connect_status
                },
                {
+                               WFD_MANAGER_ASP_INTERFACE,
+                               "SessionPeerIPAssigned",
+                               asp_tech_p2p_process_session_peer_ip
+               },
+               {
                                NULL,
                                NULL,
                                NULL
@@ -510,6 +519,60 @@ void asp_tech_p2p_process_connect_status(GDBusConnection *connection,
        return;
 }
 
+void asp_tech_p2p_process_session_peer_ip(GDBusConnection *connection,
+               const gchar *object_path, GVariant *parameters)
+{
+       __ASP_LOG_FUNC_ENTER__;
+
+       GVariantIter *iter = NULL;
+       GVariant *var = NULL;
+       const gchar *key = NULL;
+       const gchar *str = NULL;
+       guint8 session_mac[MAC_LEN] = {0,};
+       guint8 service_mac[MAC_LEN] = {0,};
+       guint32 session_id = 0;
+       gchar *peer_ip = NULL;
+
+       if (!parameters) {
+               __ASP_LOG_FUNC_EXIT__;
+               return;
+       }
+
+       g_variant_get(parameters, "(a{sv})", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (!g_strcmp0(key, "session_mac")) {
+                       if (asp_dbus_unpack_ay(session_mac, var, MAC_LEN) < 0)
+                               return;
+               } else if (!g_strcmp0(key, "session_id")) {
+                       g_variant_get(var, "u", &session_id);
+               } else if (!g_strcmp0(key, "service_mac")) {
+                       if (asp_dbus_unpack_ay(service_mac, var, MAC_LEN) < 0)
+                               return;
+               } else if (!g_strcmp0(key, "assigned_ip_address")) {
+                       g_variant_get(var, "&s", &str);
+                       peer_ip = g_strdup(str);
+               } else {
+                       ;/* Do Nothing */
+               }
+       }
+
+       if(peer_ip == NULL) {
+               ASP_LOGE("Invalid peer IP address");
+               return;
+       }
+
+       if (asp_tech_p2p_ops.ip_assigned_cb) {
+               asp_tech_p2p_ops.ip_assigned_cb(0,
+                               session_mac, session_id, service_mac, peer_ip,
+                               strlen(peer_ip), asp_tech_p2p_ops.ip_assigned_cb_user_data);
+       }
+
+       g_free(peer_ip);
+
+       __ASP_LOG_FUNC_EXIT__;
+       return;
+}
+
 gint32 asp_tech_p2p_advertise(asp_service_advertise_s *service, gint32 replace)
 {
        __ASP_LOG_FUNC_ENTER__;