Separated transmission logic for data on Both Mode.
authorjihwan.seo <jihwan.seo@samsung.com>
Fri, 8 Jul 2016 11:12:49 +0000 (20:12 +0900)
committerJon A. Cruz <jon@joncruz.org>
Thu, 4 Aug 2016 20:32:22 +0000 (20:32 +0000)
Since BLE transport has gatt server and client.
there are two sender and receiver
such as notifyCharacteristic / writeCharacteristic in BLE transport.
(while other transport has only one sender and receiver.)

thur, message has to be sent by message type which whether
it is a request or response message.

Change-Id: I7f77d86c13115138082b72a6371ce5bd49f1f0c6
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9255
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: Jon A. Cruz <jon@joncruz.org>
24 files changed:
resource/csdk/connectivity/api/cacommon.h
resource/csdk/connectivity/inc/caadapterinterface.h
resource/csdk/connectivity/inc/caedradapter.h
resource/csdk/connectivity/inc/cainterfacecontroller.h
resource/csdk/connectivity/inc/caipadapter.h
resource/csdk/connectivity/inc/camessagehandler.h
resource/csdk/connectivity/inc/canfcadapter.h
resource/csdk/connectivity/inc/caraadapter.h
resource/csdk/connectivity/inc/caretransmission.h
resource/csdk/connectivity/inc/catcpadapter.h
resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c
resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c
resource/csdk/connectivity/src/caconnectivitymanager.c
resource/csdk/connectivity/src/cainterfacecontroller.c
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/connectivity/src/caretransmission.c
resource/csdk/connectivity/src/ip_adapter/caipadapter.c
resource/csdk/connectivity/src/nfc_adapter/canfcadapter.c
resource/csdk/connectivity/src/ra_adapter/caraadapter.c
resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c
resource/csdk/connectivity/test/ca_api_unittest.cpp
resource/csdk/stack/include/internal/ocstackinternal.h
resource/csdk/stack/src/ocstack.c
resource/csdk/stack/src/oickeepalive.c

index d9c2c47..e42f75a 100644 (file)
@@ -51,7 +51,7 @@ extern "C"
 #endif
 
 /**
- * IP address Length
+ * IP address Length.
  */
 #define CA_IPADDR_SIZE 16
 
@@ -61,22 +61,22 @@ extern "C"
 #define CA_RAJABBERID_SIZE 256
 
 /**
- * Mac address length for BT port
+ * Mac address length for BT port.
  */
 #define CA_MACADDR_SIZE 18
 
 /**
- * Max header options data length
+ * Max header options data length.
  */
 #define CA_MAX_HEADER_OPTION_DATA_LENGTH 20
 
 /**
-* Max token length
+* Max token length.
 */
 #define CA_MAX_TOKEN_LEN (8)
 
 /**
- * Max URI length
+ * Max URI length.
  */
 #ifdef ARDUINO
 #define CA_MAX_URI_LENGTH 128  /* maximum size of URI for embedded platforms*/
@@ -85,7 +85,7 @@ extern "C"
 #endif
 
 /**
- * Max PDU length supported
+ * Max PDU length supported.
  */
 #ifdef ARDUINO
 #define COAP_MAX_PDU_SIZE           320  /* maximum size of a CoAP PDU for embedded platforms*/
@@ -98,12 +98,12 @@ extern "C"
 #endif
 
 /**
- *Maximum length of the remoteEndpoint identity
+ *Maximum length of the remoteEndpoint identity.
  */
 #define CA_MAX_ENDPOINT_IDENTITY_LEN   (32)
 
 /**
- * option types - the highest option number 63
+ * option types - the highest option number 63.
  */
 #define CA_OPTION_IF_MATCH 1
 #define CA_OPTION_ETAG 4
@@ -119,7 +119,7 @@ extern "C"
 #define CA_OPTION_LOCATION_QUERY 20
 
 /**
- * Payload information from resource model
+ * Payload information from resource model.
  */
 typedef uint8_t *CAPayload_t;
 
@@ -129,12 +129,12 @@ typedef uint8_t *CAPayload_t;
 typedef char *CAURI_t;
 
 /**
- * Token information for mapping the request and responses by resource model
+ * Token information for mapping the request and responses by resource model.
  */
 typedef char *CAToken_t;
 
 /*
- * Socket types and error definitions
+ * Socket types and error definitions.
  */
 #ifdef HAVE_WINSOCK2_H
 # define OC_SOCKET_ERROR      SOCKET_ERROR
@@ -208,7 +208,6 @@ typedef enum
 #define CA_SCOPE_MASK 0xf     // mask scope bits above
 
 /**
- * @enum CANetworkStatus_t
  * Information about the network status.
  */
 typedef enum
@@ -218,7 +217,7 @@ typedef enum
 } CANetworkStatus_t;
 
 /*
- * remoteEndpoint identity
+ * remoteEndpoint identity.
  */
 typedef struct
 {
@@ -227,8 +226,7 @@ typedef struct
 } CARemoteId_t;
 
 /**
- * @enum CAMessageType_t
- * Message Type for Base source code
+ * Message Type for Base source code.
  */
 typedef enum
 {
@@ -240,8 +238,7 @@ typedef enum
 } CAMessageType_t;
 
 /**
- * @enum CAMethod_t
- * Allowed method to be used by resource model
+ * Allowed method to be used by resource model.
  */
 typedef enum
 {
@@ -252,7 +249,7 @@ typedef enum
 } CAMethod_t;
 
 /**
- * block size
+ * block size.
  * it depends on defined size in libCoAP.
  */
 typedef enum
