5 #include <types/types.h>
6 #include <talloc/talloc.h>
10 static struct interface_config *config_copy_interface(struct config *ctx,
11 struct interface_config *src)
13 struct interface_config *dest = talloc_zero(ctx,
14 struct interface_config);
16 memcpy(dest->hwaddr, src->hwaddr, sizeof(src->hwaddr));
17 dest->ignore = src->ignore;
22 dest->method = src->method;
24 switch (src->method) {
25 case CONFIG_METHOD_DHCP:
27 case CONFIG_METHOD_STATIC:
28 dest->static_config.address =
29 talloc_strdup(dest, src->static_config.address);
30 dest->static_config.gateway =
31 talloc_strdup(dest, src->static_config.gateway);
32 dest->static_config.url =
33 talloc_strdup(dest, src->static_config.url);
36 dest->override = src->override;
41 struct config *config_copy(void *ctx, const struct config *src)
46 dest = talloc_zero(ctx, struct config);
47 dest->autoboot_enabled = src->autoboot_enabled;
48 dest->autoboot_timeout_sec = src->autoboot_timeout_sec;
49 dest->safe_mode = src->safe_mode;
51 dest->network.n_interfaces = src->network.n_interfaces;
52 dest->network.interfaces = talloc_array(dest, struct interface_config *,
53 dest->network.n_interfaces);
54 dest->network.n_dns_servers = src->network.n_dns_servers;
55 dest->network.dns_servers = talloc_array(dest, const char *,
56 dest->network.n_dns_servers);
58 for (i = 0; i < src->network.n_interfaces; i++)
59 dest->network.interfaces[i] = config_copy_interface(dest,
60 src->network.interfaces[i]);
62 for (i = 0; i < src->network.n_dns_servers; i++)
63 dest->network.dns_servers[i] = talloc_strdup(dest,
64 src->network.dns_servers[i]);
66 dest->http_proxy = talloc_strdup(dest, src->http_proxy);
67 dest->https_proxy = talloc_strdup(dest, src->https_proxy);
69 dest->n_autoboot_opts = src->n_autoboot_opts;
70 dest->autoboot_opts = talloc_array(dest, struct autoboot_option,
71 dest->n_autoboot_opts);
73 for (i = 0; i < src->n_autoboot_opts; i++) {
74 dest->autoboot_opts[i].boot_type =
75 src->autoboot_opts[i].boot_type;
76 if (src->autoboot_opts[i].boot_type == BOOT_DEVICE_TYPE)
77 dest->autoboot_opts[i].type =
78 src->autoboot_opts[i].type;
80 dest->autoboot_opts[i].uuid =
81 talloc_strdup(dest, src->autoboot_opts[i].uuid);
84 dest->ipmi_bootdev = src->ipmi_bootdev;
85 dest->ipmi_bootdev_persistent = src->ipmi_bootdev_persistent;
87 dest->allow_writes = src->allow_writes;
89 dest->n_consoles = src->n_consoles;
91 dest->consoles = talloc_array(dest, char *, src->n_consoles);
92 for (i = 0; i < src->n_consoles && src->n_consoles; i++)
93 dest->consoles[i] = talloc_strdup(dest->consoles,
96 if (src->boot_console)
97 dest->boot_console = talloc_strdup(dest, src->boot_console);
98 dest->manual_console = src->manual_console;
100 if (src->lang && strlen(src->lang))
101 dest->lang = talloc_strdup(dest, src->lang);