TLS backends: Move some library-dependent functions to the proper location

The comment incorrectly stated these were library-agnostic; infact, they
use library-dependent data types or macro names.
This commit is contained in:
Aaron Jones 2016-11-15 12:16:03 +00:00
parent 19ec5fb1f9
commit 05281d7a0d
No known key found for this signature in database
GPG Key ID: EC6F86EE9CD840B5
2 changed files with 42 additions and 48 deletions

View File

@ -76,9 +76,6 @@ struct ssl_connect
static const char *rb_ssl_strerror(int);
static void rb_ssl_connect_realcb(rb_fde_t *, int, struct ssl_connect *);
static ssize_t rb_sock_net_recv(gnutls_transport_ptr_t, void *, size_t);
static ssize_t rb_sock_net_xmit(gnutls_transport_ptr_t, const void *, size_t);
/*
@ -120,6 +117,22 @@ rb_ssl_cert_auth_cb(gnutls_session_t session,
return 0;
}
static ssize_t
rb_sock_net_recv(gnutls_transport_ptr_t context_ptr, void *const buf, const size_t count)
{
const int fd = rb_get_fd((rb_fde_t *)context_ptr);
return recv(fd, buf, count, 0);
}
static ssize_t
rb_sock_net_xmit(gnutls_transport_ptr_t context_ptr, const void *const buf, const size_t count)
{
const int fd = rb_get_fd((rb_fde_t *)context_ptr);
return send(fd, buf, count, 0);
}
static void
rb_ssl_init_fd(rb_fde_t *const F, const rb_fd_tls_direction dir)
{
@ -788,22 +801,6 @@ rb_ssl_tryconn(rb_fde_t *const F, const int status, void *const data)
rb_ssl_connect_common(F, sconn);
}
static ssize_t
rb_sock_net_recv(gnutls_transport_ptr_t context_ptr, void *const buf, const size_t count)
{
const int fd = rb_get_fd((rb_fde_t *)context_ptr);
return recv(fd, buf, count, 0);
}
static ssize_t
rb_sock_net_xmit(gnutls_transport_ptr_t context_ptr, const void *const buf, const size_t count)
{
const int fd = rb_get_fd((rb_fde_t *)context_ptr);
return send(fd, buf, count, 0);
}
/*

View File

@ -81,9 +81,6 @@ struct ssl_connect
static const char *rb_ssl_strerror(int);
static void rb_ssl_connect_realcb(rb_fde_t *, int, struct ssl_connect *);
static int rb_sock_net_recv(void *, unsigned char *, size_t);
static int rb_sock_net_xmit(void *, const unsigned char *, size_t);
/*
@ -118,6 +115,32 @@ rb_mbedtls_cfg_decref(rb_mbedtls_cfg_context *const cfg)
rb_free(cfg);
}
static int
rb_sock_net_recv(void *const context_ptr, unsigned char *const buf, const size_t count)
{
const int fd = rb_get_fd((rb_fde_t *)context_ptr);
const int ret = (int) read(fd, buf, count);
if(ret < 0 && rb_ignore_errno(errno))
return MBEDTLS_ERR_SSL_WANT_READ;
return ret;
}
static int
rb_sock_net_xmit(void *const context_ptr, const unsigned char *const buf, const size_t count)
{
const int fd = rb_get_fd((rb_fde_t *)context_ptr);
const int ret = (int) write(fd, buf, count);
if(ret < 0 && rb_ignore_errno(errno))
return MBEDTLS_ERR_SSL_WANT_WRITE;
return ret;
}
static void
rb_ssl_init_fd(rb_fde_t *const F, const rb_fd_tls_direction dir)
{
@ -753,32 +776,6 @@ rb_ssl_tryconn(rb_fde_t *const F, const int status, void *const data)
rb_ssl_connect_common(F, sconn);
}
static int
rb_sock_net_recv(void *const context_ptr, unsigned char *const buf, const size_t count)
{
const int fd = rb_get_fd((rb_fde_t *)context_ptr);
const int ret = (int) read(fd, buf, count);
if(ret < 0 && rb_ignore_errno(errno))
return MBEDTLS_ERR_SSL_WANT_READ;
return ret;
}
static int
rb_sock_net_xmit(void *const context_ptr, const unsigned char *const buf, const size_t count)
{
const int fd = rb_get_fd((rb_fde_t *)context_ptr);
const int ret = (int) write(fd, buf, count);
if(ret < 0 && rb_ignore_errno(errno))
return MBEDTLS_ERR_SSL_WANT_WRITE;
return ret;
}
/*