GNU libmicrohttpd 0.9.77
Loading...
Searching...
No Matches
mhd_websocket.c File Reference

Support for the websocket protocol. More...

#include "platform.h"
#include "microhttpd.h"
#include "microhttpd_ws.h"
#include "sha1.h"
Include dependency graph for mhd_websocket.c:

Go to the source code of this file.

Macros

#define MHD_WEBSOCKET_FLAG_MASK_SERVERCLIENT   MHD_WEBSOCKET_FLAG_CLIENT
 
#define MHD_WEBSOCKET_FLAG_MASK_FRAGMENTATION    MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS
 
#define MHD_WEBSOCKET_FLAG_MASK_GENERATE_CLOSE_FRAMES    MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR
 
#define MHD_WEBSOCKET_FLAG_MASK_ALL
 

Enumerations

enum  MHD_WebSocket_Opcode {
  MHD_WebSocket_Opcode_Continuation = 0x0 , MHD_WebSocket_Opcode_Text = 0x1 , MHD_WebSocket_Opcode_Binary = 0x2 , MHD_WebSocket_Opcode_Close = 0x8 ,
  MHD_WebSocket_Opcode_Ping = 0x9 , MHD_WebSocket_Opcode_Pong = 0xA
}
 
enum  MHD_WebSocket_DecodeStep {
  MHD_WebSocket_DecodeStep_Start = 0 , MHD_WebSocket_DecodeStep_Length1ofX = 1 , MHD_WebSocket_DecodeStep_Length1of2 = 2 , MHD_WebSocket_DecodeStep_Length2of2 = 3 ,
  MHD_WebSocket_DecodeStep_Length1of8 = 4 , MHD_WebSocket_DecodeStep_Length2of8 = 5 , MHD_WebSocket_DecodeStep_Length3of8 = 6 , MHD_WebSocket_DecodeStep_Length4of8 = 7 ,
  MHD_WebSocket_DecodeStep_Length5of8 = 8 , MHD_WebSocket_DecodeStep_Length6of8 = 9 , MHD_WebSocket_DecodeStep_Length7of8 = 10 , MHD_WebSocket_DecodeStep_Length8of8 = 11 ,
  MHD_WebSocket_DecodeStep_Mask1Of4 = 12 , MHD_WebSocket_DecodeStep_Mask2Of4 = 13 , MHD_WebSocket_DecodeStep_Mask3Of4 = 14 , MHD_WebSocket_DecodeStep_Mask4Of4 = 15 ,
  MHD_WebSocket_DecodeStep_HeaderCompleted = 16 , MHD_WebSocket_DecodeStep_PayloadOfDataFrame = 17 , MHD_WebSocket_DecodeStep_PayloadOfControlFrame = 18 , MHD_WebSocket_DecodeStep_BrokenStream = 99
}
 
enum  MHD_WebSocket_UTF8Result { MHD_WebSocket_UTF8Result_Invalid = 0 , MHD_WebSocket_UTF8Result_Valid = 1 , MHD_WebSocket_UTF8Result_Incomplete = 2 }
 

Functions

static void MHD_websocket_copy_payload (char *dst, const char *src, size_t len, uint32_t mask, unsigned long mask_offset)
 
static int MHD_websocket_check_utf8 (const char *buf, size_t buf_len, int *utf8_step, size_t *buf_offset)
 
static enum MHD_WEBSOCKET_STATUS MHD_websocket_decode_header_complete (struct MHD_WebSocketStream *ws, char **payload, size_t *payload_len)
 
static enum MHD_WEBSOCKET_STATUS MHD_websocket_decode_payload_complete (struct MHD_WebSocketStream *ws, char **payload, size_t *payload_len)
 
static char MHD_websocket_encode_is_masked (struct MHD_WebSocketStream *ws)
 
static char MHD_websocket_encode_overhead_size (struct MHD_WebSocketStream *ws, size_t payload_len)
 
static enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_data (struct MHD_WebSocketStream *ws, const char *payload, size_t payload_len, int fragmentation, char **frame, size_t *frame_len, char opcode)
 
static enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_ping_pong (struct MHD_WebSocketStream *ws, const char *payload, size_t payload_len, char **frame, size_t *frame_len, char opcode)
 
static uint32_t MHD_websocket_generate_mask (struct MHD_WebSocketStream *ws)
 
static uint16_t MHD_htons (uint16_t value)
 
static uint64_t MHD_htonll (uint64_t value)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_http_version (const char *http_version)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_connection_header (const char *connection_header)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_upgrade_header (const char *upgrade_header)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_version_header (const char *version_header)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_create_accept_header (const char *sec_websocket_key, char *sec_websocket_accept)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_init (struct MHD_WebSocketStream **ws, int flags, size_t max_payload_size)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_init2 (struct MHD_WebSocketStream **ws, int flags, size_t max_payload_size, MHD_WebSocketMallocCallback callback_malloc, MHD_WebSocketReallocCallback callback_realloc, MHD_WebSocketFreeCallback callback_free, void *cls_rng, MHD_WebSocketRandomNumberGenerator callback_rng)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_free (struct MHD_WebSocketStream *ws)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_invalidate (struct MHD_WebSocketStream *ws)
 
_MHD_EXTERN enum MHD_WEBSOCKET_VALIDITY MHD_websocket_stream_is_valid (struct MHD_WebSocketStream *ws)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_decode (struct MHD_WebSocketStream *ws, const char *streambuf, size_t streambuf_len, size_t *streambuf_read_len, char **payload, size_t *payload_len)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_split_close_reason (const char *payload, size_t payload_len, unsigned short *reason_code, const char **reason_utf8, size_t *reason_utf8_len)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_text (struct MHD_WebSocketStream *ws, const char *payload_utf8, size_t payload_utf8_len, int fragmentation, char **frame, size_t *frame_len, int *utf8_step)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_binary (struct MHD_WebSocketStream *ws, const char *payload, size_t payload_len, int fragmentation, char **frame, size_t *frame_len)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_ping (struct MHD_WebSocketStream *ws, const char *payload, size_t payload_len, char **frame, size_t *frame_len)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_pong (struct MHD_WebSocketStream *ws, const char *payload, size_t payload_len, char **frame, size_t *frame_len)
 
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_close (struct MHD_WebSocketStream *ws, unsigned short reason_code, const char *reason_utf8, size_t reason_utf8_len, char **frame, size_t *frame_len)
 
_MHD_EXTERN void * MHD_websocket_malloc (struct MHD_WebSocketStream *ws, size_t buf_len)
 
_MHD_EXTERN void * MHD_websocket_realloc (struct MHD_WebSocketStream *ws, void *buf, size_t new_buf_len)
 
_MHD_EXTERN int MHD_websocket_free (struct MHD_WebSocketStream *ws, void *buf)
 

Detailed Description

Support for the websocket protocol.

Author
David Gausmann

Definition in file mhd_websocket.c.

Macro Definition Documentation

◆ MHD_WEBSOCKET_FLAG_MASK_ALL

#define MHD_WEBSOCKET_FLAG_MASK_ALL
Value:

Definition at line 83 of file mhd_websocket.c.

◆ MHD_WEBSOCKET_FLAG_MASK_FRAGMENTATION

#define MHD_WEBSOCKET_FLAG_MASK_FRAGMENTATION    MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS

Definition at line 79 of file mhd_websocket.c.

◆ MHD_WEBSOCKET_FLAG_MASK_GENERATE_CLOSE_FRAMES

#define MHD_WEBSOCKET_FLAG_MASK_GENERATE_CLOSE_FRAMES    MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR

Definition at line 81 of file mhd_websocket.c.

◆ MHD_WEBSOCKET_FLAG_MASK_SERVERCLIENT

#define MHD_WEBSOCKET_FLAG_MASK_SERVERCLIENT   MHD_WEBSOCKET_FLAG_CLIENT

