Changes to IP conflict detection mode get/set API. 07/158007/9
authorAbhishek Sansanwal <abhishek.s94@samsung.com>
Fri, 27 Oct 2017 07:31:14 +0000 (13:01 +0530)
committerAbhishek Sansanwal <abhishek.s94@samsung.com>
Wed, 8 Nov 2017 06:47:26 +0000 (12:17 +0530)
Description: Removed the exponential IP conflict detection mode.
Changed and renamed the set detection mode dbus method to set only
the time period. Added the conflict detection time period get API.

Signed-off-by: Abhishek Sansanwal <abhishek.s94@samsung.com>
Change-Id: I7d05dc9f93825ef091938568fb51ae021efe091c

include/ip-conflict-detect.h
interfaces/netconfig-iface-wifi.xml
resources/etc/dbus-1/system.d/net-config.conf
src/ip-conflict-detect.c
src/wifi.c

index 6cd9608a8e94e9138cad3c648e28df506b342294..f830a4ff59e0387fdaaf73c5d5694484622c6ea0 100644 (file)
@@ -42,10 +42,12 @@ void stop_ip_conflict_mon();
 gboolean handle_ip_conflict_set_enable(Wifi *wifi, GDBusMethodInvocation *context,
                bool detect);
 gboolean handle_is_ip_conflict_detect_enabled(Wifi *wifi, GDBusMethodInvocation *context);
-gboolean handle_set_ip_conflict_mode(Wifi *wifi, GDBusMethodInvocation *context,
-               guint mode, guint initial_time);
+gboolean handle_set_ip_conflict_period(Wifi *wifi, GDBusMethodInvocation *context,
+               guint initial_time);
 gboolean handle_get_ip_conflict_state(Wifi *wifi, GDBusMethodInvocation
-                                     *context);
+               *context);
+gboolean handle_get_ip_conflict_period(Wifi *wifi, GDBusMethodInvocation *context);
+
 
 #ifdef __cplusplus
 }
index 023659cb8e8d130fcc5da8f6260a7d4b8dfeff42..54c665a6308c3efe5e5b449b674e0072b36df422 100755 (executable)
@@ -37,6 +37,9 @@
                <method name="GetIpConflictState">
                        <arg type="u" name="state" direction="out"/>
                </method>
+               <method name="GetIpConflictPeriod">
+                       <arg type="u" name="initial_time" direction="out"/>
+               </method>
                <method name="GetAutoscanmode">
                        <arg type="u" name="autoscanmode" direction="out"/>
                </method>
@@ -64,8 +67,7 @@
                        <arg type="s" name="config_id" direction="in"/>
                        <arg type="a{sv}" name="Configuration" direction="in"/>
                </method>
-               <method name="SetIpConflictMode">
-                       <arg type="u" name="mode" direction="in"/>
+               <method name="SetIpConflictPeriod">
                        <arg type="u" name="initial_time" direction="in"/>
                </method>
                <method name="RemoveConfiguration">
index 5355c87fca9f92605702548c64b0fe6fb188f790..04677f73199b308f5d91ec48fc110f80e5444736 100755 (executable)
@@ -20,6 +20,8 @@
                <allow send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="GetAutoscan" />
                <allow send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="GetAutoscanmode" />
                <allow send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="FlushBss" />
+               <allow send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="SetIpConflictPeriod" />
+               <allow send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="GetIpConflictPeriod" />
 
                <check send_destination="net.netconfig" send_interface="net.netconfig.network" send_member="AddRoute" privilege="http://tizen.org/privilege/network.set" />
                <check send_destination="net.netconfig" send_interface="net.netconfig.network" send_member="RemoveRoute" privilege="http://tizen.org/privilege/network.set" />
index 414298addb2f615ec82464e33cdaa996e658efd8..53c1dd14a32e609f1ab44b0e4ab6e1b289942115 100644 (file)
@@ -44,6 +44,7 @@
 #define IP_ADDRESS_LENGTH 4
 #define MAC_ADDRESS_LENGTH 6
 #define WLAN_MAC_ADDR_MAX 20
+#define ARP_SOURCE_IP "0.0.0.0"
 
 #define MIN_ARP_SEND_TIME 2000
 #define MAX_ARP_SEND_TIME 32000
@@ -73,12 +74,6 @@ struct arp_message {
        unsigned char  pad[18];                         /* pad for min. Ethernet payload (60 bytes) */
 };
 
