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