aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/hicn/io/hicn.c
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-light/src/hicn/io/hicn.c')
-rw-r--r--hicn-light/src/hicn/io/hicn.c95
1 files changed, 17 insertions, 78 deletions
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 <string.h>
#include <unistd.h>
-#include <hicn/core/listener.h>
-#include <hicn/core/listener_vft.h>
-#include <hicn/core/connection.h>
-#include <hicn/core/connection_vft.h>
-#include <hicn/core/connection_table.h>
-#include <hicn/core/forwarder.h>
-#include <hicn/core/mapme.h>
-#include <hicn/core/messagePacketType.h>
-#include <hicn/socket/api.h>
#include <hicn/util/log.h>
+#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);