fixed linux, android ca sample application
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Tue, 21 Jul 2015 06:39:03 +0000 (15:39 +0900)
committerErich Keane <erich.keane@intel.com>
Wed, 22 Jul 2015 05:35:46 +0000 (05:35 +0000)
after 'New IP Adapter supports IPv6' changes,
ca sample is not working. so I fixed the issue.

Change-Id: Idadf0e5ecfdd3433d8e598c9d3af392e2ffb6a0b
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1752
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/samples/android/casample/sampleService/src/main/jni/ResourceModel.c
resource/csdk/connectivity/samples/linux/sample_main.c

index 774a06d..5dc1424 100755 (executable)
@@ -395,7 +395,7 @@ Java_org_iotivity_ca_service_RMInterface_RMSendReqestToAll(JNIEnv *env, jobject
 
     // create remote endpoint
     CAEndpoint_t *endpoint = NULL;
-    res = CACreateEndpoint(CA_DEFAULT_FLAGS, g_selectedNwType, NULL, 0, &endpoint);
+    res = CACreateEndpoint(CA_IPV4, g_selectedNwType, NULL, 0, &endpoint);
 
     if (CA_STATUS_OK != res)
     {
@@ -1299,7 +1299,7 @@ void parsing_coap_uri(const char* uri, addressSet_t* address, CATransportFlags_t
     {
         LOGI("uri has '%s' prefix", COAP_PREFIX);
         startIndex = COAP_PREFIX_LEN;
-        *flags = CA_DEFAULT_FLAGS;
+        *flags = CA_IPV4;
     }
 
     // #2. copy uri for parse
index edfe4ef..2f9e2b7 100644 (file)
@@ -600,23 +600,14 @@ void send_request_all()
     }
 
     // create remote endpoint
-    CAEndpoint_t *endpoint = NULL;
-    res = CACreateEndpoint(0, g_selected_nw_type, NULL, 0, &endpoint);
+    CAEndpoint_t *group = NULL;
+    res = CACreateEndpoint(CA_IPV4, g_selected_nw_type, NULL, 0, &group);
     if (CA_STATUS_OK != res)
     {
         printf("Create remote endpoint error, error code: %d\n", res);
         return;
     }
 
-    CAEndpoint_t *group = (CAEndpoint_t *) malloc(sizeof(CAEndpoint_t));
-    if (NULL == group)
-    {
-        printf("Memory allocation failed!\n");
-        CADestroyEndpoint(endpoint);
-        return;
-    }
-    group->adapter = endpoint->adapter;
-
     // create token
     CAToken_t token = NULL;
     uint8_t tokenLength = CA_MAX_TOKEN_LEN;
@@ -625,8 +616,7 @@ void send_request_all()
     if ((CA_STATUS_OK != res) || (!token))
     {
         printf("Token generate error!!\n");
-        CADestroyEndpoint(endpoint);
-        free(group);
+        CADestroyEndpoint(group);
         return;
     }
 
@@ -666,8 +656,7 @@ void send_request_all()
     }
 
     // destroy remote endpoint
-    CADestroyEndpoint(endpoint);
-    free(group);
+    CADestroyEndpoint(group);
 
     printf("=============================================\n");
 }
@@ -1412,7 +1401,7 @@ void parsing_coap_uri(const char* uri, addressSet_t* address, CATransportFlags_t
     {
         printf("uri has '%s' prefix\n", COAP_PREFIX);
         startIndex = COAP_PREFIX_LEN;
-        *flags = CA_DEFAULT_FLAGS;
+        *flags = CA_IPV4;
     }
 
     // #2. copy uri for parse