]> git.ozlabs.org Git - petitboot/blob - lib/types/types.h
docker/build-pb: Add --interactive flag
[petitboot] / lib / types / types.h
1 #ifndef _TYPES_H
2 #define _TYPES_H
3
4 #include <stdbool.h>
5 #include <stdint.h>
6 #include <list/list.h>
7
8 enum device_type {
9         DEVICE_TYPE_NETWORK,
10         DEVICE_TYPE_DISK,
11         DEVICE_TYPE_USB,
12         DEVICE_TYPE_OPTICAL,
13         DEVICE_TYPE_ANY,
14         DEVICE_TYPE_UNKNOWN,
15 };
16
17 enum ipmi_bootdev {
18         IPMI_BOOTDEV_NONE = 0x00,
19         IPMI_BOOTDEV_NETWORK = 0x01,
20         IPMI_BOOTDEV_DISK = 0x2,
21         IPMI_BOOTDEV_SAFE = 0x3,
22         IPMI_BOOTDEV_CDROM = 0x5,
23         IPMI_BOOTDEV_SETUP = 0x6,
24         IPMI_BOOTDEV_INVALID = 0xff,
25 };
26
27 const char *ipmi_bootdev_display_name(enum ipmi_bootdev bootdev);
28 const char *device_type_display_name(enum device_type type);
29 const char *device_type_name(enum device_type type);
30 enum device_type find_device_type(const char *str);
31
32 struct device {
33         char            *id;
34         enum device_type type;
35         char            *name;
36         char            *description;
37         char            *icon_file;
38
39         int             n_options;
40         struct list     boot_options;
41
42         void            *ui_info;
43 };
44
45 struct boot_option {
46         char            *device_id;
47         char            *id;
48         char            *name;
49         char            *description;
50         char            *icon_file;
51         char            *boot_image_file;
52         char            *initrd_file;
53         char            *dtb_file;
54         char            *boot_args;
55         char            *args_sig_file;
56         bool            is_default;
57
58         struct list_item        list;
59
60         void            *ui_info;
61
62         enum {
63                 DISCOVER_BOOT_OPTION,
64                 DISCOVER_PLUGIN_OPTION,
65         } type;
66 };
67
68 struct plugin_option {
69         char            *id;
70         char            *name;
71         char            *vendor;
72         char            *vendor_id;
73         char            *version;
74         char            *date;
75         char            *plugin_file;
76
77         unsigned int    n_executables;
78         char            **executables;
79
80         void            *ui_info;
81 };
82
83 struct boot_command {
84         char *option_id;
85         char *boot_image_file;
86         char *initrd_file;
87         char *dtb_file;
88         char *boot_args;
89         char *args_sig_file;
90         char *console;
91 };
92
93 struct status {
94         enum status_type {
95                 STATUS_INFO,
96                 STATUS_ERROR,
97         } type;
98         char    *message;
99         bool    backlog;
100 };
101
102 struct statuslog_entry {
103         struct status           *status;
104         struct list_item        list;
105 };
106
107 struct interface_info {
108         unsigned int    hwaddr_size;
109         uint8_t         *hwaddr;
110         char            *name;
111         bool            link;
112         char            *address;
113 };
114
115 struct blockdev_info {
116         char            *name;
117         char            *uuid;
118         char            *mountpoint;
119 };
120
121 struct system_info {
122         char                    *type;
123         char                    *identifier;
124         char                    **platform_primary;
125         char                    **platform_other;
126         unsigned int            n_primary;
127         unsigned int            n_other;
128         char                    **bmc_current;
129         char                    **bmc_golden;
130         unsigned int            n_bmc_current;
131         unsigned int            n_bmc_golden;
132         uint8_t                 *bmc_mac;
133         struct interface_info   **interfaces;
134         unsigned int            n_interfaces;
135         struct blockdev_info    **blockdevs;
136         unsigned int            n_blockdevs;
137 };
138
139 #define HWADDR_SIZE     6
140
141 struct interface_config {
142         uint8_t hwaddr[HWADDR_SIZE];
143         bool    ignore;
144         enum {
145                 CONFIG_METHOD_DHCP,
146                 CONFIG_METHOD_STATIC,
147         } method;
148         union {
149                 struct {
150                 } dhcp_config;
151                 struct {
152                         char *address;
153                         char *gateway;
154                         char *url;
155                 } static_config;
156         };
157         bool    override;
158 };
159
160 struct network_config {
161         struct interface_config **interfaces;
162         unsigned int            n_interfaces;
163         const char              **dns_servers;
164         unsigned int            n_dns_servers;
165 };
166
167 struct autoboot_option {
168         enum {
169                 BOOT_DEVICE_TYPE,
170                 BOOT_DEVICE_UUID
171         } boot_type;
172         union {
173                 enum device_type        type;
174                 char                    *uuid;
175         };
176 };
177
178 struct config {
179         bool                    autoboot_enabled;
180         unsigned int            autoboot_timeout_sec;
181         struct network_config   network;
182
183         struct autoboot_option  *autoboot_opts;
184         unsigned int            n_autoboot_opts;
185
186         unsigned int            ipmi_bootdev;
187         bool                    ipmi_bootdev_persistent;
188
189         char                    *http_proxy;
190         char                    *https_proxy;
191
192         bool                    allow_writes;
193
194         char                    *boot_console;
195         bool                    manual_console;
196         char                    *lang;
197
198         /* not user-settable */
199         unsigned int            n_consoles;
200         char                    **consoles;
201         bool                    disable_snapshots;
202         bool                    safe_mode;
203         bool                    debug;
204 };
205
206 bool config_autoboot_active(const struct config *config);
207
208 #endif /* _TYPES_H */