Definition at line 78 of file mhd_websocket.c.

Enumeration Type Documentation

◆ MHD_WebSocket_DecodeStep

Enumerator
MHD_WebSocket_DecodeStep_Start 
MHD_WebSocket_DecodeStep_Length1ofX 
MHD_WebSocket_DecodeStep_Length1of2 
MHD_WebSocket_DecodeStep_Length2of2 
MHD_WebSocket_DecodeStep_Length1of8 
MHD_WebSocket_DecodeStep_Length2of8 
MHD_WebSocket_DecodeStep_Length3of8 
MHD_WebSocket_DecodeStep_Length4of8 
MHD_WebSocket_DecodeStep_Length5of8 
MHD_WebSocket_DecodeStep_Length6of8 
MHD_WebSocket_DecodeStep_Length7of8 
MHD_WebSocket_DecodeStep_Length8of8 
MHD_WebSocket_DecodeStep_Mask1Of4 
MHD_WebSocket_DecodeStep_Mask2Of4 
MHD_WebSocket_DecodeStep_Mask3Of4 
MHD_WebSocket_DecodeStep_Mask4Of4 
MHD_WebSocket_DecodeStep_HeaderCompleted 
MHD_WebSocket_DecodeStep_PayloadOfDataFrame 
MHD_WebSocket_DecodeStep_PayloadOfControlFrame 
MHD_WebSocket_DecodeStep_BrokenStream 

Definition at line 98 of file mhd_websocket.c.

◆ MHD_WebSocket_Opcode

Enumerator
MHD_WebSocket_Opcode_Continuation 
MHD_WebSocket_Opcode_Text 
MHD_WebSocket_Opcode_Binary 
MHD_WebSocket_Opcode_Close 
MHD_WebSocket_Opcode_Ping 
MHD_WebSocket_Opcode_Pong 

Definition at line 88 of file mhd_websocket.c.

◆ MHD_WebSocket_UTF8Result

Enumerator
MHD_WebSocket_UTF8Result_Invalid 
MHD_WebSocket_UTF8Result_Valid 
MHD_WebSocket_UTF8Result_Incomplete 

Definition at line 122 of file mhd_websocket.c.

Function Documentation

◆ MHD_htonll()

static uint64_t MHD_htonll ( uint64_t  value)
static

Converts a 64 bit value into network byte order (MSB first) in dependence of the host system

Definition at line 2421 of file mhd_websocket.c.

Referenced by MHD_websocket_decode(), and MHD_websocket_encode_data().

Here is the caller graph for this function:

◆ MHD_htons()

static uint16_t MHD_htons ( uint16_t  value)
static

Converts a 16 bit value into network byte order (MSB first) in dependence of the host system

Definition at line 2397 of file mhd_websocket.c.

Referenced by MHD_websocket_decode(), MHD_websocket_encode_close(), MHD_websocket_encode_data(), and MHD_websocket_split_close_reason().

Here is the caller graph for this function:

◆ MHD_websocket_check_connection_header()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_connection_header ( const char *  connection_header)

Checks whether the "Connection" request header has the 'Upgrade' token.

Definition at line 282 of file mhd_websocket.c.

References MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER, MHD_WEBSOCKET_STATUS_OK, and NULL.

◆ MHD_websocket_check_http_version()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_http_version ( const char *  http_version)

Checks whether the HTTP version is 1.1 or above.

Definition at line 189 of file mhd_websocket.c.

References MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER, MHD_WEBSOCKET_STATUS_OK, and NULL.

◆ MHD_websocket_check_upgrade_header()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_upgrade_header ( const char *  upgrade_header)

Checks whether the "Upgrade" request header has the "websocket" keyword.

Definition at line 365 of file mhd_websocket.c.

References MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER, MHD_WEBSOCKET_STATUS_OK, and NULL.

◆ MHD_websocket_check_utf8()

◆ MHD_websocket_check_version_header()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_version_header ( const char *  version_header)

