- mbedtls_ssl_set_bio(ssl, conn, s_ustream_write, s_ustream_read, NULL);
+ struct uloop_fd *ufd = ctx;
+ mbedtls_net_context net = {
+ .fd = ufd->fd
+ };
+
+ return mbedtls_net_recv(&net, buf, len);
+}
+
+static int s_fd_write(void *ctx, const unsigned char *buf, size_t len)
+{
+ struct uloop_fd *ufd = ctx;
+ mbedtls_net_context net = {
+ .fd = ufd->fd
+ };
+
+ return mbedtls_net_send(&net, buf, len);
+}
+
+__hidden void ustream_set_io(struct ustream_ssl *us)
+{
+ if (us->conn)
+ mbedtls_ssl_set_bio(us->ssl, us->conn, s_ustream_write, s_ustream_read, NULL);
+ else
+ mbedtls_ssl_set_bio(us->ssl, &us->fd, s_fd_write, s_fd_read, NULL);