[wifi-direct-manager]Revise connection logic and enable IP over EAPOL packet feature 55/44755/1
authorYu Jiung <jiung.yu@samsung.com>
Mon, 27 Jul 2015 10:50:21 +0000 (19:50 +0900)
committerYu Jiung <jiung.yu@samsung.com>
Mon, 27 Jul 2015 10:50:49 +0000 (19:50 +0900)
Change-Id: I2890b871d700e1b35fdecf5499b7b7c1bce77e70
Signed-off-by: Yu jiung <jiung.yu@samsung.com>
19 files changed:
CMakeLists.txt
files/common/dhcpd.p2p.conf
files/common/wifi-direct-dhcp.sh
include/wifi-direct-util.h
oem/wifi-direct-oem.c
oem/wifi-direct-oem.h
packaging/wifi-direct-manager.spec
plugin/wpasupplicant/ctrl_iface_dbus/dbus/wfd-plugin-supplicant-dbus.c
plugin/wpasupplicant/ctrl_iface_dbus/dbus/wfd-plugin-supplicant-dbus.h
plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-plugin-wpasupplicant.h
plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c
plugin/wpasupplicant/ctrl_iface_sock/include/wfd-plugin-wpasupplicant.h
plugin/wpasupplicant/ctrl_iface_sock/wfd-plugin-wpasupplicant.c
plugin/wpasupplicant/emul/include/wfd-plugin-wpasupplicant.h
plugin/wpasupplicant/emul/wfd-plugin-wpasupplicant-emul.c
src/wifi-direct-event.c
src/wifi-direct-group.c
src/wifi-direct-session.c
src/wifi-direct-util.c

index 8a0ba17..d0ccc31 100755 (executable)
@@ -8,7 +8,7 @@ SET(LIBDIR "\${prefix}/lib")
 SET(INCLUDEDIR "\${prefix}/include")
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED capi-network-wifi-direct glib-2.0 gio-2.0 gobject-2.0 dlog capi-appfw-application vconf  ${MDM_REQUIRED_PKGS})
+pkg_check_modules(pkgs REQUIRED capi-network-wifi-direct glib-2.0 gio-2.0 gobject-2.0 dlog libnl-2.0 capi-appfw-application vconf  ${MDM_REQUIRED_PKGS})
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
@@ -47,6 +47,7 @@ ENDIF(TIZEN_MOBILE)
 IF(TIZEN_TV)
        ADD_DEFINITIONS(-DTIZEN_TV)
 ENDIF(TIZEN_TV)
+
 IF(CTRL_IFACE_DBUS)
        ADD_DEFINITIONS(-DCTRL_IFACE_DBUS)
 ENDIF(CTRL_IFACE_DBUS)
index 042b08f..6c50ed2 100755 (executable)
@@ -1,11 +1,10 @@
-start          192.168.49.20           #default: 192.168.0.20
-end            192.168.49.40           #default: 192.168.0.254
-interface      p2p-wlan0-0             #default: wlan0
-max_leases     20                      #default: 254
+start           192.168.49.20             #default: 192.168.0.20
+end             192.168.49.40             #default: 192.168.0.254
+interface       p2p-wlan0-0               #default: wlan0
+max_leases      20                        #default: 254
 notify_file     /usr/bin/dhcpd-notify.sh
 
