web_socket.h
Go to the documentation of this file.
1 /**
2  * @file web_socket.h
3  * @brief WebSocket API (client and server)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2019 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 1.9.6
29  **/
30 
31 #ifndef _WEB_SOCKET_H
32 #define _WEB_SOCKET_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "core/socket.h"
37 
38 //WebSocket support
39 #ifndef WEB_SOCKET_SUPPORT
40  #define WEB_SOCKET_SUPPORT DISABLED
41 #elif (WEB_SOCKET_SUPPORT != ENABLED && WEB_SOCKET_SUPPORT != DISABLED)
42  #error WEB_SOCKET_SUPPORT parameter is not valid
43 #endif
44 
45 //Number of WebSockets that can be opened simultaneously
46 #ifndef WEB_SOCKET_MAX_COUNT
47  #define WEB_SOCKET_MAX_COUNT 4
48 #elif (WEB_SOCKET_MAX_COUNT < 1)
49  #error WEB_SOCKET_MAX_COUNT parameter is not valid
50 #endif
51 
52 //Support for WebSocket connections over TLS
53 #ifndef WEB_SOCKET_TLS_SUPPORT
54  #define WEB_SOCKET_TLS_SUPPORT DISABLED
55 #elif (WEB_SOCKET_TLS_SUPPORT != ENABLED && WEB_SOCKET_TLS_SUPPORT != DISABLED)
56  #error WEB_SOCKET_TLS_SUPPORT parameter is not valid
57 #endif
58 
59 //Basic access authentication support
60 #ifndef WEB_SOCKET_BASIC_AUTH_SUPPORT
61  #define WEB_SOCKET_BASIC_AUTH_SUPPORT DISABLED
62 #elif (WEB_SOCKET_BASIC_AUTH_SUPPORT != ENABLED && WEB_SOCKET_BASIC_AUTH_SUPPORT != DISABLED)
63  #error WEB_SOCKET_BASIC_AUTH_SUPPORT parameter is not valid
64 #endif
65 
66 //Digest access authentication support
67 #ifndef WEB_SOCKET_DIGEST_AUTH_SUPPORT
68  #define WEB_SOCKET_DIGEST_AUTH_SUPPORT DISABLED
69 #elif (WEB_SOCKET_DIGEST_AUTH_SUPPORT != ENABLED && WEB_SOCKET_DIGEST_AUTH_SUPPORT != DISABLED)
70  #error WEB_SOCKET_DIGEST_AUTH_SUPPORT parameter is not valid
71 #endif
72 
73 //Maximum number of connection attempts
74 #ifndef WEB_SOCKET_MAX_CONN_RETRIES
75  #define WEB_SOCKET_MAX_CONN_RETRIES 3
76 #elif (WEB_SOCKET_MAX_CONN_RETRIES < 1)
77  #error WEB_SOCKET_MAX_CONN_RETRIES parameter is not valid
78 #endif
79 
80 //Size of the WebSocket buffer
81 #ifndef WEB_SOCKET_BUFFER_SIZE
82  #define WEB_SOCKET_BUFFER_SIZE 1024
83 #elif (WEB_SOCKET_BUFFER_SIZE < 128)
84  #error WEB_SOCKET_BUFFER_SIZE parameter is not valid
85 #endif
86 
87 //Maximum length of the hostname
88 #ifndef WEB_SOCKET_HOST_MAX_LEN
89  #define WEB_SOCKET_HOST_MAX_LEN 32
90 #elif (WEB_SOCKET_HOST_MAX_LEN < 1)
91  #error WEB_SOCKET_HOST_MAX_LEN parameter is not valid
92 #endif
93 
94 //Maximum length of the origin header field
95 #ifndef WEB_SOCKET_ORIGIN_MAX_LEN
96  #define WEB_SOCKET_ORIGIN_MAX_LEN 16
97 #elif (WEB_SOCKET_ORIGIN_MAX_LEN < 1)
98  #error WEB_SOCKET_ORIGIN_MAX_LEN parameter is not valid
99 #endif
100 
101 //Maximum length of the sub-protocol
102 #ifndef WEB_SOCKET_SUB_PROTOCOL_MAX_LEN
103  #define WEB_SOCKET_SUB_PROTOCOL_MAX_LEN 8
104 #elif (WEB_SOCKET_SUB_PROTOCOL_MAX_LEN < 1)
105  #error WEB_SOCKET_SUB_PROTOCOL_MAX_LEN parameter is not valid
106 #endif
107 
108 //Maximum length of the URI
109 #ifndef WEB_SOCKET_URI_MAX_LEN
110  #define WEB_SOCKET_URI_MAX_LEN 32
111 #elif (WEB_SOCKET_URI_MAX_LEN < 1)
112  #error WEB_SOCKET_URI_MAX_LEN parameter is not valid
113 #endif
114 
115 //Maximum length of the query string
116 #ifndef WEB_SOCKET_QUERY_STRING_MAX_LEN
117  #define WEB_SOCKET_QUERY_STRING_MAX_LEN 32
118 #elif (WEB_SOCKET_QUERY_STRING_MAX_LEN < 1)
119  #error WEB_SOCKET_QUERY_STRING_MAX_LEN parameter is not valid
120 #endif
121 
122 //Maximum length of the realm
123 #ifndef WEB_SOCKET_REALM_MAX_LEN
124  #define WEB_SOCKET_REALM_MAX_LEN 32
125 #elif (WEB_SOCKET_REALM_MAX_LEN < 1)
126  #error WEB_SOCKET_REALM_MAX_LEN parameter is not valid
127 #endif
128 
129 //Maximum length of the user name
130 #ifndef WEB_SOCKET_USERNAME_MAX_LEN
131  #define WEB_SOCKET_USERNAME_MAX_LEN 16
132 #elif (WEB_SOCKET_USERNAME_MAX_LEN < 1)
133  #error WEB_SOCKET_USERNAME_MAX_LEN parameter is not valid
134 #endif
135 
136 //Maximum length of the password
137 #ifndef WEB_SOCKET_PASSWORD_MAX_LEN
138  #define WEB_SOCKET_PASSWORD_MAX_LEN 16
139 #elif (WEB_SOCKET_PASSWORD_MAX_LEN < 1)
140  #error WEB_SOCKET_PASSWORD_MAX_LEN parameter is not valid
141 #endif
142 
143 //Maximum length of the nonce
144 #ifndef WEB_SOCKET_NONCE_MAX_LEN
145  #define WEB_SOCKET_NONCE_MAX_LEN 32
146 #elif (WEB_SOCKET_NONCE_MAX_LEN < 1)
147  #error WEB_SOCKET_NONCE_MAX_LEN parameter is not valid
148 #endif
149 
150 //Maximum length of the opaque parameter
151 #ifndef WEB_SOCKET_OPAQUE_MAX_LEN
152  #define WEB_SOCKET_OPAQUE_MAX_LEN 32
153 #elif (WEB_SOCKET_OPAQUE_MAX_LEN < 1)
154  #error WEB_SOCKET_OPAQUE_MAX_LEN parameter is not valid
155 #endif
156 
157 //Cnonce size
158 #ifndef WEB_SOCKET_CNONCE_SIZE
159  #define WEB_SOCKET_CNONCE_SIZE 16
160 #elif (WEB_SOCKET_CNONCE_SIZE < 1)
161  #error WEB_SOCKET_CNONCE_SIZE parameter is not valid
162 #endif
163 
164 //TLS supported?
165 #if (WEB_SOCKET_TLS_SUPPORT == ENABLED)
166  #include "core/crypto.h"
167  #include "tls.h"
168 #endif
169 
170 //Client key size
171 #define WEB_SOCKET_CLIENT_KEY_SIZE 24
172 //Server key size
173 #define WEB_SOCKET_SERVER_KEY_SIZE 28
174 
175 //Forward declaration of WebSocket structure
176 struct _WebSocket;
177 #define WebSocket struct _WebSocket
178 
179 //C++ guard
180 #ifdef __cplusplus
181 extern "C" {
182 #endif
183 
184 
185 /**
186  * @brief WebSocket endpoint types
187  **/
188 
189 typedef enum
190 {
194 
195 
196 /**
197  * @brief HTTP version numbers
198  **/
199 
200 typedef enum
201 {
206 
207 
208 /**
209  * @brief Authentication schemes
210  **/
211 
212 typedef enum
213 {
218 
219 
220 /**
221  * @brief WebSocket states
222  **/
223 
224 typedef enum
225 {
238 
239 
240 /**
241  * @brief WebSocket sub-states
242  **/
243 
244 typedef enum
245 {
247  //Handshake decoding
251  //WebSocket frame decoding
256 
257 
258 /**
259  * @brief WebSocket frame types
260  **/
261 
262 typedef enum
263 {
271 
272 
273 /**
274  * @brief WebSocket status codes
275  **/
276 
277 typedef enum
278 {
292 
293 
294 //CodeWarrior or Win32 compiler?
295 #if defined(__CWCC__) || defined(_WIN32)
296  #pragma pack(push, 1)
297 #endif
298 
299 
300 /**
301  * @brief WebSocket frame
302  **/
303 
304 typedef __start_packed struct
305 {
306 #ifdef _CPU_BIG_ENDIAN
307  uint8_t fin : 1; //0
308  uint8_t reserved : 3;
309  uint8_t opcode : 4;
310  uint8_t mask : 1; //1
311  uint8_t payloadLen : 7;
312 #else
313  uint8_t opcode : 4; //0
314  uint8_t reserved : 3;
315  uint8_t fin : 1;
316  uint8_t payloadLen : 7; //1
317  uint8_t mask : 1;
318 #endif
319  uint8_t extPayloadLen[]; //2
321 
322 
323 //CodeWarrior or Win32 compiler?
324 #if defined(__CWCC__) || defined(_WIN32)
325  #pragma pack(pop)
326 #endif
327 
328 
329 /**
330  * @brief Random data generation callback function
331  **/
332 
333 typedef error_t (*WebSocketRandCallback)(uint8_t *data, size_t length);
334 
335 
336 //TLS supported?
337 #if (WEB_SOCKET_TLS_SUPPORT == ENABLED)
338 
339 /**
340  * @brief TLS initialization callback function
341  **/
342 
345 
346 #endif
347 
348 
349 /**
350  * @brief Authentication context
351  **/
352 
353 typedef struct
354 {
361 #if (WEB_SOCKET_DIGEST_AUTH_SUPPORT == ENABLED)
362  uint32_t nc;
367 #endif
369 
370 
371 /**
372  * @brief Handshake context
373  **/
374 
375 typedef struct
376 {
388 
389 
390 /**
391  * @brief Frame encoding/decoding context
392  **/
393 
394 typedef struct
395 {
396  WebSocketSubState state; ///FSM state
397  WebSocketFrameType dataFrameType; ///<Data frame type
398  WebSocketFrameType controlFrameType; ///<Control frame type
399  bool_t fin; ///<Final fragment in a message
400  bool_t mask; ///<Defines whether the payload data is masked
401  uint8_t maskingKey[4]; ///<Masking key
402  size_t payloadLen; ///<Payload length
403  size_t payloadPos; ///<Current position
404  uint8_t buffer[WEB_SOCKET_BUFFER_SIZE]; ///<Data buffer
405  size_t bufferLen; ///<Length of the data buffer
406  size_t bufferPos; ///<Current position
408 
409 
410 /**
411  * @brief UTF-8 decoding context
412  **/
413 
414 typedef struct
415 {
418  uint32_t utf8CodePoint;
420 
421 
422 /**
423  * @brief Structure describing a WebSocket
424  **/
425 
427 {
428  WebSocketEndpoint endpoint; ///<Endpoint type (client or server)
429  WebSocketState state; ///<WebSocket connection state
430  uint16_t statusCode;
433  char_t host[WEB_SOCKET_HOST_MAX_LEN + 1]; ///<Domain name of the server (for virtual hosting)
438  systime_t timeout; ///<timeout value for blocking operations
439  NetInterface *interface; ///<Underlying network interface
440  Socket *socket; ///<Underlying TCP socket
441 #if (WEB_SOCKET_TLS_SUPPORT == ENABLED)
442  TlsContext *tlsContext; ///<TLS context
443  TlsSessionState tlsSession; ///<TLS session state
444  WebSocketTlsInitCallback tlsInitCallback; ///<TLS initialization callback function
445 #endif
446 #if (WEB_SOCKET_BASIC_AUTH_SUPPORT == ENABLED || WEB_SOCKET_DIGEST_AUTH_SUPPORT == ENABLED)
448 #endif
453 };
454 
455 
456 //Random data generation callback function
458 
459 //WebSocket related functions
460 error_t webSocketInit(void);
461 
463 
464 WebSocket *webSocketOpen(void);
466 
467 #if (WEB_SOCKET_TLS_SUPPORT == ENABLED)
468 
470 
472  WebSocketTlsInitCallback callback);
473 
474 #endif
475 
476 error_t webSocketSetTimeout(WebSocket *webSocket, systime_t timeout);
477 
478 error_t webSocketSetHost(WebSocket *webSocket, const char_t *host);
479 error_t webSocketSetOrigin(WebSocket *webSocket, const char_t *origin);
480 error_t webSocketSetSubProtocol(WebSocket *webSocket, const char_t *subProtocol);
481 
482 error_t webSocketSetAuthInfo(WebSocket *webSocket, const char_t *username,
483  const char_t *password, uint_t allowedAuthModes);
484 
486 
487 error_t webSocketConnect(WebSocket *webSocket, const IpAddr *serverIpAddr,
488  uint16_t serverPort, const char_t *uri);
489 
490 error_t webSocketSetClientKey(WebSocket *webSocket, const char_t *clientKey);
493 
495  uint_t statusCode, const char_t *message);
496 
497 error_t webSocketSend(WebSocket *webSocket, const void *data,
498  size_t length, WebSocketFrameType type, size_t *written);
499 
500 error_t webSocketSendEx(WebSocket *webSocket, const void *data, size_t length,
501  WebSocketFrameType type, size_t *written, bool_t firstFrag, bool_t lastFrag);
502 
503 error_t webSocketReceive(WebSocket *webSocket, void *data,
504  size_t size, WebSocketFrameType *type, size_t *received);
505 
506 error_t webSocketReceiveEx(WebSocket *webSocket, void *data, size_t size,
507  WebSocketFrameType *type, size_t *received, bool_t *firstFrag, bool_t *lastFrag);
508 
511 void webSocketClose(WebSocket *webSocket);
512 
513 //C++ guard
514 #ifdef __cplusplus
515 }
516 #endif
517 
518 #endif
uint8_t payloadLen
Definition: web_socket.h:316
#define WEB_SOCKET_BUFFER_SIZE
Definition: web_socket.h:82
error_t webSocketSetAuthInfo(WebSocket *webSocket, const char_t *username, const char_t *password, uint_t allowedAuthModes)
Set authentication information.
Definition: web_socket.c:347
uint8_t length
Definition: dtls_misc.h:149
NetInterface * interface
Underlying network interface.
Definition: web_socket.h:439
WebSocket * webSocketUpgradeSocket(Socket *socket)
Upgrade a socket to a WebSocket.
Definition: web_socket.c:155
WebSocketUtf8Context utf8Context
Definition: web_socket.h:452
int bool_t
Definition: compiler_port.h:49
bool_t mask
Defines whether the payload data is masked.
Definition: web_socket.h:400
#define WEB_SOCKET_CLIENT_KEY_SIZE
Definition: web_socket.h:171
IP network address.
Definition: ip.h:71
error_t webSocketSetSubProtocol(WebSocket *webSocket, const char_t *subProtocol)
Set the sub-protocol header field.
Definition: web_socket.c:324
WebSocket * webSocketUpgradeSecureSocket(Socket *socket, TlsContext *tlsContext)
Upgrade a secure socket to a secure WebSocket.
Definition: web_socket.c:194
#define WEB_SOCKET_HOST_MAX_LEN
Definition: web_socket.h:89
__start_packed struct @300 WebSocketFrame
WebSocket frame.
WebSocketHttpVersion
HTTP version numbers.
Definition: web_socket.h:200
error_t webSocketReceiveEx(WebSocket *webSocket, void *data, size_t size, WebSocketFrameType *type, size_t *received, bool_t *firstFrag, bool_t *lastFrag)
Receive data from a WebSocket connection.
Definition: web_socket.c:1159
error_t webSocketSendServerHandshake(WebSocket *webSocket)
Send server's handshake.
Definition: web_socket.c:813
WebSocketTlsInitCallback tlsInitCallback
TLS initialization callback function.
Definition: web_socket.h:444
error_t(* WebSocketRandCallback)(uint8_t *data, size_t length)
Random data generation callback function.
Definition: web_socket.h:333
#define WEB_SOCKET_SUB_PROTOCOL_MAX_LEN
Definition: web_socket.h:103
#define WEB_SOCKET_ORIGIN_MAX_LEN
Definition: web_socket.h:96
error_t webSocketSendEx(WebSocket *webSocket, const void *data, size_t length, WebSocketFrameType type, size_t *written, bool_t firstFrag, bool_t lastFrag)
Transmit data over the WebSocket connection.
Definition: web_socket.c:972
error_t webSocketShutdown(WebSocket *webSocket)
Gracefully close a WebSocket connection.
Definition: web_socket.c:1439
#define WEB_SOCKET_CNONCE_SIZE
Definition: web_socket.h:159
char_t host[WEB_SOCKET_HOST_MAX_LEN+1]
Domain name of the server (for virtual hosting)
Definition: web_socket.h:433
WebSocketEndpoint endpoint
Endpoint type (client or server)
Definition: web_socket.h:428
error_t webSocketSetHost(WebSocket *webSocket, const char_t *host)
Set the domain name of the server (for virtual hosting)
Definition: web_socket.c:282
WebSocketEndpoint
WebSocket endpoint types.
Definition: web_socket.h:189
uint16_t statusCode
Definition: web_socket.h:430
error_t webSocketRegisterTlsInitCallback(WebSocket *webSocket, WebSocketTlsInitCallback callback)
Register TLS initialization callback function.
Definition: web_socket.c:233
error_t webSocketParseClientHandshake(WebSocket *webSocket)
Parse client's handshake.
Definition: web_socket.c:724
WebSocketFrameType controlFrameType
Control frame type.
Definition: web_socket.h:398
WebSocketFrameContext txContext
Definition: web_socket.h:450
uint8_t reserved
Definition: web_socket.h:314
bool_t webSocketIsRxReady(WebSocket *webSocket)
Check whether some data is available in the receive buffer.
Definition: web_socket.c:1414
WebSocketAuthMode selectedAuthMode
Definition: web_socket.h:357
#define WEB_SOCKET_NONCE_MAX_LEN
Definition: web_socket.h:145
char_t type
TlsContext * tlsContext
TLS context.
Definition: web_socket.h:442
size_t bufferLen
Length of the data buffer.
Definition: web_socket.h:405
#define TlsContext
Definition: tls.h:36
size_t payloadPos
Current position.
Definition: web_socket.h:403
error_t
Error codes.
Definition: error.h:42
Frame encoding/decoding context.
Definition: web_socket.h:394
error_t(* WebSocketTlsInitCallback)(WebSocket *webSocket, TlsContext *tlsContext)
TLS initialization callback function.
Definition: web_socket.h:343
uint8_t opcode
Definition: web_socket.h:313
int_t socket(int_t family, int_t type, int_t protocol)
Create a socket that is bound to a specific transport service provider.
Definition: bsd_socket.c:108
uint16_t statusCode
WebSocketFrameType
WebSocket frame types.
Definition: web_socket.h:262
uint32_t utf8CodePoint
Definition: web_socket.h:418
WebSocketState state
WebSocket connection state.
Definition: web_socket.h:429
#define NetInterface
Definition: net.h:36
error_t webSocketReceive(WebSocket *webSocket, void *data, size_t size, WebSocketFrameType *type, size_t *received)
Receive data from a WebSocket connection.
Definition: web_socket.c:1136
char_t subProtocol[WEB_SOCKET_SUB_PROTOCOL_MAX_LEN+1]
Definition: web_socket.h:435
Handshake context.
Definition: web_socket.h:375
systime_t timeout
timeout value for blocking operations
Definition: web_socket.h:438
UTF-8 decoding context.
Definition: web_socket.h:414
Socket * socket
Underlying TCP socket.
Definition: web_socket.h:440
General definitions for cryptographic algorithms.
WebSocketFrameType dataFrameType
FSM state.
Definition: web_socket.h:397
__start_packed struct _Ipv4Header __end_packed
error_t webSocketConnect(WebSocket *webSocket, const IpAddr *serverIpAddr, uint16_t serverPort, const char_t *uri)
Establish a WebSocket connection.
Definition: web_socket.c:404
size_t payloadLen
Payload length.
Definition: web_socket.h:402
uint8_t mask
Definition: web_socket.h:317
WebSocketAuthMode requiredAuthMode
Definition: web_socket.h:356
WebSocketState
WebSocket states.
Definition: web_socket.h:224
#define WebSocket
Definition: web_socket.h:177
Authentication context.
Definition: web_socket.h:353
error_t webSocketBindToInterface(WebSocket *webSocket, NetInterface *interface)
Bind the WebSocket to a particular network interface.
Definition: web_socket.c:380
TlsSessionState tlsSession
TLS session state.
Definition: web_socket.h:443
char_t queryString[WEB_SOCKET_QUERY_STRING_MAX_LEN+1]
Definition: web_socket.h:437
char_t uri[WEB_SOCKET_URI_MAX_LEN+1]
Definition: web_socket.h:436
WebSocket * webSocketOpen(void)
Create a WebSocket.
Definition: web_socket.c:95
WebSocketSubState state
Definition: web_socket.h:396
error_t webSocketSetClientKey(WebSocket *webSocket, const char_t *clientKey)
Set client's key.
Definition: web_socket.c:658
systime_t timestamp
Definition: web_socket.h:431
error_t webSocketSendErrorResponse(WebSocket *webSocket, uint_t statusCode, const char_t *message)
Send HTTP error response to the client.
Definition: web_socket.c:876
Structure describing a WebSocket.
Definition: web_socket.h:426
char char_t
Definition: compiler_port.h:43
WebSocketStatusCode
WebSocket status codes.
Definition: web_socket.h:277
#define WEB_SOCKET_PASSWORD_MAX_LEN
Definition: web_socket.h:138
#define WEB_SOCKET_OPAQUE_MAX_LEN
Definition: web_socket.h:152
TLS session state.
Definition: tls.h:1834
error_t webSocketInit(void)
WebSocket related initialization.
Definition: web_socket.c:60
WebSocketAuthMode
Authentication schemes.
Definition: web_socket.h:212
uint8_t extPayloadLen[]
Definition: web_socket.h:319
#define Socket
Definition: socket.h:36
bool_t fin
Final fragment in a message.
Definition: web_socket.h:399
uint8_t message[]
Definition: chap.h:152
WebSocketAuthContext authContext
Definition: web_socket.h:447
TLS (Transport Layer Security)
Socket API.
#define WEB_SOCKET_QUERY_STRING_MAX_LEN
Definition: web_socket.h:117
error_t webSocketSend(WebSocket *webSocket, const void *data, size_t length, WebSocketFrameType type, size_t *written)
Transmit data over the WebSocket connection.
Definition: web_socket.c:951
#define WEB_SOCKET_SERVER_KEY_SIZE
Definition: web_socket.h:173
size_t bufferPos
Current position.
Definition: web_socket.h:406
uint8_t fin
Definition: web_socket.h:315
error_t webSocketSetOrigin(WebSocket *webSocket, const char_t *origin)
Set the origin header field.
Definition: web_socket.c:303
char_t origin[WEB_SOCKET_ORIGIN_MAX_LEN+1]
Definition: web_socket.h:434
uint_t retryCount
Definition: web_socket.h:432
unsigned int uint_t
Definition: compiler_port.h:45
WebSocketSubState
WebSocket sub-states.
Definition: web_socket.h:244
WebSocketRandCallback webSockRandCallback
Definition: web_socket.c:52
TCP/IP stack core.
#define WEB_SOCKET_URI_MAX_LEN
Definition: web_socket.h:110
uint8_t data[]
Definition: dtls_misc.h:176
WebSocketFrameContext rxContext
Definition: web_socket.h:451
#define WEB_SOCKET_REALM_MAX_LEN
Definition: web_socket.h:124
WebSocketHandshakeContext handshakeContext
Definition: web_socket.h:449
uint32_t systime_t
Definition: compiler_port.h:46
#define WEB_SOCKET_USERNAME_MAX_LEN
Definition: web_socket.h:131
error_t webSocketRegisterRandCallback(WebSocketRandCallback callback)
Register RNG callback function.
Definition: web_socket.c:76
void webSocketClose(WebSocket *webSocket)
Close a WebSocket connection.
Definition: web_socket.c:1555
error_t webSocketSetTimeout(WebSocket *webSocket, systime_t timeout)
Set timeout value for blocking operations.
Definition: web_socket.c:257