@@ -267,7 +264,7 @@ typedef enum
 } CABlockSize_t;
 
 /**
- * Endpoint information for connectivities
+ * Endpoint information for connectivities.
  * Must be identical to OCDevAddr.
  */
 typedef struct
@@ -284,7 +281,7 @@ typedef struct
 } CAEndpoint_t;
 
 /**
- * Endpoint information for secure messages
+ * Endpoint information for secure messages.
  */
 typedef struct
 {
@@ -293,8 +290,7 @@ typedef struct
 } CASecureEndpoint_t;
 
 /**
- * @enum CAResult_t
- * Enums for CA return values
+ * Enums for CA return values.
  */
 typedef enum
 {
@@ -319,8 +315,7 @@ typedef enum
 } CAResult_t;
 
 /**
- * @enum CAResponseResult_t
- * Enums for CA Response values
+ * Enums for CA Response values.
  */
 typedef enum
 {
@@ -347,8 +342,20 @@ typedef enum
 } CAResponseResult_t;
 
 /**
- * @enum CATransportProtocolID_t
- * Transport Protocol IDs for additional options
+ * Data type whether the data is Request Message or Response Message.
+ * if there is some failure before send data on network.
+ * Type will be set as error type for error callback.
+ */
+typedef enum
+{
+    CA_REQUEST_DATA = 1,
+    CA_RESPONSE_DATA,
+    CA_ERROR_DATA,
+    CA_RESPONSE_FOR_RES
+} CADataType_t;
+
+/**
+ * Transport Protocol IDs for additional options.
  */
 typedef enum
 {
@@ -357,7 +364,6 @@ typedef enum
 } CATransportProtocolID_t;
 
 /**
- * @enum CAAdapterState_t
  * Adapter State to indicate the network changed notifications.
  */
 typedef enum
@@ -384,7 +390,7 @@ typedef enum
 } CAPayloadFormat_t;
 
 /**
- * Header options structure to be filled
+ * Header options structure to be filled.
  *
  * This structure is used to hold header information.
  */
@@ -398,9 +404,9 @@ typedef struct
 } CAHeaderOption_t;
 
 /**
- * Base Information received
+ * Base Information received.
  *
- * This structure is used to hold request & response base information
+ * This structure is used to hold request & response base information.
  */
 typedef struct
 {
@@ -422,12 +428,13 @@ typedef struct
     CAPayloadFormat_t acceptFormat;     /**< accept format for the response payload */
     CAURI_t resourceUri;        /**< Resource URI information **/
     CARemoteId_t identity;      /**< endpoint identity */
+    CADataType_t dataType;      /**< data type */
 } CAInfo_t;
 
 /**
- * Request Information to be sent
+ * Request Information to be sent.
  *
- * This structure is used to hold request information
+ * This structure is used to hold request information.
  */
 typedef struct
 {
@@ -437,9 +444,9 @@ typedef struct
 } CARequestInfo_t;
 
 /**
- * Response information received
+ * Response information received.
  *
- * This structure is used to hold response information
+ * This structure is used to hold response information.
  */
 typedef struct
 {
@@ -450,9 +457,9 @@ typedef struct
 
 /**
  * Error information from CA
- *        contains error code and message information
+ *        contains error code and message information.
  *
- * This structure holds error information
+ * This structure holds error information.
  */
 typedef struct
 {
@@ -462,7 +469,7 @@ typedef struct
 } CAErrorInfo_t;
 
 /**
- * Hold global variables for CA layer (also used by RI layer)
+ * Hold global variables for CA layer. (also used by RI layer)
  */
 typedef struct
 {
@@ -487,7 +494,7 @@ typedef struct
 } CAHistory_t;
 
 /**
- * Hold interface index for keeping track of comings and goings
+ * Hold interface index for keeping track of comings and goings.
  */
 typedef struct
 {
index 144f383..0236089 100644 (file)
@@ -88,10 +88,12 @@ typedef CAResult_t (*CAAdapterStartDiscoveryServer)();
  * reference uri and connectivity type) to which the unicast data has to be sent.
  * @param[in]   data            Data which required to be sent.
  * @param[in]   dataLen         Size of data to be sent.
+ * @param[in]   dataType        Data type which is REQUEST or RESPONSE.
  * @return The number of bytes sent on the network. Return value equal to -1 indicates error.
  */
 typedef int32_t (*CAAdapterSendUnicastData)(const CAEndpoint_t *endpoint,
-                                            const void *data, uint32_t dataLen);
+                                            const void *data, uint32_t dataLen,
+                                            CADataType_t dataType);
 
 /**
  * Sends Multicast data to the endpoint using the adapter connectivity.
@@ -99,10 +101,12 @@ typedef int32_t (*CAAdapterSendUnicastData)(const CAEndpoint_t *endpoint,
  * @param[in]   endpoint        Remote Endpoint information (like ipaddress , port,
  * @param[in]   data            Data which required to be sent.
  * @param[in]   dataLen         Size of data to be sent.
+ * @param[in]   dataType        Data type which is REQUEST or RESPONSE.
  * @return The number of bytes sent on the network. Return value equal to -1 indicates error.
  */
 typedef int32_t (*CAAdapterSendMulticastData)(const CAEndpoint_t *endpoint,
-        const void *data, uint32_t dataLen);
+                                              const void *data, uint32_t dataLen,
+                                              CADataType_t dataType);
 
 /**
  * Get Network Information.
index bec17b7..019f363 100644 (file)
@@ -96,21 +96,23 @@ CAResult_t CAStartEDRDiscoveryServer();
  *                              connectivity type) to which the unicast data has to be sent.
  * @param[in]  data             Data to be sent.
  * @param[in]  dataLength       Size of data to be sent.
+ * @param[in]  dataType         Data type which is REQUEST or RESPONSE.
  * @return The number of bytes sent on the network. Returns -1 on error.
  *
  */
 int32_t CASendEDRUnicastData(const CAEndpoint_t *endpoint, const void *data,
-                             uint32_t dataLength);
+                             uint32_t dataLength, CADataType_t dataType);
 
 /**
  * Sends multicast data to all discovered bluetooth OIC devices using the adapter.
  * @param[in]  endpoint      Remote Endpoint information (like ipaddress, port, and connectivity.
  * @param[in]  data          Data which needs to be sent to all discovered bluetooth OIC device.
  * @param[in]  dataLength    Length of data in bytes.
+ * @param[in]  dataType      Data type which is REQUEST or RESPONSE.
  * @return Number of bytes sent on the network. Returns -1 on error.
  */
 int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data,