-
-option subnet  255.255.255.0
-option router  192.168.49.1
-option lease   864000                  # 10 days of seconds
-option broadcast       192.168.49.255
+option          subnet     255.255.255.0
+option          router     192.168.49.1
+option          lease      864000         #10 days of seconds
+option          broadcast  192.168.49.255
index 9737c35..5b8b518 100755 (executable)
@@ -36,10 +36,10 @@ echo "Target is ${TARGET} and interface ${INTERFACE_PREFIX}: ${interface}."
 
 start_dhcp_server()
 {
-        if [ "X${interface}" == "X" ]; then
-                echo "interface(${INTERFACE_PREFIX}) is not up"
+       if [ "X${interface}" == "X" ]; then
+               echo "interface(${INTERFACE_PREFIX}) is not up"
                return 0
-        fi
+       fi
 
        /usr/sbin/ip addr add ${DEFAULT_NET} brd ${DEFAULT_BRD} dev ${interface}
        /usr/sbin/dhcpd /usr/etc/wifi-direct/dhcpd.${INTERFACE_PREFIX}.conf -f &
@@ -62,10 +62,10 @@ start_dhcp_server()
 
 start_dhcp_client()
 {
-        if [ "X${interface}" == "X" ]; then
-                echo "interface(${INTERFACE_PREFIX}) is not up"
+       if [ "X${interface}" == "X" ]; then
+               echo "interface(${INTERFACE_PREFIX}) is not up"
                return 0
-        fi
+       fi
        /usr/bin/dhcp -i $interface -s /usr/etc/wifi-direct/udhcp_script.non-autoip &
 }
 
index 91e718a..4df6aaa 100755 (executable)
@@ -123,7 +123,7 @@ int wfd_util_get_local_ip(unsigned char* ip_addr);
 int wfd_util_static_ip_unset(const char *ifname);
 #endif /* TIZEN_VENDOR_ATH */
 /*TODO: ODROID Image does not have support libnl-2.0*/
-//int wfd_util_ip_over_eap_assign(wfd_device_s *peer, const char *ifname);
-//int wfd_util_ip_over_eap_lease(wfd_device_s *peer);
+int wfd_util_ip_over_eap_assign(wfd_device_s *peer, const char *ifname);
+int wfd_util_ip_over_eap_lease(wfd_device_s *peer);
 #endif /* CTRL_IFACE_DBUS */
 #endif /* __WIFI_DIRECT_UTIL_H__ */
index c0dc8d0..19d7b3e 100644 (file)
@@ -193,7 +193,15 @@ int wfd_oem_set_pin(wfd_oem_ops_s *ops, char *pin)
 
        return ops->set_pin(pin);
 }
