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