Creating socket everytime when network bearer changes (#285) 34/176634/1
authorKush Agrawal/SRI-Bangalore-Smart Living/./삼성전자 <kush.agrawal@samsung.com>
Tue, 17 Apr 2018 15:18:55 +0000 (20:48 +0530)
committerAmit KS <amit.s12@samsung.com>
Fri, 20 Apr 2018 09:38:46 +0000 (15:08 +0530)
[CONPRO-1269] Creating socket everytime when network bearer changes

Socket was created only once but changed the logic for creating on every network change
When we are switching WifiAP or disconnect/connect again then we are not able to send unicast data from android side . It gives network unreachable error. So to avoid that we are closing and creating sockets again.

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/285
(cherry picked from commit 285875048bda46b6ac1a742c25849d70234d7cd1)

Change-Id: I5af2a47c925d03b50b5802229754f7f4d317be76
Signed-off-by: Kush <kush.agrawal@samsung.com>
Signed-off-by: Amit KS <amit.s12@samsung.com>
resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c

index 75f7814..e584626 100644 (file)
@@ -316,6 +316,12 @@ static CAResult_t CAAddInterfaceItem(u_arraylist_t *iflist, int index,
         return CA_STATUS_FAILED;
     }
 
+    /* Added preventive patch for CONRO-1269
+     * Network unreachable error was coming whenever WIFI-AP connection is changed.
+     * To avoid that scenario we are creating sockets again when interfaces are identified.
+     */
+    CreateMulticastSocket();
+
     return CA_STATUS_OK;
 }
 
@@ -483,11 +489,10 @@ Java_org_iotivity_ca_CaIpInterface_caIpStateEnabled(JNIEnv *env, jclass class)
 
     OIC_LOG(DEBUG, TAG, "Wifi is in Activated State");
     CAIPPassNetworkChangesToAdapter(CA_INTERFACE_UP);
-    /* Added preventive patch for CONRO-1269
-     * Network unreachable error was coming whenever WIFI-AP connection is changed.
-     * To avoid that scenario we are closing and creating sockets again.
-     */
-    CreateMulticastSocket();
+
+    // Closing sockets so that it will be created again when interfaces are identified(CONPRO-1269).
+    CloseMulticastSocket();
+
 
     // Apply network interface changes.
     u_arraylist_t *iflist = CAIPGetInterfaceInformation(0);
@@ -520,6 +525,4 @@ Java_org_iotivity_ca_CaIpInterface_caIpStateDisabled(JNIEnv *env, jclass class)
 
     OIC_LOG(DEBUG, TAG, "Wifi is in Deactivated State");
     CAIPPassNetworkChangesToAdapter(CA_INTERFACE_DOWN);
-    // Closing sockets so that it will be created again when WIFI is activated(CONPRO-1269).
-    CloseMulticastSocket();
 }