daniel-p-carvalho commented on code in PR #3893:
URL: https://github.com/apache/nuttx-apps/pull/3893#discussion_r4335515839
##########
include/netutils/wifibridge.h:
##########
@@ -66,8 +73,29 @@ struct wifibridge_status_s
bool exists; /* The bridge interface exists */
bool eth_up; /* The Ethernet port is up */
bool wlan_up; /* The Wi-Fi port is up */
- char ssid[33]; /* SSID the Wi-Fi port is set to */
struct in_addr ipaddr; /* Bridge address */
+
+ /* SSID the Wi-Fi port is set to */
+
+ char ssid[WIFIBRIDGE_SSID_MAXLEN + 1];
+};
+
+/* The part of the configuration that is kept in non-volatile memory: not the
+ * names of the interfaces nor the netmask. The passphrase is stored as is.
+ */
+
+struct wifibridge_saved_s
Review Comment:
Done, the struct is gone from the header. The record now lives only in
wifibridge.c.
##########
include/netutils/wifibridge.h:
##########
@@ -125,6 +153,55 @@ int wifibridge_stop(FAR const struct wifibridge_config_s
*config);
int wifibridge_status(FAR const struct wifibridge_config_s *config,
FAR struct wifibridge_status_s *status);
+#ifdef CONFIG_NETUTILS_WIFIBRIDGE_PERSIST
+
+/****************************************************************************
+ * Name: wifibridge_save
+ *
+ * Description:
+ * Keep the SSID, passphrase, channel, security, address and DHCP server
+ * option of the configuration in the storage
+ * (CONFIG_NETUTILS_WIFIBRIDGE_STORAGE), to survive a reset.
+ *
+ * Returned Value:
+ * Zero (OK) on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int wifibridge_save(FAR const struct wifibridge_config_s *config);
+
+/****************************************************************************
+ * Name: wifibridge_load
+ *
+ * Description:
+ * Read what wifibridge_save() kept into saved, and set the matching fields
+ * of the configuration to point to it (and to the other values). The
+ * other fields of the configuration are left alone.
+ *
+ * Returned Value:
+ * Zero (OK) on success; -ENOENT if nothing is saved, or another negated
+ * errno value on failure.
+ *
+ ****************************************************************************/
+
+int wifibridge_load(FAR struct wifibridge_config_s *config,
+ FAR struct wifibridge_saved_s *saved);
Review Comment:
Done. wifibridge_load() now takes the buffers for the SSID and the
passphrase from the caller instead of a saved struct.
##########
netutils/wifibridge/wifibridge.c:
##########
@@ -44,10 +45,64 @@
# include "netutils/dhcpd.h"
#endif
+#ifdef CONFIG_NETUTILS_WIFIBRIDGE_PERSIST
+# include <nuttx/crc32.h>
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define WIFIBRIDGE_SAVED_VERSION 1
+#define WIFIBRIDGE_RECORD_MAGIC 0x42574657 /* 'WFWB' */
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+#ifdef CONFIG_NETUTILS_WIFIBRIDGE_PERSIST
+
+/* What is written to the storage: a record that is checked before it is
+ * used.
+ */
+
+struct wifibridge_record_s
+{
+ uint32_t magic; /* WIFIBRIDGE_RECORD_MAGIC */
+ uint32_t crc; /* CRC-32 of saved */
+ struct wifibridge_saved_s saved;
Review Comment:
Done, the fields are listed directly in the record and wifibridge_saved_s is
removed. The CRC now covers everything after the crc field.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]