chore: Several comments

This commit is contained in:
2026-06-29 15:11:33 +01:00
parent 013d080bc2
commit b26c53cb0f
2 changed files with 9 additions and 3 deletions

View File

@@ -48,7 +48,7 @@ int incphub_send_local(incphub_cli_t *cli, uint8_t *buffer, size_t length, ntl_p
if (dst_port == NTL_PORT_EMPTY)
return INCPHUB_EINVAL;
// Unwind pointer
// Unwind buffer pointer
ntl_packet_t *ntl_packet = (ntl_packet_t*)(buffer - sizeof(ntl_header_t));
nil_packet_t *nil_packet = (nil_packet_t*)(ntl_packet - sizeof(ntl_header_t));
size_t extended_len = sizeof(nil_header_t) + sizeof(ntl_header_t) + length;

View File

@@ -57,10 +57,12 @@ void incphub_task_main(void *params)
while (1)
{
// Dequeue message
uint8_t *buffer;
size_t length;
dequeue_message_ingest(&buffer, &length);
// Get NIL packet
nil_packet_t *nil = extract_nil_packet(buffer, length);
if (nil == NULL)
{
@@ -68,6 +70,7 @@ void incphub_task_main(void *params)
continue;
}
// Process or route
handle_nil_packet(nil);
}
}
@@ -77,6 +80,7 @@ void incphub_task_main(void *params)
// === Private functions ===
static nil_packet_t *extract_nil_packet(uint8_t *buffer, size_t length)
{
// Ensure message is big enough to hold a packet
if (length < sizeof(nil_packet_t))
{
//TODO: Error
@@ -84,10 +88,11 @@ static nil_packet_t *extract_nil_packet(uint8_t *buffer, size_t length)
}
nil_packet_t *nil = (nil_packet_t *)buffer;
// Ensure length field is not going to cause buffer overflow
if (length < sizeof(nil_packet_t) + nil->header.len )
{
//TODO: Error
return NULL;;
return NULL;
}
return nil;
@@ -95,6 +100,7 @@ static nil_packet_t *extract_nil_packet(uint8_t *buffer, size_t length)
static ntl_packet_t *extract_ntl_packet(nil_packet_t *nil)
{
// Ensure message is big enough to hold a packet
if (nil->header.len < sizeof(ntl_packet_t))
{
//TODO: Error
@@ -102,7 +108,7 @@ static ntl_packet_t *extract_ntl_packet(nil_packet_t *nil)
}
ntl_packet_t *ntl = (ntl_packet_t *)nil->payload;
// Ensure length field is not going to cause buffer overflow
if (nil->header.len < sizeof(ntl_packet_t) + ntl->header.len)
{
//TODO: Error