-                               uint32_t dataLength);
+                               uint32_t dataLength, CADataType_t dataType);
 
 /**
  * Get EDR Connectivity network information.
index edf060f..803fe57 100644 (file)
@@ -111,19 +111,23 @@ CAResult_t CAGetNetworkInfo(CAEndpoint_t **info, uint32_t *size);
  * @param[in]   endpoint       endpoint information where the data has to be sent.
  * @param[in]   data           data that needs to be sent.
  * @param[in]   length         length of the data that needs to be sent.
+ * @param[in]   dataType       Data type which is REQUEST or RESPONSE.
  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length);
+CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data,
+                             uint32_t length, CADataType_t dataType);
 
 /**
  * Sends multicast data to all endpoints in the network.
  * @param[in]   endpoint       endpoint information where the data has to be sent.
  * @param[in]   data           data that needs to be sent.
  * @param[in]   length         length of the data that needs to be sent.
+ * @param[in]   dataType       Data type which is REQUEST or RESPONSE.
  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
 
-CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length);
+CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data,
+                               uint32_t length, CADataType_t dataType);
 
 /**
  * Start listening servers to receive search requests from clients.
index d4ec30a..7ca9267 100644 (file)
@@ -92,11 +92,12 @@ CAResult_t CAStartIPDiscoveryServer();
  *                              which the unicast data has to be sent.
  * @param[in]   data           Data which is required to be sent.
  * @param[in]   dataLen        Size of data to be sent.
+ * @param[in]   dataType       Data type which is REQUEST or RESPONSE.
  * @note  dataLen must be > 0.
  * @return  The number of bytes sent on the network, or -1 upon error.
  */
 int32_t CASendIPUnicastData(const CAEndpoint_t *endpoint, const void *data,
-                            uint32_t dataLen);
+                            uint32_t dataLen, CADataType_t dataType);
 
 /**
  * Send Multicast data to the endpoint using the IP connectivity.
@@ -104,10 +105,12 @@ int32_t CASendIPUnicastData(const CAEndpoint_t *endpoint, const void *data,
  *                              port)
  * @param[in]   data           Data which is required to be sent.
  * @param[in]   dataLen        Size of data to be sent.
+ * @param[in]   dataType       Data type which is REQUEST or RESPONSE.
  * @note  dataLen must be > 0.
  * @return  The number of bytes sent on the network, or -1 upon error.
  */
-int32_t CASendIPMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLen);
+int32_t CASendIPMulticastData(const CAEndpoint_t *endpoint, const void *data,
+                              uint32_t dataLen, CADataType_t dataType);
 
 /**
  * Get IP Connectivity network information.
index 3f2fa6c..5a70271 100644 (file)
@@ -38,13 +38,6 @@ typedef enum
     SEND_TYPE_UNICAST
 } CASendDataType_t;
 
-typedef enum
-{
-    CA_REQUEST_DATA = 1,
-    CA_RESPONSE_DATA = 2,
-    CA_ERROR_DATA = 3,
-} CADataType_t;
-
 typedef struct
 {
     CASendDataType_t type;
index 3083ab3..ba308db 100644 (file)
@@ -81,21 +81,24 @@ CAResult_t CAStartNFCDiscoveryServer();
  * @param[in]   endpoint    Remote Endpoint information.\r
  * @param[in]   data        data to be sent.\r
  * @param[in]   dataLen     Size of data to be sent.\r
+ * @param[in]   dataType    Data type which is REQUEST or RESPONSE.\r
  * @return  number of bytes sent on the network. Return value equal to -1 indicates error.\r
  * @remark  dataLen must be > 0.\r
  */\r
 int32_t CASendNFCUnicastData(const CAEndpoint_t *endpoint, const void *data,\r
-                             uint32_t dataLen);\r
+                             uint32_t dataLen, CADataType_t dataType);\r
 \r
 /**\r
  * Send Multicast data to the endpoint using the NFC connectivity.\r
  * @param[in]   endpoint    Remote Endpoint information.\r
  * @param[in]   data        Data which is required to be sent.\r
  * @param[in]   dataLen     Size of data to be sent.\r
+   @param[in]   dataType    Data type which is REQUEST or RESPONSE.\r
  * @return  number of bytes sent on the network. Return value equal to -1 indicates error.\r
  * @remark  dataLen must be > 0.\r
  */\r
