summaryrefslogtreecommitdiffstats
path: root/discover/sysinfo.c
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-12-19 15:56:49 +1100
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-12-20 16:40:22 +1100
commit0d3caaf8e9a75e9b6ebc9427c75ed2914c60439d (patch)
tree02b8930345eea0a0e0c11673ffac1cfe22495afc /discover/sysinfo.c
parentf901ce58f58ad4f7d769140fe98426e5ac9f7759 (diff)
downloadtalos-petitboot-0d3caaf8e9a75e9b6ebc9427c75ed2914c60439d.tar.gz
talos-petitboot-0d3caaf8e9a75e9b6ebc9427c75ed2914c60439d.zip
discover: Record IP address of network interfaces
If an interface has a valid IP address (either via DHCP or static config) store it in the interface_info struct so it can be referenced later. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'discover/sysinfo.c')
-rw-r--r--discover/sysinfo.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/discover/sysinfo.c b/discover/sysinfo.c
index 219369a..619c0c5 100644
--- a/discover/sysinfo.c
+++ b/discover/sysinfo.c
@@ -3,6 +3,7 @@
#include <talloc/talloc.h>
#include <process/process.h>
+#include <log/log.h>
#include "discover-server.h"
#include "platform.h"
@@ -16,6 +17,35 @@ const struct system_info *system_info_get(void)
return sysinfo;
}
+
+void system_info_set_interface_address(unsigned int hwaddr_size,
+ uint8_t *hwaddr, const char *address)
+{
+ struct interface_info *if_info;
+ unsigned int i;
+
+ for (i = 0; i < sysinfo->n_interfaces; i++) {
+ if_info = sysinfo->interfaces[i];
+
+ if (if_info->hwaddr_size != hwaddr_size)
+ continue;
+
+ if (memcmp(if_info->hwaddr, hwaddr, hwaddr_size))
+ continue;
+
+ /* Found an existing interface. Notify clients if a new address
+ * is set */
+ if (!if_info->address || strcmp(if_info->address, address)) {
+ talloc_free(if_info->address);
+ if_info->address = talloc_strdup(if_info, address);
+ discover_server_notify_system_info(server, sysinfo);
+ return;
+ }
+ }
+
+ pb_log("Couldn't find interface matching %s\n", "foo");
+}
+
void system_info_register_interface(unsigned int hwaddr_size, uint8_t *hwaddr,
const char *name, bool link)
{
OpenPOWER on IntegriCloud