56#define WSOP_Binary 0x82
58#define WSOP_Close 0x88
75#define MS_ERR_ALLOC -10
80#define MS_ERR_AUTHENTICATION -11
86#define MS_ERR_HTTP_HEADER_OVERFLOW -12
89#define MS_ERR_INVALID_HTTP -13
92#define MS_ERR_NOT_WEBSOCKET -14
95#define MS_ERR_READ -15
98#define MS_ERR_READ_TMO -16
101#define MS_ERR_SSL_HANDSHAKE -17
104#define MS_ERR_WRITE -18
107#define MS_ERR_ENCRYPTED_ZIP -30
110#define MS_ERR_FILE_IO -31
115#define MS_ERR_BUF_OVERFLOW -40
120#define MS_ERR_BUF_UNDERFLOW -41
125#define MAX_HTTP_H_SIZE 20
195 U8* hKeys[MAX_HTTP_H_SIZE];
199 U8* hVals[MAX_HTTP_H_SIZE];
320U8* msstrstrn(U8* str,
int slen,
const U8* substr);
348U8*
msi2a(U8* dest,
int* dlen, U32 n);
363U8*
msRespCT(U8* dest,
int* dlen,
int contentLen,
const U8* extHeader);
371#define MS_constructor(o) memset(o,0,sizeof(MS))
382#define MS_setSharkCon(o, sharkCon, socket) \
383 (o)->mst.u.sc=sharkCon, \
384 (o)->mst.sock=socket, \
385 (o)->mst.isSecure=TRUE
388#define MS_setSocket(o,socket,rec,recSize,send,sendSize) \
389 (o)->mst.sock=socket, \
390 (o)->mst.u.b.recBuf=rec, \
391 (o)->mst.u.b.recBufSize=recSize, \
392 (o)->mst.u.b.sendBuf=send, \
393 (o)->mst.u.b.sendBufSize=sendSize, \
394 (o)->mst.isSecure=FALSE
410#define MS_setSocket(o,socket,rec,recSize,send,sendSize) \
411 (o)->mst.sock=socket, \
412 (o)->mst.b.recBuf=rec, \
413 (o)->mst.b.recBufSize=recSize, \
414 (o)->mst.b.sendBuf=send, \
415 (o)->mst.b.sendBufSize=sendSize, \
416 (o)->mst.isSecure=FALSE
428U8*
MS_respCT(
MS* o,
int* dlen,
int contentLen,
const U8* extHeader);
469int MS_send(
MS* o, U8 opCode,
int len);
484#define MS_sendBin(o, len) MS_send(o, WSOP_Binary, len)
499#define MS_sendText(o, len) MS_send(o, WSOP_Text, len)
529#define MS_writeBin(o,data,len) MS_write(o,WSOP_Binary,data,len)
543#define MS_writeText(o,data,len) MS_write(o,WSOP_Text,data,len)
U8 * MS_prepSend(MS *o, int extSize, int *maxSize)
Prepare sending a WebSocket frame using one of MS_sendBin or MS_sendText.
U16 MST_getSendBufSize(MST *o)
Get the send buffer size.
struct MST MST
The Minnow Server Transmission Class defines a set of functions for reading and writing socket data e...
int MS_close(MS *o, int statusCode)
Sends a WebSocket close frame command to the peer and close the socket.
int MS_webServer(MS *o, WssProtocolHandshake *wph)
The Web Server function is responsible for parsing incoming HTTP requests and upgrading HTTP requests...
int MST_read(MST *o, U8 **buf, U32 timeout)
Write data to a secure layer or non secure (standard socket) layer.
U8 * MS_respCT(MS *o, int *dlen, int contentLen, const U8 *extHeader)
Format a HTTP 200 OK response with Content Length.
int MS_read(MS *o, U8 **buf, U32 timeout)
Waits for WebSocket frames sent by the peer side.
int MST_write(MST *o, U8 *buf, int len)
Write data to a secure layer or non secure (standard socket) layer.
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 appli...
Definition: MSLib.h:132
U8 * MST_getSendBufPtr(MST *o)
Get the send buffer pointer.
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.
U8 * msi2a(U8 *dest, int *dlen, U32 n)
Formats 'n' as a string and adds the string to 'dest'.
U8 * msRespCT(U8 *dest, int *dlen, int contentLen, const U8 *extHeader)
Adds the following HTTP response to buffer 'dest'.
U8 * msB64Encode(U8 *dest, int *dlen, const U8 *src, int slen)
Encodes 'src' as B64 and adds the string to 'dest'.
U8 * msCpAndInc(U8 *dest, int *dlen, const U8 *src, int slen)
Copies 'src' to 'dest'.
struct SharkSslCon SharkSslCon
SharkSslCon is an opaque handle returned by function SharkSsl_createCon.
Definition: SharkSSL.h:553
#define SOCKET
Infinite wait time option for socket read functions.
Definition: selib.h:102
The Minnow Server Transmission Buffer is used by the Minnow Server Transmission (MST) class when used...
Definition: MSLib.h:237
The Minnow Server Transmission Class defines a set of functions for reading and writing socket data e...
Definition: MSLib.h:250
MS: Minnow Server HTTP(S) and (secure) WebSocket Server.
Definition: MSLib.h:292
The WssProtocolHandshake structure keeps state information for the web server function MS_ebServer.
Definition: MSLib.h:141
U8 * origin
Out param: Set to the HTTP WebSocket header 'origin', if sent by the client.
Definition: MSLib.h:191
MSFetchPage fetchPage
In param: set the page fetch callback function if you plan on storing the web application in the devi...
Definition: MSLib.h:175
U8 * request
Out param: Set to the initial HTTP header request line.
Definition: MSLib.h:186
void * fetchPageHndl
In param: The MSFetchPage handle, if any.
Definition: MSLib.h:178
const U8 * b64Credent
In param: Enable HTTP basic authentication by setting 'b64Credent' to a B64 encoded string of 'userna...
Definition: MSLib.h:156
const U8 * realm
In param: Set the HTTP basic authentication's 'realm' name.
Definition: MSLib.h:160
The WS protocol is frame based, and struct WssReadState keeps state information for the Minnow Server...
Definition: MSLib.h:207
int frameLen
The WebSocket frame length.
Definition: MSLib.h:217
int bytesRead
Read frame data until: frameLen - bytesRead = 0.
Definition: MSLib.h:221
U8 isTimeout
Set when function msRead returns due to a timeout.
Definition: MSLib.h:225