feat: Closer to full localhost cycle

This commit is contained in:
2026-06-26 19:31:16 +01:00
parent 63ea1551ad
commit 0e094b5601
3 changed files with 36 additions and 10 deletions

View File

@@ -65,10 +65,15 @@ int incphub_send_local(incphub_cli_t *cli, uint8_t *buffer, size_t length, ntl_p
int incphub_await_msg(incphub_cli_t *cli, uint8_t **buffer_ptr, size_t *length_ptr, incphub_addr_t *sender_ptr) int incphub_await_msg(incphub_cli_t *cli, uint8_t **buffer_ptr, size_t *length_ptr, incphub_addr_t *sender_ptr)
{ {
(void)cli; if (cli == NULL)
(void)buffer_ptr; return INCPHUB_EINVAL;
(void)length_ptr; if (buffer_ptr == NULL)
(void)sender_ptr; return INCPHUB_EINVAL;
//TODO: Implement if (length_ptr == NULL)
return INCPHUB_EINVAL;
if (sender_ptr == NULL)
return INCPHUB_EINVAL;
//TODO: Implement (with await_message_dispatch)
return INCPHUB_ERR; return INCPHUB_ERR;
} }

View File

@@ -9,6 +9,8 @@
#include "nil/nil.h" #include "nil/nil.h"
#include "ntl/ntl.h" #include "ntl/ntl.h"
#include "incphub/incphub.h"
struct incphub_cli_t { struct incphub_cli_t {
@@ -58,4 +60,8 @@ int enqueue_message_ingest(uint8_t *buffer, size_t length);
/// @return INCPHUB_OK on success, an error otherwise /// @return INCPHUB_OK on success, an error otherwise
int dequeue_message_ingest(uint8_t **buffer_ptr, size_t *length_ptr); int dequeue_message_ingest(uint8_t **buffer_ptr, size_t *length_ptr);
int do_message_dispatch(incphub_cli_t *cli, uint8_t *buffer, size_t length, incphub_addr_t source);
int await_message_dispatch(uint8_t **buffer_ptr, size_t *length_ptr, incphub_addr_t *source_ptr);
#endif #endif

View File

@@ -39,7 +39,7 @@ static StaticQueue_t _ingest_queue_static;
static nil_packet_t *extract_nil_packet(uint8_t *buffer, size_t length); static nil_packet_t *extract_nil_packet(uint8_t *buffer, size_t length);
static ntl_packet_t *extract_ntl_packet(nil_packet_t *nil); static ntl_packet_t *extract_ntl_packet(nil_packet_t *nil);
static void handle_nil_packet(nil_packet_t *nil); static void handle_nil_packet(nil_packet_t *nil);
static void handle_ntl_packet(ntl_packet_t *ntl); static void handle_ntl_packet(ntl_packet_t *ntl, nil_addr_t src_addr);
@@ -123,7 +123,7 @@ static void handle_nil_packet(nil_packet_t *nil)
return; return;
} }
handle_ntl_packet(ntl); handle_ntl_packet(ntl, nil->header.src_addr);
return; return;
} }
@@ -131,8 +131,23 @@ static void handle_nil_packet(nil_packet_t *nil)
return; return;
} }
static void handle_ntl_packet(ntl_packet_t *ntl) static void handle_ntl_packet(ntl_packet_t *ntl, nil_addr_t src_addr)
{ {
(void)ntl; ntl_port_t port = ntl_get_dst(&ntl->header);
//TODO: Implement
incphub_cli_t *client;
if (get_client_with_port(port, &client) != INCPHUB_OK)
{
//TODO: Error
return;
}
incphub_addr_t sender = { .addr = src_addr, .port = ntl->header.src_port };
if (do_message_dispatch(client, ntl->payload, ntl->header.len, sender) != INCPHUB_OK)
{
//TODO: Error
return;
}
return;
} }