From 32dccec98e4c7d7e4ce902e19ba8d1b29b823758 Mon Sep 17 00:00:00 2001 From: Jordan Augé Date: Wed, 23 Sep 2020 17:50:52 +0200 Subject: [HICN-570] Message buffer (incl. CS and PIT changes) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4c508e4b04dee3acbfc3da1d26e1770cb826f22b Signed-off-by: Jordan Augé --- hicn-light/src/hicn/io/hicn.c | 95 ++++++++----------------------------------- 1 file changed, 17 insertions(+), 78 deletions(-) (limited to 'hicn-light/src/hicn/io/hicn.c') diff --git a/hicn-light/src/hicn/io/hicn.c b/hicn-light/src/hicn/io/hicn.c index 26c641e51..02b6728a9 100644 --- a/hicn-light/src/hicn/io/hicn.c +++ b/hicn-light/src/hicn/io/hicn.c @@ -26,17 +26,18 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include "base.h" +#include "../core/listener.h" +#include "../core/listener_vft.h" +#include "../core/connection.h" +#include "../core/connection_vft.h" +#include "../core/connection_table.h" +#include "../core/forwarder.h" +#include "../core/mapme.h" +#include "../socket/api.h" + #define IPv6 6 #define IPv4 4 #define MTU_SIZE 1500 // bytes @@ -242,65 +243,7 @@ typedef struct { } listener_hicn_data_t; -static -void -listener_hicn_read_callback(listener_t * listener, int fd, void * data) -{ - assert(listener); - assert(!data); /* No user data */ - uint8_t packet[MTU_SIZE]; - - int family = address_family(&listener->address); - if ((family != AF_INET) && (family != AF_INET6)) { - /* - * We need to discard the frame. Read 1 byte. This will clear it off - * the stack. - */ - int nread = read(fd, packet, 1); - - if (nread > 0) { - DEBUG("Discarded frame from fd %d", fd); - } else if (nread < 0) { - ERROR("Error trying to discard frame from fd %d: (%d) %s", fd, errno, - strerror(errno)); - } - return; - } - -#if 0 - if (!(what & PARCEventType_Read)) - return; -#endif - - ssize_t n = read(fd, packet, MTU_SIZE); - if (n < 0) { - ERROR("read failed %d: (%d) %s", fd, errno, strerror(errno)); - return; - } - -#if 0 - address_t packet_addr; - if (_createAddressFromPacket(packet, &packet_addr) < 0) - return; - - address_pair_t pair_find = { - .local = packet_addr, - .remote = /* dummy */ hicn->localAddress, - }; - const Connection *conn = _lookupConnection(listener, &pair_find); - if (!conn) { - address_pair_t pair = { - .local = hicn->localAddress, - .remote = packet_addr, - }; - connid = _createNewConnection(listener, fd, &pair); - } else { - connid = connection_GetConnectionId(conn); - } -#endif - - listener_read_callback(listener->forwarder, listener, fd, &listener->address, packet, n); -} +#define listener_hicn_read_callback listener_read_callback bool listener_hicn_bind(listener_t * listener, const address_t * address) @@ -426,7 +369,8 @@ listener_hicn_get_socket(const listener_t * listener, const address_t * local, { assert(listener); assert(listener_get_type(listener) == FACE_TYPE_HICN); - // assert(pair); + assert(local); + assert(remote); /* ... */ @@ -434,6 +378,9 @@ listener_hicn_get_socket(const listener_t * listener, const address_t * local, } +#define listener_hicn_read_single io_read_single_fd +#define listener_hicn_read_batch NULL + DECLARE_LISTENER(hicn); /****************************************************************************** @@ -503,7 +450,7 @@ static int connection_hicn_send_packet(const connection_t * connection, const uint8_t * packet, size_t size) { - // assert(ops); + assert(connection); assert(packet); /* ... */ @@ -511,12 +458,4 @@ connection_hicn_send_packet(const connection_t * connection, const uint8_t * pac return 0; } -static -void -connection_hicn_read_callback(connection_t * connection, int fd, void * data) -{ - ERROR("Unexpected read callback for hicn connection"); - return; -} - DECLARE_CONNECTION(hicn); -- cgit 1.2.3-korg