From cc3f33db7a8d3c4ad373e646b199808e01bc5d9b Mon Sep 17 00:00:00 2001 From: sss Date: Tue, 17 Jan 2023 00:38:19 +0300 Subject: added webrdp public code --- src/core/ws_protocol.h | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/core/ws_protocol.h (limited to 'src/core/ws_protocol.h') diff --git a/src/core/ws_protocol.h b/src/core/ws_protocol.h new file mode 100644 index 0000000..d961fa2 --- /dev/null +++ b/src/core/ws_protocol.h @@ -0,0 +1,79 @@ +/* BSD-2-Clause license + * + * Copyright (c) 2018-2023 NST , sss . + * + */ + +#pragma once + +#include + +/** + * OP-Codes, sent from the (JavaScript) + * client to the server. + */ +typedef enum +{ + ws_in_mouse = 0, /* input is ws_input_mouse */ + ws_in_kupdown, /* input is ws_input_kupdown */ + ws_in_kpress, /* input is uint32_t code */ + ws_in_specialcomb, + ws_in_credential_json, + ws_in_unicode, /* input is wchar_t* string stored into uint32_t array */ + + /* DRAFT */ + ws_in_clipbrd_changed, /* message with new clipboard information */ + ws_in_clipbrd_data, /* message with clipboard data in requested fromat + */ + ws_in_clipbrd_data_request, /* message containing clipboarddata request + * of specified format */ + ws_in_ft_request, /* request filetransfer */ + ws_in_ft_chunk, /* filetransfer chunk from client */ + ws_in_ft_finished, /* filetransfer from client finished */ + /* last */ + ws_in_unused +} ws_input_codes; + +typedef enum +{ + ws_out_beginpaint = 0, + ws_out_endpaint, + ws_out_bitmap, + ws_out_opaquerect, + ws_out_setbounds, + ws_out_patblt, + ws_out_multi_opaquerect, + ws_out_scr_btl, + ws_out_ptr_new, + ws_out_ptr_free, + ws_out_ptr_set, + ws_out_ptr_set_null, + ws_out_ptr_set_default, + /* DRAFT! */ + ws_out_clpbrd_changed, + ws_out_clpbrd_data, + ws_out_clpbrd_request_data, + ws_out_ft_request, + ws_out_ft_chunk, + ws_out_ft_finish, + /* last */ + ws_out_last +} ws_output_codes; + +bool ws_handle_message( + const struct wslay_event_on_msg_recv_arg *msg, ws_session *session); + +/* send text websocket message */ +void ws_send_text(const uint8_t *buf, size_t buf_size, void *_task_info); + +/* send binary websocket message */ +void ws_send_binary(const uint8_t *buf, size_t buf_size, void *_task_info); + +/* allocate new buffer of size msg_len + 4 bytes, + * prepend msg_code to msg_data + */ +uint8_t *ws_pack_msg(const uint8_t *buf, size_t buf_size, uint32_t msg_code); + +/* handle json response from external auth server */ +bool ws_handle_token_reply_json( + uint8_t *json_buf, ws_session *session, void *userdata); -- cgit v1.2.3