18#ifndef FREERDP_LIB_CORE_UDPLISTENER_INTERNAL_H
19#define FREERDP_LIB_CORE_UDPLISTENER_INTERNAL_H
21#include <winpr/wtypes.h>
22#include <winpr/synch.h>
23#include <winpr/winsock.h>
27#include <sys/socket.h>
28#include <netinet/in.h>
31#include <freerdp/api.h>
33#include "udplistener.h"
45#if !defined(MSG_NOSIGNAL)
48#if !defined(MSG_DONTWAIT)
51#if defined(SOCK_CLOEXEC)
52#define UDPLISTENER_SOCK_CLOEXEC SOCK_CLOEXEC
54#define UDPLISTENER_SOCK_CLOEXEC 0
56#if !defined(SHUT_RDWR)
57#define SHUT_RDWR SD_BOTH
61#define UDPLISTENER_RECEIVE_BUFFER (4 * 1024 * 1024)
64#define UDPLISTENER_MAX_SOCKETS 32
68#define UDPLISTENER_READ_BUDGET 256
73#define UDPFLOW_SLOTS 256
77#define UDPFLOW_FIRST_SLOTS 8
81#define UDPLISTENER_MAX_RELAYS 256
90 UINT32 interfaceIndex;
95 CRITICAL_SECTION lock;
103 UINT16 lengths[UDPFLOW_SLOTS];
109 struct sockaddr_storage peer;
119 FreeRDP_UdpFlowReceiveFn receive;
121 FreeRDP_UdpFlowSendFn send;
124 BOOL (*check)(
void* custom);
125 UINT32 (*timeout)(
void* custom);
128 freerdp_udp_listener* listener;
136 struct sockaddr_storage addr;
142 struct sockaddr_storage addr;
149typedef struct s_udp_listener_relay
151 struct s_udp_listener_relay* next;
152 freerdp_udp_listener* listener;
160typedef WSAPOLLFD udpPollFd;
162typedef struct pollfd udpPollFd;
167 CRITICAL_SECTION lock;
177 wHashTable* entriesByHash;
178 wHashTable* entriesByAddress;
196 BYTE buffer[0x10000];
203FREERDP_LOCAL BOOL udpsocket_address_equal(
const struct sockaddr_storage* a,
204 const struct sockaddr* b,
size_t blen);
208FREERDP_LOCAL
void udpsocket_unmap_address(
const struct sockaddr* addr,
size_t addrlen,
209 struct sockaddr_storage* out,
size_t* outlen);
213FREERDP_LOCAL SOCKET udpsocket_new(
int family,
int type,
int protocol);
216FREERDP_LOCAL
void udpsocket_set_no_inherit(SOCKET sockfd);
221FREERDP_LOCAL SOCKET udpsocket_bind(
const struct sockaddr* addr,
size_t addrlen);
224FREERDP_LOCAL
void udpsocket_ignore_icmp_errors(SOCKET sockfd);
229FREERDP_LOCAL BOOL udpsocket_is_message_socket(SOCKET sockfd);
238FREERDP_LOCAL
int udpsocket_receive(
const udpListenerSocket* sock, BYTE* data,
size_t size,
239 struct sockaddr_storage* addr,
int* addrlen,
245FREERDP_LOCAL BOOL udpsocket_send_from(SOCKET sockfd,
const struct sockaddr_storage* to,
253FREERDP_LOCAL BOOL udpsocket_source_address_unavailable(
int* error);
257FREERDP_LOCAL BOOL udpsocket_peer_closed(
void);
262FREERDP_LOCAL BOOL udpsocket_message_pair(SOCKET pair[2]);
264FREERDP_LOCAL
void udpsocket_poll_set(udpPollFd* fd, SOCKET sockfd);
268FREERDP_LOCAL
int udpsocket_poll(udpPollFd* fds,
size_t count);
275FREERDP_LOCAL BOOL udplistener_add_flow(freerdp_udp_listener* listener, rdpUdpFlow* flow,
281FREERDP_LOCAL
void udplistener_stop_relays(freerdp_udp_listener* listener);
284FREERDP_LOCAL
void udplistener_relays_close_after_fork(freerdp_udp_listener* listener);
Internal library implementation of include/freerdp/server/udp.h and the server UDP API,...