From 514e483bc3c5eeed82bb232b84c3615614bca6e9 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Mon, 19 Aug 2024 08:57:29 -0700 Subject: [PATCH] network: add __network_path_append_bss To reduce code duplication and prepare for moving the BSS interface to station, add a new API so station can create a BSS path without a network object directly. --- src/network.c | 12 +++++++++--- src/network.h | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/network.c b/src/network.c index 85d2a983..a8e61d48 100644 --- a/src/network.c +++ b/src/network.c @@ -1130,17 +1130,23 @@ bool network_update_known_frequencies(struct network *network) return true; } -const char *network_bss_get_path(const struct network *network, - const struct scan_bss *bss) +const char *__network_path_append_bss(const char *network_path, + const struct scan_bss *bss) { static char path[256]; snprintf(path, sizeof(path), "%s/%02x%02x%02x%02x%02x%02x", - network->object_path, MAC_STR(bss->addr)); + network_path, MAC_STR(bss->addr)); return path; } +const char *network_bss_get_path(const struct network *network, + const struct scan_bss *bss) +{ + return __network_path_append_bss(network->object_path, bss); +} + static bool network_unregister_bss(void *a, void *user_data) { struct scan_bss *bss = a; diff --git a/src/network.h b/src/network.h index 78ced99d..c9f73200 100644 --- a/src/network.h +++ b/src/network.h @@ -77,6 +77,9 @@ const char *network_bss_get_path(const struct network *network, const struct scan_bss *bss); bool network_bss_list_isempty(struct network *network); +const char *__network_path_append_bss(const char *network_path, + const struct scan_bss *bss); + struct scan_bss *network_bss_list_pop(struct network *network); struct scan_bss *network_bss_find_by_addr(struct network *network, const uint8_t *addr);