libwebsockets
Lightweight C library for HTML5 websockets
libwebsockets.h File Reference
#include <stdarg.h>
#include "lws_config.h"
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <poll.h>
#include <netdb.h>
#include <sys/time.h>
#include <libwebsockets/lws-logs.h>
#include <libwebsockets/lws-dll2.h>
#include <libwebsockets/lws-map.h>
#include <libwebsockets/lws-fault-injection.h>
#include <libwebsockets/lws-backtrace.h>
#include <libwebsockets/lws-timeout-timer.h>
#include <libwebsockets/lws-cache-ttl.h>
#include <libwebsockets/lws-state.h>
#include <libwebsockets/lws-retry.h>
#include <libwebsockets/lws-ota.h>
#include <libwebsockets/lws-system.h>
#include <libwebsockets/lws-context-vhost.h>
#include <libwebsockets/lws-purify.h>
#include <libwebsockets/lws-misc.h>
#include <libwebsockets/lws-dsh.h>
#include <libwebsockets/lws-ring.h>
#include <libwebsockets/lws-sha1-base64.h>
#include <libwebsockets/lws-x509.h>
#include <libwebsockets/lws-gencrypto.h>
#include <libwebsockets/lws-lejp.h>
#include <libwebsockets/lws-lecp.h>
#include <libwebsockets/lws-cose.h>
#include <libwebsockets/lws-struct.h>
#include <libwebsockets/lws-threadpool.h>
#include <libwebsockets/lws-tokenize.h>
#include <libwebsockets/lws-lwsac.h>
#include <libwebsockets/lws-fts.h>
#include <libwebsockets/lws-diskcache.h>
#include <libwebsockets/lws-secure-streams.h>
#include <libwebsockets/lws-secure-streams-serialization.h>
#include <libwebsockets/lws-secure-streams-policy.h>
#include <libwebsockets/lws-secure-streams-client.h>
#include <libwebsockets/lws-secure-streams-transport-proxy.h>
#include <libwebsockets/lws-jrpc.h>
#include <libwebsockets/lws-async-dns.h>
#include <libwebsockets/lws-i2c.h>
#include <libwebsockets/lws-spi.h>
#include <libwebsockets/lws-gpio.h>
#include <libwebsockets/lws-bb-i2c.h>
#include <libwebsockets/lws-bb-spi.h>
#include <libwebsockets/lws-button.h>
#include <libwebsockets/lws-led.h>
#include <libwebsockets/lws-pwm.h>
#include <libwebsockets/lws-upng.h>
#include <libwebsockets/lws-jpeg.h>
#include <libwebsockets/lws-display.h>
#include <libwebsockets/lws-dlo.h>
#include <libwebsockets/lws-ssd1306-i2c.h>
#include <libwebsockets/lws-ili9341-spi.h>
#include <libwebsockets/lws-spd1656-spi.h>
#include <libwebsockets/lws-uc8176-spi.h>
#include <libwebsockets/lws-ssd1675b-spi.h>
#include <libwebsockets/lws-settings.h>
#include <libwebsockets/lws-html.h>
+ Include dependency graph for libwebsockets.h:

Go to the source code of this file.

Data Structures

struct  lws_pollargs
 
struct  lws_fixed3232
 

Macros

#define LWS_ETHER_ADDR_LEN   ETHER_ADDR_LEN
 
#define LWS_US_PER_SEC   ((lws_usec_t)1000000)
 
#define LWS_MS_PER_SEC   ((lws_usec_t)1000)
 
#define LWS_US_PER_MS   ((lws_usec_t)1000)
 
#define LWS_NS_PER_US   ((lws_usec_t)1000)
 
#define LWS_KI   (1024)
 
#define LWS_MI   (LWS_KI * 1024)
 
#define LWS_GI   (LWS_MI * 1024)
 
#define LWS_TI   ((uint64_t)LWS_GI * 1024)
 
#define LWS_PI   ((uint64_t)LWS_TI * 1024)
 
#define LWS_US_TO_MS(x)   ((x + (LWS_US_PER_MS / 2)) / LWS_US_PER_MS)
 
