SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
MSLib.h File Reference
#include <selib.h>

Go to the source code of this file.

Data Structures

struct  WssProtocolHandshake
 The WssProtocolHandshake structure keeps state information for the web server function MS_ebServer. More...
 
struct  WssReadState
 The WS protocol is frame based, and struct WssReadState keeps state information for the Minnow Server's MS_read function. More...
 
struct  MSTBuf
 The Minnow Server Transmission Buffer is used by the Minnow Server Transmission (MST) class when used in non secure mode. More...
 
struct  MST
 The Minnow Server Transmission Class defines a set of functions for reading and writing socket data either in secure mode using SharkSSL or non secure mode. More...
 
struct  MS
 MS: Minnow Server HTTP(S) and (secure) WebSocket Server. More...
 

Macros

#define WSOP_Text   0x81
 
#define WSOP_Binary   0x82
 
#define WSOP_Close   0x88
 
#define WSOP_Ping   0x89
 
#define WSOP_Pong   0x8A
 
#define MS_ERR_ALLOC   -10
 Allocation error means the SharkSSL buffers are too small when operating in secure mode, or the buffers provided to MSTBuf is too small when operating in non secure mode. More...
 
#define MS_ERR_AUTHENTICATION   -11
 This error code is returned if WssProtocolHandshake::b64Credent is set and an HTTP client provides incorrect credentials. More...
 
#define MS_ERR_HTTP_HEADER_OVERFLOW   -12
 The HTTP request header may be stored in the SharkSSL send buffer. More...
 
#define MS_ERR_INVALID_HTTP   -13
 Received invalid HTTP header from client. More...
 
#define MS_ERR_NOT_WEBSOCKET   -14
 The request was successful, but it is not a WebSocket connection. More...
 
#define MS_ERR_READ   -15
 Socket read error. More...
 
#define MS_ERR_READ_TMO   -16
 Socket read timeout. More...
 
#define MS_ERR_SSL_HANDSHAKE   -17
 The initial SSL handshake failed. More...
 
#define MS_ERR_WRITE   -18
 Socket write error. More...
 
#define MS_ERR_ENCRYPTED_ZIP   -30
 Encrypted ZIP file not supported by ZipFileSystem. More...
 
#define MS_ERR_FILE_IO   -31
 Error reported by MSFetchPage. More...
 
#define MS_ERR_BUF_OVERFLOW   -40
 Incorrect parameter use when calling MS_prepSend and then calling one of MS_sendBin or MS_sendText. More...
 
#define MS_ERR_BUF_UNDERFLOW   -41
 Incorrect parameter use when calling MS_prepSend and then calling one of MS_sendBin or MS_sendText. More...
 
#define MAX_HTTP_H_SIZE   20
 
#define MS_constructor(o)   memset(o,0,sizeof(MS))
 Minnow Server Constructor. More...
 
#define MS_setSharkCon(o, sharkCon, socket)
 Set the SharkSSL object and the socket connection after socket select accepts and creates a new server socket. More...
 
#define MS_setSocket(o, socket, rec, recSize, send, sendSize)
 Set the socket connection after socket select accepts and creates a new server socket. More...
 
#define MS_sendBin(o, len)   MS_send(o, WSOP_Binary, len)
 Send a WebSocket binary frame using the SharkSSL zero copy API. More...
 
#define MS_sendText(o, len)   MS_send(o, WSOP_Text, len)
 Send a WebSocket text frame using the SharkSSL zero copy API. More...
 
#define MS_writeBin(o, data, len)   MS_write(o,WSOP_Binary,data,len)
 Sends data as WebSocket text frame(s). More...
 
#define MS_writeText(o, data, len)   MS_write(o,WSOP_Text,data,len)
 Send data as WebSocket binary frame(s). More...
 

Typedefs

typedef int(* MSFetchPage) (void *hndl, struct MST *mst, U8 *path)
 A page fetch callback function used by function MS_ebServer is typically installed when the web application is stored on the device. More...
 
typedef struct MST MST
 The Minnow Server Transmission Class defines a set of functions for reading and writing socket data either in secure mode using SharkSSL or non secure mode. More...
 

Functions

U8 * MST_getSendBufPtr (MST *o)
 Get the send buffer pointer. More...
 
U16 MST_getSendBufSize (MST *o)
 Get the send buffer size. More...
 
int MST_read (MST *o, U8 **buf, U32 timeout)
 Read data to a secure layer or non secure (standard socket) layer. More...
 
int MST_write (MST *o, U8 *buf, int len)
 Write data to a secure layer or non secure (standard socket) layer. More...
 
U8 * msstrstrn (U8 *str, int slen, const U8 *substr)
 
U8 * msCpAndInc (U8 *dest, int *dlen, const U8 *src, int slen)
 Copies 'src' to 'dest'. More...
 
U8 * msB64Encode (U8 *dest, int *dlen, const U8 *src, int slen)
 Encodes 'src' as B64 and adds the string to 'dest'. More...
 
U8 * msi2a (U8 *dest, int *dlen, U32 n)
 Formats 'n' as a string and adds the string to 'dest'. More...
 
U8 * msRespCT (U8 *dest, int *dlen, int contentLen, const U8 *extHeader)
 Adds the following HTTP response to buffer 'dest'. More...
 
U8 * MS_respCT (MS *o, int *dlen, int contentLen, const U8 *extHeader)
 Format a HTTP 200 OK response with Content Length. More...
 
int MS_webServer (MS *o, WssProtocolHandshake *wph)
 The Web Server function is responsible for parsing incoming HTTP requests and upgrading HTTP requests to WebSocket connections. More...
 
U8 * MS_prepSend (MS *o, int extSize, int *maxSize)
 Prepare sending a WebSocket frame using one of MS_sendBin or MS_sendText. More...
 
int MS_send (MS *o, U8 opCode, int len)
 
int MS_write (MS *o, U8 opCode, const void *data, int len)
 Function used by the two inline functions (macros) MS_writeBin and MS_writeText. More...
 
int MS_close (MS *o, int statusCode)
 Sends a WebSocket close frame command to the peer and close the socket. More...
 
int MS_read (MS *o, U8 **buf, U32 timeout)
 Waits for WebSocket frames sent by the peer side. More...