Commit 9d594906 authored by Ossama Othman's avatar Ossama Othman Committed by Jon A. Cruz

Corrected pointer arithmetic on void* variables.

Octet arrays were represented by void* and char* typed variables in
several areas of the CA layer.  Use uint8_t* where appropriate to
address undefined pointer arithemetic on pointers to void.  Code that
treated the octet arrays as strings (e.g. performed strcpy() on them)
was corrected as well.  This addresses several major issues flagged by
SonarQube.

Change-Id: I8d5c57eafa0b0e394e0ee202df1bb7b67c7a59b1
Signed-off-by: default avatarOssama Othman <ossama.othman@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2034Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarJon A. Cruz <jonc@osg.samsung.com>
parent 05cc84d9
......@@ -67,7 +67,7 @@ typedef enum
typedef struct
{
CAEndpoint_t *remoteEndpoint; /**< Remote Endpoint. */
void *data; /**< Data to be sent. */
uint8_t *data; /**< Data to be sent. */
uint32_t dataLen; /**< Length of the data to be sent. */
} CAEDRData;
......@@ -88,7 +88,7 @@ typedef struct
* @param[out] sentLength Length of the sent data.
* @pre Callback must be registered using CAEDRSetPacketReceivedCallback().
*/
typedef void (*CAEDRDataReceivedCallback)(const char *remoteAddress, const void *data,
typedef void (*CAEDRDataReceivedCallback)(const char *remoteAddress, const uint8_t *data,
uint32_t dataLength, uint32_t *sentLength);
/**
......@@ -105,8 +105,10 @@ typedef void (*CAEDRNetworkStatusCallback)(CANetworkStatus_t status);
* @param[in] result error code as defined in ::CAResult_t.
* @pre Callback must be registered using CAEDRSetPacketReceivedCallback().
*/
typedef void (*CAEDRErrorHandleCallback)(const char *remoteAddress, const void *data,
uint32_t dataLength, CAResult_t result);
typedef void (*CAEDRErrorHandleCallback)(const char *remoteAddress,
const uint8_t *data,
uint32_t dataLength,
CAResult_t result);
/**
* Initialize the network monitor module
......@@ -263,7 +265,8 @@ CAResult_t CAEDRGetAdapterEnableState(bool *state);
* @param[in] dataLength Length of the data to be sent.
* @return ::CA_STATUS_OK or Appropriate error code.
*/
CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const void *data,
CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress,
const uint8_t *data,
uint32_t dataLength);
/**
......@@ -272,7 +275,8 @@ CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const void *dat
* @param[in] dataLength Length of the data to be sent.
* @return ::CA_STATUS_OK or Appropriate error code.
*/
CAResult_t CAEDRClientSendMulticastData(const void *data, uint32_t dataLength);
CAResult_t CAEDRClientSendMulticastData(const uint8_t *data,
uint32_t dataLength);
/**
* This function gets bonded bluetooth device list
......
......@@ -123,43 +123,47 @@ extern "C"
/**
* This function is used to generate the CA specific header to
* maintain the fragmentation logic. The header structure
* explained above will be formed and returned to the caller.
* maintain the fragmentation logic. The header structure explained
* above will be formed and returned to the caller.
*
* @param[in,out] header Pointer to the octet array that will contain
* the generated header.
* @param[in] length The total length of the data. The length will
* be embedded in bits 5-16 of the header,
* meaning the maximum overall length of the
* data to be fragmented can be no more than 4096
* (2^12).
* @param[in,out] header Pointer to the octet array that will
* contain the generated header.
* @param[in] headerLength Length of the @a header octet array.
* @param[in] dataLength The total length of the data. The
* length will be embedded in bits 5-16 of
* the header, meaning the maximum overall
* length of the data to be fragmented can
* be no more than 4096 (2^12).
*
* @return ::CA_STATUS_OK on success. One of the ::CA_STATUS_FAILED or
* other error values on error.
* @retval ::CA_STATUS_OK Successful
* @retval ::CA_STATUS_INVALID_PARAM Invalid input arguments
* @retval ::CA_STATUS_FAILED Operation failed
*/
CAResult_t CAGenerateHeader(char *header, uint32_t length);
/**
* This function is used to parse the header in the receiver
* end. This function will provide the information of the total
* length of the data which has been fragmented.
* @return @c CA_STATUS_OK on success. One of the @c CA_STATUS_FAILED
* or other error values on error.
* @retval @c CA_STATUS_OK Successful
* @retval @c CA_STATUS_INVALID_PARAM Invalid input arguments
* @retval @c CA_STATUS_FAILED Operation failed
*/
CAResult_t CAGenerateHeader(uint8_t *header,
size_t headerLength,
size_t datalength);
/**
* This function is used to parse the header in the receiver end. This
* function will provide the information of the total length of the
* data which has been fragmented.
*
* @param[in] header Pointer to the octet array data which contains the
* header information. Note that pointer should
* @param[in] header Pointer to the octet array data which contains
* the header information. Note that pointer should
* point to two bytes of data header which needs to
* be parsed.
* @param[in] length Length of the @a octet array containing the
* header.
*
* @return Overall length of the data to be reassembled, or 0 on
* failure.
*/
uint32_t CAParseHeader(const char *header);
uint32_t CAParseHeader(const uint8_t *header, size_t length);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* CA_FRAGMENTATION_H_ */
......@@ -19,6 +19,8 @@
******************************************************************/
/**
* @file
*
* This file provides APIs for BLE modules.
*/
......@@ -68,7 +70,7 @@ typedef void (*CALEDeviceStateChangedCallback)(CAAdapterState_t adapter_state);
* @retval ::CA_STATUS_FAILED Operation failed.
*/
typedef CAResult_t (*CABLEDataReceivedCallback)(const char *remoteAddress,
const void *data,
const uint8_t *data,
uint32_t dataLength,
uint32_t *sentLength);
......@@ -207,9 +209,9 @@ void CASetLEReqRespServerCallback(CABLEDataReceivedCallback callback);
* Update characteristics(Read/Write) value that we want to send to
* particular client.
*
* @param[in] address BD address of Gatt client
* @param[in] charValue Data that we want to send to client(unicast)
* @param[in] charValueLen Length of the data.
* @param[in] address BD address of Gatt client
* @param[in] value Data that we want to send to client(unicast)
* @param[in] valueLen Length of the data.
*
* @return ::CA_STATUS_OK or Appropriate error code
* @retval ::CA_STATUS_OK Successful
......@@ -217,23 +219,23 @@ void CASetLEReqRespServerCallback(CABLEDataReceivedCallback callback);
* @retval ::CA_STATUS_FAILED Operation failed
*/
CAResult_t CAUpdateCharacteristicsToGattClient(const char *address,
const char *charValue,
uint32_t charValueLen);
const uint8_t *value,
uint32_t valueLen);
/**
* Update characteristics(Read/Write) value that we want to multicast
* to all clients.
*
* @param[in] charValue Data that we want to send to clients(multicast)
* @param[in] charValueLen Length of the data.
* @param[in] value Data that we want to send to clients(multicast)
* @param[in] valueLen Length of the data.
*
* @return ::CA_STATUS_OK or Appropriate error code
* @retval ::CA_STATUS_OK Successful
* @retval ::CA_STATUS_INVALID_PARAM Invalid input arguments
* @retval ::CA_STATUS_FAILED Operation failed
*/
CAResult_t CAUpdateCharacteristicsToAllGattClients(const char *charValue,
uint32_t charValueLen);
CAResult_t CAUpdateCharacteristicsToAllGattClients(const uint8_t *value,
uint32_t valueLen);
/**
* Start @c CAStartBleGattClientThread for initializing Gatt Client.
......@@ -283,7 +285,7 @@ void CACheckLEData();
* @retval ::CA_STATUS_FAILED Operation failed
*/
CAResult_t CAUpdateCharacteristicsToGattServer(const char *remoteAddress,
const char *data,
const uint8_t *data,
uint32_t dataLen,
CALETransferType_t type,
int32_t position);
......@@ -300,7 +302,7 @@ CAResult_t CAUpdateCharacteristicsToGattServer(const char *remoteAddress,
* @retval ::CA_STATUS_INVALID_PARAM Invalid input arguments
* @retval ::CA_STATUS_FAILED Operation failed
*/
CAResult_t CAUpdateCharacteristicsToAllGattServers(const char *data,
CAResult_t CAUpdateCharacteristicsToAllGattServers(const uint8_t *data,
uint32_t dataLen);
/**
......@@ -353,7 +355,7 @@ CAResult_t CAUnSetLEAdapterStateChangedCb();
* @param[in] result error code as per CAResult_t
*/
typedef void (*CABLEErrorHandleCallback)(const char *remoteAddress,
const void *data,
const uint8_t *data,
uint32_t dataLength,
CAResult_t result);
/**
......
......@@ -26,43 +26,61 @@
#include "cafragmentation.h"
/**
* @var CA_FRAGMENTATION_TAG
* @brief debugging tag for fragmentation module
* Debugging tag for fragmentation module.
*/
#define CA_FRAGMENTATION_TAG "CA_FRAGMENTATION"
CAResult_t CAGenerateHeader(char *header, uint32_t length)
CAResult_t CAGenerateHeader(uint8_t *header,
size_t headerLength,
size_t dataLength)
{
OIC_LOG(DEBUG, CA_FRAGMENTATION_TAG, "IN");
VERIFY_NON_NULL(header, CA_FRAGMENTATION_TAG, "header is NULL");
memset(header, 0x0, sizeof(char) * CA_HEADER_LENGTH);
if(length > MAX_DATA_LENGTH_SUPPORTED)
if (headerLength < CA_HEADER_LENGTH)
{
OIC_LOG(DEBUG, CA_FRAGMENTATION_TAG,
"Given length is more than 4095.It will be truncated");
return CA_STATUS_FAILED;
}
//if length is more than 4095 then it will be truncated.
header[1] = length & 0xFF;
length >>= 8;
header[0] = length & 0x0F;
header[0] = header[0] | 0x40; // Adding version 0100.(Not used. Future use)
if (dataLength > MAX_DATA_LENGTH_SUPPORTED)
{
OIC_LOG_V(WARNING,
CA_FRAGMENTATION_TAG,
"Given length is more than %d. It will be truncated.",
MAX_DATA_LENGTH_SUPPORTED);
}
// Only bother initializing the header section of the buffer. It
// is up to the caller to handle the data section.
memset(header, 0, CA_HEADER_LENGTH);
// If length is more than 4095 then it will be truncated.
header[1] = dataLength & 0xFF;
dataLength >>= 8;
header[0] = dataLength & 0x0F;
header[0] = header[0] | 0x40; // Adding version 0100.
// (Not used. Future use)
OIC_LOG(DEBUG, CA_FRAGMENTATION_TAG, "OUT");
return CA_STATUS_OK;
}
uint32_t CAParseHeader(const char *header)
uint32_t CAParseHeader(const uint8_t *header, size_t length)
{
OIC_LOG(DEBUG, CA_FRAGMENTATION_TAG, "IN");
VERIFY_NON_NULL_RET(header, CA_FRAGMENTATION_TAG, "header is NULL", 0);
uint32_t dataLen = ((header[0] & 0x0F) << 8) | (header[1] & 0xFF);
uint32_t dataLen = 0;
if (length >= CA_HEADER_LENGTH)
{
dataLen = ((header[0] & 0x0F) << 8) | (header[1] & 0xFF);
}
OIC_LOG(DEBUG, CA_FRAGMENTATION_TAG, "OUT");
return dataLen;
}
......@@ -102,21 +102,24 @@ void CAAdapterTerminateQueues();
void CAAdapterDataSendHandler(void *context);
void CAAdapterDataReceiverHandler(void *context);
CAResult_t CAAdapterStopQueue();
void CAAdapterRecvData(const char *remoteAddress, const void *data, uint32_t dataLength,
void CAAdapterRecvData(const char *remoteAddress, const uint8_t *data, uint32_t dataLength,
uint32_t *sentLength);
void CAEDRNotifyNetworkStatus(CANetworkStatus_t status);
void CAEDROnNetworkStatusChanged(void *context);
CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID, const void *data,
CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID, const uint8_t *data,
uint32_t dataLength, uint32_t *sentLength);
CAEDRNetworkEvent *CAEDRCreateNetworkEvent(CAEndpoint_t *connectivity,
CANetworkStatus_t status);
CAResult_t CAEDRClientSendData(const char *remoteAddress, const void *data,
CAResult_t CAEDRClientSendData(const char *remoteAddress,
const uint8_t *data,
uint32_t dataLength);
/**
* @fn CACreateEDRData
* @brief Helper function to create CAEDRData
*/
static CAEDRData *CACreateEDRData(const CAEndpoint_t *remoteEndpoint, const void *data,
static CAEDRData *CACreateEDRData(const CAEndpoint_t *remoteEndpoint, const uint8_t *data,
uint32_t dataLength);
/**
......@@ -133,7 +136,7 @@ void CAEDRFreeNetworkEvent(CAEDRNetworkEvent *event);
static void CAEDRDataDestroyer(void *data, uint32_t size);
static void CAEDRErrorHandler(const char *remoteAddress, const void *data,
static void CAEDRErrorHandler(const char *remoteAddress, const uint8_t *data,
uint32_t dataLength, CAResult_t result);
CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
......@@ -549,7 +552,8 @@ void CAAdapterDataSendHandler(void *context)
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
}
CAResult_t CAEDRClientSendData(const char *remoteAddress, const void *data,
CAResult_t CAEDRClientSendData(const char *remoteAddress,
const uint8_t *data,
uint32_t dataLength)
{
......@@ -641,7 +645,7 @@ CAResult_t CAAdapterStopQueue()
return CA_STATUS_OK;
}
void CAAdapterRecvData(const char *remoteAddress, const void *data, uint32_t dataLength,
void CAAdapterRecvData(const char *remoteAddress, const uint8_t *data, uint32_t dataLength,
uint32_t *sentLength)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
......@@ -678,7 +682,7 @@ void CAAdapterRecvData(const char *remoteAddress, const void *data, uint32_t dat
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
}
void CAEDRErrorHandler(const char *remoteAddress, const void *data,
void CAEDRErrorHandler(const char *remoteAddress, const uint8_t *data,
uint32_t dataLength, CAResult_t result)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
......@@ -703,7 +707,7 @@ void CAEDRErrorHandler(const char *remoteAddress, const void *data,
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
}
CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID, const void *data,
CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID, const uint8_t *data,
uint32_t dataLength, uint32_t *sentLength)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN - CAAdapterSendData");
......@@ -857,7 +861,7 @@ void CAEDRFreeNetworkEvent(CAEDRNetworkEvent *event)
}
CAEDRData *CACreateEDRData(const CAEndpoint_t *remoteEndpoint,
const void *data, uint32_t dataLength)
const uint8_t *data, uint32_t dataLength)
{
CAEDRData *edrData = (CAEDRData *)OICMalloc(sizeof (CAEDRData));
if (!edrData)
......
......@@ -583,7 +583,8 @@ void CAEDRClientDisconnectAll(void)
}
CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const void *data,
CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress,
const uint8_t *data,
uint32_t dataLength)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
......@@ -681,7 +682,8 @@ CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const void *dat
return CA_STATUS_OK;
}
CAResult_t CAEDRClientSendMulticastData(const void *data, uint32_t dataLength)
CAResult_t CAEDRClientSendMulticastData(const uint8_t *data,
uint32_t dataLength)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
......@@ -846,8 +848,10 @@ void CAEDRDataRecvCallback(bt_socket_received_data_s *data, void *userData)
uint32_t sentLength = 0;
g_edrPacketReceivedCallback(device->remoteAddress, data->data,
(uint32_t)data->data_size, &sentLength);
g_edrPacketReceivedCallback(device->remoteAddress,
(uint8_t *) data->data,
(uint32_t) data->data_size,
&sentLength);
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
}
......@@ -348,19 +348,21 @@ void CALEClientSendFinish(JNIEnv *env, jobject gatt)
CALEClientUpdateSendCnt(env);
}
CAResult_t CALEClientSendUnicastMessage(const char* address, const char* data,
CAResult_t CALEClientSendUnicastMessage(const char* address,
const uint8_t* data,
const uint32_t dataLen)
{
OIC_LOG_V(DEBUG, TAG, "CALEClientSendUnicastMessage(%s, %s)", address, data);
OIC_LOG_V(DEBUG, TAG, "CALEClientSendUnicastMessage(%s, %p)", address, data);
VERIFY_NON_NULL(address, TAG, "address is null");
VERIFY_NON_NULL(data, TAG, "data is null");
return CALEClientSendUnicastMessageImpl(address, data, dataLen);
}
CAResult_t CALEClientSendMulticastMessage(const char* data, const uint32_t dataLen)
CAResult_t CALEClientSendMulticastMessage(const uint8_t* data,
const uint32_t dataLen)
{
OIC_LOG_V(DEBUG, TAG, "CALEClientSendMulticastMessage(%s)", data);
OIC_LOG_V(DEBUG, TAG, "CALEClientSendMulticastMessage(%p)", data);
VERIFY_NON_NULL(data, TAG, "data is null");
if (!g_jvm)
......@@ -480,10 +482,10 @@ void CASetBLEClientErrorHandleCallback(CABLEErrorHandleCallback callback)
g_clientErrorCallback = callback;
}
CAResult_t CALEClientSendUnicastMessageImpl(const char* address, const char* data,
CAResult_t CALEClientSendUnicastMessageImpl(const char* address, const uint8_t* data,
const uint32_t dataLen)
{
OIC_LOG_V(DEBUG, TAG, "CALEClientSendUnicastMessageImpl, address: %s, data: %s", address,
OIC_LOG_V(DEBUG, TAG, "CALEClientSendUnicastMessageImpl, address: %s, data: %p", address,
data);
VERIFY_NON_NULL(address, TAG, "address is null");
VERIFY_NON_NULL(data, TAG, "data is null");
......@@ -619,10 +621,10 @@ error_exit:
return CA_SEND_FAILED;
}
CAResult_t CALEClientSendMulticastMessageImpl(JNIEnv *env, const char* data,
CAResult_t CALEClientSendMulticastMessageImpl(JNIEnv *env, const uint8_t* data,
const uint32_t dataLen)
{
OIC_LOG_V(DEBUG, TAG, "CASendMulticastMessageImpl, send to, data: %s, %d", data, dataLen);
OIC_LOG_V(DEBUG, TAG, "CASendMulticastMessageImpl, send to, data: %p, %u", data, dataLen);
VERIFY_NON_NULL(data, TAG, "data is null");
VERIFY_NON_NULL(env, TAG, "env is null");
......@@ -673,7 +675,7 @@ CAResult_t CALEClientSendMulticastMessageImpl(JNIEnv *env, const char* data,
res = CALEClientSendData(env, jarrayObj);
if (res != CA_STATUS_OK)
{
OIC_LOG(ERROR, TAG, "BT device[%d] - send has failed");
OIC_LOG(ERROR, TAG, "BT device - send has failed");
}
jstring jni_address = CALEGetAddressFromBTDevice(env, jarrayObj);
......@@ -3121,7 +3123,7 @@ void CATerminateLEGattClient()
CALEClientTerminate();
}
CAResult_t CAUpdateCharacteristicsToGattServer(const char *remoteAddress, const char *data,
CAResult_t CAUpdateCharacteristicsToGattServer(const char *remoteAddress, const uint8_t *data,
uint32_t dataLen, CALETransferType_t type,
int32_t position)
{
......@@ -3138,7 +3140,7 @@ CAResult_t CAUpdateCharacteristicsToGattServer(const char *remoteAddress, const
return CALEClientSendUnicastMessage(remoteAddress, data, dataLen);
}
CAResult_t CAUpdateCharacteristicsToAllGattServers(const char *data, uint32_t dataLen)
CAResult_t CAUpdateCharacteristicsToAllGattServers(const uint8_t *data, uint32_t dataLen)
{
OIC_LOG(DEBUG, TAG, "call CALEClientSendMulticastMessage");
VERIFY_NON_NULL(data, TAG, "data is null");
......@@ -3521,24 +3523,23 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicChangedCallback(
VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null");
VERIFY_NON_NULL_VOID(data, TAG, "data is null");
// get Byte Array and covert to char*
// get Byte Array and convert to uint8_t*
jint length = (*env)->GetArrayLength(env, data);
jboolean isCopy;
jbyte *jni_byte_responseData = (jbyte*) (*env)->GetByteArrayElements(env, data, &isCopy);
OIC_LOG_V(DEBUG, TAG, "CALeGattCharacteristicChangedCallback - raw data received : %s",
OIC_LOG_V(DEBUG, TAG, "CALeGattCharacteristicChangedCallback - raw data received : %p",
jni_byte_responseData);
char* receivedData = (char*) OICMalloc(sizeof(char) * length + 1);
uint8_t* receivedData = OICMalloc(length);
if (!receivedData)
{
OIC_LOG(ERROR, TAG, "recevicedData is null");
OIC_LOG(ERROR, TAG, "receivedData is null");
return;
}
memcpy(receivedData, (const char*) jni_byte_responseData, length);
receivedData[length] = '\0';
memcpy(receivedData, jni_byte_responseData, length);
(*env)->ReleaseByteArrayElements(env, data, jni_byte_responseData, JNI_ABORT);
jstring jni_address = CALEClientGetAddressFromGattObj(env, gatt);
......@@ -3557,7 +3558,7 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicChangedCallback(
return;
}
OIC_LOG_V(DEBUG, TAG, "CALeGattCharacteristicChangedCallback - data. : %s, %d",
OIC_LOG_V(DEBUG, TAG, "CALeGattCharacteristicChangedCallback - data. : %p, %d",
receivedData, length);
ca_mutex_lock(g_bleServerBDAddressMutex);
......
......@@ -60,7 +60,7 @@ typedef struct le_state_info
* @param[in] data Data received from remote device.
* @pre Callback must be registered using CALESetCallback(CAPacketReceiveCallback callback)
*/
typedef void (*CAPacketReceiveCallback)(const char *address, const char *data);
typedef void (*CAPacketReceiveCallback)(const char *address, const uint8_t *data);
/**
* initialize JNI object.
......@@ -104,7 +104,7 @@ void CALEClientSendFinish(JNIEnv *env, jobject gatt);
* @param[in] dataLen data length.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
CAResult_t CALEClientSendUnicastMessage(const char *address, const char *data,
CAResult_t CALEClientSendUnicastMessage(const char *address, const uint8_t *data,
const uint32_t dataLen);
/**
......@@ -113,7 +113,7 @@ CAResult_t CALEClientSendUnicastMessage(const char *address, const char *data,
* @param[in] dataLen data length.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
CAResult_t CALEClientSendMulticastMessage(const char *data, const uint32_t dataLen);
CAResult_t CALEClientSendMulticastMessage(const uint8_t *data, const uint32_t dataLen);
/**
* start unicast server.
......@@ -152,7 +152,7 @@ void CALEClientSetCallback(CAPacketReceiveCallback callback);
* @param[in] dataLen data length.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
CAResult_t CALEClientSendUnicastMessageImpl(const char *address, const char *data,
CAResult_t CALEClientSendUnicastMessageImpl(const char *address, const uint8_t *data,
const uint32_t dataLen);
/**
......@@ -162,7 +162,7 @@ CAResult_t CALEClientSendUnicastMessageImpl(const char *address, const char *dat
* @param[in] dataLen data length.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
CAResult_t CALEClientSendMulticastMessageImpl(JNIEnv *env, const char *data,
CAResult_t CALEClientSendMulticastMessageImpl(JNIEnv *env, const uint8_t *data,
const uint32_t dataLen);
/**
......
......@@ -1506,9 +1506,9 @@ void CALEServerTerminate()
OIC_LOG(DEBUG, TAG, "OUT - CALEServerTerminate");
}
CAResult_t CALEServerSendUnicastMessage(const char* address, const char* data, uint32_t dataLen)
CAResult_t CALEServerSendUnicastMessage(const char* address, const uint8_t* data, uint32_t dataLen)
{
OIC_LOG_V(DEBUG, TAG, "IN - CALEServerSendUnicastMessage(%s, %s)", address, data);
OIC_LOG_V(DEBUG, TAG, "IN - CALEServerSendUnicastMessage(%s, %p)", address, data);
VERIFY_NON_NULL(address, TAG, "address is null");
VERIFY_NON_NULL(data, TAG, "data is null");
......@@ -1549,9 +1549,9 @@ CAResult_t CALEServerSendUnicastMessage(const char* address, const char* data, u
return ret;
}
CAResult_t CALEServerSendMulticastMessage(const char* data, uint32_t dataLen)
CAResult_t CALEServerSendMulticastMessage(const uint8_t* data, uint32_t dataLen)
{
OIC_LOG_V(DEBUG, TAG, "IN - CALEServerSendMulticastMessage(%s)", data);
OIC_LOG_V(DEBUG, TAG, "IN - CALEServerSendMulticastMessage(%p)", data);
VERIFY_NON_NULL(data, TAG, "data is null");
if (!g_jvm)
......@@ -1710,10 +1710,10 @@ void CALEServerSetCallback(CAPacketReceiveCallback callback)
g_packetReceiveCallback = callback;
}
CAResult_t CALEServerSendUnicastMessageImpl(JNIEnv *env, const char* address, const char* data,
CAResult_t CALEServerSendUnicastMessageImpl(JNIEnv *env, const char* address, const uint8_t* data,
uint32_t dataLen)
{
OIC_LOG_V(DEBUG, TAG, "IN - CALEServerSendUnicastMessageImpl, address: %s, data: %s",
OIC_LOG_V(DEBUG, TAG, "IN - CALEServerSendUnicastMessageImpl, address: %s, data: %p",
address, data);
VERIFY_NON_NULL(env, TAG, "env is null");
VERIFY_NON_NULL(address, TAG, "address is null");
......@@ -1785,7 +1785,7 @@ CAResult_t CALEServerSendUnicastMessageImpl(JNIEnv *env, const char* address, co
return CA_STATUS_OK;
}
CAResult_t CALEServerSendMulticastMessageImpl(JNIEnv *env, const char *data, uint32_t dataLen)
CAResult_t CALEServerSendMulticastMessageImpl(JNIEnv *env, const uint8_t *data, uint32_t dataLen)
{
OIC_LOG_V(DEBUG, TAG, "IN - CALEServerSendMulticastMessageImpl, send to, data: %s", data);
VERIFY_NON_NULL(env, TAG, "env is null");
......@@ -2210,22 +2210,21 @@ Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerCharacteristicWriteReques
VERIFY_NON_NULL_VOID(device, TAG, "device");
VERIFY_NON_NULL_VOID(data, TAG, "data");
// get Byte Array and covert to char*
// get Byte Array and covert to uint8_t*
jint length = (*env)->GetArrayLength(env, data);