]> git.ozlabs.org Git - petitboot/blob - ui/common/discover-client.h
ui: callback & boot actions: kexec -> 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 /**
9  * struct discover_client_ops - Application supplied client info.
10  * @device_add: PB_PROTOCOL_ACTION_ADD event callback.
11  * @device_remove: PB_PROTOCOL_ACTION_REMOVE event callback.
12  * @cb_arg: Client managed convenience variable passed to callbacks.
13  */
14
15 struct discover_client_ops {
16         int (*device_add)(struct device *device, void *arg);
17         void (*device_remove)(struct device *device, void *arg);
18         void *cb_arg;
19 };
20
21 struct discover_client *discover_client_init(
22         const struct discover_client_ops *ops, void *cb_arg);
23
24 int discover_client_get_fd(const struct discover_client *client);
25
26 void discover_client_destroy(struct discover_client *client);
27
28 /**
29  * Process data from the server.
30  *
31  * Will read from the client socket, and call device_add on any discovered
32  * devices.
33  * 
34  */
35 int discover_client_process(struct discover_client *client);
36
37 /**
38  * Get the number of devices that the discover client has stored. This
39  * is the set of devices that have been added and not removed
40  *
41  * @param client The discover client
42  * @return       The number of devices that have been added.
43  */
44 int discover_client_device_count(struct discover_client *client);
45
46 /**
47  * Get the device at a specific index.
48  * @param client A pointer to the discover client
49  * @param index  The index of the device to retrieve
50  * @return       The device at the specified index, or NULL if none exists
51  */
52 struct device *discover_client_get_device(struct discover_client *client,
53                 int index);
54 #endif