]> git.ozlabs.org Git - petitboot/blob - lib/pb-protocol/pb-protocol.h
Add DEVPATH to udev_print_event()
[petitboot] / lib / pb-protocol / pb-protocol.h
1 #ifndef _PB_PROTOCOL_H
2 #define _PB_PROTOCOL_H
3
4 #include <stdint.h>
5 #include <stdio.h>
6
7 #include <list/list.h>
8
9 #define PB_SOCKET_PATH "/tmp/petitboot.ui"
10
11 #define PB_PROTOCOL_MAX_PAYLOAD_SIZE (64 * 1024)
12
13 enum pb_protocol_action {
14         PB_PROTOCOL_ACTION_ADD          = 0x1,
15         PB_PROTOCOL_ACTION_REMOVE       = 0x2,
16 };
17
18 struct pb_protocol_message {
19         uint32_t action;
20         uint32_t payload_len;
21         char     payload[];
22 };
23
24 struct device {
25         char *id;
26         char *name;
27         char *description;
28         char *icon_file;
29
30         struct list boot_options;
31
32         int n_options;
33         void *ui_info;
34 };
35
36 struct boot_option {
37         char *id;
38         char *name;
39         char *description;
40         char *icon_file;
41         char *boot_image_file;
42         char *initrd_file;
43         char *boot_args;
44
45         struct list_item list;
46
47         void *ui_info;
48 };
49
50 void pb_protocol_dump_device(const struct device *dev, const char *text,
51         FILE *stream);
52 int pb_protocol_device_len(const struct device *dev);
53 int pb_protocol_device_cmp(const struct device *a, const struct device *b);
54
55 int pb_protocol_boot_option_cmp(const struct boot_option *a,
56         const struct boot_option *b);
57
58 int pb_protocol_serialise_string(char *pos, const char *str);
59 char *pb_protocol_deserialise_string(void *ctx,
60                 const struct pb_protocol_message *message);
61
62 int pb_protocol_serialise_device(const struct device *dev, char *buf, int buf_len);
63
64 int pb_protocol_write_message(int fd, struct pb_protocol_message *message);
65
66 struct pb_protocol_message *pb_protocol_create_message(void *ctx,
67                 enum pb_protocol_action action, int payload_len);
68
69 struct pb_protocol_message *pb_protocol_read_message(void *ctx, int fd);
70
71 struct device *pb_protocol_deserialise_device(void *ctx,
72                 const struct pb_protocol_message *message);
73
74 #endif /* _PB_PROTOCOL_H */