FreeRDP
tcp.h
1 
21 #ifndef FREERDP_LIB_CORE_TCP_H
22 #define FREERDP_LIB_CORE_TCP_H
23 
24 #include <winpr/windows.h>
25 
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>
31 
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>
37 
38 #include <openssl/bio.h>
39 
40 #include <freerdp/utils/ringbuffer.h>
41 
42 #define BIO_TYPE_TSG 65
43 #define BIO_TYPE_SIMPLE 66
44 #define BIO_TYPE_BUFFERED 67
45 #define BIO_TYPE_NAMEDPIPE 69
46 
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
56 
57 static INLINE long BIO_set_socket(BIO* b, SOCKET* s, long c)
58 {
59  return BIO_ctrl(b, BIO_C_SET_SOCKET, c, s);
60 }
61 static INLINE long BIO_get_socket(BIO* b, SOCKET* c)
62 {
63  return BIO_ctrl(b, BIO_C_GET_SOCKET, 0, c);
64 }
65 static INLINE long BIO_get_event(BIO* b, HANDLE* c)
66 {
67  return BIO_ctrl(b, BIO_C_GET_EVENT, 0, c);
68 }
69 static INLINE long BIO_set_handle(BIO* b, HANDLE* h)
70 {
71  return BIO_ctrl(b, BIO_C_SET_HANDLE, 0, h);
72 }
73 static INLINE long BIO_set_nonblock(BIO* b, long c)
74 {
75  return BIO_ctrl(b, BIO_C_SET_NONBLOCK, c, NULL);
76 }
77 static INLINE long BIO_read_blocked(BIO* b)
78 {
79  return BIO_ctrl(b, BIO_C_READ_BLOCKED, 0, NULL);
80 }
81 static INLINE long BIO_write_blocked(BIO* b)
82 {
83  return BIO_ctrl(b, BIO_C_WRITE_BLOCKED, 0, NULL);
84 }
85 static INLINE long BIO_wait_read(BIO* b, long c)
86 {
87  return BIO_ctrl(b, BIO_C_WAIT_READ, c, NULL);
88 }
89 
90 static INLINE long BIO_wait_write(BIO* b, long c)
91 {
92  return BIO_ctrl(b, BIO_C_WAIT_WRITE, c, NULL);
93 }
94 
95 FREERDP_LOCAL BIO_METHOD* BIO_s_simple_socket(void);
96 FREERDP_LOCAL BIO_METHOD* BIO_s_buffered_socket(void);
97 
98 FREERDP_LOCAL BOOL freerdp_tcp_set_keep_alive_mode(const rdpSettings* settings, int sockfd);
99 
100 FREERDP_LOCAL int freerdp_tcp_connect(rdpContext* context, const char* hostname, int port,
101  DWORD timeout);
102 
103 FREERDP_LOCAL int freerdp_tcp_default_connect(rdpContext* context, rdpSettings* settings,
104  const char* hostname, int port, DWORD timeout);
105 
106 FREERDP_LOCAL rdpTransportLayer*
107 freerdp_tcp_connect_layer(rdpContext* context, const char* hostname, int port, DWORD timeout);
108 
109 FREERDP_LOCAL char* freerdp_tcp_get_peer_address(SOCKET sockfd);
110 
111 FREERDP_LOCAL struct addrinfo* freerdp_tcp_resolve_host(const char* hostname, int port,
112  int ai_flags);
113 FREERDP_LOCAL char* freerdp_tcp_address_to_string(const struct sockaddr_storage* addr, BOOL* pIPv6);
114 
115 #endif /* FREERDP_LIB_CORE_TCP_H */