1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/* BSD-2-Clause license
*
* Copyright (c) 2018-2023 NST <www.newinfosec.ru>, sss <sss at dark-alexandr dot net>.
*
*/
#pragma once
#include <stdbool.h>
/**
* 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);
|