s2n_socket.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #pragma once
  16. #include "tls/s2n_connection.h"
  17. /* The default read I/O context for communication over a socket */
  18. struct s2n_socket_read_io_context {
  19. /* The peer's fd */
  20. int fd;
  21. /* Has TCP_QUICKACK been set since the last read */
  22. unsigned int tcp_quickack_set : 1;
  23. /* Original SO_RCVLOWAT socket option settings before s2n takes over the fd */
  24. unsigned int original_rcvlowat_is_set : 1;
  25. int original_rcvlowat_val;
  26. };
  27. /* The default write I/O context for communication over a socket */
  28. struct s2n_socket_write_io_context {
  29. /* The peer's fd */
  30. int fd;
  31. /* Original TCP_CORK socket option settings before s2n takes over the fd */
  32. unsigned int original_cork_is_set : 1;
  33. int original_cork_val;
  34. };
  35. int s2n_socket_quickack(struct s2n_connection *conn);
  36. int s2n_socket_read_snapshot(struct s2n_connection *conn);
  37. int s2n_socket_write_snapshot(struct s2n_connection *conn);
  38. int s2n_socket_read_restore(struct s2n_connection *conn);
  39. int s2n_socket_write_restore(struct s2n_connection *conn);
  40. int s2n_socket_was_corked(struct s2n_connection *conn);
  41. int s2n_socket_write_cork(struct s2n_connection *conn);
  42. int s2n_socket_write_uncork(struct s2n_connection *conn);
  43. int s2n_socket_set_read_size(struct s2n_connection *conn, int size);
  44. int s2n_socket_read(void *io_context, uint8_t *buf, uint32_t len);
  45. int s2n_socket_write(void *io_context, const uint8_t *buf, uint32_t len);
  46. int s2n_socket_is_ipv6(int fd, uint8_t *ipv6);