]> git.ozlabs.org Git - petitboot/blob - lib/pb-config/storage-test.c
lib/pb-config: Initialise DNS server info
[petitboot] / lib / pb-config / storage-test.c
1
2 #include <string.h>
3 #include <stdlib.h>
4 #include <sys/types.h>
5 #include <sys/wait.h>
6
7 #include "pb-config.h"
8 #include "storage.h"
9
10 struct interface_config net1 = {
11         .hwaddr = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 },
12         .method = CONFIG_METHOD_DHCP,
13 };
14
15 struct interface_config net2 = {
16         .hwaddr = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x56 },
17         .method = CONFIG_METHOD_STATIC,
18         .static_config = {
19                 .address = "192.168.0.2/24",
20                 .gateway = "192.168.0.1",
21         },
22 };
23
24 struct interface_config *interface_configs[] = { &net1, &net2 };
25 const char *dns_servers[] = { "192.168.1.1", "192.168.1.2" };
26
27 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
28
29 struct config test_config = {
30         .autoboot_enabled = true,
31         .network = {
32                 .interfaces = interface_configs,
33                 .n_interfaces = ARRAY_SIZE(interface_configs),
34                 .dns_servers = dns_servers,
35                 .n_dns_servers = ARRAY_SIZE(dns_servers),
36         }
37 };
38
39 struct test_storage {
40         struct config_storage   storage;
41         struct param            *params;
42         int                     n_params;
43 };
44
45 static int load(struct config_storage *st __attribute__((unused)),
46                 struct config *config)
47 {
48         memcpy(config, &test_config, sizeof(test_config));
49         return 0;
50 }
51
52 static struct test_storage st = {
53         .storage = {
54                 .load  = load,
55         },
56 };
57
58 struct config_storage *create_test_storage(void *ctx __attribute__((unused)))
59 {
60         return &st.storage;
61 }