added multicast sending logic for response message
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Wed, 27 Jul 2016 04:25:56 +0000 (13:25 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Thu, 28 Jul 2016 04:27:59 +0000 (04:27 +0000)
Response message type can be used for presence.
so the multicast message sending logic was added.

Change-Id: Ic2efde32f9eb3a2e2aad4514e1f75fb4e7d50cb5
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9747
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jaewook Jung <jw0213.jung@samsung.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/connectivity/src/camessagehandler.c

index 17b3a9b..8dea22a 100644 (file)
@@ -406,41 +406,50 @@ static CAResult_t CAProcessMulticastData(const CAData_t *data)
     coap_list_t *options = NULL;
     coap_transport_type transport = coap_udp;
     CAResult_t res = CA_SEND_FAILED;
-    if (NULL != data->requestInfo)
+
+    if (!data->requestInfo && !data->responseInfo)
+    {
+        OIC_LOG(ERROR, TAG, "request or response info is empty");
+        return res;
+    }
+
+    if (data->requestInfo)
     {
         OIC_LOG(DEBUG, TAG, "requestInfo is available..");
 
         info = &data->requestInfo->info;
         pdu = CAGeneratePDU(CA_GET, info, data->remoteEndpoint, &options, &transport);
+    }
+    else if (data->responseInfo)
+    {
+        OIC_LOG(DEBUG, TAG, "responseInfo is available..");
 
-        if (NULL != pdu)
-        {
-#ifdef WITH_BWT
-            if (CAIsSupportedBlockwiseTransfer(data->remoteEndpoint->adapter))
-            {
-                // Blockwise transfer
-                res = CAAddBlockOption(&pdu, info, data->remoteEndpoint, &options);
-                if (CA_STATUS_OK != res)
-                {
-                    OIC_LOG(DEBUG, TAG, "CAAddBlockOption has failed");
-                    goto exit;
-                }
-            }
-#endif // WITH_BWT
-        }
-        else
-        {
-            OIC_LOG(ERROR,TAG,"Failed to generate multicast PDU");
-            CASendErrorInfo(data->remoteEndpoint, info, CA_SEND_FAILED);
-            return res;
-        }
+        info = &data->responseInfo->info;
+        pdu = CAGeneratePDU(data->responseInfo->result, info, data->remoteEndpoint,
+                            &options, &transport);
     }
-    else
+
+    if (!pdu)
     {
-        OIC_LOG(ERROR, TAG, "not supported message type for multicast.");
+        OIC_LOG(ERROR,TAG,"Failed to generate multicast PDU");
+        CASendErrorInfo(data->remoteEndpoint, info, CA_SEND_FAILED);
+        coap_delete_list(options);
         return res;
     }
 
+#ifdef WITH_BWT
+    if (CAIsSupportedBlockwiseTransfer(data->remoteEndpoint->adapter))
+    {
+        // Blockwise transfer
+        res = CAAddBlockOption(&pdu, info, data->remoteEndpoint, &options);
+        if (CA_STATUS_OK != res)
+        {
+            OIC_LOG(DEBUG, TAG, "CAAddBlockOption has failed");
+            goto exit;
+        }
+    }
+#endif // WITH_BWT
+
     CALogPDUInfo(pdu, data->remoteEndpoint);
 
     OIC_LOG(DEBUG, TAG, "pdu to send :");