1 /* 2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"). 5 * You may not use this file except in compliance with the License. 6 * A copy of the License is located at 7 * 8 * http://aws.amazon.com/apache2.0 9 * 10 * or in the "license" file accompanying this file. This file is distributed 11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 * express or implied. See the License for the specific language governing 13 * permissions and limitations under the License. 14 */ 15 16 #pragma once 17 18 #include "tls/s2n_connection.h" 19 20 /* The default read I/O context for communication over a socket */ 21 struct s2n_socket_read_io_context { 22 /* The peer's fd */ 23 int fd; 24 25 /* Has TCP_QUICKACK been set since the last read */ 26 unsigned int tcp_quickack_set:1; 27 /* Original SO_RCVLOWAT socket option settings before s2n takes over the fd */ 28 unsigned int original_rcvlowat_is_set:1; 29 int original_rcvlowat_val; 30 }; 31 32 /* The default write I/O context for communication over a socket */ 33 struct s2n_socket_write_io_context { 34 /* The peer's fd */ 35 int fd; 36 37 /* Original TCP_CORK socket option settings before s2n takes over the fd */ 38 unsigned int original_cork_is_set:1; 39 int original_cork_val; 40 }; 41 42 extern int s2n_socket_quickack(struct s2n_connection *conn); 43 extern int s2n_socket_read_snapshot(struct s2n_connection *conn); 44 extern int s2n_socket_write_snapshot(struct s2n_connection *conn); 45 extern int s2n_socket_read_restore(struct s2n_connection *conn); 46 extern int s2n_socket_write_restore(struct s2n_connection *conn); 47 extern int s2n_socket_was_corked(struct s2n_connection *conn); 48 extern int s2n_socket_write_cork(struct s2n_connection *conn); 49 extern int s2n_socket_write_uncork(struct s2n_connection *conn); 50 extern int s2n_socket_set_read_size(struct s2n_connection *conn, int size); 51 extern int s2n_socket_read(void *io_context, uint8_t *buf, uint32_t len); 52 extern int s2n_socket_write(void *io_context, const uint8_t *buf, uint32_t len); 53 extern int s2n_socket_is_ipv6(int fd, uint8_t *ipv6); 54