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:11:12 +00:00
parent 95bdc091b2
commit 0a9598655c
No known key found for this signature in database
GPG key ID: EC6F86EE9CD840B5
2 changed files with 42 additions and 48 deletions

View file

@ -74,9 +74,6 @@ struct ssl_connect
static const char *rb_ssl_strerror(int); static const char *rb_ssl_strerror(int);
static void rb_ssl_connect_realcb(rb_fde_t *, int, struct ssl_connect *); 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);
/* /*
@ -118,6 +115,22 @@ rb_ssl_cert_auth_cb(gnutls_session_t session,
return 0; 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 static void
rb_ssl_init_fd(rb_fde_t *const F, const rb_fd_tls_direction dir) rb_ssl_init_fd(rb_fde_t *const F, const rb_fd_tls_direction dir)
{ {
@ -717,22 +730,6 @@ rb_ssl_tryconn(rb_fde_t *const F, const int status, void *const data)
rb_ssl_connect_common(F, sconn); 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

@ -80,9 +80,6 @@ struct ssl_connect
static const char *rb_ssl_strerror(int); static const char *rb_ssl_strerror(int);
static void rb_ssl_connect_realcb(rb_fde_t *, int, struct ssl_connect *); 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);
/* /*
@ -117,6 +114,32 @@ rb_mbedtls_cfg_decref(rb_mbedtls_cfg_context *const cfg)
rb_free(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 static void
rb_ssl_init_fd(rb_fde_t *const F, const rb_fd_tls_direction dir) rb_ssl_init_fd(rb_fde_t *const F, const rb_fd_tls_direction dir)
{ {
@ -709,32 +732,6 @@ rb_ssl_tryconn(rb_fde_t *const F, const int status, void *const data)
rb_ssl_connect_common(F, sconn); 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;
}
/* /*