wifi_store.h 1.2 KB

12345678910111213141516171819202122232425262728
  1. /* Saved WiFi networks in /data/WIFI.CFG, shared by the `wifi` command and the
  2. * network menu. The file is a wifi_cfg_list header + record array; the old
  3. * one-record format is still read. See wifi_cfg.h for the layout. */
  4. #ifndef WIFI_STORE_H
  5. #define WIFI_STORE_H
  6. #include "wifi_cfg.h"
  7. /* Read the saved list into `out` (most recently used first), dropping
  8. * malformed and duplicate records. Returns 0..max, or 0 when the file is
  9. * absent, empty or unreadable. */
  10. int wifi_store_load(struct wifi_cfg *out, int max);
  11. /* Rewrite the list. An empty list removes the file. -> 0 / -1 */
  12. int wifi_store_save(const struct wifi_cfg *list, int count);
  13. /* Move `rec` to the front (replacing a record with the same SSID, dropping
  14. * the least recently used entry when the list is full) and write it. */
  15. int wifi_store_remember(const struct wifi_cfg *rec);
  16. /* Index of the record whose SSID matches, or -1. */
  17. int wifi_store_find(const struct wifi_cfg *list, int count,
  18. const unsigned char *ssid, unsigned int ssid_len);
  19. /* Remove one network: 1 removed, 0 not found, -1 write error. */
  20. int wifi_store_forget(const unsigned char *ssid, unsigned int ssid_len);
  21. #endif