lib: Add plugin_option type and protocol
[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
63 struct plugin_option {
64         char            *id;
65         char            *name;
66         char            *vendor;
67         char            *vendor_id;
68         char            *version;
69         char            *date;
70         char            *plugin_file;
71
72         unsigned int    n_executables;
73         char            **executables;
74
75         void            *ui_info;
76 };
77
78 struct boot_command {
79         char *option_id;
80         char *boot_image_file;
81         char *initrd_file;
82         char *dtb_file;
83         char *boot_args;
84         char *args_sig_file;
85         char *console;
86 };
87
88 struct status {
89         enum status_type {
90                 STATUS_INFO,
91                 STATUS_ERROR,
92         } type;
93         char    *message;
94         bool    backlog;
95 };
96
97 struct statuslog_entry {
98         struct status           *status;
99         struct list_item        list;
100 };
101
102 struct interface_info {
103         unsigned int    hwaddr_size;
104         uint8_t         *hwaddr;
105         char            *name;
106         bool            link;
107         char            *address;
108 };
109
110 struct blockdev_info {
111         char            *name;
112         char            *uuid;
113         char            *mountpoint;
114 };
115
116 struct system_info {
117         char                    *type;
118         char                    *identifier;
119         char                    **platform_primary;
120         char                    **platform_other;
121         unsigned int            n_primary;
122         unsigned int            n_other;
123         char                    **bmc_current;
124         char                    **bmc_golden;
125         unsigned int            n_bmc_current;
126         unsigned int            n_bmc_golden;
127         uint8_t                 *bmc_mac;
128         struct interface_info   **interfaces;
129         unsigned int            n_interfaces;
130         struct blockdev_info    **blockdevs;
131         unsigned int            n_blockdevs;
132 };
133
134 #define HWADDR_SIZE     6
135
136 struct interface_config {
137         uint8_t hwaddr[HWADDR_SIZE];
138         bool    ignore;
139         enum {
140                 CONFIG_METHOD_DHCP,
141                 CONFIG_METHOD_STATIC,
142         } method;
143         union {
144                 struct {
145                 } dhcp_config;
146                 struct {
147                         char *address;
148                         char *gateway;
149                         char *url;
150                 } static_config;
151         };
152         bool    override;
153 };
154
155 struct network_config {
156         struct interface_config **interfaces;
157         unsigned int            n_interfaces;
158         const char              **dns_servers;
159         unsigned int            n_dns_servers;
160 };
161
162 struct autoboot_option {
163         enum {
164                 BOOT_DEVICE_TYPE,
165                 BOOT_DEVICE_UUID
166         } boot_type;
167         union {
168                 enum device_type        type;
169                 char                    *uuid;
170         };
171 };
172
173 struct config {
174         bool                    autoboot_enabled;
175         unsigned int            autoboot_timeout_sec;
176         struct network_config   network;
177
178         struct autoboot_option  *autoboot_opts;
179         unsigned int            n_autoboot_opts;
180
181         unsigned int            ipmi_bootdev;
182         bool                    ipmi_bootdev_persistent;
183
184         char                    *http_proxy;
185         char                    *https_proxy;
186
187         bool                    allow_writes;
188
189         char                    *boot_console;
190         bool                    manual_console;
191         char                    *lang;
192
193         /* not user-settable */
194         unsigned int            n_consoles;
195         char                    **consoles;
196         bool                    disable_snapshots;
197         bool                    safe_mode;
198         bool                    debug;
199 };
200
201 bool config_autoboot_active(const struct config *config);
202
203 #endif /* _TYPES_H */