#define LWS_FOURCC(a, b, c, d)   ((a << 24) | (b << 16) | (c << 8) | d)
 
#define LWS_INLINE   inline
 
#define LWS_O_RDONLY   O_RDONLY
 
#define LWS_O_WRONLY   O_WRONLY
 
#define LWS_O_CREAT   O_CREAT
 
#define LWS_O_TRUNC   O_TRUNC
 
#define LWS_INVALID_FILE   -1
 
#define LWS_SOCK_INVALID   (-1)
 
#define LWS_VISIBLE
 
#define LWS_WARN_UNUSED_RESULT
 
#define LWS_WARN_DEPRECATED
 
#define LWS_FORMAT(string_index)
 
#define LWS_EXTERN   extern
 
#define lws_pthread_mutex(name)
 
#define lws_pthread_mutex_init(_a)
 
#define lws_pthread_mutex_destroy(_a)
 
#define lws_pthread_mutex_lock(_a)
 
#define lws_pthread_mutex_unlock(_a)
 
#define CONTEXT_PORT_NO_LISTEN   -1
 
#define CONTEXT_PORT_NO_LISTEN_SERVER   -2
 
#define lws_container_of(P, T, M)   ((T *)((char *)(P) - offsetof(T, M)))
 
#define LWS_ALIGN_TO(x, bou)   x += ((bou) - ((x) % (bou))) % (bou)
 
#define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_ARG
 
#define LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD
 
#define LWS_FEATURE_PROTOCOLS_HAS_PEER_WRITE_ALLOWANCE
 
#define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_LEN
 
#define LWS_FEATURE_FOPS
 
#define LWS_FEATURE_MOUNT_NO_CACHE
 
#define lws_pollfd   pollfd
 
#define LWS_POLLHUP   (POLLHUP | POLLERR)
 
#define LWS_POLLIN   (POLLIN)
 
#define LWS_POLLOUT   (POLLOUT)
 
#define lws_concat_temp(_t, _l)   (_t + sizeof(_t) - _l)
 
#define lws_concat_used(_t, _l)   (sizeof(_t) - _l)
 
#define LWS_SIZEOFPTR   ((int)sizeof (void *))
 
#define _LWS_PAD_SIZE   LWS_SIZEOFPTR /* Size of a pointer on the target arch */
 
#define _LWS_PAD(n)
 
#define LWS_PRE   _LWS_PAD(4 + 10 + 2)
 
#define LWS_SEND_BUFFER_PRE_PADDING   LWS_PRE
 
#define LWS_SEND_BUFFER_POST_PADDING   0
 
#define LWS_FX_FRACTION_MSD   100000000
 
#define lws_neg(a)   (a->whole < 0 || a->frac < 0)
 
#define lws_fx_set(a, x, y)   { a.whole = x; a.frac = x < 0 ? -y : y; }
 
#define lws_fix64(a)
 
#define lws_fix64_abs(a)
 
#define lws_fix3232(a, a64)
 

Typedefs

typedef struct lws_context * lws_ctx_t
 
typedef unsigned long long lws_intptr_t
 
typedef int lws_sockfd_type
 
typedef int lws_filefd_type
 
typedef unsigned int uint32_t
 
typedef unsigned short uint16_t
 
typedef unsigned char uint8_t
 
typedef int64_t lws_usec_t
 
typedef unsigned long long lws_filepos_t
 
typedef long long lws_fileofs_t
 
typedef uint32_t lws_fop_flags_t
 
typedef struct lws_fixed3232 lws_fx_t
 

Enumerations

enum  lws_stateful_ret_t {
  LWS_SRET_OK = 0 , LWS_SRET_WANT_INPUT = (1 << 16) , LWS_SRET_WANT_OUTPUT = (1 << 17) , LWS_SRET_FATAL = (1 << 18) ,
  LWS_SRET_NO_FURTHER_IN = (1 << 19) , LWS_SRET_NO_FURTHER_OUT = (1 << 20) , LWS_SRET_AWAIT_RETRY = (1 << 21) , LWS_SRET_YIELD = (1 << 22)
}
 