Checks whether the "Sec-WebSocket-Version" request header equals to "13"

Definition at line 453 of file mhd_websocket.c.

References MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER, MHD_WEBSOCKET_STATUS_OK, and NULL.

◆ MHD_websocket_copy_payload()

static void MHD_websocket_copy_payload ( char *  dst,
const char *  src,
size_t  len,
uint32_t  mask,
unsigned long  mask_offset 
)
static

Copies the payload to the destination (using mask)

Definition at line 2069 of file mhd_websocket.c.

Referenced by MHD_websocket_decode(), MHD_websocket_encode_close(), MHD_websocket_encode_data(), and MHD_websocket_encode_ping_pong().

Here is the caller graph for this function:

◆ MHD_websocket_create_accept_header()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_create_accept_header ( const char *  sec_websocket_key,
char *  sec_websocket_accept 
)

Creates the response for the Sec-WebSocket-Accept header

Definition at line 479 of file mhd_websocket.c.

References MHD_SHA1_finish(), MHD_SHA1_init(), MHD_SHA1_update(), MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER, MHD_WEBSOCKET_STATUS_OK, MHD_WEBSOCKET_STATUS_PARAMETER_ERROR, and NULL.

Here is the call graph for this function:

◆ MHD_websocket_decode()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_decode ( struct MHD_WebSocketStream *  ws,
const char *  streambuf,
size_t  streambuf_len,
size_t *  streambuf_read_len,
char **  payload,
size_t *  payload_len 
)

Decodes incoming data to a websocket frame

Definition at line 666 of file mhd_websocket.c.

References MHD_htonll(), MHD_htons(), MHD_websocket_check_utf8(), MHD_WEBSOCKET_CLOSEREASON_MALFORMED_UTF8, MHD_WEBSOCKET_CLOSEREASON_MAXIMUM_ALLOWED_PAYLOAD_SIZE_EXCEEDED, MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR, MHD_websocket_copy_payload(), MHD_websocket_decode_header_complete(), MHD_websocket_decode_payload_complete(), MHD_WebSocket_DecodeStep_BrokenStream, MHD_WebSocket_DecodeStep_HeaderCompleted, MHD_WebSocket_DecodeStep_Length1of2, MHD_WebSocket_DecodeStep_Length1of8, MHD_WebSocket_DecodeStep_Length1ofX, MHD_WebSocket_DecodeStep_Length2of2, MHD_WebSocket_DecodeStep_Length2of8, MHD_WebSocket_DecodeStep_Length3of8, MHD_WebSocket_DecodeStep_Length4of8, MHD_WebSocket_DecodeStep_Length5of8, MHD_WebSocket_DecodeStep_Length6of8, MHD_WebSocket_DecodeStep_Length7of8, MHD_WebSocket_DecodeStep_Length8of8, MHD_WebSocket_DecodeStep_Mask1Of4, MHD_WebSocket_DecodeStep_Mask2Of4, MHD_WebSocket_DecodeStep_Mask3Of4, MHD_WebSocket_DecodeStep_Mask4Of4, MHD_WebSocket_DecodeStep_PayloadOfControlFrame, MHD_WebSocket_DecodeStep_PayloadOfDataFrame, MHD_WebSocket_DecodeStep_Start, MHD_websocket_encode_close(), MHD_WEBSOCKET_FLAG_CLIENT, MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR, MHD_WEBSOCKET_FLAG_SERVER, MHD_WebSocket_Opcode_Binary, MHD_WebSocket_Opcode_Close, MHD_WebSocket_Opcode_Continuation, MHD_WebSocket_Opcode_Ping, MHD_WebSocket_Opcode_Pong, MHD_WebSocket_Opcode_Text, MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED, MHD_WEBSOCKET_STATUS_OK, MHD_WEBSOCKET_STATUS_PARAMETER_ERROR, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_STATUS_STREAM_BROKEN, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WebSocket_UTF8Result_Invalid, MHD_WEBSOCKET_VALIDITY_INVALID, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, NULL, and SIZE_MAX.

