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;
19 config->network.dns_servers = NULL;
20 config->network.n_dns_servers = 0;
23 static void dump_config(struct config *config)
27 pb_log("configuration:\n");
29 if (config->autoboot_enabled)
30 pb_log(" autoboot: enabled, %d sec\n",
31 config->autoboot_timeout_sec);
33 pb_log(" autoboot: disabled\n");
35 if (config->network.n_interfaces || config->network.n_dns_servers)
36 pb_log(" network configuration:\n");
38 for (i = 0; i < config->network.n_interfaces; i++) {
39 struct interface_config *ifconf =
40 config->network.interfaces[i];
42 pb_log(" interface %02x:%02x:%02x:%02x:%02x:%02x\n",
43 ifconf->hwaddr[0], ifconf->hwaddr[1],
44 ifconf->hwaddr[2], ifconf->hwaddr[3],
45 ifconf->hwaddr[4], ifconf->hwaddr[5]);
52 if (ifconf->method == CONFIG_METHOD_DHCP) {
55 } else if (ifconf->method == CONFIG_METHOD_STATIC) {
57 pb_log(" ip: %s\n", ifconf->static_config.address);
58 pb_log(" gw: %s\n", ifconf->static_config.gateway);
62 for (i = 0; i < config->network.n_dns_servers; i++)
63 pb_log(" dns server %s\n", config->network.dns_servers[i]);
66 int config_init(void *ctx)
68 config = talloc(ctx, struct config);
69 config_set_defaults(config);
71 storage = create_powerpc_nvram_storage(config);
73 storage->load(storage, config);
80 const struct config *config_get(void)
85 void config_set_autoboot(bool autoboot_enabled)
87 config->autoboot_enabled = autoboot_enabled;
89 pb_log("set autoboot: %s\n",
90 config->autoboot_enabled ? "enabled" : "disabled");