1 #ifndef _DEVICE_HANDLER_H
2 #define _DEVICE_HANDLER_H
7 #include <types/types.h>
10 struct discover_device;
11 struct discover_server;
20 struct discover_device {
21 struct device *device;
31 const char *device_path;
32 struct ramdisk_device *ramdisk;
39 struct list boot_options;
43 struct discover_boot_option {
44 struct parser *source;
45 struct discover_device *device;
46 struct boot_option *option;
47 struct list_item list;
49 struct resource *boot_image;
50 struct resource *initrd;
52 struct resource *args_sig_file;
53 struct resource *icon;
57 struct discover_context {
58 struct device_handler *handler;
59 struct parser *parser;
61 struct discover_device *device;
62 struct list boot_options;
63 struct pb_url *conf_url;
67 struct ramdisk_device {
75 struct device_handler *device_handler_init(struct discover_server *server,
76 struct waitset *waitset, int dry_run);
78 void device_handler_destroy(struct device_handler *devices);
80 int device_handler_get_device_count(const struct device_handler *handler);
81 const struct discover_device *device_handler_get_device(
82 const struct device_handler *handler, unsigned int index);
83 struct network *device_handler_get_network(
84 const struct device_handler *handler);
86 struct discover_device *discover_device_create(struct device_handler *handler,
87 const char *uuid, const char *id);
88 void device_handler_add_device(struct device_handler *handler,
89 struct discover_device *device);
90 void device_handler_add_ramdisk(struct device_handler *handler,
92 struct ramdisk_device *device_handler_get_ramdisk(
93 struct device_handler *handler);
94 void device_handler_release_ramdisk(struct discover_device *device);
95 int device_handler_discover(struct device_handler *handler,
96 struct discover_device *dev);
97 int device_handler_dhcp(struct device_handler *handler,
98 struct discover_device *dev, struct event *event);
99 void device_handler_remove(struct device_handler *handler,
100 struct discover_device *device);
102 void device_handler_status(struct device_handler *handler,
103 struct status *status);
104 void device_handler_status_info(struct device_handler *handler,
105 const char *fmt, ...);
106 void device_handler_status_err(struct device_handler *handler,
107 const char *fmt, ...);
108 void device_handler_status_dev_info(struct device_handler *handler,
109 struct discover_device *dev, const char *fmt, ...);
110 void device_handler_status_dev_err(struct device_handler *handler,
111 struct discover_device *dev, const char *fmt, ...);
112 void device_handler_status_download(struct device_handler *handler,
113 const struct process_info *procinfo,
114 unsigned int percentage, unsigned int size, char suffix);
115 void device_handler_status_download_remove(struct device_handler *handler,
116 struct process_info *procinfo);
118 struct discover_context *device_handler_discover_context_create(
119 struct device_handler *handler,
120 struct discover_device *device);
121 void device_handler_discover_context_commit(struct device_handler *handler,
122 struct discover_context *ctx);
124 struct discover_boot_option *discover_boot_option_create(
125 struct discover_context *ctx,
126 struct discover_device *dev);
127 void discover_context_add_boot_option(struct discover_context *ctx,
128 struct discover_boot_option *opt);
130 int device_handler_user_event(struct device_handler *handler,
131 struct event *event);
133 struct discover_device *device_lookup_by_name(struct device_handler *handler,
135 struct discover_device *device_lookup_by_uuid(struct device_handler *handler,
137 struct discover_device *device_lookup_by_label(struct device_handler *handler,
139 struct discover_device *device_lookup_by_id(struct device_handler *handler,
141 struct discover_device *device_lookup_by_serial(
142 struct device_handler *device_handler,
145 void discover_device_set_param(struct discover_device *device,
146 const char *name, const char *value);
147 const char *discover_device_get_param(struct discover_device *device,
150 void device_handler_boot(struct device_handler *handler,
151 struct boot_command *cmd);
152 void device_handler_cancel_default(struct device_handler *handler);
153 void device_handler_update_config(struct device_handler *handler,
154 struct config *config);
155 void device_handler_process_url(struct device_handler *handler,
156 const char *url, const char *mac, const char *ip);
157 void device_handler_reinit(struct device_handler *handler);
159 int device_request_write(struct discover_device *dev, bool *release);
160 void device_release_write(struct discover_device *dev, bool release);
161 void device_sync_snapshots(struct device_handler *handler, const char *device);
163 #endif /* _DEVICE_HANDLER_H */