summaryrefslogtreecommitdiffstats
path: root/hicn-light
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge@cisco.com>2019-10-30 17:56:08 +0100
committerJordan Augé <jordan.auge@cisco.com>2019-10-31 13:41:47 +0100
commit95170bf3a69597b49238bb7ff396d41f6dc94f30 (patch)
tree2f9b565e84514d7ee25cfd874235dd25e9300a0f /hicn-light
parentfc6dfe9f7ee02834ae1e6f56e0aaee36ac3e88dd (diff)
[HICN-369] Implement reconciliation state machine in face manager incl. reattempts in case of errors
Change-Id: Ia4ecf621fbd513d9e29313d2aaa487aa65811183 Signed-off-by: Jordan Augé <jordan.auge@cisco.com>
Diffstat (limited to 'hicn-light')
-rw-r--r--hicn-light/src/hicn/io/udpListener.c78
1 files changed, 52 insertions, 26 deletions
diff --git a/hicn-light/src/hicn/io/udpListener.c b/hicn-light/src/hicn/io/udpListener.c
index e484dc2db..ebb24022e 100644
--- a/hicn-light/src/hicn/io/udpListener.c
+++ b/hicn-light/src/hicn/io/udpListener.c
@@ -130,22 +130,35 @@ ListenerOps *udpListener_CreateInet6(Forwarder *forwarder, char *listenerName,
if (failure == 0) {
#ifdef __linux__
- 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 (strncmp("lo", interfaceName, 2) != 0) {
+ 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__,
- "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);
- }
+ "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);
+ close(udp->udp_socket);
+ addressDestroy(&udp->localAddress);
+ logger_Release(&udp->logger);
+ parcMemory_Deallocate((void **)&udp);
+ return NULL;
+ } else {
+ logger_Log(udp->logger, LoggerFacility_IO, PARCLogLevel_Debug, __func__,
+ "bindSocket(%d, %s) success", udp->udp_socket, interfaceName);
+ }
+#else
+ close(udp->udp_socket);
+ addressDestroy(&udp->localAddress);
+ logger_Release(&udp->logger);
+ parcMemory_Deallocate((void **)&udp);
+ return NULL;
#endif
+ }
}
#endif
@@ -236,22 +249,35 @@ ListenerOps *udpListener_CreateInet(Forwarder *forwarder, char *listenerName,
failure = bind(udp->udp_socket, (struct sockaddr *)&sin, sizeof(sin));
if (failure == 0) {
#ifdef __linux__
- 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 (strncmp("lo", interfaceName, 2) != 0) {
+ 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__,
- "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);
- }
+ "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);
+ close(udp->udp_socket);
+ addressDestroy(&udp->localAddress);
+ logger_Release(&udp->logger);
+ parcMemory_Deallocate((void **)&udp);
+ return NULL;
+ } else {
+ logger_Log(udp->logger, LoggerFacility_IO, PARCLogLevel_Debug, __func__,
+ "bindSocket(%d, %s) success", udp->udp_socket, interfaceName);
+ }
+#else
+ close(udp->udp_socket);
+ addressDestroy(&udp->localAddress);
+ logger_Release(&udp->logger);
+ parcMemory_Deallocate((void **)&udp);
+ return NULL;
#endif
+ }
}
#endif
ops = parcMemory_AllocateAndClear(sizeof(ListenerOps));