Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Helper functions for WebSockets. More...
Go to the source code of this file.
Functions | |
void | webSocketChangeState (WebSocket *webSocket, WebSocketState newState) |
Update WebSocket state. | |
error_t | webSocketParseHandshake (WebSocket *webSocket) |
Parse client or server handshake. | |
error_t | webSocketParseRequestLine (WebSocket *webSocket, char_t *line) |
Parse the Request-Line of the client's handshake. | |
error_t | webSocketParseStatusLine (WebSocket *webSocket, char_t *line) |
Parse the Status-Line of the server's handshake. | |
error_t | webSocketParseHeaderField (WebSocket *webSocket, char_t *line) |
Parse a header field. | |
void | webSocketParseConnectionField (WebSocket *webSocket, char_t *value) |
Parse Connection header field. | |
error_t | webSocketFormatClientHandshake (WebSocket *webSocket, uint16_t serverPort) |
Format client's handshake. | |
error_t | webSocketFormatServerHandshake (WebSocket *webSocket) |
Format server's handshake. | |
error_t | webSocketFormatErrorResponse (WebSocket *webSocket, uint_t statusCode, const char_t *message) |
Format HTTP error response. | |
error_t | webSocketVerifyClientHandshake (WebSocket *webSocket) |
Verify client's handshake. | |
error_t | webSocketVerifyServerHandshake (WebSocket *webSocket) |
Verify server's handshake. | |
error_t | webSocketGenerateClientKey (WebSocket *webSocket) |
Generate client's key. | |
error_t | webSocketGenerateServerKey (WebSocket *webSocket) |
Generate server's key. | |
error_t | webSocketVerifyClientKey (WebSocket *webSocket) |
Verify client's key. | |
error_t | webSocketVerifyServerKey (WebSocket *webSocket) |
Verify server's key. | |
bool_t | webSocketCheckStatusCode (uint16_t statusCode) |
Check whether a status code is valid. | |
error_t | webSocketDecodePercentEncodedString (const char_t *input, char_t *output, size_t outputSize) |
Decode a percent-encoded string. | |
bool_t | webSocketCheckUtf8Stream (WebSocketUtf8Context *context, const uint8_t *data, size_t length, size_t remaining) |
Check whether a an UTF-8 stream is valid. | |
Variables | |
static const WebSocketStatusCodeDesc | statusCodeList [] |
HTTP status codes. |
Detailed Description
Helper functions for WebSockets.
License
Copyright (C) 2010-2017 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:
- 1.7.6
Definition in file web_socket_misc.c.
Function Documentation
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 86 of file web_socket_misc.c.
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 1138 of file web_socket_misc.c.
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 1239 of file web_socket_misc.c.
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 1177 of file web_socket_misc.c.
error_t webSocketFormatClientHandshake | ( | WebSocket * | webSocket, |
uint16_t | serverPort | ||
) |
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 641 of file web_socket_misc.c.
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 775 of file web_socket_misc.c.
error_t webSocketFormatServerHandshake | ( | WebSocket * | webSocket ) |
Format server's handshake.
- Parameters:
-
[in] webSocket Handle to a WebSocket
- Returns:
- Error code
Definition at line 723 of file web_socket_misc.c.
error_t webSocketGenerateClientKey | ( | WebSocket * | webSocket ) |
Generate client's key.
- Parameters:
-
[in] webSocket Handle to a WebSocket
- Returns:
- Error code
Definition at line 963 of file web_socket_misc.c.
error_t webSocketGenerateServerKey | ( | WebSocket * | webSocket ) |
Generate server's key.
- Parameters:
-
[in] webSocket Handle to a WebSocket
- Returns:
- Error code
Definition at line 1007 of file web_socket_misc.c.
void webSocketParseConnectionField | ( | WebSocket * | webSocket, |
char_t * | value | ||
) |
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 597 of file web_socket_misc.c.
error_t webSocketParseHandshake | ( | WebSocket * | webSocket ) |
Parse client or server handshake.
- Parameters:
-
[in] webSocket Handle to a WebSocket
- Returns:
- Error code
Definition at line 105 of file web_socket_misc.c.
error_t webSocketParseHeaderField | ( | WebSocket * | webSocket, |
char_t * | line | ||
) |
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 510 of file web_socket_misc.c.
error_t webSocketParseRequestLine | ( | WebSocket * | webSocket, |
char_t * | line | ||
) |
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 364 of file web_socket_misc.c.
error_t webSocketParseStatusLine | ( | WebSocket * | webSocket, |
char_t * | line | ||
) |
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 472 of file web_socket_misc.c.
error_t webSocketVerifyClientHandshake | ( | WebSocket * | webSocket ) |
Verify client's handshake.
- Parameters:
-
[in] webSocket Handle to a WebSocket
- Returns:
- Error code
Definition at line 851 of file web_socket_misc.c.
error_t webSocketVerifyClientKey | ( | WebSocket * | webSocket ) |
Verify client's key.
- Parameters:
-
[in] webSocket Handle to a WebSocket
- Returns:
- Error code
Definition at line 1047 of file web_socket_misc.c.
error_t webSocketVerifyServerHandshake | ( | WebSocket * | webSocket ) |
Verify server's handshake.
- Parameters:
-
[in] webSocket Handle to a WebSocket
- Returns:
- Error code
Definition at line 900 of file web_socket_misc.c.
error_t webSocketVerifyServerKey | ( | WebSocket * | webSocket ) |
Verify server's key.
- Parameters:
-
[in] webSocket Handle to a WebSocket
- Returns:
- Error code
Definition at line 1088 of file web_socket_misc.c.
Variable Documentation
const WebSocketStatusCodeDesc statusCodeList[] [static] |
{ {200, "OK"}, {201, "Created"}, {202, "Accepted"}, {204, "No Content"}, {301, "Moved Permanently"}, {302, "Found"}, {304, "Not Modified"}, {400, "Bad Request"}, {401, "Unauthorized"}, {403, "Forbidden"}, {404, "Not Found"}, {500, "Internal Server Error"}, {501, "Not Implemented"}, {502, "Bad Gateway"}, {503, "Service Unavailable"} }
HTTP status codes.
Definition at line 56 of file web_socket_misc.c.
Generated on Tue Jul 12 2022 17:10:23 by