Functions

LWS_VISIBLE LWS_EXTERN const lws_fx_tlws_fx_add (lws_fx_t *r, const lws_fx_t *a, const lws_fx_t *b)
 
LWS_VISIBLE LWS_EXTERN const lws_fx_tlws_fx_sub (lws_fx_t *r, const lws_fx_t *a, const lws_fx_t *b)
 
LWS_VISIBLE LWS_EXTERN const lws_fx_tlws_fx_mul (lws_fx_t *r, const lws_fx_t *a, const lws_fx_t *b)
 
LWS_VISIBLE LWS_EXTERN const lws_fx_tlws_fx_div (lws_fx_t *r, const lws_fx_t *a, const lws_fx_t *b)
 
LWS_VISIBLE LWS_EXTERN const lws_fx_tlws_fx_sqrt (lws_fx_t *r, const lws_fx_t *a)
 
LWS_VISIBLE LWS_EXTERN int lws_fx_comp (const lws_fx_t *a, const lws_fx_t *b)
 
LWS_VISIBLE LWS_EXTERN int lws_fx_roundup (const lws_fx_t *a)
 
LWS_VISIBLE LWS_EXTERN int lws_fx_rounddown (const lws_fx_t *a)
 
LWS_VISIBLE LWS_EXTERN const char * lws_fx_string (const lws_fx_t *a, char *buf, size_t size)
 

Data Structure Documentation

◆ lws_pollargs

struct lws_pollargs

struct lws_pollargs - argument structure for all external poll related calls passed in via 'in'

Definition at line 586 of file libwebsockets.h.

+ Collaboration diagram for lws_pollargs:
Data Fields
lws_sockfd_type fd

applicable socket descriptor

int events

the new event mask

int prev_events

the previous event mask

◆ lws_fixed3232

struct lws_fixed3232

Definition at line 632 of file libwebsockets.h.

+ Collaboration diagram for lws_fixed3232:
Data Fields
int32_t whole
int32_t frac

Macro Definition Documentation

◆ LWS_ETHER_ADDR_LEN

#define LWS_ETHER_ADDR_LEN   ETHER_ADDR_LEN

Definition at line 50 of file libwebsockets.h.

◆ LWS_US_PER_SEC

#define LWS_US_PER_SEC   ((lws_usec_t)1000000)

Definition at line 66 of file libwebsockets.h.

◆ LWS_MS_PER_SEC

#define LWS_MS_PER_SEC   ((lws_usec_t)1000)

Definition at line 67 of file libwebsockets.h.

◆ LWS_US_PER_MS

#define LWS_US_PER_MS   ((lws_usec_t)1000)

Definition at line 68 of file libwebsockets.h.

◆ LWS_NS_PER_US

#define LWS_NS_PER_US   ((lws_usec_t)1000)

Definition at line 69 of file libwebsockets.h.

◆ LWS_KI

#define LWS_KI   (1024)

Definition at line 71 of file libwebsockets.h.

◆ LWS_MI

#define LWS_MI   (LWS_KI * 1024)

Definition at line 72 of file libwebsockets.h.

◆ LWS_GI

#define LWS_GI   (LWS_MI * 1024)

Definition at line 73 of file libwebsockets.h.

◆ LWS_TI

#define LWS_TI   ((uint64_t)LWS_GI * 1024)

Definition at line 74 of file libwebsockets.h.

◆ LWS_PI

#define LWS_PI   ((uint64_t)LWS_TI * 1024)

Definition at line 75 of file libwebsockets.h.

◆ LWS_US_TO_MS

#define LWS_US_TO_MS (   x)    ((x + (LWS_US_PER_MS / 2)) / LWS_US_PER_MS)

Definition at line 77 of file libwebsockets.h.

◆ LWS_FOURCC

#define LWS_FOURCC (   a,
  b,
  c,
 
)    ((a << 24) | (b << 16) | (c << 8) | d)

Definition at line 79 of file libwebsockets.h.

◆ LWS_INLINE

