From 79e0d4f89c4d532189aae06cc5dfbc14e3269703 Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Mon, 11 Feb 2019 10:44:29 +0100 Subject: [HICN-50] Added udp application connector. Change-Id: I0c5afad4b404ec485f50b1342b81e70ef85a5163 Signed-off-by: Mauro Sardara Signed-off-by: michele papalini --- hicn-light/src/config/configurationListeners.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'hicn-light/src/config/configurationListeners.c') diff --git a/hicn-light/src/config/configurationListeners.c b/hicn-light/src/config/configurationListeners.c index 01ab9a3e7..11276e2dd 100644 --- a/hicn-light/src/config/configurationListeners.c +++ b/hicn-light/src/config/configurationListeners.c @@ -217,7 +217,7 @@ static bool _setupTcpListenerOnInet(Forwarder *forwarder, ipv4_addr_t *addr4, struct sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; - addr.sin_port = *port; + addr.sin_port = htons(*port); addr.sin_addr.s_addr = *addr4; ListenerOps *ops = tcpListener_CreateInet(forwarder, addr); @@ -231,12 +231,13 @@ static bool _setupTcpListenerOnInet(Forwarder *forwarder, ipv4_addr_t *addr4, static bool _setupUdpListenerOnInet(Forwarder *forwarder, ipv4_addr_t *addr4, uint16_t *port) { + bool success = false; struct sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; - addr.sin_port = *port; + addr.sin_port = htons(*port); addr.sin_addr.s_addr = *addr4; ListenerOps *ops = udpListener_CreateInet(forwarder, addr); @@ -256,7 +257,7 @@ static bool _setupTcpListenerOnInet6Light(Forwarder *forwarder, struct sockaddr_in6 addr; memset(&addr, 0, sizeof(addr)); addr.sin6_family = AF_INET6; - addr.sin6_port = *port; + addr.sin6_port = htons(*port); addr.sin6_addr = *addr6; addr.sin6_scope_id = scopeId; @@ -276,7 +277,7 @@ static bool _setupUdpListenerOnInet6Light(Forwarder *forwarder, struct sockaddr_in6 addr; memset(&addr, 0, sizeof(addr)); addr.sin6_family = AF_INET6; - addr.sin6_port = *port; + addr.sin6_port = htons(*port); addr.sin6_addr = *addr6; addr.sin6_scope_id = 0; @@ -529,9 +530,13 @@ void configurationListeners_SetupAll(const Configuration *config, uint16_t port, } } - // if (localPath != NULL) { - // _setupLocalListener(forwarder, localPath); - //} - interfaceSetDestroy(&set); } + +void configurationListeners_SetutpLocalIPv4(const Configuration *config, + uint16_t port) { + Forwarder *forwarder = configuration_GetForwarder(config); + in_addr_t addr = inet_addr("127.0.0.1"); + _setupUdpListenerOnInet(forwarder, (ipv4_addr_t *) &(addr), &port); + _setupTcpListenerOnInet(forwarder, (ipv4_addr_t *) &(addr), &port); +} -- cgit 1.2.3-korg