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