-int32_t CASendNFCMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLen);\r
+int32_t CASendNFCMulticastData(const CAEndpoint_t *endpoint, const void *data,\r
+                               uint32_t dataLen, CADataType_t dataType);\r
 \r
 /**\r
  * Get NFC Connectivity network information\r
index ed730f0..95961de 100644 (file)
@@ -68,11 +68,12 @@ CAResult_t CAStartRA();
  *                           the unicast data has to be sent.
  * @param[in]   data        Data which is required to be sent.
  * @param[in]   dataLen     Size of data to be sent.
+ * @param[in]   dataType    Data type which is REQUEST or RESPONSE.
  * @note dataLen must be > 0.
  * @return The number of bytes sent on the network, or -1 upon error.
  */
 int32_t CASendRAUnicastData(const CAEndpoint_t *endpoint, const void *data,
-                            uint32_t dataLen);
+                            uint32_t dataLen, CADataType_t dataType);
 
 /**
  * Get RA Connectivity network information.
@@ -107,7 +108,7 @@ CAResult_t CASetRAInfo(const CARAInfo_t *caraInfo);
  * These functions are not applicable to Remote Access adapter.
  */
 int32_t CASendRAMulticastData(const CAEndpoint_t *endpoint,
-                 const void *data, uint32_t dataLen);
+                              const void *data, uint32_t dataLen, CADataType_t dataType);
 
 /**
  * Start listening server for receiving search requests.
index b1a9971..d764e51 100644 (file)
@@ -50,7 +50,8 @@
 /** retransmission data send method type. **/
 typedef CAResult_t (*CADataSendMethod_t)(const CAEndpoint_t *endpoint,
                                          const void *pdu,
-                                         uint32_t size);
+                                         uint32_t size,
+                                         CADataType_t dataType);
 
 /** retransmission timeout callback type. **/
 typedef void (*CATimeoutCallback_t)(const CAEndpoint_t *endpoint,
@@ -128,13 +129,15 @@ CAResult_t CARetransmissionStart(CARetransmission_t *context);
  * process the retransmission data.
  * @param[in]   context      context for retransmission.
  * @param[in]   endpoint     endpoint information.
+ * @param[in]   dataType     Data type which is REQUEST or RESPONSE.
  * @param[in]   pdu          sent pdu binary data.
  * @param[in]   size         sent pdu binary data size.
  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-CAResult_t CARetransmissionSentData(CARetransmission_t* context,
-                                    const CAEndpoint_t* endpoint,
-                                    const void* pdu, uint32_t size);
+CAResult_t CARetransmissionSentData(CARetransmission_t *context,
+                                    const CAEndpoint_t *endpoint,
+                                    CADataType_t dataType,
+                                    const void *pdu, uint32_t size);
 
 /**
  * Pass the received pdu data. if received pdu is ACK data for the retransmission CON data,
index 9e9fde5..e892e07 100644 (file)
@@ -110,11 +110,13 @@ CAResult_t CAStartTCPDiscoveryServer();
  *                              which the unicast data has to be sent.
  * @param[in]   data           Data which is required to be sent.
  * @param[in]   dataLen        Size of data to be sent.
+ * @param[in]   dataType       Data type which is REQUEST or RESPONSE.
  * @note  dataLen must be > 0.
  * @return  The number of bytes sent on the network, or -1 upon error.
  */
 int32_t CASendTCPUnicastData(const CAEndpoint_t *endpoint,
-                             const void *data, uint32_t dataLen);
+                             const void *data, uint32_t dataLen,
+                             CADataType_t dataType);
 
 /**
  * Send Multicast data to the endpoint using the TCP connectivity.
@@ -122,11 +124,13 @@ int32_t CASendTCPUnicastData(const CAEndpoint_t *endpoint,
  *                              port)
  * @param[in]   data           Data which is required to be sent.
  * @param[in]   dataLen        Size of data to be sent.
+ * @param[in]   dataType       Data type which is REQUEST or RESPONSE.
  * @note  dataLen must be > 0.
  * @return  The number of bytes sent on the network, or -1 upon error.
  */
 int32_t CASendTCPMulticastData(const CAEndpoint_t *endpoint,
-                               const void *data, uint32_t dataLen);
+                               const void *data, uint32_t dataLen,
+                               CADataType_t dataType);
 
 /**
  * Get TCP Connectivity network information.
index f0b3fdf..c5a86d8 100644 (file)
@@ -264,11 +264,12 @@ CAResult_t CAStartEDRDiscoveryServer()
 }
 
 int32_t CASendEDRUnicastData(const CAEndpoint_t *remoteEndpoint, const void *data,
-                             uint32_t dataLength)
+                             uint32_t dataLength, CADataType_t dataType)
 {
     // Input validation
     VERIFY_NON_NULL_RET(remoteEndpoint, TAG, "Remote endpoint is null", -1);
     VERIFY_NON_NULL_RET(data, TAG, "Data is null", -1);
+    (void)dataType;
 
     if (0 == dataLength)
     {
@@ -296,9 +297,11 @@ int32_t CASendEDRUnicastData(const CAEndpoint_t *remoteEndpoint, const void *dat
     return sentLength;
 }
 
-int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength)
+int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength,
+                               CADataType_t dataType)
 {
     OIC_LOG(DEBUG, TAG, "IN - CASendEDRMulticastData");
+    (void)dataType;
 
     // Input validation
     VERIFY_NON_NULL_RET(data, TAG, "Data is null", -1);
index 302a2e8..f6c001f 100644 (file)
@@ -1490,7 +1490,8 @@ static CAResult_t CAStartLEDiscoveryServer();
  */
 static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
                                    const void *data,