-//int wfd_oem_generate_pin(char *pin)
+
+int wfd_oem_generate_pin(wfd_oem_ops_s *ops, char **pin)
+{
+       if (!ops || !ops->generate_pin) {
+               return -1;
+       }
+
+       return ops->generate_pin(pin);
+}
 int wfd_oem_get_supported_wps_mode(wfd_oem_ops_s *ops, int *wps_mode)
 {
        if (!ops || !ops->get_supported_wps_mode) {
index bdf316d..0d5f6dc 100755 (executable)
@@ -399,7 +399,7 @@ typedef struct _wfd_oem_ops_s {
        int (*wps_cancel) (void);
        int (*get_pin) (char *pin);
        int (*set_pin) (char *pin);
-//     int (*generate_pin) (char *pin);
+       int (*generate_pin) (char **pin);
        int (*get_supported_wps_mode) (int *wps_mode);
        int (*create_group) (int persistent, int freq, const char *passphrase);
        int (*destroy_group) (const char *ifname);
@@ -459,7 +459,7 @@ int wfd_oem_enrollee_start(wfd_oem_ops_s *ops, unsigned char *peer_addr, int wps
 int wfd_oem_wps_cancel(wfd_oem_ops_s *ops);
 int wfd_oem_get_pin(wfd_oem_ops_s *ops, char *pin);
 int wfd_oem_set_pin(wfd_oem_ops_s *ops, char *pin);
-//int wfd_oem_generate_pin(wfd_oem_ops_s *ops, char *pin);
+int wfd_oem_generate_pin(wfd_oem_ops_s *ops, char **pin);
 int wfd_oem_get_supported_wps_mode(wfd_oem_ops_s *ops, int *wps_mode);
 int wfd_oem_create_group(wfd_oem_ops_s *ops, int persistent, int freq, const char *passphrase);
 int wfd_oem_destroy_group(wfd_oem_ops_s *ops, const char *ifname);
index a406d80..d7de44d 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          wifi-direct-manager
 Summary:       Wi-Fi Direct manger
-Version:       1.2.87
+Version:       1.2.88
 Release:       1
 Group:      Network & Connectivity/Wireless
 License:    Apache-2.0
index 5ad4189..47bc483 100755 (executable)
@@ -28,7 +28,7 @@ int dbus_set_method_param(dbus_method_param_s *params, char *method_name,
 }
 
 int dbus_method_call(dbus_method_param_s *params, char *interface_name,
-               dbus_result_function function, void *user_data)
+               handle_reply function, void *user_data)
 {
        __WDP_LOG_FUNC_ENTER__;
        GVariant *reply = NULL;
index 2fd0851..cc448e5 100755 (executable)
@@ -51,7 +51,7 @@
                WDP_LOGD("signal params type [%s]", g_variant_get_type_string(parameters));\
        } while (0)
 
-typedef void (*dbus_result_function) (GVariant *value, void *user_data);
+typedef void (*handle_reply) (GVariant *value, void *user_data);
 
 typedef void (*dbus_property_function) (const char *key,
                GVariant *value, void *user_data);
@@ -67,7 +67,7 @@ int dbus_set_method_param(dbus_method_param_s *params, char *method_name,
                char *object_path, GDBusConnection *connection);
 
 int dbus_method_call(dbus_method_param_s *params, char *interface_name,
-               dbus_result_function function, void *user_data);
+               handle_reply function, void *user_data);
 
 int dbus_property_get_all(const char *path, GDBusConnection *connection,
                const char *interface, dbus_property_function function,
index a5f612b..5e61e6e 100755 (executable)
@@ -368,6 +368,7 @@ int ws_cancel_connection(unsigned char *peer_addr);
 int ws_get_connected_peers(GList **peers, int *peer_count);
 int ws_get_pin(char *pin);
 int ws_set_pin(char *pin);
+int ws_generate_pin(char **pin);
 int ws_get_supported_wps_mode();
 int ws_create_group(int persistent, int freq, const char *passphrase);
 int ws_destroy_group(const char *ifname);
index 2836f76..f64a0ee 100755 (executable)
@@ -77,6 +77,7 @@ static wfd_oem_ops_s supplicant_ops = {
        .get_connected_peers = ws_get_connected_peers,
        .get_pin = ws_get_pin,
        .set_pin = ws_set_pin,
+       .generate_pin = ws_generate_pin,
        .get_supported_wps_mode = ws_get_supported_wps_mode,
 
        .create_group = ws_create_group,
@@ -593,7 +594,7 @@ static void __ws_get_peer_property(const char *key, GVariant *value, void *user_
                if (__ws_unpack_ay(peer->dev_addr, value, WS_MACADDR_LEN))
                        WDP_LOGD("[" MACSTR "]", MAC2STR(peer->dev_addr));
 
-       } else if (g_strcmp0(key, "InterfacedAddress") == 0) {
+       } else if (g_strcmp0(key, "InterfaceAddress") == 0) {
 
                if (__ws_unpack_ay(peer->intf_addr, value, WS_MACADDR_LEN))
                        WDP_LOGD("[" MACSTR "]", MAC2STR(peer->intf_addr));
@@ -686,7 +687,7 @@ static void __ws_peer_property(const char *key, GVariant *value, void *user_data
                if (__ws_unpack_ay(peer->p2p_dev_addr, value, WS_MACADDR_LEN))
                        WDP_LOGD("[" MACSTR "]", MAC2STR(peer->p2p_dev_addr));
 
-       } else if (g_strcmp0(key, "InterfacedAddress") == 0) {
+       } else if (g_strcmp0(key, "InterfaceAddress") == 0) {
 
                if (__ws_unpack_ay(peer->p2p_intf_addr, value, WS_MACADDR_LEN))
                        WDP_LOGD("[" MACSTR "]", MAC2STR(peer->p2p_intf_addr));
@@ -1980,7 +1981,7 @@ static void __register_p2pdevice_signal(GVariant *value, void *user_data)
        __WDP_LOG_FUNC_EXIT__;
 }
 
-static int _ws_create_interface(const char *iface_name)
+static int _ws_create_interface(const char *iface_name, handle_reply function, void *user_data)
 {
        __WDP_LOG_FUNC_ENTER__;
        GDBusConnection *g_dbus = NULL;
@@ -2003,7 +2004,7 @@ static int _ws_create_interface(const char *iface_name)
        g_variant_builder_add(builder, "{sv}", "ConfigFile", g_variant_new_string(CONF_FILE_PATH));
        params.params = g_variant_new("(a{sv})", builder);
        g_variant_builder_unref(builder);
-       res = dbus_method_call(&params, SUPPLICANT_INTERFACE, __register_p2pdevice_signal, NULL);
+       res = dbus_method_call(&params, SUPPLICANT_INTERFACE, function, user_data);
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
        else
@@ -2013,7 +2014,7 @@ static int _ws_create_interface(const char *iface_name)
        return 0;
 }
 
-static int _ws_get_interface(const char *iface_name)
+static int _ws_get_interface(const char *iface_name, handle_reply function, void *user_data)
 {
        __WDP_LOG_FUNC_ENTER__;
        GDBusConnection *g_dbus = NULL;
@@ -2033,7 +2034,7 @@ static int _ws_get_interface(const char *iface_name)
        WDP_LOGE("param [%s]", g_variant_print(params.params,TRUE));
 
        res = dbus_method_call(&params, SUPPLICANT_INTERFACE,
-                               __register_p2pdevice_signal, g_pd);
+                       function, user_data);
 
        if (res < 0)
                WDP_LOGE("Failed to send command to wpa_supplicant");
@@ -2045,25 +2046,25 @@ static int _ws_get_interface(const char *iface_name)
 }
 
 #if 0
-static int _ws_remove_interface(const char *iface_name)
+static void __ws_remove_interface(GVariant *value, void *user_data)
 {
        __WDP_LOG_FUNC_ENTER__;
        GDBusConnection *g_dbus = NULL;
        dbus_method_param_s params;
+       const char *path = NULL;
        static char interface_path[DBUS_OBJECT_PATH_MAX] = {'\0',};
        int res = 0;
 
        g_dbus = g_pd->g_dbus;
        if (!g_dbus) {
                WDP_LOGE("DBus connection is NULL");
-               return -1;
+               return;
        }
 
-       res = _ws_get_interface(iface_name, interface_path);
-       if (res < 0) {
-               WDP_LOGE("Failed to get interface object");
-               return -1;
-       }
+       g_variant_get(value, "(o)", &path);
+       g_strlcpy(interface_path, path, DBUS_OBJECT_PATH_MAX);
+       WDP_LOGD("interface object path [%s]", interface_path);
+
        memset(&params, 0x0, sizeof(dbus_method_param_s));
 
        dbus_set_method_param(&params, "RemoveInterface", SUPPLICANT_PATH, g_dbus);
@@ -2076,7 +2077,7 @@ static int _ws_remove_interface(const char *iface_name)
                WDP_LOGD("Succeeded to RemoveInterface");
 
        __WDP_LOG_FUNC_EXIT__;
-       return 0;
+       return;
 }
 #endif
 
@@ -2113,8 +2114,8 @@ static int _ws_init_dbus_connection(void)
                G_DBUS_SIGNAL_FLAGS_NONE,
                _supplicant_signal_cb,
                NULL, NULL);
-       if(_ws_get_interface(COMMON_IFACE_NAME) < 0)
-               res = _ws_create_interface(COMMON_IFACE_NAME);
+       if(_ws_get_interface(COMMON_IFACE_NAME, __register_p2pdevice_signal, NULL) < 0)
+               res = _ws_create_interface(COMMON_IFACE_NAME, __register_p2pdevice_signal, NULL);
 
        if (res < 0)
                        WDP_LOGE("Failed to subscribe interface signal");
@@ -2205,7 +2206,7 @@ static int __ws_check_net_interface(char* if_name)
 
        if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
                close(fd);
-               WDP_LOGE("ioctl error: SIOCGIFFLAGS: %s", strerror(errno)); /* interface is not found. */
+               WDP_LOGE("ioctl error: SIOCGIFFLAGS: %s [ %s ]", strerror(errno), if_name); /* interface is not found. */
                return -3;
        }
 
@@ -2769,7 +2770,6 @@ int ws_deactivate(int concurrent)
        ws_stop_scan();
 
        g_pd->concurrent = concurrent;
-
        _ws_deinit_dbus_connection();
 
        if(concurrent == 0) {
@@ -3265,6 +3265,47 @@ int ws_set_pin(char *pin)
        return 0;
 }
 
+static void __ws_get_pin(GVariant *value, void *user_data)
+{
+       __WDP_LOG_FUNC_ENTER__;
+       const char *pin = NULL;
+
+       g_variant_get(value, "(s)", &pin);
+       g_strlcpy((char *)user_data, pin, OEM_PINSTR_LEN + 1);
+
+       __WDP_LOG_FUNC_EXIT__;
+       return;
+}
+
+int ws_generate_pin(char **pin)
+{
+       __WDP_LOG_FUNC_ENTER__;
+       GDBusConnection *g_dbus = NULL;
+       dbus_method_param_s params;
+       char n_pin[9] = {0,};
+       int res = 0;
+
+       g_dbus = g_pd->g_dbus;
+       if (!g_dbus) {
+               WDP_LOGE("DBus connection is NULL");
+               return -1;
+       }
+       memset(&params, 0x0, sizeof(dbus_method_param_s));
+
+       dbus_set_method_param(&params, "GeneratePin", g_pd->iface_path ,g_dbus);
+       params.params = NULL;
+
+       res = dbus_method_call(&params, SUPPLICANT_WPS, __ws_get_pin, (void *)n_pin);
+       if (res < 0)
+               WDP_LOGE("Failed to send command to wpa_supplicant");
+       else
+               WDP_LOGD("Succeeded to generate_pin [ %s ]", n_pin);
+
+       *pin = strndup(n_pin, OEM_PINSTR_LEN);
+       __WDP_LOG_FUNC_EXIT__;
+       return 0;
+}
+
 int ws_get_supported_wps_mode()
 {
        __WDP_LOG_FUNC_ENTER__;
index 3310db4..4646204 100755 (executable)
@@ -571,6 +571,7 @@ int ws_cancel_connection(unsigned char *peer_addr);
 int ws_get_connected_peers(GList **peers, int *peer_count);
 int ws_get_pin(char *pin);
 int ws_set_pin(char *pin);
+int ws_generate_pin(char **pin);
 int ws_get_supported_wps_mode();
 int ws_create_group(int persistent, int freq, const char *passphrase);
 int ws_destroy_group(const char *ifname);
index 2474101..50f0c0c 100755 (executable)
@@ -211,6 +211,7 @@ static wfd_oem_ops_s supplicant_ops = {
        .get_connected_peers = ws_get_connected_peers,
        .get_pin = ws_get_pin,
        .set_pin = ws_set_pin,
+       .generate_pin = ws_generate_pin,
        .get_supported_wps_mode = ws_get_supported_wps_mode,
 
        .create_group = ws_create_group,
@@ -3357,6 +3358,44 @@ int ws_set_pin(char *pin)
        return 0;
 }
 
+int ws_generate_pin(char **pin)
+{
+       __WDP_LOG_FUNC_ENTER__;
+       ws_sock_data_s *sock = g_pd->common;
+       char cmd[32] = {0, };
+       char reply[1024] = {0,};
+       int res = 0;
+       if (!pin) {
+               WDP_LOGE("Invalid parameter");
+               return -1;
+       }
+
+       if (!sock) {
+               WDP_LOGE("Socket is NULL");
+               return -1;
+       }
+
+       snprintf(cmd, sizeof(cmd), WS_CMD_WPS_PIN "get");
+       res = _ws_send_cmd(sock->ctrl_sock, cmd, reply, sizeof(reply));
+       if (res < 0) {
+               WDP_LOGE("Failed to send command to wpa_supplicant");
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       if (strstr(reply, "FAIL")) {
+               WDP_LOGE("Failed to generate the pin");
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+       WDP_LOGE("Succeeded to generate the pin [ %s ]", reply);
+
+       *pin = strndup(reply, OEM_PINSTR_LEN);
+
+       __WDP_LOG_FUNC_EXIT__;
+       return 0;
+}
+
 int ws_get_supported_wps_mode()
 {
        __WDP_LOG_FUNC_ENTER__;
index cdbff32..6c5b532 100755 (executable)
@@ -95,6 +95,7 @@ int ws_cancel_connection(unsigned char *peer_addr);
 int ws_get_connected_peers(GList **peers, int *peer_count);
 int ws_get_pin(char *pin);
 int ws_set_pin(char *pin);
+int ws_generate_pin(char **pin);
 int ws_get_supported_wps_mode();
 int ws_create_group(int persistent, int freq, const char *passphrase);
 int ws_destroy_group(const char *ifname);
index 80ee7bb..26465f4 100644 (file)
@@ -35,6 +35,7 @@ static wfd_oem_ops_s supplicant_ops = {
        .get_connected_peers = ws_get_connected_peers,
        .get_pin = ws_get_pin,
        .set_pin = ws_set_pin,
+       .generate_pin = ws_generate_pin,
        .get_supported_wps_mode = ws_get_supported_wps_mode,
 
        .create_group = ws_create_group,
@@ -220,6 +221,14 @@ int ws_set_pin(char *pin)
        return -1;
 }
 
+int ws_generate_pin(char **pin)
+{
+       __WDP_LOG_FUNC_ENTER__;
+
+       __WDP_LOG_FUNC_EXIT__;
+       return -1;
+}
+
 int ws_get_supported_wps_mode()
 {
        __WDP_LOG_FUNC_ENTER__;
index 01d9d56..1e74e67 100755 (executable)
@@ -293,6 +293,12 @@ int wfd_process_event(void *user_data, void *data)
 
                wfd_state_set(manager, WIFI_DIRECT_STATE_CONNECTING);
 
+               res = wfd_session_start(session);
+               if (res < 0) {
+                       WDS_LOGE("Failed to start session");
+                       return -1;
+               }
+
                wifi_direct_client_noti_s noti;
                memset(&noti, 0x0, sizeof(wifi_direct_client_noti_s));
                noti.event = WIFI_DIRECT_CLI_EVENT_CONNECTION_REQ;
@@ -451,10 +457,8 @@ int wfd_process_event(void *user_data, void *data)
                                memcpy(peer->go_ip_addr, manager->local->ip_addr, IPADDR_LEN);
                                WDS_LOGE("Peer's GO IP [" IPSTR "]", IP2STR((char*) &peer->go_ip_addr));
                        }
-                       if(peer->ip_type == WFD_IP_TYPE_OVER_EAPOL) {
-                               /*TODO: ODROID Image does not have support libnl-2.0*/
-                               //wfd_util_ip_over_eap_lease(peer);
-                       }
+                       if(peer->ip_type == WFD_IP_TYPE_OVER_EAPOL)
+                               wfd_util_ip_over_eap_lease(peer);
                        else
 #endif /* CTRL_IFACE_DBUS */
                        wfd_util_dhcps_wait_ip_leased(peer);
@@ -594,12 +598,10 @@ int wfd_process_event(void *user_data, void *data)
 
                wifi_direct_client_noti_s noti;
                memset(&noti, 0x0, sizeof(wifi_direct_client_noti_s));
-               if (group->role == WFD_DEV_ROLE_GC) {
+               if (group->role == WFD_DEV_ROLE_GC && session) {
 #ifdef CTRL_IFACE_DBUS
-                       if(session->peer->ip_type == WFD_IP_TYPE_OVER_EAPOL) {
-                               /*TODO: ODROID Image does not have support libnl-2.0*/
-                               //wfd_util_ip_over_eap_assign(session->peer, event->ifname);
-                               }
+                       if(session->peer && session->peer->ip_type == WFD_IP_TYPE_OVER_EAPOL)
+                               wfd_util_ip_over_eap_assign(session->peer, event->ifname);
 #else /* CTRL_IFACE_DBUS */
                        wfd_destroy_session(manager);
 #endif /* CTRL_IFACE_DBUS */
index a2e5f3b..1789eee 100755 (executable)
@@ -207,7 +207,7 @@ int wfd_group_complete(void *data, wfd_oem_event_s *group_info)
                                WDS_LOGE("Peer's GO IP [" IPSTR "]", IP2STR((char*) &peer->go_ip_addr));
                        }
                }
-               if(peer->ip_type != WFD_IP_TYPE_OVER_EAPOL)
+               if(peer && peer->ip_type != WFD_IP_TYPE_OVER_EAPOL)
 #endif /* CTRL_IFACE_DBUS */
                wfd_util_dhcpc_start(peer);
        }
index cc455a2..4387c53 100644 (file)
@@ -190,6 +190,24 @@ wfd_session_s *wfd_create_session(void *data, unsigned char *peer_addr, int wps_
 
        manager->session = session;
        manager->local->wps_mode = session->wps_mode;
+
+       if (peer->dev_role == WFD_DEV_ROLE_GO &&
+                       manager->local->wps_mode == WFD_WPS_MODE_DISPLAY) {
+                       char *generated_pin = NULL;
+                       session->wps_mode = WFD_WPS_MODE_DISPLAY;
+                       session->req_wps_mode = WFD_WPS_MODE_KEYPAD;
+
+                       if (wfd_oem_generate_pin(manager->oem_ops, &generated_pin) != 0) {
+                               WDS_LOGE("Failed to generate pin");
+                               g_free(session);
+                               __WDS_LOG_FUNC_EXIT__;
+                               return NULL;
+                       }
+
+                       g_strlcpy(session->wps_pin, generated_pin, PINSTR_LEN + 1);
+                       g_free(generated_pin);
+       }
+
        if (peer->dev_role == WFD_DEV_ROLE_GO && manager->local->dev_role != WFD_DEV_ROLE_GO)
                manager->local->dev_role = WFD_DEV_ROLE_GC;
 
@@ -690,6 +708,8 @@ int wfd_session_process_event(wfd_manager_s *manager, wfd_oem_event_s *event)
                                break;
                        }
                        WDS_LOGD("=====> session already exist. (invitation session)");
+                       session->req_wps_mode = req_wps_mode;
+                       session->wps_mode = event->wps_mode;
                } else {
                        session = wfd_create_session(manager, event->dev_addr,
                                                                req_wps_mode, SESSION_DIRECTION_INCOMING);
@@ -721,6 +741,17 @@ int wfd_session_process_event(wfd_manager_s *manager, wfd_oem_event_s *event)
 
                if (session->type == SESSION_TYPE_INVITE) {
                        WDS_LOGD("Start WPS corresponding to OEM event [%d]", event->event_id);
+                       if (session->wps_mode != WFD_WPS_MODE_PBC) {
+                               wifi_direct_client_noti_s noti;
+                               memset(&noti, 0x0, sizeof(wifi_direct_client_noti_s));
+                               noti.event = WIFI_DIRECT_CLI_EVENT_CONNECTION_WPS_REQ;
+                               g_snprintf(noti.param1, sizeof(noti.param1), MACSTR, MAC2STR(event->dev_addr));
+                               wfd_client_send_event(manager, &noti);
+                               if (session->wps_mode == WFD_WPS_MODE_KEYPAD) {
+                                       /* We have to wait until user type PIN using Keypad */
+                                       break;
+                               }
+                       }
                        res = wfd_session_wps(session);
                        if (res < 0)
                                _wfd_notify_session_failed(manager, event->dev_addr);
@@ -747,6 +778,11 @@ int wfd_session_process_event(wfd_manager_s *manager, wfd_oem_event_s *event)
                        break;
                }
 
+               if (session->type == SESSION_TYPE_INVITE) {
+                       WDS_LOGE("Session type is invite, ignore provision discovery response");
+                       break;
+               }
+
                /* Update session */
                session->wps_mode = event->wps_mode;
                if (event->wps_mode == WFD_WPS_MODE_DISPLAY) {
index cd59dcc..c31c98a 100755 (executable)
@@ -63,6 +63,9 @@
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
 
+#include <netlink/netlink.h>
+#include <netlink/socket.h>
+#include <netlink/route/neighbour.h>
 #endif /* CTRL_IFACE_DBUS */
 
 static int _txt_to_mac(char *txt, unsigned char *mac)
@@ -976,9 +979,6 @@ int wfd_util_get_local_ip(unsigned char* ip_addr)
 }
 
 #ifdef CTRL_IFACE_DBUS
-
-/*TODO: ODROID Image does not have support libnl-2.0 */
-#if 0
 static int _wfd_util_set_vconf_for_static_ip(const char *ifname, char *static_ip)
 {
        __WDS_LOG_FUNC_ENTER__;
@@ -996,99 +996,10 @@ static int _wfd_util_set_vconf_for_static_ip(const char *ifname, char *static_ip
        return 0;
 }
 
-int _wfd_util_set_static_arp(const char *ifname, unsigned char *peer_ip, unsigned char *peer_mac)
-{
-       __WDS_LOG_FUNC_ENTER__;
-
-       struct nl_sock *sock;
-       struct rtnl_neigh *neigh;
-       struct nl_addr *ip_addr;
-       struct nl_addr *mac_addr;
-
-       char ip_str[IPSTR_LEN] = {0, };
-       char mac_str[MACSTR_LEN] = {0, };
-       int if_index = 0;
-       int res = 0;
-
-       if (!ifname || !peer_ip || !peer_mac) {
-               WDS_LOGE("Invalid parameter");
-               __WDS_LOG_FUNC_EXIT__;
-               return -1;
-       }
-       snprintf(ip_str, IPSTR_LEN, IPSTR, IP2STR(peer_ip));
-       snprintf(mac_str, MACSTR_LEN, MACSTR, MAC2STR(peer_mac));
-
-       WDS_LOGE("ifname : [%s] peer ip : [%s] peer mac : [%s]", ifname, ip_str, mac_str);
-
-       /* Get index of interface */
-       if_index = if_nametoindex(ifname);
-       if(if_index < 0) {
-               WDS_LOGE("Failed to get interface index.");
-               __WDS_LOG_FUNC_EXIT__;
-               return -1;
-       }
-
-       sock = nl_socket_alloc();
-       if (!sock) {
-               WDS_LOGE("Failed to create netlink socket.");
-               __WDS_LOG_FUNC_EXIT__;
-               return -1;
-       }
-
-       res = nl_connect(sock, NETLINK_ROUTE);
-       if (res < 0) {
-               WDS_LOGE("Failed to connect netlink socket. [%s]", nl_geterror(res));
-               nl_socket_free(sock);
-               __WDS_LOG_FUNC_EXIT__;
-               return -1;
-       }
-
-       neigh = rtnl_neigh_alloc();
-       if(!neigh) {
-               WDS_LOGE("Failed to create neigh. [%s]");
-               nl_socket_free(sock);
-               __WDS_LOG_FUNC_EXIT__;
-               return -1;
-       }
-
-       if(nl_addr_parse(ip_str, rtnl_neigh_get_family(neigh), &ip_addr) < 0) {
-               WDS_LOGE("Failed to parse ip addr.");
-               nl_socket_free(sock);
-               rtnl_neigh_put(neigh);
-               __WDS_LOG_FUNC_EXIT__;
-               return -1;
-       }
-
-       if(nl_addr_parse(mac_str, AF_UNSPEC, &mac_addr) < 0) {
-               WDS_LOGE("Failed to parse mac addr.");
-               nl_socket_free(sock);
-               rtnl_neigh_put(neigh);
-               __WDS_LOG_FUNC_EXIT__;
-               return -1;
-       }
-
-       rtnl_neigh_set_dst(neigh, ip_addr);
-       rtnl_neigh_set_lladdr(neigh, mac_addr);
-       rtnl_neigh_set_ifindex(neigh, if_index);
-       rtnl_neigh_set_state(neigh, rtnl_neigh_str2state("reachable"));
-
-       res = rtnl_neigh_add(sock, neigh, NLM_F_CREATE);
-       if(res < 0) {
-               WDS_LOGE("Failed to add neigh. [%s]\n", nl_geterror(res));
-       }
-
-       WDS_LOGE("Set static ARP as reachable success!");
-       nl_socket_free(sock);
-       rtnl_neigh_put(neigh);
-       __WDS_LOG_FUNC_EXIT__;
-       return res;
-}
-
 
 static int _wfd_util_static_ip_set(const char *ifname, unsigned char *static_ip)
 {
        __WDS_LOG_FUNC_ENTER__;
-
        int res = 0;
        unsigned char ip_addr[IPADDR_LEN];
        char ip_str[IPSTR_LEN] = {0, };
@@ -1189,8 +1100,6 @@ static int _wfd_util_static_ip_set(const char *ifname, unsigned char *static_ip)
 int wfd_util_static_ip_unset(const char *ifname)
 {
        __WDS_LOG_FUNC_ENTER__;
-
-
        int res = 0;
        unsigned char ip_addr[IPADDR_LEN];
        char error_buf[MAX_SIZE_ERROR_BUFFER] = {};
@@ -1287,7 +1196,6 @@ int wfd_util_static_ip_unset(const char *ifname)
 }
 #endif /* TIZEN_VENDOR_ATH */
 
-
 int wfd_util_ip_over_eap_assign(wfd_device_s *peer, const char *ifname)
 {
        __WDS_LOG_FUNC_ENTER__;
@@ -1300,7 +1208,6 @@ int wfd_util_ip_over_eap_assign(wfd_device_s *peer, const char *ifname)
 
        _wfd_util_static_ip_set(ifname, peer->client_ip_addr);
        memcpy(peer->ip_addr, peer->go_ip_addr, IPADDR_LEN);
-       _wfd_util_set_static_arp(ifname, peer->ip_addr, peer->intf_addr);
 
        wfd_destroy_session(manager);
 
@@ -1333,7 +1240,6 @@ int wfd_util_ip_over_eap_lease(wfd_device_s *peer)
        }
 
        memcpy(peer->ip_addr, peer->client_ip_addr, IPADDR_LEN);
-       _wfd_util_set_static_arp(group->ifname, peer->ip_addr, peer->intf_addr);
 
        wifi_direct_client_noti_s noti;
        memset(&noti, 0x0, sizeof(wifi_direct_client_noti_s));
@@ -1346,7 +1252,4 @@ int wfd_util_ip_over_eap_lease(wfd_device_s *peer)
        __WDS_LOG_FUNC_EXIT__;
        return 0;
 }
-#endif
-
-
 #endif /* CTRL_IFACE_DBUS */