[IOT-1528]update file path and remove static analysis warring
authorbg.chun <bg.chun@samsung.com>
Wed, 9 Nov 2016 08:49:16 +0000 (17:49 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Mon, 21 Nov 2016 16:32:26 +0000 (16:32 +0000)
update file path(ifaddrs.x -> caifaddrs.x)
and fix netlink usage for remove static analysis warring

Change-Id: I672d9ba1250710cc10c66cbbde56b6b12afc15e8
Signed-off-by: bg.chun <bg.chun@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14153
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/connectivity/src/ip_adapter/android/SConscript
resource/csdk/connectivity/src/ip_adapter/android/caifaddrs.c [moved from resource/csdk/connectivity/src/ip_adapter/android/ifaddrs.c with 79% similarity]
resource/csdk/connectivity/src/ip_adapter/android/caifaddrs.h [new file with mode: 0644]
resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c
resource/csdk/connectivity/src/ip_adapter/android/ifaddrs.h [deleted file]
resource/csdk/connectivity/src/ip_adapter/linux/caipnwmonitor.c
resource/csdk/connectivity/src/ip_adapter/tizen/caipnwmonitor.c

index b1a6a52..9e33ff5 100644 (file)
@@ -8,6 +8,6 @@ import os.path
 env.AppendUnique(CPPPATH = [ os.path.join(src_dir, 'android') ])
 
 src_files = [ 'caipnwmonitor.c',
-              'ifaddrs.c' ]
+              'caifaddrs.c' ]
 
 Return('src_files')
@@ -1,24 +1,24 @@
-/******************************************************************
-*
-* Copyright 2014 Samsung Electronics All Rights Reserved.
-*
-*
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-******************************************************************/
-
-#include "ifaddrs.h"
+/* *****************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#include "caifaddrs.h"
 
 #include <stdbool.h>
 #include <string.h>
@@ -155,10 +155,21 @@ CAResult_t CAGetIfaddrsUsingNetlink(struct ifaddrs **ifap)
     while (1)
     {
         char recvBuf[NETLINK_MESSAGE_LENGTH] = {0};
-        int len = recv(netlinkFd, recvBuf, sizeof(recvBuf), 0);
-        struct nlmsghdr *recvMsg = (struct nlmsghdr*)recvBuf;
+        struct nlmsghdr *recvMsg = NULL;
         struct ifaddrs *node = NULL;
-        for (; NLMSG_OK(recvMsg, len); recvMsg = NLMSG_NEXT(recvMsg, len))
+        struct sockaddr_nl sa = { .nl_family = 0 };
+        struct iovec iov = { .iov_base = recvBuf,
+                         .iov_len = sizeof (recvBuf) };
+
+        struct msghdr msg = { .msg_name = (void *)&sa,
+                          .msg_namelen = sizeof (sa),
+                          .msg_iov = &iov,
+                          .msg_iovlen = 1 };
+
+        ssize_t len = recvmsg(netlinkFd, &msg, 0);
+
+        for (recvMsg = (struct nlmsghdr *)recvBuf; NLMSG_OK(recvMsg, len);
+             recvMsg = NLMSG_NEXT(recvMsg, len))
         {
             switch (recvMsg->nlmsg_type)
             {
diff --git a/resource/csdk/connectivity/src/ip_adapter/android/caifaddrs.h b/resource/csdk/connectivity/src/ip_adapter/android/caifaddrs.h
new file mode 100644 (file)
index 0000000..a576af6
--- /dev/null
@@ -0,0 +1,47 @@
+/* *****************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+#include "cacommon.h"
+
+/**
+ * CA partial define for the structure ifaddrs.
+ */
+struct ifaddrs
+{
+    struct ifaddrs     *ifa_next;
+    char               *ifa_name;
+    unsigned int       ifa_flags;
+    struct sockaddr    *ifa_addr;
+};
+
+/**
+ * CA internal definition for getifaddrs.
+ *
+ * @param[out]  ifap    List of ifaddrs.
+ * @return  On success, returns CA_STATUS_OK; on error, CA error code is returned.
+ */
+CAResult_t CAGetIfaddrsUsingNetlink(struct ifaddrs **ifap);
+
+/**
+ * CA internal definition for freeifaddrs
+ *
+ * @param[in]  ifa      List of ifaddrs.
+ */
+void CAFreeIfAddrs(struct ifaddrs *ifa);
+
index 3fbc3c8..781bcf3 100644 (file)
@@ -39,7 +39,7 @@
 #include "oic_malloc.h"
 #include "oic_string.h"
 #include "org_iotivity_ca_CaIpInterface.h"
-#include "ifaddrs.h"
+#include "caifaddrs.h"
 
 #define TAG "OIC_CA_IP_MONITOR"
 #define NETLINK_MESSAGE_LENGTH  (4096)
@@ -194,7 +194,7 @@ u_arraylist_t *CAFindInterfaceChange()
                           .msg_iov = &iov,
                           .msg_iovlen = 1 };
 
-    size_t len = recvmsg(caglobals.ip.netlinkFd, &msg, 0);
+    ssize_t len = recvmsg(caglobals.ip.netlinkFd, &msg, 0);
     return NULL;
 }
 
diff --git a/resource/csdk/connectivity/src/ip_adapter/android/ifaddrs.h b/resource/csdk/connectivity/src/ip_adapter/android/ifaddrs.h
deleted file mode 100644 (file)
index cee33c5..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/******************************************************************
-*
-* Copyright 2014 Samsung Electronics All Rights Reserved.
-*
-*
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-******************************************************************/
-#include "cacommon.h"
-
-/**
- * CA partial define for the structure ifaddrs.
- */
-struct ifaddrs
-{
-    struct ifaddrs     *ifa_next;
-    char               *ifa_name;
-    unsigned int       ifa_flags;
-    struct sockaddr    *ifa_addr;
-};
-
-/**
- * CA internal definition for getifaddrs.
- *
- * @param[out]  ifap    List of ifaddrs.
- * @return  On success, returns CA_STATUS_OK; on error, CA error code is returned.
- */
-CAResult_t CAGetIfaddrsUsingNetlink(struct ifaddrs **ifap);
-
-/**
- * CA internal definition for freeifaddrs
- *
- * @param[in]  ifa      List of ifaddrs.
- */
-void CAFreeIfAddrs(struct ifaddrs *ifa);
-
index a0f18ad..1d8d631 100644 (file)
@@ -325,7 +325,7 @@ u_arraylist_t *CAFindInterfaceChange()
                           .msg_iov = &iov,
                           .msg_iovlen = 1 };
 
-    size_t len = recvmsg(caglobals.ip.netlinkFd, &msg, 0);
+    ssize_t len = recvmsg(caglobals.ip.netlinkFd, &msg, 0);
 
     for (nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len); nh = NLMSG_NEXT(nh, len))
     {
index b04a283..d5f258c 100644 (file)
@@ -167,7 +167,7 @@ u_arraylist_t *CAFindInterfaceChange()
                           .msg_iov = &iov,
                           .msg_iovlen = 1 };
 
-    size_t len = recvmsg(caglobals.ip.netlinkFd, &msg, 0);
+    ssize_t len = recvmsg(caglobals.ip.netlinkFd, &msg, 0);
 
     for (struct nlmsghdr *nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len); nh = NLMSG_NEXT(nh, len))
     {