aboutsummaryrefslogtreecommitdiffstats
path: root/api/session.c
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2020-10-31 10:28:25 +0100
committerSimon Rozman <simon@rozman.si>2020-10-31 19:11:50 +0100
commitefbc70635b18eeb2d6356d6e9ddac29329b40892 (patch)
treecb2903cf3b88f9e60c4eabcf1104c6ac247eede6 /api/session.c
parentapi: rename MAX_POOL to WINTUN_MAX_POOL (diff)
downloadwintun-efbc70635b18eeb2d6356d6e9ddac29329b40892.tar.xz
wintun-efbc70635b18eeb2d6356d6e9ddac29329b40892.zip
api expose Send.TailMoved event to clients
This allows clients to use it in WaitForMultipleObjects(). Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'api/session.c')
-rw-r--r--api/session.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/api/session.c b/api/session.c
index e39f21b..eb71147 100644
--- a/api/session.c
+++ b/api/session.c
@@ -65,7 +65,11 @@ typedef struct _TUN_SESSION
} TUN_SESSION;
WINTUN_STATUS WINAPI
-WintunStartSession(_In_ const WINTUN_ADAPTER *Adapter, _In_ DWORD Capacity, _Out_ TUN_SESSION **Session)
+WintunStartSession(
+ _In_ const WINTUN_ADAPTER *Adapter,
+ _In_ DWORD Capacity,
+ _Out_ TUN_SESSION **Session,
+ _Out_ HANDLE *ReadWait)
{
TUN_SESSION *s = HeapAlloc(ModuleHeap, HEAP_ZERO_MEMORY, sizeof(TUN_SESSION));
if (!s)
@@ -127,6 +131,7 @@ WintunStartSession(_In_ const WINTUN_ADAPTER *Adapter, _In_ DWORD Capacity, _Out
(void)InitializeCriticalSectionAndSpinCount(&s->Receive.Lock, LOCK_SPIN_COUNT);
(void)InitializeCriticalSectionAndSpinCount(&s->Send.Lock, LOCK_SPIN_COUNT);
*Session = s;
+ *ReadWait = s->Descriptor.Send.TailMoved;
return ERROR_SUCCESS;
cleanupHandle:
CloseHandle(s->Handle);
@@ -157,12 +162,6 @@ WintunEndSession(_In_ TUN_SESSION *Session)
}
WINTUN_STATUS WINAPI
-WintunWaitForPacket(_In_ TUN_SESSION *Session, _In_ DWORD Milliseconds)
-{
- return WaitForSingleObject(Session->Descriptor.Send.TailMoved, Milliseconds);
-}
-
-WINTUN_STATUS WINAPI
WintunReceivePacket(_In_ TUN_SESSION *Session, _Out_bytecapcount_(*PacketSize) BYTE **Packet, _Out_ DWORD *PacketSize)
{
DWORD Result;