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;
50 struct resource *boot_image;
51 struct resource *initrd;
53 struct resource *args_sig_file;
54 struct resource *icon;
58 struct discover_context {
59 struct device_handler *handler;
60 struct parser *parser;
62 struct discover_device *device;
63 struct list boot_options;
64 struct pb_url *conf_url;
68 struct ramdisk_device {
76 struct device_handler *device_handler_init(struct discover_server *server,
77 struct waitset *waitset, int dry_run);
79 void device_handler_destroy(struct device_handler *devices);
81 int device_handler_get_device_count(const struct device_handler *handler);
82 const struct discover_device *device_handler_get_device(
83 const struct device_handler *handler, unsigned int index);
84 int device_handler_get_plugin_count(const struct device_handler *handler);
85 const struct plugin_option *device_handler_get_plugin(
86 const struct device_handler *handler, unsigned int index);
87 struct network *device_handler_get_network(
88 const struct device_handler *handler);
90 struct discover_device *discover_device_create(struct device_handler *handler,
91 const char *uuid, const char *id);
92 void device_handler_add_device(struct device_handler *handler,
93 struct discover_device *device);
94 void device_handler_add_ramdisk(struct device_handler *handler,
96 struct ramdisk_device *device_handler_get_ramdisk(
97 struct device_handler *handler);
98 void device_handler_release_ramdisk(struct discover_device *device);
99 int device_handler_discover(struct device_handler *handler,
100 struct discover_device *dev);
101 int device_handler_dhcp(struct device_handler *handler,
102 struct discover_device *dev, struct event *event);
103 void device_handler_remove(struct device_handler *handler,
104 struct discover_device *device);
106 void device_handler_status(struct device_handler *handler,
107 struct status *status);
108 void device_handler_status_info(struct device_handler *handler,
109 const char *fmt, ...);
110 void device_handler_status_err(struct device_handler *handler,
111 const char *fmt, ...);
112 void device_handler_status_dev_info(struct device_handler *handler,
113 struct discover_device *dev, const char *fmt, ...);
114 void device_handler_status_dev_err(struct device_handler *handler,
115 struct discover_device *dev, const char *fmt, ...);
116 void device_handler_status_download(struct device_handler *handler,
117 const struct process_info *procinfo,
118 unsigned int percentage, unsigned int size, char suffix);
119 void device_handler_status_download_remove(struct device_handler *handler,
120 struct process_info *procinfo);
122 struct discover_context *device_handler_discover_context_create(
123 struct device_handler *handler,
124 struct discover_device *device);
125 void device_handler_discover_context_commit(struct device_handler *handler,
126 struct discover_context *ctx);
128 struct discover_boot_option *discover_boot_option_create(
129 struct discover_context *ctx,
130 struct discover_device *dev);
131 void discover_context_add_boot_option(struct discover_context *ctx,
132 struct discover_boot_option *opt);
133 void device_handler_add_plugin_option(struct device_handler *handler,
134 struct plugin_option *opt);
136 int device_handler_user_event(struct device_handler *handler,
137 struct event *event);
139 struct discover_device *device_lookup_by_name(struct device_handler *handler,
141 struct discover_device *device_lookup_by_uuid(struct device_handler *handler,
143 struct discover_device *device_lookup_by_label(struct device_handler *handler,
145 struct discover_device *device_lookup_by_id(struct device_handler *handler,
147 struct discover_device *device_lookup_by_serial(
148 struct device_handler *device_handler,
151 void discover_device_set_param(struct discover_device *device,
152 const char *name, const char *value);
153 const char *discover_device_get_param(struct discover_device *device,
156 void device_handler_boot(struct device_handler *handler,
157 struct boot_command *cmd);
158 void device_handler_cancel_default(struct device_handler *handler);
159 void device_handler_update_config(struct device_handler *handler,
160 struct config *config);
161 void device_handler_process_url(struct device_handler *handler,
162 const char *url, const char *mac, const char *ip);
163 void device_handler_install_plugin(struct device_handler *handler,
164 const char *plugin_file);
165 void device_handler_reinit(struct device_handler *handler);
167 int device_request_write(struct discover_device *dev, bool *release);
168 void device_release_write(struct discover_device *dev, bool release);
169 void device_sync_snapshots(struct device_handler *handler, const char *device);
171 #endif /* _DEVICE_HANDLER_H */