Here is the call graph for this function:

◆ MHD_websocket_decode_header_complete()

◆ MHD_websocket_decode_payload_complete()

◆ MHD_websocket_encode_binary()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_binary ( struct MHD_WebSocketStream *  ws,
const char *  payload,
size_t  payload_len,
int  fragmentation,
char **  frame,
size_t *  frame_len 
)

Encodes binary data into a websocket binary frame

Definition at line 1696 of file mhd_websocket.c.

References MHD_websocket_encode_data(), MHD_WEBSOCKET_FRAGMENTATION_LAST, MHD_WEBSOCKET_FRAGMENTATION_NONE, MHD_WebSocket_Opcode_Binary, MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED, MHD_WEBSOCKET_STATUS_PARAMETER_ERROR, and NULL.

Here is the call graph for this function:

◆ MHD_websocket_encode_close()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_close ( struct MHD_WebSocketStream *  ws,
unsigned short  reason_code,
const char *  reason_utf8,
size_t  reason_utf8_len,
char **  frame,
size_t *  frame_len 
)

◆ MHD_websocket_encode_data()

static enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_data ( struct MHD_WebSocketStream *  ws,
const char *  payload,
size_t  payload_len,
int  fragmentation,
char **  frame,
size_t *  frame_len,
char  opcode 
)
static

◆ MHD_websocket_encode_is_masked()

static char MHD_websocket_encode_is_masked ( struct MHD_WebSocketStream *  ws)
static

Returns the 0x80 prefix for masked data, 0x00 otherwise

Definition at line 2043 of file mhd_websocket.c.

References MHD_WEBSOCKET_FLAG_CLIENT, and MHD_WEBSOCKET_FLAG_MASK_SERVERCLIENT.

Referenced by MHD_websocket_encode_close(), MHD_websocket_encode_data(), MHD_websocket_encode_overhead_size(), and MHD_websocket_encode_ping_pong().

Here is the caller graph for this function:

◆ MHD_websocket_encode_overhead_size()

static char MHD_websocket_encode_overhead_size ( struct MHD_WebSocketStream *  ws,
size_t  payload_len 
)
static

Calculates the size of the overhead in bytes

Definition at line 2054 of file mhd_websocket.c.

References MHD_websocket_encode_is_masked().

Referenced by MHD_websocket_encode_close(), MHD_websocket_encode_data(), and MHD_websocket_encode_ping_pong().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_websocket_encode_ping()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_ping ( struct MHD_WebSocketStream *  ws,
const char *  payload,
size_t  payload_len,
char **  frame,
size_t *  frame_len 
)

Encodes a websocket ping frame

Definition at line 1825 of file mhd_websocket.c.

References MHD_websocket_encode_ping_pong(), and MHD_WebSocket_Opcode_Ping.

Here is the call graph for this function:

◆ MHD_websocket_encode_ping_pong()

static enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_ping_pong ( struct MHD_WebSocketStream *  ws,
const char *  payload,
size_t  payload_len,
char **  frame,
size_t *  frame_len,
char  opcode 
)
static

◆ MHD_websocket_encode_pong()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_pong ( struct MHD_WebSocketStream *  ws,
const char *  payload,
size_t  payload_len,
char **  frame,
size_t *  frame_len 
)

Encodes a websocket pong frame

Definition at line 1845 of file mhd_websocket.c.

References MHD_websocket_encode_ping_pong(), and MHD_WebSocket_Opcode_Pong.

Here is the call graph for this function:

◆ MHD_websocket_encode_text()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_text ( struct MHD_WebSocketStream *  ws,
const char *  payload_utf8,
size_t  payload_utf8_len,
int  fragmentation,
char **  frame,
size_t *  frame_len,
int *  utf8_step 
)

◆ MHD_websocket_free()

_MHD_EXTERN int MHD_websocket_free ( struct MHD_WebSocketStream *  ws,
void *  buf 
)

