From efbc70635b18eeb2d6356d6e9ddac29329b40892 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 31 Oct 2020 10:28:25 +0100 Subject: api expose Send.TailMoved event to clients This allows clients to use it in WaitForMultipleObjects(). Signed-off-by: Simon Rozman --- api/wintun.h | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'api/wintun.h') diff --git a/api/wintun.h b/api/wintun.h index 67a87be..b6e1663 100644 --- a/api/wintun.h +++ b/api/wintun.h @@ -250,12 +250,18 @@ typedef void *WINTUN_SESSION_HANDLE; * * @param Session Pointer to a variable to receive Wintun session handle * + * @param ReadWait Pointer to receive event handle to wait for available data when reading. Should + * WintunReceivePackets return ERROR_NO_MORE_ITEMS (after spinning on it for a while under heavy + * load), wait for this event to become signaled before retrying WintunReceivePackets. Do not call + * CloseHandle on this event - it is managed by the session. + * * @return ERROR_SUCCESS on success; Win32 error code otherwise. */ typedef WINTUN_STATUS(WINAPI *WINTUN_START_SESSION_FUNC)( _In_ WINTUN_ADAPTER_HANDLE Adapter, _In_ DWORD Capacity, - _Out_ WINTUN_SESSION_HANDLE *Session); + _Out_ WINTUN_SESSION_HANDLE *Session, + _Out_ HANDLE *ReadWait); /** * Ends Wintun session. @@ -269,20 +275,6 @@ typedef void(WINAPI *WINTUN_END_SESSION_FUNC)(_In_ WINTUN_SESSION_HANDLE Session */ #define WINTUN_MAX_IP_PACKET_SIZE 0xFFFF -/** - * Waits for a packet to become available for reading. - * - * @param Session Wintun session handle obtained with WintunStartSession - * - * @param Milliseconds The time-out interval, in milliseconds. If a nonzero value is specified, the function waits - * until a packet is available or the interval elapses. If Milliseconds is zero, the function - * does not enter a wait state if a packet is not available; it always returns immediately. - * If Milliseconds is INFINITE, the function will return only when a packet is available. - * - * @return See WaitForSingleObject() for return values. - */ -typedef WINTUN_STATUS(WINAPI *WINTUN_WAIT_FOR_PACKET_FUNC)(_In_ WINTUN_SESSION_HANDLE Session, _In_ DWORD Milliseconds); - /** * Retrieves one or packet. After the packet content is consumed, call WintunReceiveRelease with Packet returned * from this function to release internal buffer. This function is thread-safe. @@ -301,8 +293,10 @@ typedef WINTUN_STATUS(WINAPI *WINTUN_WAIT_FOR_PACKET_FUNC)(_In_ WINTUN_SESSION_H * ERROR_SUCCESS on success. * Regardless, if the error was returned, some packets might have been read nevertheless. */ -typedef WINTUN_STATUS(WINAPI *WINTUN_RECEIVE_PACKETS_FUNC) -(_In_ WINTUN_SESSION_HANDLE *Session, _Out_bytecapcount_(*PacketSize) BYTE **Packet, _Out_ DWORD *PacketSize); +typedef WINTUN_STATUS(WINAPI *WINTUN_RECEIVE_PACKETS_FUNC)( + _In_ WINTUN_SESSION_HANDLE *Session, + _Out_bytecapcount_(*PacketSize) BYTE **Packet, + _Out_ DWORD *PacketSize); /** * Releases internal buffer after the received packet has been processed by the client. This function is thread-safe. @@ -329,8 +323,10 @@ typedef void(WINAPI *WINTUN_RECEIVE_RELEASE_FUNC)(_In_ WINTUN_SESSION_HANDLE *Se * ERROR_BUFFER_OVERFLOW Wintun buffer is full; * ERROR_SUCCESS on success. */ -typedef WINTUN_STATUS(WINAPI *WINTUN_ALLOCATE_SEND_PACKET_FUNC) -(_In_ WINTUN_SESSION_HANDLE *Session, _In_ DWORD PacketSize, _Out_bytecapcount_(PacketSize) BYTE **Packet); +typedef WINTUN_STATUS(WINAPI *WINTUN_ALLOCATE_SEND_PACKET_FUNC)( + _In_ WINTUN_SESSION_HANDLE *Session, + _In_ DWORD PacketSize, + _Out_bytecapcount_(PacketSize) BYTE **Packet); /** * Sends the packet and releases internal buffer. WintunSendPacket is thread-safe, but the WintunAllocateSendPacket -- cgit v1.2.3-59-g8ed1b