Webserver+3d print
cyclone_tcp/web_socket/web_socket_misc.h@0:8918a71cdbe9, 2017-02-04 (annotated)
- Committer:
- Sergunb
- Date:
- Sat Feb 04 18:15:49 2017 +0000
- Revision:
- 0:8918a71cdbe9
nothing else
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sergunb | 0:8918a71cdbe9 | 1 | /** |
Sergunb | 0:8918a71cdbe9 | 2 | * @file web_socket_misc.h |
Sergunb | 0:8918a71cdbe9 | 3 | * @brief Helper functions for WebSockets |
Sergunb | 0:8918a71cdbe9 | 4 | * |
Sergunb | 0:8918a71cdbe9 | 5 | * @section License |
Sergunb | 0:8918a71cdbe9 | 6 | * |
Sergunb | 0:8918a71cdbe9 | 7 | * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. |
Sergunb | 0:8918a71cdbe9 | 8 | * |
Sergunb | 0:8918a71cdbe9 | 9 | * This file is part of CycloneTCP Open. |
Sergunb | 0:8918a71cdbe9 | 10 | * |
Sergunb | 0:8918a71cdbe9 | 11 | * This program is free software; you can redistribute it and/or |
Sergunb | 0:8918a71cdbe9 | 12 | * modify it under the terms of the GNU General Public License |
Sergunb | 0:8918a71cdbe9 | 13 | * as published by the Free Software Foundation; either version 2 |
Sergunb | 0:8918a71cdbe9 | 14 | * of the License, or (at your option) any later version. |
Sergunb | 0:8918a71cdbe9 | 15 | * |
Sergunb | 0:8918a71cdbe9 | 16 | * This program is distributed in the hope that it will be useful, |
Sergunb | 0:8918a71cdbe9 | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Sergunb | 0:8918a71cdbe9 | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Sergunb | 0:8918a71cdbe9 | 19 | * GNU General Public License for more details. |
Sergunb | 0:8918a71cdbe9 | 20 | * |
Sergunb | 0:8918a71cdbe9 | 21 | * You should have received a copy of the GNU General Public License |
Sergunb | 0:8918a71cdbe9 | 22 | * along with this program; if not, write to the Free Software Foundation, |
Sergunb | 0:8918a71cdbe9 | 23 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
Sergunb | 0:8918a71cdbe9 | 24 | * |
Sergunb | 0:8918a71cdbe9 | 25 | * @author Oryx Embedded SARL (www.oryx-embedded.com) |
Sergunb | 0:8918a71cdbe9 | 26 | * @version 1.7.6 |
Sergunb | 0:8918a71cdbe9 | 27 | **/ |
Sergunb | 0:8918a71cdbe9 | 28 | |
Sergunb | 0:8918a71cdbe9 | 29 | #ifndef _WEB_SOCKET_MISC_H |
Sergunb | 0:8918a71cdbe9 | 30 | #define _WEB_SOCKET_MISC_H |
Sergunb | 0:8918a71cdbe9 | 31 | |
Sergunb | 0:8918a71cdbe9 | 32 | //Dependencies |
Sergunb | 0:8918a71cdbe9 | 33 | #include "core/net.h" |
Sergunb | 0:8918a71cdbe9 | 34 | #include "web_socket/web_socket.h" |
Sergunb | 0:8918a71cdbe9 | 35 | |
Sergunb | 0:8918a71cdbe9 | 36 | |
Sergunb | 0:8918a71cdbe9 | 37 | /** |
Sergunb | 0:8918a71cdbe9 | 38 | * @brief HTTP status code |
Sergunb | 0:8918a71cdbe9 | 39 | **/ |
Sergunb | 0:8918a71cdbe9 | 40 | |
Sergunb | 0:8918a71cdbe9 | 41 | typedef struct |
Sergunb | 0:8918a71cdbe9 | 42 | { |
Sergunb | 0:8918a71cdbe9 | 43 | uint_t value; |
Sergunb | 0:8918a71cdbe9 | 44 | const char_t message[28]; |
Sergunb | 0:8918a71cdbe9 | 45 | } WebSocketStatusCodeDesc; |
Sergunb | 0:8918a71cdbe9 | 46 | |
Sergunb | 0:8918a71cdbe9 | 47 | |
Sergunb | 0:8918a71cdbe9 | 48 | //WebSocket related functions |
Sergunb | 0:8918a71cdbe9 | 49 | void webSocketChangeState(WebSocket *webSocket, WebSocketState newState); |
Sergunb | 0:8918a71cdbe9 | 50 | |
Sergunb | 0:8918a71cdbe9 | 51 | error_t webSocketParseHandshake(WebSocket *webSocket); |
Sergunb | 0:8918a71cdbe9 | 52 | error_t webSocketParseRequestLine(WebSocket *webSocket, char_t *line); |
Sergunb | 0:8918a71cdbe9 | 53 | error_t webSocketParseStatusLine(WebSocket *webSocket, char_t *line); |
Sergunb | 0:8918a71cdbe9 | 54 | error_t webSocketParseHeaderField(WebSocket *webSocket, char_t *line); |
Sergunb | 0:8918a71cdbe9 | 55 | |
Sergunb | 0:8918a71cdbe9 | 56 | void webSocketParseConnectionField(WebSocket *webSocket, char_t *value); |
Sergunb | 0:8918a71cdbe9 | 57 | |
Sergunb | 0:8918a71cdbe9 | 58 | error_t webSocketFormatClientHandshake(WebSocket *webSocket, uint16_t serverPort); |
Sergunb | 0:8918a71cdbe9 | 59 | error_t webSocketFormatServerHandshake(WebSocket *webSocket); |
Sergunb | 0:8918a71cdbe9 | 60 | |
Sergunb | 0:8918a71cdbe9 | 61 | error_t webSocketFormatErrorResponse(WebSocket *webSocket, |
Sergunb | 0:8918a71cdbe9 | 62 | uint_t statusCode, const char_t *message); |
Sergunb | 0:8918a71cdbe9 | 63 | |
Sergunb | 0:8918a71cdbe9 | 64 | error_t webSocketVerifyClientHandshake(WebSocket *webSocket); |
Sergunb | 0:8918a71cdbe9 | 65 | error_t webSocketVerifyServerHandshake(WebSocket *webSocket); |
Sergunb | 0:8918a71cdbe9 | 66 | |
Sergunb | 0:8918a71cdbe9 | 67 | error_t webSocketGenerateClientKey(WebSocket *webSocket); |
Sergunb | 0:8918a71cdbe9 | 68 | error_t webSocketGenerateServerKey(WebSocket *webSocket); |
Sergunb | 0:8918a71cdbe9 | 69 | |
Sergunb | 0:8918a71cdbe9 | 70 | error_t webSocketVerifyClientKey(WebSocket *webSocket); |
Sergunb | 0:8918a71cdbe9 | 71 | error_t webSocketVerifyServerKey(WebSocket *webSocket); |
Sergunb | 0:8918a71cdbe9 | 72 | |
Sergunb | 0:8918a71cdbe9 | 73 | bool_t webSocketCheckStatusCode(uint16_t statusCode); |
Sergunb | 0:8918a71cdbe9 | 74 | |
Sergunb | 0:8918a71cdbe9 | 75 | error_t webSocketDecodePercentEncodedString(const char_t *input, |
Sergunb | 0:8918a71cdbe9 | 76 | char_t *output, size_t outputSize); |
Sergunb | 0:8918a71cdbe9 | 77 | |
Sergunb | 0:8918a71cdbe9 | 78 | bool_t webSocketCheckUtf8Stream(WebSocketUtf8Context *context, |
Sergunb | 0:8918a71cdbe9 | 79 | const uint8_t *data, size_t length, size_t remaining); |
Sergunb | 0:8918a71cdbe9 | 80 | |
Sergunb | 0:8918a71cdbe9 | 81 | #endif |
Sergunb | 0:8918a71cdbe9 | 82 |