libwebsockets
Lightweight C library for HTML5 websockets
lws-callbacks.h
Go to the documentation of this file.
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  */
24 
37 
38 struct lws_ssl_info {
39  int where;
40  int ret;
41 };
42 
48 
57 };
58 
59 enum {
67 
69 
74 
76 };
77 
79  struct lws_vhost *vh;
80  const char *element_overrides[LWS_TLS_TOTAL_COUNT]; /* NULL = use pvo */
81 };
82 
83 /*
84  * With LWS_CALLBACK_FILTER_NETWORK_CONNECTION callback, user_data pointer
85  * points to one of these
86  */
87 
90  socklen_t clilen;
92 };
93 
94 /*
95  * NOTE: These public enums are part of the abi. If you want to add one,
96  * add it at where specified so existing users are unaffected.
97  */
100 
101  /* ---------------------------------------------------------------------
102  * ----- Callbacks related to wsi and protocol binding lifecycle -----
103  */
104 
125  /* ---------------------------------------------------------------------
126  * ----- Callbacks related to Server TLS -----
127  */
128 
170  /* ---------------------------------------------------------------------
171  * ----- Callbacks related to Client TLS -----
172  */
173 
205  /* ---------------------------------------------------------------------
206  * ----- Callbacks related to HTTP Server -----
207  */
208 
217  LWS_CALLBACK_HTTP = 12,
344  /* ---------------------------------------------------------------------
345  * ----- Callbacks related to HTTP Client -----
346  */
347 
400 
401  /* ---------------------------------------------------------------------
402  * ----- Callbacks related to Websocket Server -----
403  */
404 
463 
464  /* ---------------------------------------------------------------------
465  * ----- Callbacks related to Websocket Client -----
466  */
467 
604 
605  /* ---------------------------------------------------------------------
606  * ----- Callbacks related to external poll loop integration -----
607  */
608 
614  /* external poll() management support */
664  /* ---------------------------------------------------------------------
665  * ----- Callbacks related to CGI serving -----
666  */
667 
668  LWS_CALLBACK_CGI = 40,
696  /* ---------------------------------------------------------------------
697  * ----- Callbacks related to Generic Sessions -----
698  */
699 
716  /* ---------------------------------------------------------------------
717  * ----- Callbacks related to RAW PROXY -----
718  */
719 
750 
751 
752  /* ---------------------------------------------------------------------
753  * ----- Callbacks related to RAW sockets -----
754  */
755 
756  LWS_CALLBACK_RAW_RX = 59,
773 
774  /* ---------------------------------------------------------------------
775  * ----- Callbacks related to RAW file handles -----
776  */
777 
795 
796  /* ---------------------------------------------------------------------
797  * ----- Callbacks related to generic wsi events -----
798  */
799 
800  LWS_CALLBACK_TIMER = 73,
829  /* ---------------------------------------------------------------------
830  * ----- Callbacks related to TLS certificate management -----
831  */
832 
852  /* ---------------------------------------------------------------------
853  * ----- Callbacks related to MQTT Client -----
854  */
855 
865  LWS_CALLBACK_MQTT_ACK = 209,
887  /****** add new things just above ---^ ******/
888 
889  LWS_CALLBACK_USER = 1000,
891 };
892 
893 
894 
910 typedef int
911 lws_callback_function(struct lws *wsi, enum lws_callback_reasons reason,
912  void *user, void *in, size_t len);
913 
914 #define LWS_CB_REASON_AUX_BF__CGI 1
915 #define LWS_CB_REASON_AUX_BF__PROXY 2
916 #define LWS_CB_REASON_AUX_BF__CGI_CHUNK_END 4
917 #define LWS_CB_REASON_AUX_BF__CGI_HEADERS 8
918 #define LWS_CB_REASON_AUX_BF__PROXY_TRANS_END 16
919 #define LWS_CB_REASON_AUX_BF__PROXY_HEADERS 32
const char * element_overrides[LWS_TLS_TOTAL_COUNT]
Definition: lws-callbacks.h:80
struct sockaddr_storage cli_addr
Definition: lws-callbacks.h:89
struct lws_vhost * vh
Definition: lws-callbacks.h:79
lws_cert_update_state
Definition: lws-callbacks.h:43
int lws_callback_function(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len)
lws_callback_reasons
Definition: lws-callbacks.h:99
@ LWS_TLS_REQ_ELEMENT_STATE
Definition: lws-callbacks.h:61
@ LWS_TLS_SET_AUTH_PATH
Definition: lws-callbacks.h:71
@ LWS_TLS_REQ_ELEMENT_SUBJECT_ALT_NAME
Definition: lws-callbacks.h:65
@ LWS_TLS_REQ_ELEMENT_LOCALITY
Definition: lws-callbacks.h:62
@ LWS_TLS_TOTAL_COUNT
Definition: lws-callbacks.h:75
@ LWS_TLS_REQ_ELEMENT_COUNTRY
Definition: lws-callbacks.h:60
@ LWS_TLS_SET_KEY_PATH
Definition: lws-callbacks.h:73
@ LWS_TLS_REQ_ELEMENT_COUNT
Definition: lws-callbacks.h:68
@ LWS_TLS_REQ_ELEMENT_ORGANIZATION
Definition: lws-callbacks.h:63
@ LWS_TLS_REQ_ELEMENT_EMAIL
Definition: lws-callbacks.h:66
@ LWS_TLS_SET_CERT_PATH
Definition: lws-callbacks.h:72
@ LWS_TLS_SET_DIR_URL
Definition: lws-callbacks.h:70
@ LWS_TLS_REQ_ELEMENT_COMMON_NAME
Definition: lws-callbacks.h:64
@ LWS_CUS_REQ
Definition: lws-callbacks.h:54
@ LWS_CUS_FAILED
Definition: lws-callbacks.h:47
@ LWS_CUS_IDLE
Definition: lws-callbacks.h:44
@ LWS_CUS_STARTING
Definition: lws-callbacks.h:45
@ LWS_CUS_ISSUE
Definition: lws-callbacks.h:56
@ LWS_CUS_CHALLENGE
Definition: lws-callbacks.h:52
@ LWS_CUS_REG
Definition: lws-callbacks.h:50
@ LWS_CUS_AUTH
Definition: lws-callbacks.h:51
@ LWS_CUS_CREATE_KEYS
Definition: lws-callbacks.h:49
@ LWS_CUS_SUCCESS
Definition: lws-callbacks.h:46
@ LWS_CUS_CREATE_REQ
Definition: lws-callbacks.h:53
@ LWS_CUS_CONFIRM
Definition: lws-callbacks.h:55
@ LWS_CALLBACK_RAW_PROXY_SRV_BIND_PROTOCOL
@ LWS_CALLBACK_FILTER_NETWORK_CONNECTION
@ LWS_CALLBACK_VERIFY_BASIC_AUTHORIZATION
@ LWS_CALLBACK_HTTP_BIND_PROTOCOL
@ LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS
@ LWS_CALLBACK_MQTT_SUBSCRIBED
@ LWS_CALLBACK_UNLOCK_POLL
@ LWS_CALLBACK_CLIENT_RECEIVE_PONG
@ LWS_CALLBACK_RAW_ADOPT
@ LWS_CALLBACK_OPENSSL_PERFORM_SERVER_CERT_VERIFICATION
@ LWS_CALLBACK_COMPLETED_CLIENT_HTTP
@ LWS_CALLBACK_CLIENT_CLOSED
@ LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED
@ LWS_CALLBACK_DEL_POLL_FD
@ LWS_CALLBACK_RAW_PROXY_CLI_BIND_PROTOCOL
@ LWS_CALLBACK_CGI
@ LWS_CALLBACK_RAW_PROXY_CLI_CLOSE
@ LWS_CALLBACK_ESTABLISHED
@ LWS_CALLBACK_RAW_SKT_BIND_PROTOCOL
@ LWS_CALLBACK_CLIENT_HTTP_BIND_PROTOCOL
@ LWS_CALLBACK_RECEIVE_PONG
@ LWS_CALLBACK_HTTP_BODY_COMPLETION
@ LWS_CALLBACK_RAW_PROXY_SRV_CLOSE
@ LWS_CALLBACK_MQTT_ACK
@ LWS_CALLBACK_CGI_PROCESS_ATTACH
@ LWS_CALLBACK_HTTP_CONFIRM_UPGRADE
@ LWS_CALLBACK_MQTT_NEW_CLIENT_INSTANTIATED
@ LWS_CALLBACK_CONFIRM_EXTENSION_OKAY
@ LWS_CALLBACK_MQTT_CLIENT_WRITEABLE
@ LWS_CALLBACK_MQTT_RESEND
@ LWS_CALLBACK_TIMER
@ LWS_CALLBACK_HTTP_DROP_PROTOCOL
@ LWS_CALLBACK_WS_SERVER_BIND_PROTOCOL
@ LWS_CALLBACK_VHOST_CERT_AGING
@ LWS_CALLBACK_RAW_ADOPT_FILE
@ LWS_CALLBACK_WS_CLIENT_DROP_PROTOCOL
@ LWS_CALLBACK_CLOSED
@ LWS_CALLBACK_RECEIVE
@ LWS_CALLBACK_RAW_SKT_DROP_PROTOCOL
@ LWS_CALLBACK_SSL_INFO
@ LWS_CALLBACK_VHOST_CERT_UPDATE
@ LWS_CALLBACK_PROTOCOL_DESTROY
@ LWS_CALLBACK_RAW_PROXY_SRV_WRITEABLE
@ LWS_CALLBACK_RAW_FILE_BIND_PROTOCOL
@ LWS_CALLBACK_CGI_STDIN_DATA
@ LWS_CALLBACK_RAW_PROXY_CLI_RX
@ LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP
@ LWS_CALLBACK_RAW_RX
@ LWS_CALLBACK_MQTT_IDLE
@ LWS_CALLBACK_FILTER_HTTP_CONNECTION
@ LWS_CALLBACK_CLIENT_ESTABLISHED
@ LWS_CALLBACK_MQTT_CLIENT_RX
@ LWS_CALLBACK_SERVER_WRITEABLE
@ LWS_CALLBACK_MQTT_DROP_PROTOCOL
@ LWS_CALLBACK_WSI_TX_CREDIT_GET
@ LWS_CALLBACK_CLOSED_HTTP
@ LWS_CALLBACK_MQTT_CLIENT_CLOSED
@ LWS_CALLBACK_CONNECTING
@ LWS_CALLBACK_LOCK_POLL
@ LWS_CALLBACK_PROCESS_HTML
@ LWS_CALLBACK_RAW_PROXY_SRV_RX
@ LWS_CALLBACK_CLIENT_WRITEABLE
@ LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER
@ LWS_CALLBACK_USER
@ LWS_CALLBACK_MQTT_CLIENT_ESTABLISHED
@ LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH
@ LWS_CALLBACK_HTTP_PMO
@ LWS_CALLBACK_HTTP_FILE_COMPLETION
@ LWS_CALLBACK_CHILD_CLOSING
@ LWS_CALLBACK_CHANGE_MODE_POLL_FD
@ LWS_CALLBACK_WS_CLIENT_BIND_PROTOCOL
@ LWS_CALLBACK_RAW_CONNECTED
@ LWS_CALLBACK_RECEIVE_CLIENT_HTTP
@ LWS_CALLBACK_ADD_POLL_FD
@ LWS_CALLBACK_EVENT_WAIT_CANCELLED
@ LWS_CALLBACK_ADD_HEADERS
@ LWS_CALLBACK_RAW_FILE_DROP_PROTOCOL
@ LWS_CALLBACK_CLIENT_RECEIVE
@ LWS_CALLBACK_WS_EXT_DEFAULTS
@ LWS_CALLBACK_CLIENT_HTTP_DROP_PROTOCOL
@ LWS_CALLBACK_SESSION_INFO
@ LWS_CALLBACK_WS_PEER_INITIATED_CLOSE
@ LWS_CALLBACK_CLOSED_CLIENT_HTTP
@ LWS_CALLBACK_HTTP_BODY
@ LWS_CALLBACK_RAW_WRITEABLE_FILE
@ LWS_CALLBACK_RAW_RX_FILE
@ LWS_CALLBACK_CGI_TERMINATED
@ LWS_CALLBACK_MQTT_UNSUBSCRIBED
@ LWS_CALLBACK_WSI_DESTROY
@ LWS_CALLBACK_WS_SERVER_DROP_PROTOCOL
@ LWS_CALLBACK_RAW_PROXY_CLI_DROP_PROTOCOL
@ LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION
@ LWS_CALLBACK_RAW_WRITEABLE
@ LWS_CALLBACK_RAW_PROXY_CLI_ADOPT
@ LWS_CALLBACK_RAW_CLOSE_FILE
@ LWS_CALLBACK_PROTOCOL_INIT
@ LWS_CALLBACK_CGI_STDIN_COMPLETED
@ LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ
@ LWS_CALLBACK_CLIENT_CONNECTION_ERROR
@ LWS_CALLBACK_RAW_PROXY_CLI_WRITEABLE
@ LWS_CALLBACK_GET_THREAD_ID
@ LWS_CALLBACK_MQTT_UNSUBSCRIBE_TIMEOUT
@ LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS
@ LWS_CALLBACK_MQTT_SHADOW_TIMEOUT
@ LWS_CALLBACK_RAW_CLOSE
@ LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION
@ LWS_CALLBACK_HTTP
@ LWS_CALLBACK_SERVER_NEW_CLIENT_INSTANTIATED
@ LWS_CALLBACK_CLIENT_HTTP_WRITEABLE
@ LWS_CALLBACK_RAW_PROXY_SRV_DROP_PROTOCOL
@ LWS_CALLBACK_GS_EVENT
@ LWS_CALLBACK_CLIENT_HTTP_REDIRECT
@ LWS_CALLBACK_CHECK_ACCESS_RIGHTS
@ LWS_CALLBACK_RAW_PROXY_SRV_ADOPT
@ LWS_CALLBACK_WSI_CREATE
@ LWS_CALLBACK_HTTP_WRITEABLE
int lws_sockfd_type