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