modified to check the size of selected network list on send_request
authorjw1103.kim <jw1103.kim@samsung.com>
Wed, 15 Apr 2015 02:52:13 +0000 (11:52 +0900)
committerErich Keane <erich.keane@intel.com>
Mon, 20 Apr 2015 17:23:00 +0000 (17:23 +0000)
Change-Id: Idec4a331bee1039c8727618797f3d8468629c123
Signed-off-by: jw1103.kim <jw1103.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/724
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/src/camessagehandler.c [changed mode: 0644->0755]
resource/csdk/connectivity/test/ca_api_unittest.cpp [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 1ea2b7d..5025518
@@ -72,6 +72,18 @@ static CARetransmission_t g_retransmissionContext;
 static CARequestCallback g_requestHandler = NULL;
 static CAResponseCallback g_responseHandler = NULL;
 
+static bool CAIsSelectedNetworkAvailable()
+{
+    u_arraylist_t *list = CAGetSelectedNetworkList();
+    if (!list || list->length == 0)
+    {
+        OIC_LOG(ERROR, TAG, "No selected network");
+        return false;
+    }
+
+    return true;
+}
+
 static void CATimeoutCallback(const CARemoteEndpoint_t *endpoint, const void *pdu, uint32_t size)
 {
     OIC_LOG(DEBUG, TAG, "IN");
@@ -582,6 +594,11 @@ CAResult_t CADetachRequestMessage(const CARemoteEndpoint_t *object, const CARequ
     VERIFY_NON_NULL(object, TAG, "object");
     VERIFY_NON_NULL(request, TAG, "request");
 
+    if (false == CAIsSelectedNetworkAvailable())
+    {
+        return CA_STATUS_FAILED;
+    }
+
     CARemoteEndpoint_t *remoteEndpoint = NULL;
     CARequestInfo_t *requestInfo = NULL;
     CAData_t *data = (CAData_t *) OICCalloc(1, sizeof(CAData_t));
@@ -633,6 +650,11 @@ CAResult_t CADetachRequestToAllMessage(const CAGroupEndpoint_t *object,
         return CA_STATUS_INVALID_PARAM;
     }
 
+    if (false == CAIsSelectedNetworkAvailable())
+    {
+        return CA_STATUS_FAILED;
+    }
+
     CARemoteEndpoint_t *remoteEndpoint = NULL;
     CARequestInfo_t *requestInfo = NULL;
 
@@ -642,7 +664,7 @@ CAResult_t CADetachRequestToAllMessage(const CAGroupEndpoint_t *object,
 
     CAAddress_t addr = {};
     remoteEndpoint = CACreateRemoteEndpointInternal(object->resourceUri, addr,
-                                                                        object->connectivityType);
+                                                    object->connectivityType);
 
     // clone request info
     requestInfo = CACloneRequestInfo(request);
@@ -677,6 +699,11 @@ CAResult_t CADetachResponseMessage(const CARemoteEndpoint_t *object,
     VERIFY_NON_NULL(object, TAG, "object");
     VERIFY_NON_NULL(response, TAG, "response");
 
+    if (false == CAIsSelectedNetworkAvailable())
+    {
+        return CA_STATUS_FAILED;
+    }
+
     CARemoteEndpoint_t *remoteEndpoint = NULL;
     CAResponseInfo_t *responseInfo = NULL;
 
@@ -722,6 +749,11 @@ CAResult_t CADetachMessageResourceUri(const CAURI_t resourceUri, const CAToken_t
     VERIFY_NON_NULL(resourceUri, TAG, "resourceUri is NULL");
     VERIFY_NON_NULL(token, TAG, "Token is NULL");
 
+    if (false == CAIsSelectedNetworkAvailable())
+    {
+        return CA_STATUS_FAILED;
+    }
+
     CARemoteEndpoint_t *remoteEndpoint = NULL;
     CARequestInfo_t *reqInfo = NULL;
     char *tempToken = NULL;
old mode 100644 (file)
new mode 100755 (executable)
index 3a04120..40f81ad
@@ -636,6 +636,8 @@ TEST_F(CATests, HandlerRequestResponseTest)
 // check return value
 TEST(SendRequestToAllTest, DISABLED_TC_31_Positive_01)
 {
+    CASelectNetwork(CA_ETHERNET);
+
     uri = (char *) RESOURCE_URI;
     CACreateRemoteEndpoint(uri, CA_ETHERNET, &tempRep);
     CAGroupEndpoint_t *group = NULL;