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(ctx, struct interface_config);
15 memcpy(dest->hwaddr, src->hwaddr, sizeof(src->hwaddr));
16 dest->ignore = src->ignore;
21 dest->method = src->method;
23 switch (src->method) {
24 case CONFIG_METHOD_DHCP:
26 case CONFIG_METHOD_STATIC:
27 dest->static_config.address =
28 talloc_strdup(dest, src->static_config.address);
29 dest->static_config.gateway =
30 talloc_strdup(dest, src->static_config.gateway);
37 struct config *config_copy(void *ctx, const struct config *src)
42 dest = talloc(ctx, struct config);
43 dest->autoboot_enabled = src->autoboot_enabled;
44 dest->autoboot_timeout_sec = src->autoboot_timeout_sec;
45 dest->safe_mode = src->safe_mode;
47 dest->network.n_interfaces = src->network.n_interfaces;
48 dest->network.interfaces = talloc_array(dest, struct interface_config *,
49 dest->network.n_interfaces);
50 dest->network.n_dns_servers = src->network.n_dns_servers;
51 dest->network.dns_servers = talloc_array(dest, const char *,
52 dest->network.n_dns_servers);
54 for (i = 0; i < src->network.n_interfaces; i++)
55 dest->network.interfaces[i] = config_copy_interface(dest,
56 src->network.interfaces[i]);
58 for (i = 0; i < src->network.n_dns_servers; i++)
59 dest->network.dns_servers[i] = talloc_strdup(dest,
60 src->network.dns_servers[i]);
62 dest->n_autoboot_opts = src->n_autoboot_opts;
63 dest->autoboot_opts = talloc_array(dest, struct autoboot_option,
64 dest->n_autoboot_opts);
66 for (i = 0; i < src->n_autoboot_opts; i++) {
67 dest->autoboot_opts[i].boot_type =
68 src->autoboot_opts[i].boot_type;
69 if (src->autoboot_opts[i].boot_type == BOOT_DEVICE_TYPE)
70 dest->autoboot_opts[i].type =
71 src->autoboot_opts[i].type;
73 dest->autoboot_opts[i].uuid =
74 talloc_strdup(dest, src->autoboot_opts[i].uuid);
77 dest->ipmi_bootdev = src->ipmi_bootdev;
78 dest->ipmi_bootdev_persistent = src->ipmi_bootdev_persistent;
80 dest->allow_writes = src->allow_writes;
82 if (src->lang && strlen(src->lang))
83 dest->lang = talloc_strdup(dest, src->lang);