Skip to content

Commit

Permalink
line width
Browse files Browse the repository at this point in the history
  • Loading branch information
toidiu committed Aug 17, 2023
1 parent 77ebe1b commit 11f93c1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
17 changes: 11 additions & 6 deletions tls/s2n_ktls.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,23 @@ typedef enum {
} s2n_ktls_mode;

bool s2n_ktls_is_supported_on_platform();
S2N_RESULT s2n_ktls_get_file_descriptor(struct s2n_connection *conn, s2n_ktls_mode ktls_mode, int *fd);
S2N_RESULT s2n_ktls_sendmsg(struct s2n_connection *conn, uint8_t record_type, const struct iovec *msg_iov,
size_t msg_iovlen, s2n_blocked_status *blocked, size_t *bytes_written);
S2N_RESULT s2n_ktls_get_file_descriptor(struct s2n_connection *conn, s2n_ktls_mode ktls_mode,
int *fd);
S2N_RESULT s2n_ktls_sendmsg(struct s2n_connection *conn, uint8_t record_type,
const struct iovec *msg_iov, size_t msg_iovlen, s2n_blocked_status *blocked,
size_t *bytes_written);

/* These functions will be part of the public API. */
int s2n_connection_ktls_enable_send(struct s2n_connection *conn);
int s2n_connection_ktls_enable_recv(struct s2n_connection *conn);

/* Testing */
typedef int (*s2n_setsockopt_fn)(int socket, int level, int option_name, const void *option_value, socklen_t option_len);
typedef int (*s2n_setsockopt_fn)(int socket, int level, int option_name, const void *option_value,
socklen_t option_len);
S2N_RESULT s2n_ktls_set_setsockopt_cb(s2n_setsockopt_fn cb);
typedef ssize_t (*s2n_ktls_sendmsg_fn)(void *io_context, const struct msghdr *msg);
typedef ssize_t (*s2n_ktls_recvmsg_fn)(void *io_context, struct msghdr *msg);
S2N_RESULT s2n_ktls_set_sendmsg_cb(struct s2n_connection *conn, s2n_ktls_sendmsg_fn send_cb, void *send_ctx);
S2N_RESULT s2n_ktls_set_recvmsg_cb(struct s2n_connection *conn, s2n_ktls_recvmsg_fn recv_cb, void *recv_ctx);
S2N_RESULT s2n_ktls_set_sendmsg_cb(struct s2n_connection *conn, s2n_ktls_sendmsg_fn send_cb,
void *send_ctx);
S2N_RESULT s2n_ktls_set_recvmsg_cb(struct s2n_connection *conn, s2n_ktls_recvmsg_fn recv_cb,
void *recv_ctx);
14 changes: 9 additions & 5 deletions tls/s2n_ktls_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ static ssize_t s2n_ktls_default_recvmsg(void *io_context, struct msghdr *msg);
s2n_ktls_sendmsg_fn s2n_sendmsg_fn = s2n_ktls_default_sendmsg;
s2n_ktls_recvmsg_fn s2n_recvmsg_fn = s2n_ktls_default_recvmsg;

S2N_RESULT s2n_ktls_set_sendmsg_cb(struct s2n_connection *conn, s2n_ktls_sendmsg_fn send_cb, void *send_ctx)
S2N_RESULT s2n_ktls_set_sendmsg_cb(struct s2n_connection *conn, s2n_ktls_sendmsg_fn send_cb,
void *send_ctx)
{
RESULT_ENSURE_REF(conn);
RESULT_ENSURE_REF(send_ctx);
Expand All @@ -51,7 +52,8 @@ S2N_RESULT s2n_ktls_set_sendmsg_cb(struct s2n_connection *conn, s2n_ktls_sendmsg
return S2N_RESULT_OK;
}

S2N_RESULT s2n_ktls_set_recvmsg_cb(struct s2n_connection *conn, s2n_ktls_recvmsg_fn recv_cb, void *recv_ctx)
S2N_RESULT s2n_ktls_set_recvmsg_cb(struct s2n_connection *conn, s2n_ktls_recvmsg_fn recv_cb,
void *recv_ctx)
{
RESULT_ENSURE_REF(conn);
RESULT_ENSURE_REF(recv_ctx);
Expand Down Expand Up @@ -174,8 +176,9 @@ S2N_RESULT s2n_ktls_get_control_data(struct msghdr *msg, int cmsg_type, uint8_t
return S2N_RESULT_OK;
}

S2N_RESULT s2n_ktls_sendmsg(struct s2n_connection *conn, uint8_t record_type, const struct iovec *msg_iov,
size_t msg_iovlen, s2n_blocked_status *blocked, size_t *bytes_written)
S2N_RESULT s2n_ktls_sendmsg(struct s2n_connection *conn, uint8_t record_type,
const struct iovec *msg_iov, size_t msg_iovlen, s2n_blocked_status *blocked,
size_t *bytes_written)
{
RESULT_ENSURE_REF(conn);
RESULT_ENSURE_REF(msg_iov);
Expand All @@ -193,7 +196,8 @@ S2N_RESULT s2n_ktls_sendmsg(struct s2n_connection *conn, uint8_t record_type, co
msg.msg_iovlen = msg_iovlen;

char control_data[S2N_KTLS_CONTROL_BUFFER_SIZE] = { 0 };
RESULT_GUARD(s2n_ktls_set_control_data(&msg, control_data, sizeof(control_data), S2N_TLS_SET_RECORD_TYPE, record_type));
RESULT_GUARD(s2n_ktls_set_control_data(&msg, control_data, sizeof(control_data),
S2N_TLS_SET_RECORD_TYPE, record_type));

ssize_t result = s2n_sendmsg_fn(conn->send_io_context, &msg);
if (result < 0) {
Expand Down

0 comments on commit 11f93c1

Please sign in to comment.