summaryrefslogtreecommitdiffstats
path: root/hicn-light/src
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-light/src')
-rw-r--r--hicn-light/src/hicn/CMakeLists.txt3
-rw-r--r--hicn-light/src/hicn/io/udpListener.c38
2 files changed, 36 insertions, 5 deletions
diff --git a/hicn-light/src/hicn/CMakeLists.txt b/hicn-light/src/hicn/CMakeLists.txt
index 0f711e353..9129cba17 100644
--- a/hicn-light/src/hicn/CMakeLists.txt
+++ b/hicn-light/src/hicn/CMakeLists.txt
@@ -43,9 +43,6 @@ list(APPEND TO_INSTALL_HEADER_FILES
${CMAKE_CURRENT_BINARY_DIR}/hicn-light/config.h
)
-set(TO_INSTALL_HEADER_FILES
-)
-
if (ANDROID_API)
build_library(${LIBHICN_LIGHT}
STATIC
diff --git a/hicn-light/src/hicn/io/udpListener.c b/hicn-light/src/hicn/io/udpListener.c
index 02deb49d1..f6b434fed 100644
--- a/hicn-light/src/hicn/io/udpListener.c
+++ b/hicn-light/src/hicn/io/udpListener.c
@@ -72,6 +72,10 @@ static ListenerOps udpTemplate = {
static void _readcb(int fd, PARCEventType what, void * listener_void);
+#ifdef __ANDROID__
+extern int bindSocket(int sock, const char* ifname);
+#endif
+
#ifdef __linux__
ListenerOps *udpListener_CreateInet6(Forwarder *forwarder,
struct sockaddr_in6 sin6, const char *interfaceName) {
@@ -122,8 +126,23 @@ ListenerOps *udpListener_CreateInet6(Forwarder *forwarder,
if (failure == 0) {
#ifdef __linux__
- setsockopt(udp->udp_socket, SOL_SOCKET, SO_BINDTODEVICE,
+ int ret = setsockopt(udp->udp_socket, SOL_SOCKET, SO_BINDTODEVICE,
interfaceName, strlen(interfaceName) + 1);
+ if (ret < 0) {
+ logger_Log(udp->logger, LoggerFacility_IO, PARCLogLevel_Debug, __func__,
+ "setsockopt(%d, SO_BINDTODEVICE, %s) failed (%d) %s",
+ udp->udp_socket, interfaceName, errno, strerror(errno));
+#ifdef __ANDROID__
+ ret = bindSocket(udp->udp_socket, interfaceName);
+ if (ret < 0) {
+ logger_Log(udp->logger, LoggerFacility_IO, PARCLogLevel_Debug, __func__,
+ "bindSocket(%d, %s) failed", udp->udp_socket, interfaceName);
+ } else {
+ logger_Log(udp->logger, LoggerFacility_IO, PARCLogLevel_Debug, __func__,
+ "bindSocket(%d, %s) success", udp->udp_socket, interfaceName);
+ }
+#endif
+ }
#endif
ops = parcMemory_AllocateAndClear(sizeof(ListenerOps));
@@ -214,8 +233,23 @@ ListenerOps *udpListener_CreateInet(Forwarder *forwarder,
failure = bind(udp->udp_socket, (struct sockaddr *)&sin, sizeof(sin));
if (failure == 0) {
#ifdef __linux__
- setsockopt(udp->udp_socket, SOL_SOCKET, SO_BINDTODEVICE,
+ int ret = setsockopt(udp->udp_socket, SOL_SOCKET, SO_BINDTODEVICE,
interfaceName, strlen(interfaceName) + 1);
+ if (ret < 0) {
+ logger_Log(udp->logger, LoggerFacility_IO, PARCLogLevel_Debug, __func__,
+ "setsockopt(%d, SO_BINDTODEVICE, %s) failed (%d) %s",
+ udp->udp_socket, interfaceName, errno, strerror(errno));
+#ifdef __ANDROID__
+ ret = bindSocket(udp->udp_socket, interfaceName);
+ if (ret < 0) {
+ logger_Log(udp->logger, LoggerFacility_IO, PARCLogLevel_Debug, __func__,
+ "bindSocket(%d, %s) failed", udp->udp_socket, interfaceName);
+ } else {
+ logger_Log(udp->logger, LoggerFacility_IO, PARCLogLevel_Debug, __func__,
+ "bindSocket(%d, %s) success", udp->udp_socket, interfaceName);
+ }
+#endif
+ }
#endif
ops = parcMemory_AllocateAndClear(sizeof(ListenerOps));
parcAssertNotNull(ops, "parcMemory_AllocateAndClear(%zu) returned NULL",