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;
42 struct waiter *requery_waiter;
45 struct discover_boot_option {
46 struct parser *source;
47 struct discover_device *device;
48 struct boot_option *option;
49 struct list_item list;
52 struct resource *boot_image;
53 struct resource *initrd;
55 struct resource *args_sig_file;
56 struct resource *icon;
60 struct discover_context {
61 struct device_handler *handler;
62 struct parser *parser;
64 struct discover_device *device;
65 struct list boot_options;
66 struct pb_url *conf_url;
70 struct ramdisk_device {
78 struct device_handler *device_handler_init(struct discover_server *server,
79 struct waitset *waitset, int dry_run);
81 void device_handler_destroy(struct device_handler *devices);
83 int device_handler_get_device_count(const struct device_handler *handler);
84 const struct discover_device *device_handler_get_device(
85 const struct device_handler *handler, unsigned int index);
86 int device_handler_get_plugin_count(const struct device_handler *handler);
87 const struct plugin_option *device_handler_get_plugin(
88 const struct device_handler *handler, unsigned int index);
89 struct network *device_handler_get_network(
90 const struct device_handler *handler);
92 struct discover_device *discover_device_create(struct device_handler *handler,
93 const char *uuid, const char *id);
94 void device_handler_add_device(struct device_handler *handler,
95 struct discover_device *device);
96 void device_handler_add_ramdisk(struct device_handler *handler,
98 struct ramdisk_device *device_handler_get_ramdisk(
99 struct device_handler *handler);
100 void device_handler_release_ramdisk(struct discover_device *device);
101 int device_handler_discover(struct device_handler *handler,
102 struct discover_device *dev);
103 int device_handler_dhcp(struct device_handler *handler,
104 struct discover_device *dev, struct event *event);
105 void device_handler_remove(struct device_handler *handler,
106 struct discover_device *device);
107 void device_handler_start_requery_timeout( struct device_handler *handler,
108 struct discover_device *dev, int timeout);
110 void device_handler_status(struct device_handler *handler,
111 struct status *status);
112 void device_handler_status_info(struct device_handler *handler,
113 const char *fmt, ...);
114 void device_handler_status_err(struct device_handler *handler,
115 const char *fmt, ...);
116 void device_handler_status_dev_info(struct device_handler *handler,
117 struct discover_device *dev, const char *fmt, ...);
118 void device_handler_status_dev_err(struct device_handler *handler,
119 struct discover_device *dev, const char *fmt, ...);
120 void device_handler_status_download(struct device_handler *handler,
121 const struct process_info *procinfo,
122 unsigned int percentage, unsigned int size, char suffix);
123 void device_handler_status_download_remove(struct device_handler *handler,
124 struct process_info *procinfo);
126 struct discover_context *device_handler_discover_context_create(
127 struct device_handler *handler,
128 struct discover_device *device);
129 void device_handler_discover_context_commit(struct device_handler *handler,
130 struct discover_context *ctx);
132 struct discover_boot_option *discover_boot_option_create(
133 struct discover_context *ctx,
134 struct discover_device *dev);
135 void discover_context_add_boot_option(struct discover_context *ctx,
136 struct discover_boot_option *opt);
137 void device_handler_add_plugin_option(struct device_handler *handler,
138 struct plugin_option *opt);
140 int device_handler_user_event(struct device_handler *handler,
141 struct event *event);
143 struct discover_device *device_lookup_by_name(struct device_handler *handler,
145 struct discover_device *device_lookup_by_uuid(struct device_handler *handler,
147 struct discover_device *device_lookup_by_label(struct device_handler *handler,
149 struct discover_device *device_lookup_by_id(struct device_handler *handler,
151 struct discover_device *device_lookup_by_serial(
152 struct device_handler *device_handler,
155 void discover_device_set_param(struct discover_device *device,
156 const char *name, const char *value);
157 const char *discover_device_get_param(struct discover_device *device,
160 void device_handler_boot(struct device_handler *handler,
161 struct boot_command *cmd);
162 void device_handler_cancel_default(struct device_handler *handler);
163 void device_handler_update_config(struct device_handler *handler,
164 struct config *config);
165 void device_handler_process_url(struct device_handler *handler,
166 const char *url, const char *mac, const char *ip);
167 void device_handler_install_plugin(struct device_handler *handler,
168 const char *plugin_file);
169 void device_handler_reinit(struct device_handler *handler);
170 void device_handler_apply_temp_autoboot(struct device_handler *handler,
171 struct autoboot_option *opt);
173 int device_request_write(struct discover_device *dev, bool *release);
174 void device_release_write(struct discover_device *dev, bool release);
175 void device_sync_snapshots(struct device_handler *handler, const char *device);
177 #endif /* _DEVICE_HANDLER_H */