-                                   uint32_t dataLen);
+                                   uint32_t dataLen,
+                                   CADataType_t dataType);
 
 /**
  * Send multicast data to the endpoint using the LE connectivity.
@@ -1506,7 +1507,8 @@ static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
  */
 static int32_t CASendLEMulticastData(const CAEndpoint_t *endpoint,
                                      const void *data,
-                                     uint32_t dataLen);
+                                     uint32_t dataLen,
+                                     CADataType_t dataType);
 
 /**
  * Get LE Connectivity network information.
@@ -1998,9 +2000,10 @@ static CAResult_t CAReadLEData()
 
 static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
                                    const void *data,
-                                   uint32_t dataLen)
+                                   uint32_t dataLen,
+                                   CADataType_t dataType)
 {
-    OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN - CASendLEUnicastData");
+    OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "IN - CASendLEUnicastData : type(%d)", dataType);
 
     //Input validation
     VERIFY_NON_NULL_RET(endpoint, CALEADAPTER_TAG, "Remote endpoint is null", -1);
@@ -2015,7 +2018,8 @@ static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
     }
 
     ca_mutex_lock(g_bleIsServerMutex);
-    if (ADAPTER_SERVER == g_adapterType || ADAPTER_BOTH_CLIENT_SERVER == g_adapterType)
+    if (ADAPTER_SERVER == g_adapterType ||
+            (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_RESPONSE_DATA == dataType))
     {
         result = CALEAdapterServerSendData(endpoint, data, dataLen);
         if (CA_STATUS_OK != result)
@@ -2031,7 +2035,9 @@ static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
         }
     }
 
-    if (ADAPTER_CLIENT == g_adapterType || ADAPTER_BOTH_CLIENT_SERVER == g_adapterType)
+    if (ADAPTER_CLIENT == g_adapterType ||
+            (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_REQUEST_DATA == dataType) ||
+            (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_RESPONSE_FOR_RES == dataType))
     {
         result = CALEAdapterClientSendData(endpoint, data, dataLen);
         if (CA_STATUS_OK != result)
@@ -2054,7 +2060,8 @@ static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
 
 static int32_t CASendLEMulticastData(const CAEndpoint_t *endpoint,
                                      const void *data,
-                                     uint32_t dataLen)
+                                     uint32_t dataLen,
+                                     CADataType_t dataType)
 {
     OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN - CASendLEMulticastData");
 
@@ -2076,7 +2083,8 @@ static int32_t CASendLEMulticastData(const CAEndpoint_t *endpoint,
     }
 
     ca_mutex_lock(g_bleIsServerMutex);
-    if (ADAPTER_SERVER == g_adapterType || ADAPTER_BOTH_CLIENT_SERVER == g_adapterType)
+    if (ADAPTER_SERVER == g_adapterType ||
+            (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_RESPONSE_DATA == dataType))
     {
         result = CALEAdapterServerSendData(NULL, data, dataLen);
         if (CA_STATUS_OK != result)
@@ -2093,7 +2101,9 @@ static int32_t CASendLEMulticastData(const CAEndpoint_t *endpoint,
         }
     }
 
-    if (ADAPTER_CLIENT == g_adapterType || ADAPTER_BOTH_CLIENT_SERVER == g_adapterType)
+    if (ADAPTER_CLIENT == g_adapterType ||
+            (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_REQUEST_DATA == dataType) ||
+            (ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_RESPONSE_FOR_RES == dataType))
     {
         result = CALEAdapterClientSendData(NULL, data, dataLen);
         if (CA_STATUS_OK != result)
index 7355e2a..f5ddd6f 100644 (file)
@@ -331,14 +331,19 @@ CAResult_t CASendResponse(const CAEndpoint_t *object, const CAResponseInfo_t *re
         return CA_STATUS_NOT_INITIALIZED;
     }
 
-    if (responseInfo && responseInfo->isMulticast &&
+    if (!responseInfo || !object)
+    {
+        return CA_STATUS_INVALID_PARAM;
+    }
+
+    if (responseInfo->isMulticast &&
             (object->adapter == CA_DEFAULT_ADAPTER || object->adapter == CA_ALL_ADAPTERS))
     {
-        return CASendMessageMultiAdapter(object, responseInfo, CA_RESPONSE_DATA);
+        return CASendMessageMultiAdapter(object, responseInfo, responseInfo->info.dataType);
     }
     else
     {
-        return CADetachSendMessage(object, responseInfo, CA_RESPONSE_DATA);
+        return CADetachSendMessage(object, responseInfo, responseInfo->info.dataType);
     }
 }
 
index 5de93f1..e4dea19 100644 (file)
@@ -361,7 +361,8 @@ memory_error_exit:
     return CA_MEMORY_ALLOC_FAILED;
 }
 
-CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length)
+CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length,
+                             CADataType_t dataType)
 {
     if (endpoint == NULL)
     {
@@ -406,7 +407,7 @@ CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uin
         if (NULL != g_adapterHandler[index].sendData)
         {
             OIC_LOG(DEBUG, TAG, "unicast message to adapter");
-            sentDataLen = g_adapterHandler[index].sendData(endpoint, data, length);
+            sentDataLen = g_adapterHandler[index].sendData(endpoint, data, length, dataType);
         }
 
         if (sentDataLen != (int32_t)length)
@@ -423,7 +424,8 @@ CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uin
     return CA_STATUS_OK;
 }
 
-CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length)
+CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length,
+                               CADataType_t dataType)
 {
     u_arraylist_t *list = CAGetSelectedNetworkList();
     if (!list)
@@ -467,7 +469,7 @@ CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, u
                 return CA_MEMORY_ALLOC_FAILED;
             }
             memcpy(payload, data, length);
-            sentDataLen = g_adapterHandler[index].sendDataToAll(endpoint, payload, length);
+            sentDataLen = g_adapterHandler[index].sendDataToAll(endpoint, payload, length, dataType);
             OICFree(payload);
         }
 
index 8dea22a..8cc0858 100644 (file)
@@ -455,7 +455,7 @@ static CAResult_t CAProcessMulticastData(const CAData_t *data)
     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);
+    res = CASendMulticastData(data->remoteEndpoint, pdu->hdr, pdu->length, data->dataType);
     if (CA_STATUS_OK != res)
     {
         OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
@@ -552,7 +552,8 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
 #endif // WITH_BWT
             CALogPDUInfo(pdu, data->remoteEndpoint);
 
-            res = CASendUnicastData(data->remoteEndpoint, pdu->hdr, pdu->length);
+            OIC_LOG_V(INFO, TAG, "CASendUnicastData type : %d", data->dataType);
+            res = CASendUnicastData(data->remoteEndpoint, pdu->hdr, pdu->length, data->dataType);
             if (CA_STATUS_OK != res)
             {
                 OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
@@ -574,7 +575,9 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
 #endif
             {
                 // for retransmission
-                res = CARetransmissionSentData(&g_retransmissionContext, data->remoteEndpoint,
+                res = CARetransmissionSentData(&g_retransmissionContext,
+                                               data->remoteEndpoint,
+                                               data->dataType,
                                                pdu->hdr, pdu->length);
                 if ((CA_STATUS_OK != res) && (CA_NOT_SUPPORTED != res))
                 {
@@ -883,7 +886,7 @@ static CAData_t* CAPrepareSendData(const CAEndpoint_t *endpoint, const void *sen
         cadata->type = request->isMulticast ? SEND_TYPE_MULTICAST : SEND_TYPE_UNICAST;
         cadata->requestInfo =  request;
     }
-    else if (CA_RESPONSE_DATA == dataType)
+    else if (CA_RESPONSE_DATA == dataType || CA_RESPONSE_FOR_RES == dataType)
     {
         // clone response info
         CAResponseInfo_t *response = CACloneResponseInfo((CAResponseInfo_t *)sendData);
index 56edbef..4c6f55c 100644 (file)
@@ -82,6 +82,7 @@ typedef struct
 #endif
     uint8_t triedCount;                 /**< retransmission count */
     uint16_t messageId;                 /**< coap PDU message id */
