Disable auto-discovery of NSProvider over TCP. 31/204731/1
authorSenthil Kumar G S <senthil.gs@samsung.com>
Mon, 22 Apr 2019 13:18:54 +0000 (18:48 +0530)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Fri, 26 Apr 2019 04:17:52 +0000 (13:17 +0900)
For disabling auto-discovery, DISABLE_AUTO_TCP_NSPROVIDER_DISCOVERY flag should be set to 1
in scons build command.

Background:-
For TCP Connected events, NS Consumer automatically discovers initiates the discovery
of NS Provider. Due to which, there is a problem which occurs when app perform sign-in
and there is no TCP connection, then connection will be established first.
NS Consumer will then receive the TCP connected event and initiate NS Provider discovery.
Even before sign-in, upon receiving the NS Provider discovery closes the connection as it is
in the process of sign-in.

This patch addresses the problem by disabling auto-discovery of NSProvider over TCP
for TCP connected events.

As auto discovery is disabled, application should explicitly perform discovery by calling
"NSConsumerEnableRemoteService" API (strictly after sign-in).

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/488
(cherry picked from 8edd5e6a62a3d3892871efc9f4fb1f7f4b32fd9b)

Change-Id: I41910070ad8c60c64aa8fa4567f98d98690965a4
Signed-off-by: Senthil Kumar G S <senthil.gs@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
build_common/SConscript
service/notification/src/consumer/NSConsumerNetworkEventListener.c

index c351abe..577cbff 100755 (executable)
@@ -109,7 +109,6 @@ help_vars.Add(BoolVariable('SIMULATOR', 'Build with simulator module', False))
 help_vars.Add(BoolVariable('WITH_RA_IBB', 'Build with Remote Access module(workssys)', False))
 help_vars.Add(BoolVariable('WITH_ASAN', 'Build with Address Sanitizer support', False))
 
-
 if target_os in targets_disallow_multitransport:
        help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'IP', ['BT', 'BLE', 'IP', 'NFC']))
 else:
@@ -139,6 +138,7 @@ help_vars.Add(PathVariable('TIZENRT_OS_DIR', 'Absolute Path to TizenRT OS direct
 help_vars.Add(EnumVariable('PLATFORM_TLS', 'Use platform tls instead of local mbedtls', '0', allowed_values=('0', '1')))
 help_vars.Add(EnumVariable('OIC_SUPPORT_TIZEN_TRACE', 'Tizen Trace(T-trace) api availability', 'False', allowed_values=('True', 'False')))
 help_vars.Add(BoolVariable('WITH_PROCESS_EVENT','Build including process event logics in ocstack', 'False'))
+help_vars.Add(BoolVariable('DISABLE_AUTO_TCP_NSPROVIDER_DISCOVERY', 'Disable auto-discovery of NSProvider over TCP for TCP connected events', False))
 AddOption('--prefix',
                   dest='prefix',
                   type='string',
@@ -370,6 +370,9 @@ if env.get('DISABLE_BLE_SERVER'):
 if env.get('WITH_PROCESS_EVENT'):
     env.AppendUnique(CPPDEFINES=['WITH_PROCESS_EVENT'])
 
+if env.get('DISABLE_AUTO_TCP_NSPROVIDER_DISCOVERY'):
+       env.AppendUnique(CPPDEFINES = ['DISABLE_AUTO_TCP_NSPROVIDER_DISCOVERY'])
+
 libs = []
 if env.get('SECURED') == '1':
     defines.append('-D__WITH_DTLS__=1')
index 21881b1..078b6a5 100644 (file)
@@ -84,6 +84,14 @@ void NSConnectionStateListener(const CAEndpoint_t * info, bool connected)
     NS_LOG_V(INFO_PRIVATE, "remote_address : %s:%d", info->addr, info->port);
     NS_LOG_V(DEBUG, "isConnect : %d", connected);
 
+#ifdef DISABLE_AUTO_TCP_NSPROVIDER_DISCOVERY
+    if (info->adapter == CA_ADAPTER_TCP)
+    {
+        NS_LOG(DEBUG, "Ignoring the TCP event.");
+        return;
+    }
+#endif
+
     NSTaskType type = TASK_EVENT_CONNECTED;
     OCDevAddr * addr = NULL;
     if (connected)