60#ifndef PROTOCORE_WEBSOCKET_H
61#define PROTOCORE_WEBSOCKET_H
65#if PROTOCORE_ENABLE_WEBSOCKET
69#if PROTOCORE_ENABLE_WS_DEFLATE
79#define PROTOCORE_PLAINTEXT_WORK_WS_SEND \
80 (DEFLATE_SCRATCH_SIZE + PROTOCORE_WS_DEFLATE_MAX + (PROTOCORE_WS_DEFLATE_MAX / 8) + 16)
88#define PROTOCORE_PLAINTEXT_WORK_WS_RECV (WS_FRAME_SIZE + 4 + WS_FRAME_SIZE + INFLATE_SCRATCH_SIZE)
90#define PROTOCORE_PLAINTEXT_WORK_WS_SEND 0
91#define PROTOCORE_PLAINTEXT_WORK_WS_RECV 0
100 WS_OP_CONTINUATION = 0x0,
110 WS_CLOSE_NORMAL = 1000,
111 WS_CLOSE_GOING_AWAY = 1001,
112 WS_CLOSE_PROTOCOL = 1002,
113 WS_CLOSE_UNSUPPORTED = 1003,
114 WS_CLOSE_INVALID_PAYLOAD = 1007,
115 WS_CLOSE_TOO_BIG = 1009
156 WsParseState parse_state;
162 uint32_t payload_len;
163 uint32_t payload_idx;
171 embed_bool fragmenting;
174 uint8_t ctl_buf[125 + 1];
176#if PROTOCORE_ENABLE_WS_DEFLATE
178 embed_bool msg_compressed;
194typedef void (*WsConnectHandler)(uint8_t ws_id);
204typedef void (*WsMessageHandler)(uint8_t ws_id);
211typedef void (*WsCloseHandler)(uint8_t ws_id);
214#define PROTOCORE_WS_NONE 0xFFu
219 WsConnectHandler on_connect;
220 WsMessageHandler on_message;
221 WsCloseHandler on_close;
228 const uint8_t *payload;
290#if PROTOCORE_ENABLE_WS_DEFLATE
301 WsConnectHandler connect_handler;
302 WsMessageHandler message_handler;
303 WsCloseHandler close_handler;
312 void (*
const route_add)(uint8_t *work);
313 void (*
const route_reset)(uint8_t *work);
314 void (*
const route_connect)(uint8_t *work);
315 void (*
const route_message)(uint8_t *work);
316 void (*
const route_close)(uint8_t *work);
317 void (*
const init)(uint8_t *work);
318 void (*
const active)(uint8_t *work);
319 void (*
const payload_of)(uint8_t *work);
320 void (*
const alloc)(uint8_t *work);
321 void (*
const find)(uint8_t *work);
322 void (*
const free)(uint8_t *work);
323 void (*
const parse)(uint8_t *work);
324 void (*
const feed_byte)(uint8_t *work);
325 void (*
const reset_frame)(uint8_t *work);
326 void (*
const send_frame)(uint8_t *work);
327 void (*
const set_frag_size)(uint8_t *work);
328 void (*
const close)(uint8_t *work);
333void protocore_ws_route_add(uint8_t *work);
334void protocore_ws_route_reset(uint8_t *work);
335void protocore_ws_route_connect(uint8_t *work);
336void protocore_ws_route_message(uint8_t *work);
337void protocore_ws_route_close(uint8_t *work);
338void protocore_ws_init(uint8_t *work);
339void protocore_ws_active(uint8_t *work);
340void protocore_ws_payload_of(uint8_t *work);
341void protocore_ws_alloc(uint8_t *work);
342void protocore_ws_find(uint8_t *work);
343void protocore_ws_free(uint8_t *work);
344void protocore_ws_parse(uint8_t *work);
345void protocore_ws_feed_byte(uint8_t *work);
346void protocore_ws_reset_frame(uint8_t *work);
347void protocore_ws_send_frame(uint8_t *work);
348void protocore_ws_set_frag_size(uint8_t *work);
349void protocore_ws_close(uint8_t *work);
355static const WsNs Ws __attribute__((unused)) = {
356 .route_add = protocore_ws_route_add,
357 .route_reset = protocore_ws_route_reset,
358 .route_connect = protocore_ws_route_connect,
359 .route_message = protocore_ws_route_message,
360 .route_close = protocore_ws_route_close,
361 .init = protocore_ws_init,
362 .active = protocore_ws_active,
363 .payload_of = protocore_ws_payload_of,
364 .alloc = protocore_ws_alloc,
365 .find = protocore_ws_find,
366 .free = protocore_ws_free,
367 .parse = protocore_ws_parse,
368 .feed_byte = protocore_ws_feed_byte,
369 .reset_frame = protocore_ws_reset_frame,
370 .send_frame = protocore_ws_send_frame,
371 .set_frag_size = protocore_ws_set_frag_size,
372 .close = protocore_ws_close,
376uint8_t *protocore_ws_span(
void);
EMBED_ENUM_BYTE(ProtoConn, PROTO_NONE=0, PROTO_HTTP=1, PROTO_TELNET=2, PROTO_SSH=3, PROTO_MODBUS=4, PROTO_OPCUA=5, PROTO_SSH_RFWD=6, PROTO_RELAY=7, PROTO_BRIDGE=8, PROTO_NTRIP_CASTER=9, PROTO_MESH=10, PROTO_UDP=11,)
Application protocol spoken on a listener port or connection slot.
#define WS_FRAME_SIZE
Maximum WebSocket frame payload in bytes.
#define MAX_WS_CONNS
Maximum simultaneous WebSocket connections.
Bounded RFC 1951 DEFLATE decompressor (INFLATE) - no heap.
Bounded RFC 1951 DEFLATE compressor (DEFLATE) - no heap.