env.AppendUnique(CPPPATH = [ os.path.join(src_dir, 'android') ])
src_files = [ 'caipnwmonitor.c',
- 'ifaddrs.c' ]
+ 'caifaddrs.c' ]
Return('src_files')
-/******************************************************************
-*
-* 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>
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)
{
--- /dev/null
+/* *****************************************************************
+ *
+ * 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);
+
#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)
.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;
}
+++ /dev/null
-/******************************************************************
-*
-* 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);
-
.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))
{
.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))
{