From 1c8b4c0269a6a2a808b8049fde0574187bc33628 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kush=20Agrawal/SRI-Bangalore-Smart=20Living/=2E/=EC=82=BC?= =?utf8?q?=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 17 Apr 2018 20:48:55 +0530 Subject: [PATCH] Creating socket everytime when network bearer changes (#285) [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 Signed-off-by: Amit KS --- .../connectivity/src/ip_adapter/android/caipnwmonitor.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c b/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c index 75f7814..e584626 100644 --- a/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c +++ b/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c @@ -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(); } -- 2.7.4