Helper functions for WebSockets. More...
Go to the source code of this file.
Data Structures | |
struct | WebSocketStatusCodeDesc |
HTTP status code. More... | |
Functions | |
void | webSocketChangeState (WebSocket *webSocket, WebSocketState newState) |
Update WebSocket state. More... | |
error_t | webSocketParseHandshake (WebSocket *webSocket) |
Parse client or server handshake. More... | |
error_t | webSocketParseRequestLine (WebSocket *webSocket, char_t *line) |
Parse the Request-Line of the client's handshake. More... | |
error_t | webSocketParseStatusLine (WebSocket *webSocket, char_t *line) |
Parse the Status-Line of the server's handshake. More... | |
error_t | webSocketParseHeaderField (WebSocket *webSocket, char_t *line) |
Parse a header field. More... | |
void | webSocketParseConnectionField (WebSocket *webSocket, char_t *value) |
Parse Connection header field. More... | |
error_t | webSocketFormatClientHandshake (WebSocket *webSocket, uint16_t serverPort) |
Format client's handshake. More... | |
error_t | webSocketFormatServerHandshake (WebSocket *webSocket) |
Format server's handshake. More... | |
error_t | webSocketFormatErrorResponse (WebSocket *webSocket, uint_t statusCode, const char_t *message) |
Format HTTP error response. More... | |
error_t | webSocketVerifyClientHandshake (WebSocket *webSocket) |
Verify client's handshake. More... | |
error_t | webSocketVerifyServerHandshake (WebSocket *webSocket) |
Verify server's handshake. More... | |
error_t | webSocketGenerateClientKey (WebSocket *webSocket) |
Generate client's key. More... | |
error_t | webSocketGenerateServerKey (WebSocket *webSocket) |
Generate server's key. More... | |
error_t | webSocketVerifyClientKey (WebSocket *webSocket) |
Verify client's key. More... | |
error_t | webSocketVerifyServerKey (WebSocket *webSocket) |
Verify server's key. More... | |
bool_t | webSocketCheckStatusCode (uint16_t statusCode) |
Check whether a status code is valid. More... | |
error_t | webSocketDecodePercentEncodedString (const char_t *input, char_t *output, size_t outputSize) |
Decode a percent-encoded string. More... | |
bool_t | webSocketCheckUtf8Stream (WebSocketUtf8Context *context, const uint8_t *data, size_t length, size_t remaining) |
Check whether a an UTF-8 stream is valid. More... | |
Detailed Description
Helper functions for WebSockets.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneTCP Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.4.4
Definition in file web_socket_misc.h.
Function Documentation
◆ webSocketChangeState()
void webSocketChangeState | ( | WebSocket * | webSocket, |
WebSocketState | newState | ||
) |
Update WebSocket state.
- Parameters
-
[in] webSocket Handle to a WebSocket [in] newState New state to switch to
Definition at line 88 of file web_socket_misc.c.
◆ webSocketCheckStatusCode()
bool_t webSocketCheckStatusCode | ( | uint16_t | statusCode | ) |
Check whether a status code is valid.
- Parameters
-
[in] statusCode Status code
- Returns
- The function returns TRUE is the specified status code is valid. Otherwise, FALSE is returned
Definition at line 1146 of file web_socket_misc.c.
◆ webSocketCheckUtf8Stream()
bool_t webSocketCheckUtf8Stream | ( | WebSocketUtf8Context * | context, |
const uint8_t * | data, | ||
size_t | length, | ||
size_t | remaining | ||
) |
Check whether a an UTF-8 stream is valid.
- Parameters
-
[in] context UTF-8 decoding context [in] data Pointer to the chunk of data to be processed [in] length Data chunk length [in] remaining number of remaining bytes in the UTF-8 stream
- Returns
- The function returns TRUE is the specified UTF-8 stream is valid. Otherwise, FALSE is returned
Definition at line 1247 of file web_socket_misc.c.
◆ webSocketDecodePercentEncodedString()
error_t webSocketDecodePercentEncodedString | ( | const char_t * | input, |
char_t * | output, | ||
size_t | outputSize | ||
) |
Decode a percent-encoded string.
- Parameters
-
[in] input NULL-terminated string to be decoded [out] output NULL-terminated string resulting from the decoding process [in] outputSize Size of the output buffer in bytes
- Returns
- Error code
Definition at line 1185 of file web_socket_misc.c.
◆ webSocketFormatClientHandshake()
Format client's handshake.
- Parameters
-
[in] webSocket Handle to a WebSocket [in] serverPort TCP port number used to establish the connection
- Returns
- Error code
Definition at line 645 of file web_socket_misc.c.
◆ webSocketFormatErrorResponse()
error_t webSocketFormatErrorResponse | ( | WebSocket * | webSocket, |
uint_t | statusCode, | ||
const char_t * | message | ||
) |
Format HTTP error response.
- Parameters
-
[in] webSocket Handle to a WebSocket [in] statusCode HTTP status code [in] message User message
- Returns
- Error code
Definition at line 783 of file web_socket_misc.c.
◆ webSocketFormatServerHandshake()
Format server's handshake.
- Parameters
-
[in] webSocket Handle to a WebSocket
- Returns
- Error code
Definition at line 731 of file web_socket_misc.c.
◆ webSocketGenerateClientKey()
Generate client's key.
- Parameters
-
[in] webSocket Handle to a WebSocket
- Returns
- Error code
Definition at line 971 of file web_socket_misc.c.
◆ webSocketGenerateServerKey()
Generate server's key.
- Parameters
-
[in] webSocket Handle to a WebSocket
- Returns
- Error code
Definition at line 1015 of file web_socket_misc.c.
◆ webSocketParseConnectionField()
Parse Connection header field.
- Parameters
-
[in] webSocket Handle to a WebSocket [in] value NULL-terminated string that contains the value of header field
Definition at line 601 of file web_socket_misc.c.
◆ webSocketParseHandshake()
Parse client or server handshake.
- Parameters
-
[in] webSocket Handle to a WebSocket
- Returns
- Error code
Definition at line 107 of file web_socket_misc.c.
◆ webSocketParseHeaderField()
Parse a header field.
- Parameters
-
[in] webSocket Handle to a WebSocket [in] line NULL-terminated string that contains the header field
- Returns
- Error code
Definition at line 514 of file web_socket_misc.c.
◆ webSocketParseRequestLine()
Parse the Request-Line of the client's handshake.
- Parameters
-
[in] webSocket Handle to a WebSocket [in] line NULL-terminated string that contains the Request-Line
- Returns
- Error code
Definition at line 368 of file web_socket_misc.c.
◆ webSocketParseStatusLine()
Parse the Status-Line of the server's handshake.
- Parameters
-
[in] webSocket Handle to a WebSocket [in] line NULL-terminated string that contains the Status-Line
- Returns
- Error code
Definition at line 476 of file web_socket_misc.c.
◆ webSocketVerifyClientHandshake()
Verify client's handshake.
- Parameters
-
[in] webSocket Handle to a WebSocket
- Returns
- Error code
Definition at line 859 of file web_socket_misc.c.
◆ webSocketVerifyClientKey()
Verify client's key.
- Parameters
-
[in] webSocket Handle to a WebSocket
- Returns
- Error code
Definition at line 1055 of file web_socket_misc.c.
◆ webSocketVerifyServerHandshake()
Verify server's handshake.
- Parameters
-
[in] webSocket Handle to a WebSocket
- Returns
- Error code
Definition at line 908 of file web_socket_misc.c.
◆ webSocketVerifyServerKey()
Verify server's key.
- Parameters
-
[in] webSocket Handle to a WebSocket
- Returns
- Error code
Definition at line 1096 of file web_socket_misc.c.