From: jw1103.kim Date: Wed, 15 Apr 2015 02:52:13 +0000 (+0900) Subject: modified to check the size of selected network list on send_request X-Git-Tag: 1.2.0+RC1~1813 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e3e820176d198af85a67092999886343224dccf9;p=platform%2Fupstream%2Fiotivity.git modified to check the size of selected network list on send_request Change-Id: Idec4a331bee1039c8727618797f3d8468629c123 Signed-off-by: jw1103.kim Reviewed-on: https://gerrit.iotivity.org/gerrit/724 Tested-by: jenkins-iotivity Reviewed-by: Ashok Babu Channa Reviewed-by: Erich Keane --- diff --git a/resource/csdk/connectivity/src/camessagehandler.c b/resource/csdk/connectivity/src/camessagehandler.c old mode 100644 new mode 100755 index 1ea2b7dc3..5025518bf --- a/resource/csdk/connectivity/src/camessagehandler.c +++ b/resource/csdk/connectivity/src/camessagehandler.c @@ -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; diff --git a/resource/csdk/connectivity/test/ca_api_unittest.cpp b/resource/csdk/connectivity/test/ca_api_unittest.cpp old mode 100644 new mode 100755 index 3a04120de..40f81ad4a --- a/resource/csdk/connectivity/test/ca_api_unittest.cpp +++ b/resource/csdk/connectivity/test/ca_api_unittest.cpp @@ -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;