Skip to content

Commit 2af8361

Browse files
committed
feat: Add Selective Source Routing (SSR) support to c-mesh-api
Implement SSR (Selective Source Routing) integration for the Linux gateway, enabling automatic source-routed packet transmission based on first-hop information learned from mesh node registrations. Key additions: - First-Hop Table (FHT): Open-addressing hash table with linear probing, tombstone deletion, and automatic growth. Maintains routes with configurable validity windows and automatic expiry purging. - SSR module: Integration layer that maintains the FHT, processes incoming SSR registration indications from the sink, and provides route lookup for the send path. - DSAP extensions: New dsap_data_tx_ssr_request() function for sending single-frame and fragmented packets with source-routing hop lists. Refactored common TX logic into dsap_data_tx_request_internal(). - WPC integration: Automatic SSR route lookup in WPC_send_data_with_options(). Falls back to traditional routing if no SSR route is available. SSR module initialized/deinitialized with WPC lifecycle. - MSAP handler: New msap_ssr_registration_indication_handler() processes incoming registration packets and updates the FHT. - Platform integration: SSR purge called periodically from the dispatch thread alongside reassembly garbage collection. - Comprehensive unit tests covering FHT operations, SSR module lifecycle, frame layout validation, and integration with WPC send path.
1 parent b70b379 commit 2af8361

21 files changed

Lines changed: 3118 additions & 89 deletions

lib/api/wpc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,8 @@ app_res_e WPC_send_data(const uint8_t * bytes,
952952
* \param message_p
953953
* The message to send
954954
* \return Return code of the operation
955+
* \note If a valid SSR first-hop is available for the destination and the
956+
* payload can be routed through SSR, SSR routing is used automatically.
955957
*/
956958
app_res_e WPC_send_data_with_options(const app_message_t * message_p);
957959

lib/platform/linux/platform.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "logger.h"
1717
#include "platform.h"
1818
#include "reassembly.h"
19+
#include "ssr.h"
1920
#include "wpc_proto.h"
2021

2122
// Maximum number of indication to be retrieved from a single poll
@@ -112,6 +113,7 @@ static void * dispatch_indication(void * unused)
112113

113114
// Force a garbage collect (to be sure it's called even if no frag are received)
114115
reassembly_garbage_collect();
116+
ssr_purge_expired();
115117

116118
// Check if we wake up but nothing in queue
117119
if (m_queue_empty)

lib/wpc/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ add_library(wpc STATIC
77
${CMAKE_CURRENT_LIST_DIR}/wpc.c
88
${CMAKE_CURRENT_LIST_DIR}/wpc_internal.c
99
${CMAKE_CURRENT_LIST_DIR}/reassembly/reassembly.c
10+
${CMAKE_CURRENT_LIST_DIR}/ssr/fht.c
11+
${CMAKE_CURRENT_LIST_DIR}/ssr/ssr.c
1012
)
1113

1214
target_include_directories(wpc PUBLIC

0 commit comments

Comments
 (0)