Duplicated station information issue is fixed
authorSeungyoun Ju <sy39.ju@samsung.com>
Tue, 27 Nov 2012 10:05:52 +0000 (19:05 +0900)
committerSeungyoun Ju <sy39.ju@samsung.com>
Fri, 7 Dec 2012 04:46:34 +0000 (13:46 +0900)
- Issues
  When DHCP ACK is came repeatedly, duplicated station notification
  is sent to application.

- Fix description
  If it is already connected device's DHCP ACK, it is ignored.

Change-Id: I9692c09ed096238c2ac991461d0ffd0259658c97

include/mobileap_agent.h
src/mobileap_common.c
src/mobileap_main.c

index 76513a9..841ef85 100644 (file)
@@ -207,8 +207,8 @@ gboolean _deinit_tethering(MobileAPObject *obj);
 gboolean _mobileap_clear_state(int state);
 
 
-int _mobileap_is_disabled(void);
-int _mobileap_is_enabled(int state);
+gboolean _mobileap_is_disabled(void);
+gboolean _mobileap_is_enabled(mobile_ap_type_e type);
 gboolean _mobileap_set_state(int state);
 
 #endif
index af57fb8..084f965 100644 (file)
@@ -162,6 +162,12 @@ int _add_station_info(mobile_ap_station_info_t *info)
        mobile_ap_station_info_t *si = NULL;
        int i = 0;
 
+       if (_get_station_info(info->mac, _slist_find_station_by_mac, &si) ==
+                       MOBILE_AP_ERROR_NONE) {
+               DBG("Already exist station : %s\n", info->mac);
+               return MOBILE_AP_ERROR_INTERNAL;
+       }
+
        station_list = g_slist_append(station_list, info);
        for (l = station_list; l != NULL; l = g_slist_next(l)) {
                si = (mobile_ap_station_info_t *)l->data;
index c35181a..36c8e3c 100644 (file)
@@ -151,14 +151,14 @@ gboolean _mobileap_set_state(int state)
        return TRUE;
 }
 
-int _mobileap_is_disabled(void)
+gboolean _mobileap_is_disabled(void)
 {
-       return !mobileap_state;
+       return mobileap_state ? FALSE : TRUE;
 }
 
-int _mobileap_is_enabled(int state)
+gboolean _mobileap_is_enabled(mobile_ap_type_e type)
 {
-       return (mobileap_state & state) ? 1 : 0;
+       return (mobileap_state & type) ? TRUE : FALSE;
 }
 
 gboolean _mobileap_clear_state(int state)
@@ -447,12 +447,16 @@ static DBusHandlerResult __dnsmasq_signal_filter(DBusConnection *conn,
                        dbus_error_free(&error);
                        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
                }
-
                DBG("DhcpConnected signal : %s  %s %s\n", ip_addr, mac, name);
 
                if (_get_tethering_type_from_ip(ip_addr, &type) != MOBILE_AP_ERROR_NONE)
                        return DBUS_HANDLER_RESULT_HANDLED;
 
+               if (_mobileap_is_enabled(type) != FALSE) {
+                       DBG("Tethering[%d] is disabled. Ignore ACK\n", type);
+                       return DBUS_HANDLER_RESULT_HANDLED;
+               }
+
                info = (mobile_ap_station_info_t *)malloc(sizeof(mobile_ap_station_info_t));
                if (info == NULL) {
                        ERR("malloc failed\n");
@@ -483,7 +487,11 @@ static DBusHandlerResult __dnsmasq_signal_filter(DBusConnection *conn,
                        }
                }
 
-               _add_station_info(info);
+               if (_add_station_info(info) != MOBILE_AP_ERROR_NONE) {
+                       free(info);
+                       return DBUS_HANDLER_RESULT_HANDLED;
+               }
+
                _send_dbus_station_info("DhcpConnected", info);
 
                return DBUS_HANDLER_RESULT_HANDLED;