From 32e6a41f33e5576716b351bd473a27939fe94fa1 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Mon, 15 Dec 2008 15:22:34 +1100 Subject: Initial support for multiple UIs Move the device discovery code from separate udev helpers to a single process to listen on two sockets: one SOCK_DGRAM for incoming udev events, and one SOCK_STREAM for UIs to connect. Initial support for client/server infrastructure, still need to wire-up the udev messages. Signed-off-by: Jeremy Kerr --- lib/pb-protocol/pb-protocol.h | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 lib/pb-protocol/pb-protocol.h (limited to 'lib/pb-protocol/pb-protocol.h') diff --git a/lib/pb-protocol/pb-protocol.h b/lib/pb-protocol/pb-protocol.h new file mode 100644 index 0000000..7b557d6 --- /dev/null +++ b/lib/pb-protocol/pb-protocol.h @@ -0,0 +1,57 @@ +#ifndef _PB_PROTOCOL_H +#define _PB_PROTOCOL_H + +#include + +#define PB_SOCKET_PATH "/tmp/petitboot.ui" + +#define PB_PROTOCOL_MAX_PAYLOAD_SIZE 4096 + +enum pb_protocol_action { + PB_PROTOCOL_ACTION_ADD = 0x1, + PB_PROTOCOL_ACTION_REMOVE = 0x2, +}; + +struct pb_protocol_message { + uint32_t action; + uint32_t payload_len; + char payload[]; +}; + +struct device { + char *id; + char *name; + char *description; + char *icon_file; + + struct boot_option { + char *id; + char *name; + char *description; + char *icon_file; + char *boot_image_file; + char *initrd_file; + char *boot_args; + } *options; + int n_options; +}; + +int pb_protocol_device_len(struct device *dev); + +int pb_protocol_serialise_string(char *pos, const char *str); +char *pb_protocol_deserialise_string(void *ctx, + struct pb_protocol_message *message); + +int pb_protocol_serialise_device(struct device *dev, char *buf, int buf_len); + +int pb_protocol_write_message(int fd, struct pb_protocol_message *message); + +struct pb_protocol_message *pb_protocol_create_message(void *ctx, + int action, int payload_len); + +struct pb_protocol_message *pb_protocol_read_message(void *ctx, int fd); + +struct device *pb_protocol_deserialise_device(void *ctx, + struct pb_protocol_message *message); + +#endif /* _PB_PROTOCOL_H */ -- cgit v1.2.1