Commit dc3ad3c6 authored by hyuna0213.jo's avatar hyuna0213.jo Committed by Erich Keane

fixed linux, android sample app in CA

- add the payload length
- resolve the compile warning

Change-Id: I2766090765790283afecc05f052ec77b85252334
Signed-off-by: default avatarhyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1658Reviewed-by: default avatarjihwan seo <jihwan.seo@samsung.com>
Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarErich Keane <erich.keane@intel.com>
parent 5abfe2ad
......@@ -328,6 +328,7 @@ Java_org_iotivity_ca_service_RMInterface_RMSendRequest(JNIEnv *env, jobject obj,
return;
}
snprintf(requestData.payload, length, SECURE_INFO_DATA, resourceURI, g_localSecurePort);
requestData.payloadSize = length;
}
else
{
......@@ -343,6 +344,7 @@ Java_org_iotivity_ca_service_RMInterface_RMSendRequest(JNIEnv *env, jobject obj,
return;
}
snprintf(requestData.payload, length, NORMAL_INFO_DATA, resourceURI);
requestData.payloadSize = length;
}
requestData.type = messageType;
......@@ -419,7 +421,8 @@ Java_org_iotivity_ca_service_RMInterface_RMSendReqestToAll(JNIEnv *env, jobject
CAInfo_t requestData = { 0 };
requestData.token = token;
requestData.tokenLength = tokenLength;
requestData.payload = "Temp Json Payload";
requestData.payload = (CAPayload_t) "TempJsonPayload";
requestData.payloadSize = strlen((const char *) requestData.payload);
requestData.type = CA_MSG_NONCONFIRM;
const char* strUri = (*env)->GetStringUTFChars(env, uri, NULL);
......@@ -521,12 +524,14 @@ Java_org_iotivity_ca_service_RMInterface_RMSendResponse(JNIEnv *env, jobject obj
responseData.payload = (CAPayload_t) malloc(length);
sprintf(responseData.payload, SECURE_INFO_DATA, g_resourceUri,
g_localSecurePort);
responseData.payloadSize = length;
}
else
{
uint32_t length = strlen(NORMAL_INFO_DATA) + strlen(g_resourceUri) + 1;
responseData.payload = (CAPayload_t) malloc(length);
sprintf(responseData.payload, NORMAL_INFO_DATA, g_resourceUri);
responseData.payloadSize = length;
}
}
//msgType is RESET
......
......@@ -474,7 +474,9 @@ void send_request()
CADestroyToken(token);
return;
}
snprintf(requestData.payload, length, SECURE_INFO_DATA, resourceURI, g_local_secure_port);
snprintf((char *) requestData.payload, length, SECURE_INFO_DATA,
(const char *) resourceURI, g_local_secure_port);
requestData.payloadSize = length;
}
else
{
......@@ -487,7 +489,9 @@ void send_request()
CADestroyToken(token);
return;
}
snprintf(requestData.payload, length, NORMAL_INFO_DATA, resourceURI);
snprintf((char *) requestData.payload, length, NORMAL_INFO_DATA,
(const char *) resourceURI);
requestData.payloadSize = length;
}
requestData.type = msgType;
CAHeaderOption_t* headerOpt = get_option_data(&requestData);
......@@ -631,7 +635,8 @@ void send_request_all()
CAInfo_t requestData = { 0 };
requestData.token = token;
requestData.tokenLength = tokenLength;
requestData.payload = "Temp Json Payload";
requestData.payload = (CAPayload_t) "TempJsonPayload";
requestData.payloadSize = strlen((const char *) requestData.payload);
requestData.type = CA_MSG_NONCONFIRM;
requestData.resourceUri = (CAURI_t)resourceURI;
......@@ -733,7 +738,8 @@ void send_notification()
CAInfo_t respondData = { 0 };
respondData.token = token;
respondData.tokenLength = tokenLength;
respondData.payload = "Temp Notification Data";
respondData.payload = (CAPayload_t) "TempNotificationData";
respondData.payloadSize = strlen((const char *) respondData.payload);
respondData.type = messageType;
respondData.resourceUri = (CAURI_t)uri;
......@@ -1166,28 +1172,31 @@ void send_response(const CAEndpoint_t *endpoint, const CAInfo_t *info)
{
printf("Sending response on secure communication\n");
uint32_t length = sizeof(SECURE_INFO_DATA);
uint32_t length = sizeof(SECURE_INFO_DATA) + strlen(responseData.resourceUri);
responseData.payload = (CAPayload_t) calloc(length, sizeof(char));
if (NULL == responseData.payload)
{
printf("Memory allocation fail\n");
return;
}
snprintf(responseData.payload, length, SECURE_INFO_DATA, responseData.resourceUri,
g_local_secure_port);
snprintf((char *) responseData.payload, length, SECURE_INFO_DATA,
(const char *) responseData.resourceUri, g_local_secure_port);
responseData.payloadSize = length;
}
else
{
printf("Sending response on non-secure communication\n");
uint32_t length = sizeof(NORMAL_INFO_DATA);
uint32_t length = sizeof(NORMAL_INFO_DATA) + strlen(responseData.resourceUri);
responseData.payload = (CAPayload_t) calloc(length, sizeof(char));
if (NULL == responseData.payload)
{
printf("Memory allocation fail\n");
return;
}
snprintf(responseData.payload, length, NORMAL_INFO_DATA, responseData.resourceUri);
snprintf((char *) responseData.payload, length, NORMAL_INFO_DATA,
(const char *) responseData.resourceUri);
responseData.payloadSize = length;
}
}
......@@ -1225,13 +1234,13 @@ int get_secure_information(CAPayload_t payLoad)
}
char *subString = NULL;
if (NULL == (subString = strstr(payLoad, "\"sec\":1")))
if (NULL == (subString = strstr((const char *) payLoad, "\"sec\":1")))
{
printf("This is not secure resource\n");
return -1;
}
if (NULL == (subString = strstr(payLoad, "\"port\":")))
if (NULL == (subString = strstr((const char *) payLoad, "\"port\":")))
{
printf("This secure resource does not have port information\n");
return -1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment