+#endif // SINGLE_THREAD
+
+static CAResult_t CAProcessMulticastData(const CAData_t *data)
+{
+ VERIFY_NON_NULL(data, TAG, "data");
+ VERIFY_NON_NULL(data->remoteEndpoint, TAG, "remoteEndpoint");
+
+ coap_pdu_t *pdu = NULL;
+ CAInfo_t *info = NULL;
+ coap_list_t *options = NULL;
+ coap_transport_type transport;
+ CAResult_t res = CA_SEND_FAILED;
+ if (NULL != data->requestInfo)
+ {
+ OIC_LOG(DEBUG, TAG, "requestInfo is available..");
+
+ info = &data->requestInfo->info;
+ pdu = CAGeneratePDU(CA_GET, info, data->remoteEndpoint, &options, &transport);
+
+ 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;
+ }
+ }
+ else if (NULL != data->responseInfo)
+ {
+ OIC_LOG(DEBUG, TAG, "responseInfo is available..");
+
+ info = &data->responseInfo->info;
+ pdu = CAGeneratePDU(data->responseInfo->result, info, data->remoteEndpoint,
+ &options, &transport);
+
+ if (NULL != pdu)
+ {
+#ifdef WITH_BWT
+ if (CAIsSupportedBlockwiseTransfer(data->remoteEndpoint->adapter))
+ {
+ // Blockwise transfer
+ if (NULL != info)
+ {
+ res = CAAddBlockOption(&pdu, info, data->remoteEndpoint, &options);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG(INFO, TAG, "to write block option 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;
+ }
+ }
+ else
+ {
+ OIC_LOG(ERROR, TAG, "request or response info is empty");
+ return res;
+ }
+
+ CALogPDUInfo(pdu, data->remoteEndpoint);
+
+ OIC_LOG(DEBUG, TAG, "pdu to send :");
+ OIC_LOG_BUFFER(DEBUG, TAG, (uint8_t*)pdu->hdr, pdu->length);
+
+ res = CASendMulticastData(data->remoteEndpoint, pdu->hdr, pdu->length);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
+ goto exit;
+ }
+
+ coap_delete_list(options);
+ coap_delete_pdu(pdu);
+ return res;
+
+exit:
+ CAErrorHandler(data->remoteEndpoint, pdu->hdr, pdu->length, res);
+ coap_delete_list(options);
+ coap_delete_pdu(pdu);
+ return res;
+}