+    CADataType_t dataType;              /**< data Type (Request/Response) */
     CAEndpoint_t *endpoint;             /**< remote endpoint */
     void *pdu;                          /**< coap PDU */
     uint32_t size;                      /**< coap PDU size */
@@ -196,7 +197,8 @@ static void CACheckRetransmissionList(CARetransmission_t *context)
             {
                 OIC_LOG_V(DEBUG, TAG, "retransmission CON data!!, msgid=%d",
                           retData->messageId);
-                context->dataSendMethod(retData->endpoint, retData->pdu, retData->size);
+                context->dataSendMethod(retData->endpoint, retData->pdu,
+                                        retData->size, retData->dataType);
             }
 
             // #3. increase the retransmission count and update timestamp.
@@ -358,6 +360,7 @@ CAResult_t CARetransmissionInitialize(CARetransmission_t *context,
 
 CAResult_t CARetransmissionSentData(CARetransmission_t *context,
                                     const CAEndpoint_t *endpoint,
+                                    CADataType_t dataType,
                                     const void *pdu, uint32_t size)
 {
     if (NULL == context || NULL == endpoint || NULL == pdu)
@@ -425,6 +428,7 @@ CAResult_t CARetransmissionSentData(CARetransmission_t *context,
     retData->endpoint = remoteEndpoint;
     retData->pdu = pduData;
     retData->size = size;
+    retData->dataType = dataType;
 #ifndef SINGLE_THREAD
     // mutex lock
     ca_mutex_lock(context->threadMutex);
index e77f46d..04f16c8 100644 (file)
@@ -379,13 +379,17 @@ static int32_t CAQueueIPData(bool isMulticast, const CAEndpoint_t *endpoint,
 }
 
 int32_t CASendIPUnicastData(const CAEndpoint_t *endpoint,
-                            const void *data, uint32_t dataLength)
+                            const void *data, uint32_t dataLength,
+                            CADataType_t dataType)
 {
+    (void)dataType;
     return CAQueueIPData(false, endpoint, data, dataLength);
 }
 
-int32_t CASendIPMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength)
+int32_t CASendIPMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength,
+                              CADataType_t dataType)
 {
+    (void)dataType;
     return CAQueueIPData(true, endpoint, data, dataLength);
 }
 
index eddee4d..4f8e57e 100644 (file)
@@ -300,13 +300,17 @@ static int32_t CAQueueNFCData(const CAEndpoint_t *endpoint, const void *data,
 
 }
 
-int32_t CASendNFCUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength)
+int32_t CASendNFCUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength,
+                             CADataType_t dataType)
 {
+    (void)dataType;
     return CAQueueNFCData(endpoint, data, dataLength);
 }
 
-int32_t CASendNFCMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength)
+int32_t CASendNFCMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength,
+                               CADataType_t dataType)
 {
+    (void)dataType;
     return CAQueueNFCData(endpoint, data, dataLength);
 }
 
