Lines Matching defs:wsi

36 int lws_openssl_describe_cipher(struct lws *wsi)
40 SSL *s = wsi->tls.ssl;
43 lwsl_info("%s: %s: %s, %s, %d bits, %s\n", __func__, lws_wsi_tag(wsi),
51 int lws_ssl_get_error(struct lws *wsi, int n)
55 if (!wsi->tls.ssl)
58 m = SSL_get_error(wsi->tls.ssl, n);
59 lwsl_debug("%s: %p %d -> %d (errno %d)\n", __func__, wsi->tls.ssl, n, m, LWS_ERRNO);
197 lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, size_t len)
199 struct lws_context *context = wsi->a.context;
200 struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi];
203 if (!wsi->tls.ssl)
204 return lws_ssl_capable_read_no_ssl(wsi, buf, len);
212 n = SSL_read(wsi->tls.ssl, buf, (int)(ssize_t)len);
215 lwsl_debug("%s: SSL_read ENOTCONN\n", lws_wsi_tag(wsi));
220 lwsl_debug("%s: SSL_read says %d\n", lws_wsi_tag(wsi), n);
246 m = lws_ssl_get_error(wsi, n);
247 lwsl_debug("%s: ssl err %d errno %d\n", lws_wsi_tag(wsi), m, LWS_ERRNO);
261 wsi->socket_is_permanently_unusable = 1;
264 if (wsi->a.vhost)
265 lws_metric_event(wsi->a.vhost->mt_traffic_rx,
273 if (SSL_want_read(wsi->tls.ssl)) {
275 lwsl_debug("%s: LWS_SSL_CAPABLE_MORE_SERVICE\n", lws_wsi_tag(wsi));
278 if (SSL_want_write(wsi->tls.ssl)) {
280 lwsl_debug("%s: LWS_SSL_CAPABLE_MORE_SERVICE\n", lws_wsi_tag(wsi));
281 wsi->tls_read_wanted_write = 1;
282 lws_callback_on_writable(wsi);
299 if (wsi->a.vhost)
300 lws_metric_event(wsi->a.vhost->mt_traffic_rx, METRES_GO, (u_mt_t)n);
312 if (!wsi->tls.ssl)
315 if (SSL_pending(wsi->tls.ssl)) {
316 if (lws_dll2_is_detached(&wsi->tls.dll_pending_tls))
317 lws_dll2_add_head(&wsi->tls.dll_pending_tls,
320 __lws_ssl_remove_wsi_from_buffered_list(wsi);
324 lws_ssl_remove_wsi_from_buffered_list(wsi);
330 lws_ssl_pending(struct lws *wsi)
332 if (!wsi->tls.ssl)
335 return SSL_pending(wsi->tls.ssl);
339 lws_ssl_capable_write(struct lws *wsi, unsigned char *buf, size_t len)
354 if (!wsi->tls.ssl)
355 return lws_ssl_capable_write_no_ssl(wsi, buf, len);
359 n = SSL_write(wsi->tls.ssl, buf, (int)(ssize_t)len);
362 if (wsi->a.vhost)
363 lws_metric_event(wsi->a.vhost->mt_traffic_tx,
369 m = lws_ssl_get_error(wsi, n);
371 if (m == SSL_ERROR_WANT_READ || SSL_want_read(wsi->tls.ssl)) {
377 if (m == SSL_ERROR_WANT_WRITE || SSL_want_write(wsi->tls.ssl)) {
378 lws_set_blocking_send(wsi);
389 wsi->socket_is_permanently_unusable = 1;
392 if (wsi->a.vhost)
393 lws_metric_event(wsi->a.vhost->mt_traffic_tx,
403 struct lws *wsi;
424 wsi = wsi_from_fd(context, fd);
425 if (!wsi)
428 if (!(where & wsi->a.vhost->tls.ssl_info_event_mask))
434 if (user_callback_handle_rxflow(wsi->a.protocol->callback,
435 wsi, LWS_CALLBACK_SSL_INFO,
436 wsi->user_space, &si, 0))
437 lws_set_timeout(wsi, PENDING_TIMEOUT_KILLED_BY_SSL_INFO, -1);
442 lws_ssl_close(struct lws *wsi)
446 if (!wsi->tls.ssl)
451 * table linking it to the wsi
453 if (wsi->a.vhost->tls.ssl_info_event_mask)
454 SSL_set_info_callback(wsi->tls.ssl, NULL);
458 lws_sul_cancel(&wsi->tls.sul_cb_synth);
463 lws_sess_cache_synth_cb(&wsi->tls.sul_cb_synth);
466 n = SSL_get_fd(wsi->tls.ssl);
467 if (!wsi->socket_is_permanently_unusable)
468 SSL_shutdown(wsi->tls.ssl);
470 SSL_free(wsi->tls.ssl);
471 wsi->tls.ssl = NULL;
473 lws_tls_restrict_return(wsi);
476 // wsi->a.context->simultaneous_ssl_restriction,
477 // wsi->a.context->simultaneous_ssl);
525 lws_tls_ctx_from_wsi(struct lws *wsi)
527 if (!wsi->tls.ssl)
530 return SSL_get_SSL_CTX(wsi->tls.ssl);
534 __lws_tls_shutdown(struct lws *wsi)
544 n = SSL_shutdown(wsi->tls.ssl);
545 lwsl_debug("SSL_shutdown=%d for fd %d\n", n, wsi->desc.sockfd);
548 n = shutdown(wsi->desc.sockfd, SHUT_WR);
552 __lws_change_pollfd(wsi, 0, LWS_POLLIN);
556 n = SSL_get_error(wsi->tls.ssl, n);
558 if (SSL_want_read(wsi->tls.ssl)) {
560 __lws_change_pollfd(wsi, 0, LWS_POLLIN);
563 if (SSL_want_write(wsi->tls.ssl)) {
565 __lws_change_pollfd(wsi, 0, LWS_POLLOUT);