#define LWS_INLINE   inline

Definition at line 161 of file libwebsockets.h.

◆ LWS_O_RDONLY

#define LWS_O_RDONLY   O_RDONLY

Definition at line 162 of file libwebsockets.h.

◆ LWS_O_WRONLY

#define LWS_O_WRONLY   O_WRONLY

Definition at line 163 of file libwebsockets.h.

◆ LWS_O_CREAT

#define LWS_O_CREAT   O_CREAT

Definition at line 164 of file libwebsockets.h.

◆ LWS_O_TRUNC

#define LWS_O_TRUNC   O_TRUNC

Definition at line 165 of file libwebsockets.h.

◆ LWS_INVALID_FILE

#define LWS_INVALID_FILE   -1

Definition at line 170 of file libwebsockets.h.

◆ LWS_SOCK_INVALID

#define LWS_SOCK_INVALID   (-1)

Definition at line 171 of file libwebsockets.h.

◆ LWS_VISIBLE

#define LWS_VISIBLE

Definition at line 220 of file libwebsockets.h.

◆ LWS_WARN_UNUSED_RESULT

#define LWS_WARN_UNUSED_RESULT

Definition at line 221 of file libwebsockets.h.

◆ LWS_WARN_DEPRECATED

#define LWS_WARN_DEPRECATED

Definition at line 222 of file libwebsockets.h.

◆ LWS_FORMAT

#define LWS_FORMAT (   string_index)

Definition at line 223 of file libwebsockets.h.

◆ LWS_EXTERN

#define LWS_EXTERN   extern

Definition at line 225 of file libwebsockets.h.

◆ lws_pthread_mutex

#define lws_pthread_mutex (   name)

Definition at line 363 of file libwebsockets.h.

◆ lws_pthread_mutex_init

#define lws_pthread_mutex_init (   _a)

Definition at line 364 of file libwebsockets.h.

◆ lws_pthread_mutex_destroy

#define lws_pthread_mutex_destroy (   _a)

Definition at line 365 of file libwebsockets.h.

◆ lws_pthread_mutex_lock

#define lws_pthread_mutex_lock (   _a)

Definition at line 366 of file libwebsockets.h.

◆ lws_pthread_mutex_unlock

#define lws_pthread_mutex_unlock (   _a)

Definition at line 367 of file libwebsockets.h.

◆ CONTEXT_PORT_NO_LISTEN

#define CONTEXT_PORT_NO_LISTEN   -1

Definition at line 371 of file libwebsockets.h.

◆ CONTEXT_PORT_NO_LISTEN_SERVER

#define CONTEXT_PORT_NO_LISTEN_SERVER   -2

Definition at line 372 of file libwebsockets.h.

◆ lws_container_of

#define lws_container_of (   P,
  T,
 
)    ((T *)((char *)(P) - offsetof(T, M)))

Definition at line 380 of file libwebsockets.h.

◆ LWS_ALIGN_TO

#define LWS_ALIGN_TO (   x,
  bou 
)    x += ((bou) - ((x) % (bou))) % (bou)

Definition at line 382 of file libwebsockets.h.

◆ LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_ARG

#define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_ARG

Definition at line 388 of file libwebsockets.h.

◆ LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD

#define LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD

Definition at line 391 of file libwebsockets.h.

◆ LWS_FEATURE_PROTOCOLS_HAS_PEER_WRITE_ALLOWANCE

#define LWS_FEATURE_PROTOCOLS_HAS_PEER_WRITE_ALLOWANCE

Definition at line 394 of file libwebsockets.h.

◆ LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_LEN

#define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_LEN

Definition at line 397 of file libwebsockets.h.

◆ LWS_FEATURE_FOPS

#define LWS_FEATURE_FOPS

Definition at line 400 of file libwebsockets.h.

◆ LWS_FEATURE_MOUNT_NO_CACHE

#define LWS_FEATURE_MOUNT_NO_CACHE

Definition at line 403 of file libwebsockets.h.

◆ lws_pollfd

#define lws_pollfd   pollfd

