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->autoboot_timeout_sec = 10;
17 config->network.interfaces = NULL;
18 config->network.n_interfaces = 0;
21 static void dump_config(struct config *config)
25 pb_log("configuration:\n");
27 if (config->autoboot_enabled)
28 pb_log(" autoboot: enabled, %d sec\n",
29 config->autoboot_timeout_sec);
31 pb_log(" autoboot: disabled\n");
33 if (config->network.n_interfaces || config->network.n_dns_servers)
34 pb_log(" network configuration:\n");
36 for (i = 0; i < config->network.n_interfaces; i++) {
37 struct interface_config *ifconf =
38 config->network.interfaces[i];
40 pb_log(" interface %02x:%02x:%02x:%02x:%02x:%02x\n",
41 ifconf->hwaddr[0], ifconf->hwaddr[1],
42 ifconf->hwaddr[2], ifconf->hwaddr[3],
43 ifconf->hwaddr[4], ifconf->hwaddr[5]);
50 if (ifconf->method == CONFIG_METHOD_DHCP) {
53 } else if (ifconf->method == CONFIG_METHOD_STATIC) {
55 pb_log(" ip: %s\n", ifconf->static_config.address);
56 pb_log(" gw: %s\n", ifconf->static_config.gateway);
60 for (i = 0; i < config->network.n_dns_servers; i++)
61 pb_log(" dns server %s\n", config->network.dns_servers[i]);
64 int config_init(void *ctx)
66 config = talloc(ctx, struct config);
67 config_set_defaults(config);
69 storage = create_powerpc_nvram_storage(config);
71 storage->load(storage, config);
78 const struct config *config_get(void)
83 void config_set_autoboot(bool autoboot_enabled)
85 config->autoboot_enabled = autoboot_enabled;
87 pb_log("set autoboot: %s\n",
88 config->autoboot_enabled ? "enabled" : "disabled");