/* * rt_config.h * NVS-backed known networks + C2 fallback addresses. */ #pragma once #include #include #include #ifdef __cplusplus extern "C" { #endif #ifndef CONFIG_RT_MAX_KNOWN_NETWORKS #define CONFIG_RT_MAX_KNOWN_NETWORKS 16 #endif #ifndef CONFIG_RT_MAX_C2_FALLBACKS #define CONFIG_RT_MAX_C2_FALLBACKS 4 #endif #define RT_SSID_MAX_LEN 33 /* 32 + NUL */ #define RT_PASS_MAX_LEN 65 /* 64 + NUL */ #define RT_ADDR_MAX_LEN 64 /* "ip:port" or "host:port" */ /* ============================================================ * Known WiFi networks * ============================================================ */ typedef struct { char ssid[RT_SSID_MAX_LEN]; char pass[RT_PASS_MAX_LEN]; } rt_network_t; /* Init NVS namespace, load config */ void rt_config_init(void); /* Add/update a known network. Empty pass = open network. */ bool rt_config_net_add(const char *ssid, const char *pass); /* Remove a known network by SSID. Returns false if not found. */ bool rt_config_net_remove(const char *ssid); /* Get known networks list. Returns count. */ int rt_config_net_list(rt_network_t *out, int max_count); /* Get count of known networks. */ int rt_config_net_count(void); /* ============================================================ * C2 fallback addresses * ============================================================ */ typedef struct { char addr[RT_ADDR_MAX_LEN]; /* "ip:port" */ } rt_c2_addr_t; /* Add a C2 fallback address. Returns false if full. */ bool rt_config_c2_add(const char *addr); /* Remove a C2 fallback address. Returns false if not found. */ bool rt_config_c2_remove(const char *addr); /* Get C2 fallback addresses. Returns count. */ int rt_config_c2_list(rt_c2_addr_t *out, int max_count); /* Get count of C2 fallback addresses. */ int rt_config_c2_count(void); /* ============================================================ * Original MAC storage (for restoration) * ============================================================ */ /* Save the current STA MAC as the original. Called once at boot. */ void rt_config_save_orig_mac(void); /* Get the saved original MAC. Returns false if not saved. */ bool rt_config_get_orig_mac(uint8_t mac[6]); #ifdef __cplusplus } #endif