4 #include "ui/common/discover-client.h"
6 static const char *device_type_string(enum device_type type)
13 case DEVICE_TYPE_NETWORK:
15 case DEVICE_TYPE_OPTICAL:
19 case DEVICE_TYPE_LUKS:
21 case DEVICE_TYPE_UNKNOWN:
27 static int print_device_add(struct device *device,
28 void __attribute__((unused)) *arg)
30 struct boot_option *opt;
32 printf("new device:\n");
33 printf("\tid: %s\n", device->id);
34 printf("\ttype: %s\n", device_type_string(device->type));
35 printf("\tname: %s\n", device->name);
36 printf("\tdesc: %s\n", device->description);
37 printf("\ticon: %s\n", device->icon_file);
39 printf("\tboot options:\n");
40 list_for_each_entry(&device->boot_options, opt, list) {
41 printf("\t\tid: %s\n", opt->id);
42 printf("\t\tname: %s\n", opt->name);
43 printf("\t\tdesc: %s\n", opt->description);
44 printf("\t\ticon: %s\n", opt->icon_file);
45 printf("\t\tboot: %s\n", opt->boot_image_file);
46 printf("\t\tinit: %s\n", opt->initrd_file);
47 printf("\t\tdtb: %s\n", opt->dtb_file);
48 printf("\t\targs: %s\n", opt->boot_args);
54 static int print_boot_option_add(struct device *dev,
55 struct boot_option *opt,
56 void __attribute__((unused)) *arg)
58 printf("new boot option (dev: %s):\n", dev->id);
59 printf("\tdev id: %s\n", opt->device_id);
60 printf("\tid: %s\n", opt->id);
61 printf("\tname: %s\n", opt->name);
62 printf("\tdesc: %s\n", opt->description);
63 printf("\ticon: %s\n", opt->icon_file);
64 printf("\tboot: %s\n", opt->boot_image_file);
65 printf("\tinit: %s\n", opt->initrd_file);
66 printf("\targs: %s\n", opt->boot_args);
67 printf("\tdefault:%d\n", opt->is_default);
72 static void print_device_remove(struct device *device,
73 void __attribute__((unused)) *arg)
75 printf("removed device:\n");
76 printf("\tid: %s\n", device->id);
77 printf("\tname: %s\n", device->name);
80 static void print_status(struct status *status,
81 void __attribute__((unused)) *arg)
84 printf("\ttype: %d\n", status->type);
85 printf("\tmessage: %s\n", status->message);
89 static void print_sysinfo(struct system_info *sysinfo,
90 void __attribute__((unused)) *arg)
95 printf("\ttype: %s\n", sysinfo->type);
96 printf("\tid: %s\n", sysinfo->identifier);
98 if (sysinfo->n_interfaces == 0)
99 printf("\tno interfaces.\n");
101 printf("\tinterfaces:\n");
103 for (i = 0; i < sysinfo->n_interfaces; i++) {
104 struct interface_info *if_info = sysinfo->interfaces[i];
105 uint8_t *m = if_info->hwaddr;
107 printf("\t\tname: %s\n", if_info->name);
109 if (if_info->hwaddr_size == 6)
110 printf("\t\tmac: %02x:%02x:%02x:%02x:%02x:%02x\n",
111 m[0], m[1], m[2], m[3], m[4], m[5]);
113 printf("\t\tmac: unknown hwaddr size %d\n",
114 if_info->hwaddr_size);
118 static struct discover_client_ops client_ops = {
119 .device_add = print_device_add,
120 .boot_option_add = print_boot_option_add,
121 .device_remove = print_device_remove,
122 .update_status = print_status,
123 .update_sysinfo = print_sysinfo,
128 struct discover_client *client;
129 struct waitset *waitset;
131 waitset = waitset_create(NULL);
133 client = discover_client_init(waitset, &client_ops, NULL);
140 rc = waiter_poll(waitset);