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;
46 dest->network.n_interfaces = src->network.n_interfaces;
47 dest->network.interfaces = talloc_array(dest, struct interface_config *,
48 dest->network.n_interfaces);
49 dest->network.n_dns_servers = src->network.n_dns_servers;
50 dest->network.dns_servers = talloc_array(dest, const char *,
51 dest->network.n_dns_servers);
53 for (i = 0; i < src->network.n_interfaces; i++)
54 dest->network.interfaces[i] = config_copy_interface(dest,
55 src->network.interfaces[i]);
57 for (i = 0; i < src->network.n_dns_servers; i++)
58 dest->network.dns_servers[i] = talloc_strdup(dest,
59 src->network.dns_servers[i]);
61 dest->n_boot_priorities = src->n_boot_priorities;
62 dest->boot_priorities = talloc_array(dest, struct boot_priority,
63 src->n_boot_priorities);
65 for (i = 0; i < src->n_boot_priorities; i++) {
66 dest->boot_priorities[i].priority =
67 src->boot_priorities[i].priority;
68 dest->boot_priorities[i].type = src->boot_priorities[i].type;