Calls the free function associated with the websocket steam

Definition at line 2378 of file mhd_websocket.c.

References MHD_WEBSOCKET_STATUS_OK, MHD_WEBSOCKET_STATUS_PARAMETER_ERROR, and NULL.

◆ MHD_websocket_generate_mask()

static uint32_t MHD_websocket_generate_mask ( struct MHD_WebSocketStream *  ws)
static

Generates a mask for masking by calling a random number generator.

Definition at line 2314 of file mhd_websocket.c.

References NULL, and offset.

Referenced by MHD_websocket_encode_close(), MHD_websocket_encode_data(), and MHD_websocket_encode_ping_pong().

Here is the caller graph for this function:

◆ MHD_websocket_malloc()

_MHD_EXTERN void * MHD_websocket_malloc ( struct MHD_WebSocketStream *  ws,
size_t  buf_len 
)

Calls the malloc function associated with the websocket steam

Definition at line 2345 of file mhd_websocket.c.

References NULL.

◆ MHD_websocket_realloc()

_MHD_EXTERN void * MHD_websocket_realloc ( struct MHD_WebSocketStream *  ws,
void *  buf,
size_t  new_buf_len 
)

Calls the realloc function associated with the websocket steam

Definition at line 2361 of file mhd_websocket.c.

References NULL.

◆ MHD_websocket_split_close_reason()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_split_close_reason ( const char *  payload,
size_t  payload_len,
unsigned short *  reason_code,
const char **  reason_utf8,
size_t *  reason_utf8_len 
)

◆ MHD_websocket_stream_free()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_free ( struct MHD_WebSocketStream *  ws)

Frees a previously allocated websocket stream

Definition at line 612 of file mhd_websocket.c.

References MHD_WEBSOCKET_STATUS_OK, MHD_WEBSOCKET_STATUS_PARAMETER_ERROR, and NULL.

◆ MHD_websocket_stream_init()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_init ( struct MHD_WebSocketStream **  ws,
int  flags,
size_t  max_payload_size 
)

Initializes a new websocket stream

Definition at line 538 of file mhd_websocket.c.

References MHD_websocket_stream_init2(), and NULL.

Here is the call graph for this function:

◆ MHD_websocket_stream_init2()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_init2 ( struct MHD_WebSocketStream **  ws,
int  flags,
size_t  max_payload_size,
MHD_WebSocketMallocCallback  callback_malloc,
MHD_WebSocketReallocCallback  callback_realloc,
MHD_WebSocketFreeCallback  callback_free,
void *  cls_rng,
MHD_WebSocketRandomNumberGenerator  callback_rng 
)

Initializes a new websocket stream with additional parameters for allocation functions

Definition at line 558 of file mhd_websocket.c.

References MHD_WEBSOCKET_FLAG_CLIENT, MHD_WEBSOCKET_FLAG_MASK_ALL, MHD_WEBSOCKET_STATUS_MEMORY_ERROR, MHD_WEBSOCKET_STATUS_OK, MHD_WEBSOCKET_STATUS_PARAMETER_ERROR, MHD_WEBSOCKET_VALIDITY_VALID, and NULL.

Referenced by MHD_websocket_stream_init().

Here is the caller graph for this function:

◆ MHD_websocket_stream_invalidate()

_MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_invalidate ( struct MHD_WebSocketStream *  ws)

Invalidates a websocket stream (no more decoding possible)

Definition at line 635 of file mhd_websocket.c.

References MHD_WEBSOCKET_STATUS_OK, MHD_WEBSOCKET_STATUS_PARAMETER_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, and NULL.

◆ MHD_websocket_stream_is_valid()

_MHD_EXTERN enum MHD_WEBSOCKET_VALIDITY MHD_websocket_stream_is_valid ( struct MHD_WebSocketStream *  ws)

Returns whether a websocket stream is valid

Definition at line 652 of file mhd_websocket.c.

References MHD_WEBSOCKET_VALIDITY_INVALID, and NULL.