| 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 |
| 15 | #ifndef OPENSSL_HEADER_CRYPTO_BIO_INTERNAL_H |
| 16 | #define OPENSSL_HEADER_CRYPTO_BIO_INTERNAL_H |
| 17 |
| 18 | #include <openssl/base.h> |
| 19 |
| 20 | #if !defined(OPENSSL_NO_SOCK) |
| 21 | #if !defined(OPENSSL_WINDOWS) |
| 22 | #if defined(OPENSSL_PNACL) |
| 23 | // newlib uses u_short in socket.h without defining it. |
| 24 | typedef unsigned short u_short; |
| 25 | #endif |
| 26 | #include <sys/types.h> |
| 27 | #include <sys/socket.h> |
| 28 | #else |
| 29 | #include <winsock2.h> |
| 30 | typedef int socklen_t; |
| 31 | #endif |
| 32 | #endif // !OPENSSL_NO_SOCK |
| 33 |
| 34 | #if defined(__cplusplus) |
| 35 | extern "C" { |
| 36 | #endif |
| 37 |
| 38 |
| 39 | #if !defined(OPENSSL_NO_SOCK) |
| 40 |
| 41 | // bio_ip_and_port_to_socket_and_addr creates a socket and fills in |*out_addr| |
| 42 | // and |*out_addr_length| with the correct values for connecting to |hostname| |
| 43 | // on |port_str|. It returns one on success or zero on error. |
| 44 | int bio_ip_and_port_to_socket_and_addr(int *out_sock, |
| 45 | struct sockaddr_storage *out_addr, |
| 46 | socklen_t *out_addr_length, |
| 47 | const char *hostname, |
| 48 | const char *port_str); |
| 49 |
| 50 | // bio_socket_nbio sets whether |sock| is non-blocking. It returns one on |
| 51 | // success and zero otherwise. |
| 52 | int bio_socket_nbio(int sock, int on); |
| 53 |
| 54 | // bio_clear_socket_error clears the last system socket error. |
| 55 | // |
| 56 | // TODO(fork): remove all callers of this. |
| 57 | void bio_clear_socket_error(void); |
| 58 |
| 59 | // bio_sock_error returns the last socket error on |sock|. |
| 60 | int bio_sock_error(int sock); |
| 61 |
| 62 | // bio_socket_should_retry returns non-zero if |return_value| indicates an error |
| 63 | // and the last socket error indicates that it's non-fatal. |
| 64 | int bio_socket_should_retry(int return_value); |
| 65 |
| 66 | #endif // !OPENSSL_NO_SOCK |
| 67 |
| 68 | // bio_errno_should_retry returns non-zero if |return_value| indicates an error |
| 69 | // and |errno| indicates that it's non-fatal. |
| 70 | int bio_errno_should_retry(int return_value); |
| 71 |
| 72 |
| 73 | #if defined(__cplusplus) |
| 74 | } // extern C |
| 75 | #endif |
| 76 |
| 77 | #endif // OPENSSL_HEADER_CRYPTO_BIO_INTERNAL_H |
| 78 |