From: Kush Agrawal/SRI-Bangalore-Smart Living/./삼성전자 Date: Tue, 17 Apr 2018 15:18:55 +0000 (+0530) Subject: Creating socket everytime when network bearer changes (#285) X-Git-Tag: submit/tizen_4.0/20180618.100047~12^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F34%2F176634%2F1;p=platform%2Fupstream%2Fiotivity.git 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 --- 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(); }