Definition at line 539 of file libwebsockets.h.

◆ LWS_POLLHUP

#define LWS_POLLHUP   (POLLHUP | POLLERR)

Definition at line 540 of file libwebsockets.h.

◆ LWS_POLLIN

#define LWS_POLLIN   (POLLIN)

Definition at line 541 of file libwebsockets.h.

◆ LWS_POLLOUT

#define LWS_POLLOUT   (POLLOUT)

Definition at line 542 of file libwebsockets.h.

◆ lws_concat_temp

#define lws_concat_temp (   _t,
  _l 
)    (_t + sizeof(_t) - _l)

Definition at line 581 of file libwebsockets.h.

◆ lws_concat_used

#define lws_concat_used (   _t,
  _l 
)    (sizeof(_t) - _l)

Definition at line 582 of file libwebsockets.h.

◆ LWS_SIZEOFPTR

#define LWS_SIZEOFPTR   ((int)sizeof (void *))

Definition at line 593 of file libwebsockets.h.

◆ _LWS_PAD_SIZE

#define _LWS_PAD_SIZE   LWS_SIZEOFPTR /* Size of a pointer on the target arch */

Definition at line 599 of file libwebsockets.h.

◆ _LWS_PAD

#define _LWS_PAD (   n)
Value:
(((n) % _LWS_PAD_SIZE) ? \
((n) + (_LWS_PAD_SIZE - ((n) % _LWS_PAD_SIZE))) : (n))
#define _LWS_PAD_SIZE

Definition at line 601 of file libwebsockets.h.

◆ LWS_PRE

#define LWS_PRE   _LWS_PAD(4 + 10 + 2)

Definition at line 604 of file libwebsockets.h.

◆ LWS_SEND_BUFFER_PRE_PADDING

#define LWS_SEND_BUFFER_PRE_PADDING   LWS_PRE

Definition at line 606 of file libwebsockets.h.

◆ LWS_SEND_BUFFER_POST_PADDING

#define LWS_SEND_BUFFER_POST_PADDING   0

Definition at line 607 of file libwebsockets.h.

◆ LWS_FX_FRACTION_MSD

#define LWS_FX_FRACTION_MSD   100000000

Definition at line 637 of file libwebsockets.h.

◆ lws_neg

#define lws_neg (   a)    (a->whole < 0 || a->frac < 0)

Definition at line 638 of file libwebsockets.h.

◆ lws_fx_set

#define lws_fx_set (   a,
  x,
 
)    { a.whole = x; a.frac = x < 0 ? -y : y; }

Definition at line 639 of file libwebsockets.h.

◆ lws_fix64

#define lws_fix64 (   a)
Value:
(((int64_t)a->whole << 32) + \
(((1ll << 32) * (a->frac < 0 ? -a->frac : a->frac)) / LWS_FX_FRACTION_MSD))
#define LWS_FX_FRACTION_MSD

Definition at line 640 of file libwebsockets.h.

◆ lws_fix64_abs

#define lws_fix64_abs (   a)
Value:
((((int64_t)(a->whole < 0 ? (-a->whole) : a->whole) << 32) + \
(((1ll << 32) * (a->frac < 0 ? -a->frac : a->frac)) / LWS_FX_FRACTION_MSD)))

Definition at line 642 of file libwebsockets.h.

◆ lws_fix3232

#define lws_fix3232 (   a,
  a64 
)
Value:
{ a->whole = (int32_t)(a64 >> 32); \
a->frac = (int32_t)((100000000 * (a64 & 0xffffffff)) >> 32); }

Definition at line 646 of file libwebsockets.h.

Typedef Documentation

◆ lws_ctx_t

typedef struct lws_context* lws_ctx_t

Definition at line 59 of file libwebsockets.h.

◆ lws_intptr_t

typedef unsigned long long lws_intptr_t

Definition at line 85 of file libwebsockets.h.

◆ lws_sockfd_type

typedef int lws_sockfd_type

Definition at line 428 of file libwebsockets.h.

◆ lws_filefd_type

typedef int lws_filefd_type

