Fixed wrong address conversion of ip information
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Tue, 16 Aug 2016 08:22:46 +0000 (17:22 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Fri, 19 Aug 2016 10:51:28 +0000 (10:51 +0000)
Fixed wrong address conversion of ip information

Change-Id: I8c730ae9ca0efcef51d3e9f90e24f24d3a90bd8b
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10495
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c

index 64bc8aa90a1511e59ef9d6be0347e91977784b46..24c82248a179165bf4595889c5469ec7cf5cbb63 100644 (file)
@@ -123,8 +123,6 @@ CAInterface_t *CAFindInterfaceChange()
     {
         struct ifreq* item = &ifr[i];
         char *name = item->ifr_name;
-        struct sockaddr_in *sa4 = (struct sockaddr_in *)&item->ifr_addr;
-        uint32_t ipv4addr = sa4->sin_addr.s_addr;
 
         if (ioctl(s, SIOCGIFFLAGS, item) < 0)
         {
@@ -167,7 +165,12 @@ CAInterface_t *CAFindInterfaceChange()
             continue;
         }
 
-        foundNewInterface = CANewInterfaceItem(ifIndex, name, AF_INET, ipv4addr, flags);
+        // Get address of network interface.
+        char addr[MAX_ADDR_STR_SIZE_CA] = { 0 };
+        struct sockaddr_in *sa = (struct sockaddr_in *)&item->ifr_addr;
+        inet_ntop(AF_INET, (void *)&(sa->sin_addr), addr, sizeof(addr));
+
+        foundNewInterface = CANewInterfaceItem(ifIndex, name, AF_INET, addr, flags);
     }
 
     OICFree(previous);