3 #include <talloc/talloc.h>
9 static struct config *config;
10 static struct config_storage *storage;
13 static void config_set_defaults(struct config *config)
15 config->autoboot_enabled = true;
16 config->network.interfaces = NULL;
17 config->network.n_interfaces = 0;
20 static void dump_config(struct config *config)
24 pb_log("configuration:\n");
26 pb_log(" autoboot: %s\n",
27 config->autoboot_enabled ? "enabled" : "disabled");
29 if (config->network.n_interfaces || config->network.n_dns_servers)
30 pb_log(" network configuration:\n");
32 for (i = 0; i < config->network.n_interfaces; i++) {
33 struct interface_config *ifconf =
34 config->network.interfaces[i];
36 pb_log(" interface %02x:%02x:%02x:%02x:%02x:%02x\n",
37 ifconf->hwaddr[0], ifconf->hwaddr[1],
38 ifconf->hwaddr[2], ifconf->hwaddr[3],
39 ifconf->hwaddr[4], ifconf->hwaddr[5]);
46 if (ifconf->method == CONFIG_METHOD_DHCP) {
49 } else if (ifconf->method == CONFIG_METHOD_STATIC) {
51 pb_log(" ip: %s\n", ifconf->static_config.address);
52 pb_log(" gw: %s\n", ifconf->static_config.gateway);
56 for (i = 0; i < config->network.n_dns_servers; i++)
57 pb_log(" dns server %s\n", config->network.dns_servers[i]);
60 int config_init(void *ctx)
62 config = talloc(ctx, struct config);
63 config_set_defaults(config);
65 storage = create_powerpc_nvram_storage(config);
67 storage->load(storage, config);
74 const struct config *config_get(void)
79 void config_set_autoboot(bool autoboot_enabled)
81 config->autoboot_enabled = autoboot_enabled;
83 pb_log("set autoboot: %s\n",
84 config->autoboot_enabled ? "enabled" : "disabled");