]> git.ozlabs.org Git - petitboot/blob - ui/common/discover-client.h
discover-client: Add discover_client_boot
[petitboot] / ui / common / discover-client.h
1 #ifndef _DISCOVER_CLIENT_H
2 #define _DISCOVER_CLIENT_H
3
4 #include <types/types.h>
5
6 struct discover_client;
7
8 struct pb_boot_data {
9         char *image;
10         char *initrd;
11         char *args;
12 };
13
14 /**
15  * struct discover_client_ops - Application supplied client info.
16  * @device_add: PB_PROTOCOL_ACTION_ADD event callback.
17  * @device_remove: PB_PROTOCOL_ACTION_REMOVE event callback.
18  * @cb_arg: Client managed convenience variable passed to callbacks.
19  */
20
21 struct discover_client_ops {
22         int (*device_add)(struct device *device, void *arg);
23         void (*device_remove)(struct device *device, void *arg);
24         void *cb_arg;
25 };
26
27 struct discover_client *discover_client_init(
28         const struct discover_client_ops *ops, void *cb_arg);
29
30 int discover_client_get_fd(const struct discover_client *client);
31
32 void discover_client_destroy(struct discover_client *client);
33
34 /**
35  * Process data from the server.
36  *
37  * Will read from the client socket, and call device_add on any discovered
38  * devices.
39  * 
40  */
41 int discover_client_process(struct discover_client *client);
42
43 /**
44  * Get the number of devices that the discover client has stored. This
45  * is the set of devices that have been added and not removed
46  *
47  * @param client The discover client
48  * @return       The number of devices that have been added.
49  */
50 int discover_client_device_count(struct discover_client *client);
51
52 /**
53  * Get the device at a specific index.
54  * @param client A pointer to the discover client
55  * @param index  The index of the device to retrieve
56  * @return       The device at the specified index, or NULL if none exists
57  */
58 struct device *discover_client_get_device(struct discover_client *client,
59                 int index);
60
61 /* Tell the discover server to boot an image
62  * @param client A pointer to the discover client
63  * @param boot_command The command to boot
64  */
65 int discover_client_boot(struct discover_client *client,
66                 const struct device *device,
67                 const struct boot_option *boot_option,
68                 const struct pb_boot_data *data);
69 #endif