diff options
author | Kenny Levinsen <kl@kl.wtf> | 2020-07-31 00:22:18 +0200 |
---|---|---|
committer | Kenny Levinsen <kl@kl.wtf> | 2020-07-31 00:22:18 +0200 |
commit | 61716a2c77dfde9addf6b41a6d72d26a8584150e (patch) | |
tree | 537cd84661955497bdb304f88896e36896df4e5f /include/protocol.h | |
parent | f85434de666f10da0cbcaccdbb7d88917c5fa887 (diff) |
Initial implementation of seatd and libseat
Diffstat (limited to 'include/protocol.h')
-rw-r--r-- | include/protocol.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/include/protocol.h b/include/protocol.h new file mode 100644 index 0000000..7444b85 --- /dev/null +++ b/include/protocol.h @@ -0,0 +1,64 @@ +#ifndef _SEATD_CONSTANTS_H +#define _SEATD_CONSTANTS_H + +#define MAX_PATH_LEN 256 +#define MAX_SEAT_LEN 64 +#define MAX_SEAT_DEVICES 128 +#define MAX_SESSION_LEN 64 + +#define CLIENT_EVENT(opcode) (opcode) +#define SERVER_EVENT(opcode) ((opcode) + (1 << 15)) + +#define CLIENT_OPEN_SEAT CLIENT_EVENT(1) +#define CLIENT_CLOSE_SEAT CLIENT_EVENT(2) +#define CLIENT_OPEN_DEVICE CLIENT_EVENT(3) +#define CLIENT_CLOSE_DEVICE CLIENT_EVENT(4) +#define CLIENT_DISABLE_SEAT CLIENT_EVENT(5) +#define CLIENT_SWITCH_SESSION CLIENT_EVENT(6) + +#define SERVER_SEAT_OPENED SERVER_EVENT(1) +#define SERVER_SEAT_CLOSED SERVER_EVENT(2) +#define SERVER_DEVICE_OPENED SERVER_EVENT(3) +#define SERVER_DEVICE_CLOSED SERVER_EVENT(4) +#define SERVER_DISABLE_SEAT SERVER_EVENT(5) +#define SERVER_ENABLE_SEAT SERVER_EVENT(6) +#define SERVER_ERROR SERVER_EVENT(0x7FFF) + +#include <stdint.h> + +struct proto_header { + uint16_t opcode; + uint16_t size; +}; + +struct proto_client_open_device { + uint16_t path_len; + // NULL-terminated byte-sequence path_len long follows +}; + +struct proto_client_close_device { + int device_id; +}; + +struct proto_client_switch_session { + int session; +}; + +struct proto_server_seat_opened { + uint16_t seat_name_len; + // NULL-terminated byte-sequence seat_name_len long follows +}; + +struct proto_server_device_opened { + int device_id; +}; + +struct proto_server_device_closed { + int device_id; +}; + +struct proto_server_error { + int error_code; +}; + +#endif |