lib: Move config structure defitinitions to types.h
[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_OPTICAL,
12         DEVICE_TYPE_UNKNOWN,
13 };
14
15 struct device {
16         char            *id;
17         enum device_type type;
18         char            *name;
19         char            *description;
20         char            *icon_file;
21
22         int             n_options;
23         struct list     boot_options;
24
25         void            *ui_info;
26 };
27
28 struct boot_option {
29         char            *device_id;
30         char            *id;
31         char            *name;
32         char            *description;
33         char            *icon_file;
34         char            *boot_image_file;
35         char            *initrd_file;
36         char            *dtb_file;
37         char            *boot_args;
38         bool            is_default;
39
40         struct list_item        list;
41
42         void            *ui_info;
43 };
44
45 struct boot_command {
46         char *option_id;
47         char *boot_image_file;
48         char *initrd_file;
49         char *dtb_file;
50         char *boot_args;
51 };
52
53 struct boot_status {
54         enum {
55                 BOOT_STATUS_INFO,
56                 BOOT_STATUS_ERROR,
57         } type;
58         char    *message;
59         char    *detail;
60         int     progress;
61 };
62
63 struct interface_info {
64         unsigned int    hwaddr_size;
65         uint8_t         *hwaddr;
66         char            *name;
67 };
68
69 struct system_info {
70         char                    *type;
71         char                    *identifier;
72         struct interface_info   **interfaces;
73         unsigned int            n_interfaces;
74 };
75
76 #define HWADDR_SIZE     6
77
78 struct interface_config {
79         uint8_t hwaddr[HWADDR_SIZE];
80         bool    ignore;
81         enum {
82                 CONFIG_METHOD_DHCP,
83                 CONFIG_METHOD_STATIC,
84         } method;
85         union {
86                 struct {
87                 } dhcp_config;
88                 struct {
89                         char *address;
90                         char *gateway;
91                 } static_config;
92         };
93 };
94
95 struct network_config {
96         struct interface_config **interfaces;
97         int                     n_interfaces;
98         const char              **dns_servers;
99         int                     n_dns_servers;
100 };
101
102 struct boot_priority {
103         enum device_type        type;
104 };
105
106 struct config {
107         bool                    autoboot_enabled;
108         int                     autoboot_timeout_sec;
109         struct network_config   network;
110         struct boot_priority    *boot_priorities;
111         int                     n_boot_priorities;
112 };
113
114 #endif /* _TYPES_H */