summaryrefslogtreecommitdiffstats
path: root/lib/types/types.h
blob: f7e47522dcd818d6b2a226e469fd7ee48543f50e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#ifndef _TYPES_H
#define _TYPES_H

#include <stdbool.h>
#include <stdint.h>
#include <list/list.h>

enum device_type {
	DEVICE_TYPE_NETWORK,
	DEVICE_TYPE_DISK,
	DEVICE_TYPE_OPTICAL,
	DEVICE_TYPE_ANY,
	DEVICE_TYPE_UNKNOWN,
};

enum ipmi_bootdev {
	IPMI_BOOTDEV_NONE = 0x00,
	IPMI_BOOTDEV_NETWORK = 0x01,
	IPMI_BOOTDEV_DISK = 0x2,
	IPMI_BOOTDEV_SAFE = 0x3,
	IPMI_BOOTDEV_CDROM = 0x5,
	IPMI_BOOTDEV_SETUP = 0x6,
	IPMI_BOOTDEV_INVALID = 0xff,
};

const char *ipmi_bootdev_display_name(enum ipmi_bootdev bootdev);
const char *device_type_display_name(enum device_type type);
const char *device_type_name(enum device_type type);
enum device_type find_device_type(const char *str);

struct device {
	char		*id;
	enum device_type type;
	char		*name;
	char		*description;
	char		*icon_file;

	int		n_options;
	struct list	boot_options;

	void		*ui_info;
};

struct boot_option {
	char		*device_id;
	char		*id;
	char		*name;
	char		*description;
	char		*icon_file;
	char		*boot_image_file;
	char		*initrd_file;
	char		*dtb_file;
	char		*boot_args;
	bool		is_default;

	struct list_item	list;

	void		*ui_info;
};

struct boot_command {
	char *option_id;
	char *boot_image_file;
	char *initrd_file;
	char *dtb_file;
	char *boot_args;
};

struct boot_status {
	enum {
		BOOT_STATUS_INFO,
		BOOT_STATUS_ERROR,
	} type;
	char	*message;
	char	*detail;
	int	progress;
};

struct interface_info {
	unsigned int	hwaddr_size;
	uint8_t		*hwaddr;
	char		*name;
	bool		link;
};

struct blockdev_info {
	char		*name;
	char		*uuid;
	char		*mountpoint;
};

struct system_info {
	char			*type;
	char			*identifier;
	struct interface_info	**interfaces;
	unsigned int		n_interfaces;
	struct blockdev_info	**blockdevs;
	unsigned int		n_blockdevs;
};

#define HWADDR_SIZE	6

struct interface_config {
	uint8_t	hwaddr[HWADDR_SIZE];
	bool	ignore;
	enum {
		CONFIG_METHOD_DHCP,
		CONFIG_METHOD_STATIC,
	} method;
	union {
		struct {
		} dhcp_config;
		struct {
			char *address;
			char *gateway;
		} static_config;
	};
};

struct network_config {
	struct interface_config	**interfaces;
	unsigned int		n_interfaces;
	const char		**dns_servers;
	unsigned int		n_dns_servers;
};

struct autoboot_option {
	enum {
		BOOT_DEVICE_TYPE,
		BOOT_DEVICE_UUID
	} boot_type;
	union {
		enum device_type	type;
		char			*uuid;
	};
};

struct config {
	bool			autoboot_enabled;
	unsigned int		autoboot_timeout_sec;
	struct network_config	network;

	struct autoboot_option	*autoboot_opts;
	unsigned int		n_autoboot_opts;

	unsigned int		ipmi_bootdev;
	bool			ipmi_bootdev_persistent;

	bool			allow_writes;

	char			*lang;

	/* not user-settable */
	bool			safe_mode;
	bool			debug;
};

#endif /* _TYPES_H */
OpenPOWER on IntegriCloud