ethernet_interface: Fix u-boot MAC environment variable
Previously, no matter what interface we were changing we would always
set the MAC address for eth0 on the next boot. There is a loose
mapping between ethaddr <-> eth0 and eth1addr <-> eth1 for storing the
MAC address in the u-boot environment.
https://www.denx.de/wiki/view/DULG/UBootEnvVariables
Change-Id: I90f608a876c03e74c32561cf24947cfc44da0e34
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/util.hpp b/util.hpp
index 1f86815..3aad4a1 100644
--- a/util.hpp
+++ b/util.hpp
@@ -8,6 +8,7 @@
#include <unistd.h>
#include <cstring>
+#include <optional>
#include <sdbusplus/bus.hpp>
#include <string>
#include <string_view>
@@ -140,6 +141,14 @@
*/
void deleteInterface(const std::string& intf);
+/** @brief Converts the interface name into a u-boot environment
+ * variable that would hold its ethernet address.
+ *
+ * @param[in] intf - interface name
+ * @return The name of th environment key
+ */
+std::optional<std::string> interfaceToUbootEthAddr(const char* intf);
+
/** @brief read the DHCP value from the configuration file
* @param[in] confDir - Network configuration directory.
* @param[in] intf - Interface name.