-typedef enum {
-       IP_CONFLICT_MODE_EXPONENTIAL = 0x00,
-       IP_CONFLICT_MODE_PERIODIC,
-       IP_CONFLICT_MODE_MAX
-} ip_conflict_mode_e;
-
 typedef enum {
        NETCONFIG_IP_CONFLICT_STATE_UNKNOWN,
        NETCONFIG_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED,
@@ -88,10 +83,9 @@ typedef enum {
 struct timer_data {
        guint initial_time;
        guint timeout;
-       ip_conflict_mode_e mode;
 };
 static struct timer_data td = {
-       MIN_ARP_SEND_TIME, MIN_ARP_SEND_TIME, IP_CONFLICT_MODE_PERIODIC
+       MIN_ARP_SEND_TIME, MIN_ARP_SEND_TIME
 };
 
 int ioctl_sock;
@@ -121,6 +115,11 @@ static unsigned int __convert_uchar_to_uint(unsigned char b[IP_ADDRESS_LENGTH])
 
 static gboolean __arp_reply_timeout_cb(gpointer data)
 {
+       if (sd == NULL) {
+               INFO("Ignore timeout cb");
+               return G_SOURCE_REMOVE;
+       }
+
        sd->iteration++;
        sd->arp_reply_timer = -1;
        if (sd->timer_id != -1)
@@ -250,7 +249,7 @@ static gboolean send_arp(gpointer data)
                goto err;
        }
 
-       source_ip = inet_addr(default_ip);
+       source_ip = inet_addr(ARP_SOURCE_IP);
        target_ip = inet_addr(default_ip);
        memcpy(arp.s_IPaddr, &source_ip, IP_ADDRESS_LENGTH);                    /* source IP address */
        memcpy(arp.s_hwaddr, source_mac, MAC_ADDRESS_LENGTH);                   /* source hardware address */
@@ -302,10 +301,8 @@ static gboolean send_arp(gpointer data)
        }
 
        g_source_remove(sd->timer_id);
-       if (td.mode == IP_CONFLICT_MODE_PERIODIC)
-               sd->timeout = td.initial_time;
-       else if (td.mode == IP_CONFLICT_MODE_EXPONENTIAL && 2*sd->timeout < MAX_ARP_SEND_TIME)
-               sd->timeout *= 2;
+
+       sd->timeout = td.initial_time;
 
        /* Adding timeout callback for arp request */
        sd->arp_reply_timer = g_timeout_add(1000, __arp_reply_timeout_cb,
@@ -460,19 +457,17 @@ gboolean handle_is_ip_conflict_detect_enabled(Wifi *wifi, GDBusMethodInvocation
        return TRUE;
 }
 
-gboolean handle_set_ip_conflict_mode(Wifi *wifi, GDBusMethodInvocation *context,
-                                    guint mode, guint initial_time)
+gboolean handle_set_ip_conflict_period(Wifi *wifi, GDBusMethodInvocation *context, guint initial_time)
 {
        g_return_val_if_fail(wifi != NULL, FALSE);
        if (initial_time < MAX_ARP_SEND_TIME && initial_time > MIN_ARP_SEND_TIME)
                return FALSE;
 
        td.initial_time = 1000 * initial_time;
-       td.mode = mode;
        // remove timer
        stop_ip_conflict_mon();
        start_ip_conflict_mon();
-       wifi_complete_set_ip_conflict_mode(wifi, context);
+       wifi_complete_set_ip_conflict_period(wifi, context);
        return TRUE;
 }
 
@@ -484,3 +479,12 @@ gboolean handle_get_ip_conflict_state(Wifi *wifi, GDBusMethodInvocation *context
        g_dbus_method_invocation_return_value(context, param);
        return TRUE;
 }
+
+gboolean handle_get_ip_conflict_period(Wifi *wifi, GDBusMethodInvocation *context)
+{
+       g_return_val_if_fail(wifi != NULL, FALSE);
+       GVariant *param = NULL;
+       param = g_variant_new("(u)", td.initial_time/1000);
+       g_dbus_method_invocation_return_value(context, param);
+       return TRUE;
+}
index 0fdc0baa23ce47f008407f1c25180b6e0a56efdb..3ec8d94c400a85e8119d202457a406f3bde70445 100755 (executable)
@@ -196,10 +196,12 @@ void wifi_object_create_and_init(void)
                        G_CALLBACK(handle_ip_conflict_set_enable), NULL);
        g_signal_connect(wifi_object, "handle-is-ip-conflict-detect-enabled",
                        G_CALLBACK(handle_is_ip_conflict_detect_enabled), NULL);
-       g_signal_connect(wifi_object, "handle-set-ip-conflict-mode",
-                       G_CALLBACK(handle_set_ip_conflict_mode), NULL);
+       g_signal_connect(wifi_object, "handle-set-ip-conflict-period",
+                       G_CALLBACK(handle_set_ip_conflict_period), NULL);
        g_signal_connect(wifi_object, "handle-get-ip-conflict-state",
                        G_CALLBACK(handle_get_ip_conflict_state), NULL);
+       g_signal_connect(wifi_object, "handle-get-ip-conflict-period",
+                       G_CALLBACK(handle_get_ip_conflict_period), NULL);
 
        /* WIFI configuration */
        g_signal_connect(wifi_object, "handle-save-configuration",