20 #ifndef FREERDP_LIB_CORE_GATEWAY_WEBSOCKET_H
21 #define FREERDP_LIB_CORE_GATEWAY_WEBSOCKET_H
23 #include <winpr/wtypes.h>
24 #include <winpr/stream.h>
26 #include <freerdp/api.h>
28 #include "../../crypto/tls.h"
30 #define WEBSOCKET_MASK_BIT 0x80
31 #define WEBSOCKET_FIN_BIT 0x80
35 WebsocketContinuationOpcode = 0x0,
36 WebsocketTextOpcode = 0x1,
37 WebsocketBinaryOpcode = 0x2,
38 WebsocketCloseOpcode = 0x8,
39 WebsocketPingOpcode = 0x9,
40 WebsocketPongOpcode = 0xa,
45 WebsocketStateOpcodeAndFin,
46 WebsocketStateLengthAndMasking,
47 WebsocketStateShortLength,
48 WebsocketStateLongLength,
49 WebSocketStateMaskingKey,
50 WebSocketStatePayload,
53 typedef struct s_websocket_context websocket_context;
55 FREERDP_LOCAL
void websocket_context_free(websocket_context* context);
57 WINPR_ATTR_MALLOC(websocket_context_free, 1)
58 FREERDP_LOCAL websocket_context* websocket_context_new(
void);
60 FREERDP_LOCAL BOOL websocket_context_reset(websocket_context* context);
62 FREERDP_LOCAL BOOL websocket_context_write_wstream(websocket_context* context, BIO* bio,
63 wStream* sPacket, WEBSOCKET_OPCODE opcode);
64 FREERDP_LOCAL
int websocket_context_write(websocket_context* context, BIO* bio, const BYTE* buf,
65 int isize, WEBSOCKET_OPCODE opcode);
66 FREERDP_LOCAL
int websocket_context_read(websocket_context* encodingContext, BIO* bio,
67 BYTE* pBuffer,
size_t size);
69 WINPR_ATTR_MALLOC(Stream_Free, 1)
70 FREERDP_LOCAL
wStream* websocket_context_packet_new(
size_t len, WEBSOCKET_OPCODE opcode,
73 FREERDP_LOCAL BOOL websocket_context_mask_and_send(BIO* bio,
wStream* sPacket,
wStream* sDataPacket,