21 #ifndef FREERDP_LIB_CORE_TCP_H
22 #define FREERDP_LIB_CORE_TCP_H
24 #include <winpr/windows.h>
26 #include <freerdp/types.h>
27 #include <freerdp/settings.h>
28 #include <freerdp/freerdp.h>
29 #include <freerdp/api.h>
30 #include <freerdp/transport_io.h>
32 #include <winpr/crt.h>
33 #include <winpr/synch.h>
34 #include <winpr/stream.h>
35 #include <winpr/winsock.h>
36 #include <winpr/crypto.h>
38 #include <openssl/bio.h>
40 #include <freerdp/utils/ringbuffer.h>
42 #define BIO_TYPE_TSG 65
43 #define BIO_TYPE_SIMPLE 66
44 #define BIO_TYPE_BUFFERED 67
45 #define BIO_TYPE_NAMEDPIPE 69
47 #define BIO_C_SET_SOCKET 1101
48 #define BIO_C_GET_SOCKET 1102
49 #define BIO_C_GET_EVENT 1103
50 #define BIO_C_SET_NONBLOCK 1104
51 #define BIO_C_READ_BLOCKED 1105
52 #define BIO_C_WRITE_BLOCKED 1106
53 #define BIO_C_WAIT_READ 1107
54 #define BIO_C_WAIT_WRITE 1108
55 #define BIO_C_SET_HANDLE 1109
57 static INLINE
long BIO_set_socket(BIO* b, SOCKET* s,
long c)
59 return BIO_ctrl(b, BIO_C_SET_SOCKET, c, s);
61 static INLINE
long BIO_get_socket(BIO* b, SOCKET* c)
63 return BIO_ctrl(b, BIO_C_GET_SOCKET, 0, c);
65 static INLINE
long BIO_get_event(BIO* b, HANDLE* c)
67 return BIO_ctrl(b, BIO_C_GET_EVENT, 0, c);
69 static INLINE
long BIO_set_handle(BIO* b, HANDLE* h)
71 return BIO_ctrl(b, BIO_C_SET_HANDLE, 0, h);
73 static INLINE
long BIO_set_nonblock(BIO* b,
long c)
75 return BIO_ctrl(b, BIO_C_SET_NONBLOCK, c, NULL);
77 static INLINE
long BIO_read_blocked(BIO* b)
79 return BIO_ctrl(b, BIO_C_READ_BLOCKED, 0, NULL);
81 static INLINE
long BIO_write_blocked(BIO* b)
83 return BIO_ctrl(b, BIO_C_WRITE_BLOCKED, 0, NULL);
85 static INLINE
long BIO_wait_read(BIO* b,
long c)
87 return BIO_ctrl(b, BIO_C_WAIT_READ, c, NULL);
90 static INLINE
long BIO_wait_write(BIO* b,
long c)
92 return BIO_ctrl(b, BIO_C_WAIT_WRITE, c, NULL);
95 FREERDP_LOCAL BIO_METHOD* BIO_s_simple_socket(
void);
96 FREERDP_LOCAL BIO_METHOD* BIO_s_buffered_socket(
void);
98 FREERDP_LOCAL BOOL freerdp_tcp_set_keep_alive_mode(
const rdpSettings* settings,
int sockfd);
100 FREERDP_LOCAL
int freerdp_tcp_connect(rdpContext* context,
const char* hostname,
int port,
103 FREERDP_LOCAL
int freerdp_tcp_default_connect(rdpContext* context, rdpSettings* settings,
104 const char* hostname,
int port, DWORD timeout);
107 freerdp_tcp_connect_layer(rdpContext* context,
const char* hostname,
int port, DWORD timeout);
109 FREERDP_LOCAL
char* freerdp_tcp_get_peer_address(SOCKET sockfd);
111 FREERDP_LOCAL
struct addrinfo* freerdp_tcp_resolve_host(
const char* hostname,
int port,
113 FREERDP_LOCAL
char* freerdp_tcp_address_to_string(
const struct sockaddr_storage* addr, BOOL* pIPv6);