Debian Codegraph @

debian/rust-vendor/aws-lc-sys/aws-lc/crypto/bio/internal.h

raw
1 // Copyright (C) 1995-1998 Eric Young ([email protected]) All rights reserved.
2 // SPDX-License-Identifier: Apache-2.0
3
4 #ifndef OPENSSL_HEADER_BIO_INTERNAL_H
5 #define OPENSSL_HEADER_BIO_INTERNAL_H
6
7 #include <openssl/bio.h>
8
9 #if !defined(OPENSSL_NO_SOCK)
10 #if !defined(OPENSSL_WINDOWS)
11 #if defined(OPENSSL_PNACL)
12 // newlib uses u_short in socket.h without defining it.
13 typedef unsigned short u_short;
14 #endif
15 #include <sys/types.h>
16 #include <sys/socket.h>
17 #include <netinet/in.h>
18 #include <sys/un.h>
19 #include <unistd.h>
20 #else
21 OPENSSL_MSVC_PRAGMA(warning(push, 3))
22 #include <winsock2.h>
23 #include <ws2ipdef.h>
24 OPENSSL_MSVC_PRAGMA(warning(pop))
25 typedef int socklen_t;
26 #if !defined(_SSIZE_T_DEFINED)
27 typedef SSIZE_T ssize_t;
28 #endif
29 #endif
30 #endif // !OPENSSL_NO_SOCK
31
32 #if defined(__cplusplus)
33 extern "C" {
34 #endif
35
36
37 #if !defined(OPENSSL_NO_SOCK)
38
39 // bio_ip_and_port_to_socket_and_addr creates a socket and fills in |*out_addr|
40 // and |*out_addr_length| with the correct values for connecting to |hostname|
41 // on |port_str|. It returns one on success or zero on error.
42 int bio_ip_and_port_to_socket_and_addr(int *out_sock,
43 struct sockaddr_storage *out_addr,
44 socklen_t *out_addr_length,
45 const char *hostname,
46 const char *port_str);
47
48 // bio_socket_nbio sets whether |sock| is non-blocking. It returns one on
49 // success and zero otherwise.
50 int bio_socket_nbio(int sock, int on);
51
52 // bio_clear_socket_error clears the last socket error on |sock|.
53 void bio_clear_socket_error(int sock);
54
55 // bio_sock_error_get_and_clear clears and returns the last socket error on |sock|.
56 int bio_sock_error_get_and_clear(int sock);
57
58 // bio_socket_should_retry returns non-zero if |return_value| indicates an error
59 // and the last socket error indicates that it's non-fatal.
60 int bio_socket_should_retry(int return_value);
61
62 #if defined(AF_UNIX) && !defined(OPENSSL_WINDOWS) && !defined(OPENSSL_ANDROID)
63 // Winsock2 APIs don't support AF_UNIX.
64 // > The values currently supported are AF_INET or AF_INET6, which are the
65 // > Internet address family formats for IPv4 and IPv6.
66 // https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-socket
67 #define AWS_LC_HAS_AF_UNIX 1
68 #endif
69
70 union bio_addr_st {
71 struct sockaddr sa;
72 #ifdef AF_INET6
73 struct sockaddr_in6 s_in6;
74 #endif
75 struct sockaddr_in s_in;
76 #if AWS_LC_HAS_AF_UNIX
77 struct sockaddr_un s_un;
78 #endif
79 };
80
81 #endif // !OPENSSL_NO_SOCK
82
83 // bio_errno_should_retry returns non-zero if |return_value| indicates an error
84 // and |errno| indicates that it's non-fatal.
85 int bio_errno_should_retry(int return_value);
86
87 #if defined(__cplusplus)
88 } // extern C
89 #endif
90
91 #endif // OPENSSL_HEADER_BIO_INTERNAL_H