Definition at line 429 of file libwebsockets.h.

◆ uint32_t

typedef unsigned int uint32_t

Definition at line 570 of file libwebsockets.h.

◆ uint16_t

typedef unsigned short uint16_t

Definition at line 571 of file libwebsockets.h.

◆ uint8_t

typedef unsigned char uint8_t

Definition at line 572 of file libwebsockets.h.

◆ lws_usec_t

typedef int64_t lws_usec_t

Definition at line 576 of file libwebsockets.h.

◆ lws_filepos_t

typedef unsigned long long lws_filepos_t

Definition at line 577 of file libwebsockets.h.

◆ lws_fileofs_t

typedef long long lws_fileofs_t

Definition at line 578 of file libwebsockets.h.

◆ lws_fop_flags_t

Definition at line 579 of file libwebsockets.h.

◆ lws_fx_t

typedef struct lws_fixed3232 lws_fx_t

Enumeration Type Documentation

◆ lws_stateful_ret_t

Enumerator
LWS_SRET_OK 
LWS_SRET_WANT_INPUT 
LWS_SRET_WANT_OUTPUT 
LWS_SRET_FATAL 
LWS_SRET_NO_FURTHER_IN 
LWS_SRET_NO_FURTHER_OUT 
LWS_SRET_AWAIT_RETRY 
LWS_SRET_YIELD 

Definition at line 621 of file libwebsockets.h.

621  {
622  LWS_SRET_OK = 0,
623  LWS_SRET_WANT_INPUT = (1 << 16),
624  LWS_SRET_WANT_OUTPUT = (1 << 17),
625  LWS_SRET_FATAL = (1 << 18),
626  LWS_SRET_NO_FURTHER_IN = (1 << 19),
627  LWS_SRET_NO_FURTHER_OUT = (1 << 20),
628  LWS_SRET_AWAIT_RETRY = (1 << 21),
629  LWS_SRET_YIELD = (1 << 22), /* return to the event loop and continue */
lws_stateful_ret_t
@ LWS_SRET_WANT_OUTPUT
@ LWS_SRET_NO_FURTHER_OUT
@ LWS_SRET_FATAL
@ LWS_SRET_OK
@ LWS_SRET_NO_FURTHER_IN
@ LWS_SRET_YIELD
@ LWS_SRET_WANT_INPUT
@ LWS_SRET_AWAIT_RETRY

Function Documentation

◆ lws_fx_add()

LWS_VISIBLE LWS_EXTERN const lws_fx_t* lws_fx_add ( lws_fx_t r,
const lws_fx_t a,
const lws_fx_t b 
)

◆ lws_fx_sub()

LWS_VISIBLE LWS_EXTERN const lws_fx_t* lws_fx_sub ( lws_fx_t r,
const lws_fx_t a,
const lws_fx_t b 
)

◆ lws_fx_mul()

LWS_VISIBLE LWS_EXTERN const lws_fx_t* lws_fx_mul ( lws_fx_t r,
const lws_fx_t a,
const lws_fx_t b 
)

◆ lws_fx_div()

LWS_VISIBLE LWS_EXTERN const lws_fx_t* lws_fx_div ( lws_fx_t r,
const lws_fx_t a,
const lws_fx_t b 
)

◆ lws_fx_sqrt()

LWS_VISIBLE LWS_EXTERN const lws_fx_t* lws_fx_sqrt ( lws_fx_t r,
const lws_fx_t a 
)

◆ lws_fx_comp()

LWS_VISIBLE LWS_EXTERN int lws_fx_comp ( const lws_fx_t a,
const lws_fx_t b 
)

◆ lws_fx_roundup()

LWS_VISIBLE LWS_EXTERN int lws_fx_roundup ( const lws_fx_t a)

◆ lws_fx_rounddown()

LWS_VISIBLE LWS_EXTERN int lws_fx_rounddown ( const lws_fx_t a)

◆ lws_fx_string()

LWS_VISIBLE LWS_EXTERN const char* lws_fx_string ( const lws_fx_t a,
char *  buf,
size_t  size 
)