index fba4ca8..86741fe 100644 (file)
@@ -493,8 +493,10 @@ CAResult_t CAStopRA()
 }
 
 int32_t CASendRAUnicastData(const CAEndpoint_t *remoteEndpoint, const void *data,
-                                  uint32_t dataLength)
+                            uint32_t dataLength, CADataType_t dataType)
 {
+    SET_BUT_NOT_USED(dataType);
+
     if (!remoteEndpoint || !data)
     {
         OIC_LOG(ERROR, RA_ADAPTER_TAG, "Invalid parameter!");
@@ -563,12 +565,14 @@ CAResult_t CAGetRAInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
 }
 
 int32_t CASendRAMulticastData(const CAEndpoint_t *endpoint,
-                    const void *data, uint32_t dataLength)
+                              const void *data, uint32_t dataLength,
+                              CADataType_t dataType)
 {
     OIC_LOG(INFO, RA_ADAPTER_TAG, "RA adapter does not support sending multicast data");
     SET_BUT_NOT_USED(endpoint);
     SET_BUT_NOT_USED(data);
     SET_BUT_NOT_USED(dataLength);
+    SET_BUT_NOT_USED(dataType);
     return 0;
 }
 
@@ -879,8 +883,9 @@ CAResult_t CAStopRA()
 }
 
 int32_t CASendRAUnicastData(const CAEndpoint_t *remoteEndpoint, const void *data,
-                                  uint32_t dataLength)
+                            uint32_t dataLength, CADataType_t dataType)
 {
+    (void)dataType;
     if (!remoteEndpoint || !data)
     {
         OIC_LOG(ERROR, RA_ADAPTER_TAG, "Invalid parameter!");
@@ -947,7 +952,8 @@ CAResult_t CAGetRAInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
 }
 
 int32_t CASendRAMulticastData(const CAEndpoint_t *endpoint,
-                    const void *data, uint32_t dataLength)
+                              const void *data, uint32_t dataLength,
+                              CADataType_t dataType)
 {
     OIC_LOG(INFO, RA_ADAPTER_TAG, "RA adapter does not support sending multicast data");
     return 0;
index d81f600..b9f2c11 100644 (file)
@@ -368,9 +368,11 @@ static size_t CAQueueTCPData(bool isMulticast, const CAEndpoint_t *endpoint,
 }
 
 int32_t CASendTCPUnicastData(const CAEndpoint_t *endpoint,
-                             const void *data, uint32_t dataLength)
+                             const void *data, uint32_t dataLength,
+                             CADataType_t dataType)
 {
     OIC_LOG(DEBUG, TAG, "IN");
+    (void)dataType;
 #ifndef SINGLE_THREAD
     return CAQueueTCPData(false, endpoint, data, dataLength);
 #else
@@ -380,8 +382,10 @@ int32_t CASendTCPUnicastData(const CAEndpoint_t *endpoint,
 }
 
 int32_t CASendTCPMulticastData(const CAEndpoint_t *endpoint,
-                               const void *data, uint32_t dataLength)
+                               const void *data, uint32_t dataLength,
+                               CADataType_t dataType)
 {
+    (void)dataType;
     return CAQueueTCPData(true, endpoint, data, dataLength);
 }
 
index eccca11..d45ef4d 100644 (file)
@@ -344,6 +344,7 @@ TEST_F(CATests, SendResponseTestWithInvalidCode)
     responseData.type = CA_MSG_RESET;
     responseData.messageId = 1;
     responseData.payload = (CAPayload_t)malloc(sizeof("response payload"));
+    responseData.dataType = CA_RESPONSE_DATA;
 
     EXPECT_TRUE(responseData.payload != NULL);
 
@@ -376,6 +377,7 @@ TEST(SendResponseTest, DISABLED_TC_19_Positive_01)
     responseData.type = CA_MSG_NONCONFIRM;
     responseData.messageId = 1;
     responseData.payload = (CAPayload_t)malloc(sizeof("response payload"));
+    responseData.dataType = CA_RESPONSE_DATA;
 
     EXPECT_TRUE(responseData.payload != NULL);
     if(!responseData.payload)
@@ -413,6 +415,7 @@ TEST(SendResponseTest, DISABLED_TC_20_Negative_01)
     responseData.type = CA_MSG_NONCONFIRM;
     responseData.messageId = 1;
     responseData.payload = (CAPayload_t)malloc(sizeof("response payload"));
+    responseData.dataType = CA_RESPONSE_DATA;
     EXPECT_TRUE(responseData.payload != NULL);
 
     if(!responseData.payload)
index 7120951..e067d28 100644 (file)
@@ -202,7 +202,8 @@ OCStackResult HandleStackRequests(OCServerProtocolRequest * protocolRequest);
 OCStackResult SendDirectStackResponse(const CAEndpoint_t* endPoint, const uint16_t coapID,
         const CAResponseResult_t responseResult, const CAMessageType_t type,
         const uint8_t numOptions, const CAHeaderOption_t *options,
-        CAToken_t token, uint8_t tokenLength, const char *resourceUri);
+        CAToken_t token, uint8_t tokenLength, const char *resourceUri,
+        CADataType_t dataType);
 
 #ifdef WITH_PRESENCE
 
index 28f9645..7498896 100644 (file)
@@ -1447,7 +1447,7 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
             if(responseInfo->info.type == CA_MSG_CONFIRM)
             {
                 SendDirectStackResponse(endPoint, responseInfo->info.messageId, CA_EMPTY,
-                        CA_MSG_ACKNOWLEDGE, 0, NULL, NULL, 0, NULL);
+                        CA_MSG_ACKNOWLEDGE, 0, NULL, NULL, 0, NULL, CA_RESPONSE_FOR_RES);
             }
 
             OCPayloadDestroy(response.payload);
