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
345U8*
msi2a(U8* dest,
int* dlen, U32 n);
360U8*
msRespCT(U8* dest,
int* dlen,
int contentLen,
const U8* extHeader);
368#define MS_constructor(o) memset(o,0,sizeof(MS))
379#define MS_setSharkCon(o, sharkCon, socket) \
380 (o)->mst.u.sc=sharkCon, \
381 (o)->mst.sock=socket, \
382 (o)->mst.isSecure=TRUE
385#define MS_setSocket(o,socket,rec,recSize,send,sendSize) \
386 (o)->mst.sock=socket, \
387 (o)->mst.u.b.recBuf=rec, \
388 (o)->mst.u.b.recBufSize=recSize, \
389 (o)->mst.u.b.sendBuf=send, \
390 (o)->mst.u.b.sendBufSize=sendSize, \
391 (o)->mst.isSecure=FALSE
407#define MS_setSocket(o,socket,rec,recSize,send,sendSize) \
408 (o)->mst.sock=socket, \
409 (o)->mst.b.recBuf=rec, \
410 (o)->mst.b.recBufSize=recSize, \
411 (o)->mst.b.sendBuf=send, \
412 (o)->mst.b.sendBufSize=sendSize, \
413 (o)->mst.isSecure=FALSE
425U8*
MS_respCT(
MS* o,
int* dlen,
int contentLen,
const U8* extHeader);
486#define MS_sendBin(o, len) MS_send(o, WSOP_Binary, len)
501#define MS_sendText(o, len) MS_send(o, WSOP_Text, len)
531#define MS_writeBin(o,data,len) MS_write(o,WSOP_Binary,data,len)
545#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_send(MS *o, U8 opCode, int len)
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)
Read 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.
#define MAX_HTTP_H_SIZE
Definition: MSLib.h:125
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 * msstrstrn(U8 *str, int slen, const U8 *substr)
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:496
#define SOCKET
Infinite wait time option for socket read functions.
Definition: selib.h:103
The Minnow Server Transmission Buffer is used by the Minnow Server Transmission (MST) class when used...
Definition: MSLib.h:237
U8 * recBuf
Definition: MSLib.h:238
U16 recBufSize
Definition: MSLib.h:240
U8 * sendBuf
Definition: MSLib.h:239
U16 sendBufSize
Definition: MSLib.h:241
The Minnow Server Transmission Class defines a set of functions for reading and writing socket data e...
Definition: MSLib.h:250
SOCKET * sock
Definition: MSLib.h:251
MSTBuf b
Definition: MSLib.h:258
BaBool isSecure
Definition: MSLib.h:260
MS: Minnow Server HTTP(S) and (secure) WebSocket Server.
Definition: MSLib.h:289
MST mst
Definition: MSLib.h:291
WssReadState rs
Definition: MSLib.h:290
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
U8 * overflowPtr
Definition: MSLib.h:209
int frameLen
The WebSocket frame length.
Definition: MSLib.h:217
int overflowLen
Definition: MSLib.h:210
U8 * maskPtr
Definition: MSLib.h:212
int frameHeaderIx
Definition: MSLib.h:211
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