From: bg.chun Date: Wed, 9 Nov 2016 08:49:16 +0000 (+0900) Subject: [IOT-1528]update file path and remove static analysis warring X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=695ab8934ed161917783febab67a9a6acd6c4b3d;p=contrib%2Fiotivity.git [IOT-1528]update file path and remove static analysis warring update file path(ifaddrs.x -> caifaddrs.x) and fix netlink usage for remove static analysis warring Change-Id: I672d9ba1250710cc10c66cbbde56b6b12afc15e8 Signed-off-by: bg.chun Reviewed-on: https://gerrit.iotivity.org/gerrit/14153 Tested-by: jenkins-iotivity Reviewed-by: Jaehong Jo Reviewed-by: Ashok Babu Channa --- diff --git a/resource/csdk/connectivity/src/ip_adapter/android/SConscript b/resource/csdk/connectivity/src/ip_adapter/android/SConscript index b1a6a52..9e33ff5 100644 --- a/resource/csdk/connectivity/src/ip_adapter/android/SConscript +++ b/resource/csdk/connectivity/src/ip_adapter/android/SConscript @@ -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') diff --git a/resource/csdk/connectivity/src/ip_adapter/android/ifaddrs.c b/resource/csdk/connectivity/src/ip_adapter/android/caifaddrs.c similarity index 79% rename from resource/csdk/connectivity/src/ip_adapter/android/ifaddrs.c rename to resource/csdk/connectivity/src/ip_adapter/android/caifaddrs.c index a2b07c0..291c913 100644 --- a/resource/csdk/connectivity/src/ip_adapter/android/ifaddrs.c +++ b/resource/csdk/connectivity/src/ip_adapter/android/caifaddrs.c @@ -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 #include @@ -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 index 0000000..a576af6 --- /dev/null +++ b/resource/csdk/connectivity/src/ip_adapter/android/caifaddrs.h @@ -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); + diff --git a/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c b/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c index 3fbc3c8..781bcf3 100644 --- a/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c +++ b/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c @@ -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 index cee33c5..0000000 --- a/resource/csdk/connectivity/src/ip_adapter/android/ifaddrs.h +++ /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); - diff --git a/resource/csdk/connectivity/src/ip_adapter/linux/caipnwmonitor.c b/resource/csdk/connectivity/src/ip_adapter/linux/caipnwmonitor.c index a0f18ad..1d8d631 100644 --- a/resource/csdk/connectivity/src/ip_adapter/linux/caipnwmonitor.c +++ b/resource/csdk/connectivity/src/ip_adapter/linux/caipnwmonitor.c @@ -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)) { diff --git a/resource/csdk/connectivity/src/ip_adapter/tizen/caipnwmonitor.c b/resource/csdk/connectivity/src/ip_adapter/tizen/caipnwmonitor.c index b04a283..d5f258c 100644 --- a/resource/csdk/connectivity/src/ip_adapter/tizen/caipnwmonitor.c +++ b/resource/csdk/connectivity/src/ip_adapter/tizen/caipnwmonitor.c @@ -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)) {