@@ -1497,7 +1497,7 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
             {
                 OIC_LOG(INFO, TAG, "Received a message without callbacks. Sending RESET");
                 SendDirectStackResponse(endPoint, responseInfo->info.messageId, CA_EMPTY,
-                                        CA_MSG_RESET, 0, NULL, NULL, 0, NULL);
+                                        CA_MSG_RESET, 0, NULL, NULL, 0, NULL, CA_RESPONSE_FOR_RES);
             }
         }
 
@@ -1611,7 +1611,8 @@ void HandleCAErrorResponse(const CAEndpoint_t *endPoint, const CAErrorInfo_t *er
 OCStackResult SendDirectStackResponse(const CAEndpoint_t* endPoint, const uint16_t coapID,
         const CAResponseResult_t responseResult, const CAMessageType_t type,
         const uint8_t numOptions, const CAHeaderOption_t *options,
-        CAToken_t token, uint8_t tokenLength, const char *resourceUri)
+        CAToken_t token, uint8_t tokenLength, const char *resourceUri,
+        CADataType_t dataType)
 {
     OIC_LOG(DEBUG, TAG, "Entering SendDirectStackResponse");
     CAResponseInfo_t respInfo = {
@@ -1635,6 +1636,7 @@ OCStackResult SendDirectStackResponse(const CAEndpoint_t* endPoint, const uint16
     respInfo.info.type = type;
     respInfo.info.resourceUri = OICStrdup (resourceUri);
     respInfo.info.acceptFormat = CA_FORMAT_UNDEFINED;
+    respInfo.info.dataType = dataType;
 
 #if defined (ROUTING_GATEWAY) || defined (ROUTING_EP)
     // Add the destination to route option from the endpoint->routeData.
@@ -1870,7 +1872,8 @@ void OCHandleRequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
             SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_BAD_REQ,
                         requestInfo->info.type, requestInfo->info.numOptions,
                         requestInfo->info.options, requestInfo->info.token,
-                        requestInfo->info.tokenLength, requestInfo->info.resourceUri);
+                        requestInfo->info.tokenLength, requestInfo->info.resourceUri,
+                        CA_RESPONSE_DATA);
             OICFree(serverRequest.payload);
             return;
     }
@@ -1889,7 +1892,8 @@ void OCHandleRequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
             SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_INTERNAL_SERVER_ERROR,
                     requestInfo->info.type, requestInfo->info.numOptions,
                     requestInfo->info.options, requestInfo->info.token,
-                    requestInfo->info.tokenLength, requestInfo->info.resourceUri);
+                    requestInfo->info.tokenLength, requestInfo->info.resourceUri,
+                    CA_RESPONSE_DATA);
             OICFree(serverRequest.payload);
             return;
         }
@@ -1940,7 +1944,8 @@ void OCHandleRequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
         SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_BAD_OPT,
                 requestInfo->info.type, requestInfo->info.numOptions,
                 requestInfo->info.options, requestInfo->info.token,
-                requestInfo->info.tokenLength, requestInfo->info.resourceUri);
+                requestInfo->info.tokenLength, requestInfo->info.resourceUri,
+                CA_RESPONSE_DATA);
         OICFree(serverRequest.payload);
         OICFree(serverRequest.requestToken);
         return;
@@ -1960,7 +1965,8 @@ void OCHandleRequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
         if (requestInfo->info.type == CA_MSG_CONFIRM)
         {
             SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_EMPTY,
-                                    CA_MSG_ACKNOWLEDGE,0, NULL, NULL, 0, NULL);
+                                    CA_MSG_ACKNOWLEDGE,0, NULL, NULL, 0, NULL,
+                                    CA_RESPONSE_DATA);
         }
     }
     else if(!OCResultToSuccess(requestResult))
@@ -1973,7 +1979,8 @@ void OCHandleRequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
         SendDirectStackResponse(endPoint, requestInfo->info.messageId, stackResponse,
                 requestInfo->info.type, requestInfo->info.numOptions,
                 requestInfo->info.options, requestInfo->info.token,
-                requestInfo->info.tokenLength, requestInfo->info.resourceUri);
+                requestInfo->info.tokenLength, requestInfo->info.resourceUri,
+                CA_RESPONSE_DATA);
     }
     // requestToken is fed to HandleStackRequests, which then goes to AddServerRequest.
     // The token is copied in there, and is thus still owned by this function.
index 2dd2b2f..f0ae1cd 100644 (file)
@@ -356,7 +356,7 @@ OCStackResult HandleKeepAliveGETRequest(const CAEndpoint_t* endPoint,
     SendDirectStackResponse(endPoint, requestInfo->info.messageId, result, requestInfo->info.type,
                             requestInfo->info.numOptions, requestInfo->info.options,
                             requestInfo->info.token, requestInfo->info.tokenLength,
-                            requestInfo->info.resourceUri);
+                            requestInfo->info.resourceUri, CA_RESPONSE_DATA);
 
     return OC_STACK_OK;
 }
@@ -396,7 +396,7 @@ OCStackResult HandleKeepAlivePUTRequest(const CAEndpoint_t* endPoint,
     SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_CHANGED, requestInfo->info.type,
                             requestInfo->info.numOptions, requestInfo->info.options,
                             requestInfo->info.token, requestInfo->info.tokenLength,
-                            requestInfo->info.resourceUri);
+                            requestInfo->info.resourceUri, CA_RESPONSE_DATA);
 
     return OC_STACK_OK;
 }