feat: Closer to full localhost cycle
This commit is contained in:
@@ -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)
|
||||
{
|
||||
(void)cli;
|
||||
(void)buffer_ptr;
|
||||
(void)length_ptr;
|
||||
(void)sender_ptr;
|
||||
//TODO: Implement
|
||||
if (cli == NULL)
|
||||
return INCPHUB_EINVAL;
|
||||
if (buffer_ptr == NULL)
|
||||
return INCPHUB_EINVAL;
|
||||
if (length_ptr == NULL)
|
||||
return INCPHUB_EINVAL;
|
||||
if (sender_ptr == NULL)
|
||||
return INCPHUB_EINVAL;
|
||||
|
||||
//TODO: Implement (with await_message_dispatch)
|
||||
return INCPHUB_ERR;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "nil/nil.h"
|
||||
#include "ntl/ntl.h"
|
||||
|
||||
#include "incphub/incphub.h"
|
||||
|
||||
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
@@ -39,7 +39,7 @@ static StaticQueue_t _ingest_queue_static;
|
||||
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 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;
|
||||
}
|
||||
|
||||
handle_ntl_packet(ntl);
|
||||
handle_ntl_packet(ntl, nil->header.src_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -131,8 +131,23 @@ static void handle_nil_packet(nil_packet_t *nil)
|
||||
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;
|
||||
//TODO: Implement
|
||||
ntl_port_t port = ntl_get_dst(&ntl->header);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user