wifi_cfg.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* WiFi credential records: the staged connect request written by the network
  2. * menu and read by `wifi connectfile <path>`, plus the saved-network list in
  3. * /data/WIFI.CFG (see wifi_store.c).
  4. *
  5. * The normal `wifi connect <ssid> <pass>` command arguments are limited by
  6. * SYS_SPAWN's VFS_PATH_MAX buffer (64 bytes), which is too small for a long
  7. * SSID plus a 63-character WPA2 passphrase. The menu therefore writes the
  8. * single fixed-size record to a /share file and spawns a helper with a short
  9. * path.
  10. *
  11. * /data/WIFI.CFG is a header (`struct wifi_cfg_list`) followed by `count`
  12. * `struct wifi_cfg` records, most recently connected first. A file that
  13. * starts directly with WIFI_CFG_MAGIC is the old one-record format and is
  14. * accepted as a one-entry list. */
  15. #ifndef WIFI_CFG_H
  16. #define WIFI_CFG_H
  17. #define WIFI_CFG_MAGIC 0x4E425746u /* "NBWF": one network record */
  18. #define WIFI_CFG_LIST_MAGIC 0x4E42574Cu /* "NBWL": saved-network list */
  19. #define WIFI_CFG_LIST_VER 1u
  20. #define WIFI_CFG_MAX 16 /* saved networks in /data/WIFI.CFG */
  21. #define WIFI_CFG_STAGED "/share/netmenu.wifi"
  22. #define WIFI_CRED_PATH "/data/WIFI.CFG"
  23. struct wifi_cfg {
  24. unsigned int magic;
  25. unsigned char ssid_len; /* 1..32 */
  26. unsigned char pass_len; /* 0..64 (64 = raw hex PSK) */
  27. unsigned char bssid[6];
  28. unsigned char ssid[32];
  29. char pass[65]; /* NUL terminated, pass_len used */
  30. };
  31. struct wifi_cfg_list {
  32. unsigned int magic;
  33. unsigned int version;
  34. unsigned int count;
  35. struct wifi_cfg net[WIFI_CFG_MAX];
  36. };
  37. #endif