]> git.ozlabs.org Git - petitboot/blob - ui/common/discover-client.h
configure: only test for msgfmt if NLS enabled
[petitboot] / ui / common / discover-client.h
1 #ifndef _DISCOVER_CLIENT_H
2 #define _DISCOVER_CLIENT_H
3
4 #include <types/types.h>
5 #include <waiter/waiter.h>
6
7 struct discover_client;
8
9 struct pb_boot_data {
10         char *image;
11         char *initrd;
12         char *dtb;
13         char *args;
14         char *args_sig_file;
15 };
16
17 struct pb_plugin_data {
18         char *plugin_file;
19         struct plugin_option *opt;
20 };
21
22 /**
23  * struct discover_client_ops - Application supplied client info.
24  * @device_add: PB_PROTOCOL_ACTION_ADD event callback.
25  * @device_remove: PB_PROTOCOL_ACTION_REMOVE event callback.
26  * @cb_arg: Client managed convenience variable passed to callbacks.
27  *
28  * The discover client holds talloc references to the devices (and the
29  * devices' boot options), so callbacks may store boot options and devices
30  * as long as the client remains allocated.
31  *
32  * The status and system_info structs are allocated by the client,
33  * and will be free()ed after the callback is invoked. If the callback
34  * stores these structures for usage beyond the duration of the callback,
35  * it must talloc_steal() them.
36  */
37
38 struct discover_client_ops {
39         int (*device_add)(struct device *device, void *arg);
40         int (*boot_option_add)(struct device *dev, struct boot_option *option,
41                         void *arg);
42         void (*device_remove)(struct device *device, void *arg);
43         int (*plugin_option_add)(struct plugin_option *option, void *arg);
44         int (*plugins_remove)(void *arg);
45         void (*update_status)(struct status *status, void *arg);
46         void (*update_sysinfo)(struct system_info *sysinfo, void *arg);
47         void (*update_config)(struct config *sysinfo, void *arg);
48         void *cb_arg;
49 };
50
51 struct discover_client *discover_client_init(struct waitset *waitset,
52         const struct discover_client_ops *ops, void *cb_arg);
53
54 void discover_client_destroy(struct discover_client *client);
55
56 /**
57  * Get the number of devices that the discover client has stored. This
58  * is the set of devices that have been added and not removed
59  *
60  * @param client The discover client
61  * @return       The number of devices that have been added.
62  */
63 int discover_client_device_count(struct discover_client *client);
64
65 /**
66  * Get the device at a specific index.
67  * @param client A pointer to the discover client
68  * @param index  The index of the device to retrieve
69  * @return       The device at the specified index, or NULL if none exists
70  */
71 struct device *discover_client_get_device(struct discover_client *client,
72                 int index);
73
74 /* Tell the discover server to boot an image
75  * @param client A pointer to the discover client
76  * @param boot_command The command to boot
77  */
78 int discover_client_boot(struct discover_client *client,
79                 const struct device *device,
80                 const struct boot_option *boot_option,
81                 const struct pb_boot_data *data);
82
83 /* Tell the discover server to cancel the default boot option, if any
84  */
85 int discover_client_cancel_default(struct discover_client *client);
86
87 /* Tell the discover server to reinitialise */
88 int discover_client_send_reinit(struct discover_client *client);
89
90 /* Send new configuration data to the discover server */
91 int discover_client_send_config(struct discover_client *client,
92                 struct config *config);
93
94 /* Re-enumerate the collected devices & boot options, calling ops->device_add
95  * and ops->boot_option_add on each.
96  */
97 void discover_client_enumerate(struct discover_client *client);
98
99 /* Send url to config to the discover server */
100 int discover_client_send_url(struct discover_client *client, char *url);
101 /* Send plugin file path to discover server to install */
102 int discover_client_send_plugin_install(struct discover_client *client,
103                 char *file);
104
105 #endif