Support secure network info in CAGetNetworkInformation
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Thu, 6 Apr 2017 10:25:40 +0000 (19:25 +0900)
committerZiran Sun <ziran.sun@samsung.com>
Wed, 12 Apr 2017 09:11:12 +0000 (09:11 +0000)
Secured network interface information should be provided

Change-Id: I65fe446d84ed67e00486782901b8b9f07f47c32c
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18565
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Ziran Sun <ziran.sun@samsung.com>
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c

index 22d3b5d..da65231 100644 (file)
@@ -1314,6 +1314,11 @@ CAResult_t CAGetTCPInterfaceInformation(CAEndpoint_t **info, size_t *size)
     }
 
     size_t len = u_arraylist_length(iflist);
+    size_t length = len;
+
+#ifdef __WITH_TLS__
+    length = len * 2;
+#endif
 
     CAEndpoint_t *ep = (CAEndpoint_t *)OICCalloc(len, sizeof (CAEndpoint_t));
     if (!ep)
@@ -1349,6 +1354,25 @@ CAResult_t CAGetTCPInterfaceInformation(CAEndpoint_t **info, size_t *size)
             continue;
         }
         OICStrcpy(ep[j].addr, sizeof(ep[j].addr), ifitem->addr);
+
+#ifdef __WITH_TLS__
+        j++;
+
+        ep[j].adapter = CA_ADAPTER_TCP;
+        ep[j].ifindex = ifitem->index;
+
+        if (ifitem->family == AF_INET6)
+        {
+            ep[j].flags = CA_IPV6 | CA_SECURE;
+            ep[j].port = caglobals.tcp.ipv6s.port;
+        }
+        else
+        {
+            ep[j].flags = CA_IPV4 | CA_SECURE;
+            ep[j].port = caglobals.tcp.ipv4s.port;
+        }
+        OICStrcpy(ep[j].addr, sizeof(ep[j].addr), ifitem->addr);
+#endif
         j++;
     }