Lines Matching refs:wsi

45 lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, size_t len)
47 struct lws_context *context = wsi->a.context;
48 struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi];
51 if (!wsi->tls.ssl)
52 return lws_ssl_capable_read_no_ssl(wsi, buf, len);
55 n = SSL_read(wsi->tls.ssl, buf, (int)len);
58 lwsl_debug("%s: SSL_read ENOTCONN\n", lws_wsi_tag(wsi));
63 lwsl_debug("%s: %s: SSL_read says %d\n", __func__, lws_wsi_tag(wsi), n);
66 wsi->socket_is_permanently_unusable = 1;
72 m = SSL_get_error(wsi->tls.ssl, n);
73 lwsl_debug("%s: %s: ssl err %d errno %d\n", __func__, lws_wsi_tag(wsi), m, errno);
87 if (m == SSL_ERROR_WANT_READ || SSL_want_read(wsi->tls.ssl)) {
89 lwsl_debug("%s: LWS_SSL_CAPABLE_MORE_SERVICE\n", lws_wsi_tag(wsi));
92 if (m == SSL_ERROR_WANT_WRITE || SSL_want_write(wsi->tls.ssl)) {
94 lwsl_debug("%s: LWS_SSL_CAPABLE_MORE_SERVICE\n", lws_wsi_tag(wsi));
95 wsi->tls_read_wanted_write = 1;
96 lws_callback_on_writable(wsi);
101 wsi->socket_is_permanently_unusable = 1;
105 if (wsi->a.vhost)
106 lws_metric_event(wsi->a.vhost->mt_traffic_rx, METRES_NOGO, 0);
122 if (wsi->a.vhost)
123 lws_metric_event(wsi->a.vhost->mt_traffic_rx,
136 if (!wsi->tls.ssl)
139 if (SSL_pending(wsi->tls.ssl)) {
140 if (lws_dll2_is_detached(&wsi->tls.dll_pending_tls))
141 lws_dll2_add_head(&wsi->tls.dll_pending_tls,
144 __lws_ssl_remove_wsi_from_buffered_list(wsi);
148 lws_ssl_remove_wsi_from_buffered_list(wsi);
154 lws_ssl_pending(struct lws *wsi)
156 if (!wsi->tls.ssl)
159 return SSL_pending(wsi->tls.ssl);
163 lws_ssl_capable_write(struct lws *wsi, unsigned char *buf, size_t len)
177 if (!wsi->tls.ssl)
178 return lws_ssl_capable_write_no_ssl(wsi, buf, len);
180 n = SSL_write(wsi->tls.ssl, buf, (int)len);
183 if (wsi->a.vhost)
184 lws_metric_event(wsi->a.vhost->mt_traffic_tx,
190 m = SSL_get_error(wsi->tls.ssl, n);
192 if (m == SSL_ERROR_WANT_READ || SSL_want_read(wsi->tls.ssl)) {
198 if (m == SSL_ERROR_WANT_WRITE || SSL_want_write(wsi->tls.ssl)) {
199 lws_set_blocking_send(wsi);
207 wsi->socket_is_permanently_unusable = 1;
210 if (wsi->a.vhost)
211 lws_metric_event(wsi->a.vhost->mt_traffic_tx,
223 struct lws *wsi;
232 wsi = wsi_from_fd(context, SSL_get_fd(ssl));
233 if (!wsi)
236 if (!(where & wsi->a.vhost->tls.ssl_info_event_mask))
242 if (user_callback_handle_rxflow(wsi->a.protocol->callback,
243 wsi, LWS_CALLBACK_SSL_INFO,
244 wsi->user_space, &si, 0))
245 lws_set_timeout(wsi, PENDING_TIMEOUT_KILLED_BY_SSL_INFO, -1);
250 lws_ssl_close(struct lws *wsi)
254 if (!wsi->tls.ssl)
259 * table linking it to the wsi
261 if (wsi->a.vhost->tls.ssl_info_event_mask)
262 SSL_set_info_callback(wsi->tls.ssl, NULL);
266 lws_sul_cancel(&wsi->tls.sul_cb_synth);
271 lws_sess_cache_synth_cb(&wsi->tls.sul_cb_synth);
274 n = SSL_get_fd(wsi->tls.ssl);
275 if (!wsi->socket_is_permanently_unusable)
276 SSL_shutdown(wsi->tls.ssl);
278 SSL_free(wsi->tls.ssl);
279 wsi->tls.ssl = NULL;
281 lws_tls_restrict_return(wsi);
305 lws_tls_ctx_from_wsi(struct lws *wsi)
307 if (!wsi->tls.ssl)
310 return SSL_get_SSL_CTX(wsi->tls.ssl);
314 __lws_tls_shutdown(struct lws *wsi)
316 int n = SSL_shutdown(wsi->tls.ssl);
318 lwsl_debug("SSL_shutdown=%d for fd %d\n", n, wsi->desc.sockfd);
322 (void)shutdown(wsi->desc.sockfd, SHUT_WR);
326 __lws_change_pollfd(wsi, 0, LWS_POLLIN);
330 n = SSL_get_error(wsi->tls.ssl, n);
332 if (SSL_want_read(wsi->tls.ssl)) {
334 __lws_change_pollfd(wsi, 0, LWS_POLLIN);
337 if (SSL_want_write(wsi->tls.ssl)) {
339 __lws_change_pollfd(wsi, 0, LWS_POLLOUT);