1 #ifndef _DEVICE_HANDLER_H
2 #define _DEVICE_HANDLER_H
7 #include <types/types.h>
10 struct discover_device;
11 struct discover_server;
19 struct discover_device {
20 struct device *device;
30 const char *device_path;
31 struct ramdisk_device *ramdisk;
38 struct list boot_options;
42 struct discover_boot_option {
43 struct parser *source;
44 struct discover_device *device;
45 struct boot_option *option;
46 struct list_item list;
48 struct resource *boot_image;
49 struct resource *initrd;
51 struct resource *args_sig_file;
52 struct resource *icon;
56 struct discover_context {
57 struct device_handler *handler;
58 struct parser *parser;
60 struct discover_device *device;
61 struct list boot_options;
62 struct pb_url *conf_url;
66 struct ramdisk_device {
74 struct device_handler *device_handler_init(struct discover_server *server,
75 struct waitset *waitset, int dry_run);
77 void device_handler_destroy(struct device_handler *devices);
79 int device_handler_get_device_count(const struct device_handler *handler);
80 const struct discover_device *device_handler_get_device(
81 const struct device_handler *handler, unsigned int index);
82 struct network *device_handler_get_network(
83 const struct device_handler *handler);
85 struct discover_device *discover_device_create(struct device_handler *handler,
86 const char *uuid, const char *id);
87 void device_handler_add_device(struct device_handler *handler,
88 struct discover_device *device);
89 void device_handler_add_ramdisk(struct device_handler *handler,
91 struct ramdisk_device *device_handler_get_ramdisk(
92 struct device_handler *handler);
93 void device_handler_release_ramdisk(struct discover_device *device);
94 int device_handler_discover(struct device_handler *handler,
95 struct discover_device *dev);
96 int device_handler_dhcp(struct device_handler *handler,
97 struct discover_device *dev, struct event *event);
98 void device_handler_remove(struct device_handler *handler,
99 struct discover_device *device);
101 void device_handler_status(struct device_handler *handler,
102 struct status *status);
103 void device_handler_status_info(struct device_handler *handler,
104 const char *fmt, ...);
105 void device_handler_status_err(struct device_handler *handler,
106 const char *fmt, ...);
107 void device_handler_status_dev_info(struct device_handler *handler,
108 struct discover_device *dev, const char *fmt, ...);
109 void device_handler_status_dev_err(struct device_handler *handler,
110 struct discover_device *dev, const char *fmt, ...);
112 struct discover_context *device_handler_discover_context_create(
113 struct device_handler *handler,
114 struct discover_device *device);
115 void device_handler_discover_context_commit(struct device_handler *handler,
116 struct discover_context *ctx);
118 struct discover_boot_option *discover_boot_option_create(
119 struct discover_context *ctx,
120 struct discover_device *dev);
121 void discover_context_add_boot_option(struct discover_context *ctx,
122 struct discover_boot_option *opt);
124 int device_handler_user_event(struct device_handler *handler,
125 struct event *event);
127 struct discover_device *device_lookup_by_name(struct device_handler *handler,
129 struct discover_device *device_lookup_by_uuid(struct device_handler *handler,
131 struct discover_device *device_lookup_by_label(struct device_handler *handler,
133 struct discover_device *device_lookup_by_id(struct device_handler *handler,
135 struct discover_device *device_lookup_by_serial(
136 struct device_handler *device_handler,
139 void discover_device_set_param(struct discover_device *device,
140 const char *name, const char *value);
141 const char *discover_device_get_param(struct discover_device *device,
144 void device_handler_boot(struct device_handler *handler,
145 struct boot_command *cmd);
146 void device_handler_cancel_default(struct device_handler *handler);
147 void device_handler_update_config(struct device_handler *handler,
148 struct config *config);
149 void device_handler_process_url(struct device_handler *handler,
150 const char *url, const char *mac, const char *ip);
151 void device_handler_reinit(struct device_handler *handler);
153 int device_request_write(struct discover_device *dev, bool *release);
154 void device_release_write(struct discover_device *dev, bool release);
155 void device_sync_snapshots(struct device_handler *handler, const char *device);
157 #endif /* _DEVICE_HANDLER_H */