Commit Graph

18 Commits

Author SHA1 Message Date
Jason A. Donenfeld
9f3d466791 api: remove WintunOpenAdapterDeviceObject
Discourage use of kernel interface, which gives us more flexibility if
we ever want to change it.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-05 16:58:43 +01:00
Jason A. Donenfeld
1285b8f528 api: rename WintunGetAdapter to WintunOpenAdapter
"Create" and "Open" natural names for these.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-05 16:58:43 +01:00
Jason A. Donenfeld
e9e790605a api: rename ReceiveRelease to ReleaseReceivePacket
This makes the API parallel:
Wintun*Allocate*SendPacket -> WintunSendPacket
WintunReceivePacket -> Wintun*Release*ReceivePacket

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-05 16:58:43 +01:00
Jason A. Donenfeld
dc99f96da7 api: rename GetVersion to GetRunningDriverVersion
This makes our intentions a lot more clear, and in case we ever add
other version functions, makes the forward path simpler.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-04 14:53:39 +01:00
Jason A. Donenfeld
8963f7258e api: remove guid getter
The iphlpapi takes both LUIDs and GUIDs but prefers LUIDs, so exposing
the NET_LUID makes sense. However, we were previously exposing the
configuration GUID, rather than the net GUID, which is confusing, so
just make it all go away.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 12:34:19 +01:00
Jason A. Donenfeld
2af7fbd64a api: use 'open' name since caller must close handle
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 12:31:49 +01:00
Jason A. Donenfeld
7dede73406 api: add pool/driver removal for uninstaller semantics
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 12:27:42 +01:00
Simon Rozman
283f6c8e63 api: install driver on demand
...and add API for uninstalling it.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-02 23:33:20 +01:00
Jason A. Donenfeld
c20e1683c2 api: separate read-wait handle into other function
Makes the API a bit more clear.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-02 16:38:56 +01:00
Jason A. Donenfeld
724508d61f api: make nci.lib work on x86
This is an appalling hack. We need the lib tool to generate a coff lib
with the "undecorate" parameter. And apparently the only way to do this
with the MSVC tools is by making a stub object, and then rewriting the
symbols using the def file. See Q131313 for Microsoft-sanctioned
details.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-02 11:38:02 +01:00
Simon Rozman
efbc70635b api expose Send.TailMoved event to clients
This allows clients to use it in WaitForMultipleObjects().

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 19:11:50 +01:00
Simon Rozman
e11897e343 api: depretiate WintunIsPacketAvailable()
Spinning on the WintunReceivePacket() while it returns
ERROR_NO_MORE_ITEMS achieves the same.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:46 +01:00
Simon Rozman
2439b05212 api: upgrade ring management
- Return pointer to ring buffer with packet data allowing clients to
  read/write directly. This eliminates one memcpy().

- Make sending/receiving packets thread-safe.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:15:15 +01:00
Simon Rozman
4b8f879fd6 api: add ring management
Rather than every client reinvent the art of using the Wintun and its
ring buffers, we offer helper structs and functions to unify and
simplify Wintun usage.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:01 +01:00
Simon Rozman
f316c13b3e api: introduce logging
And other unifications with installer before merging.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
7e3740018d api: finish porting from wireguard-go
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:58 +01:00
Simon Rozman
d3a63116ba api: port GetInterface member from wireguard-go
Mind that this also fixes the order of adapter detection checks. A fast
test to eliminate non-Wintun adapters from iteration to speed things up
rendered the method incapable of detecting a non-Wintun adapter with the
name we are looking for.

ERROR_OBJECT_NOT_FOUND was replaced with ERROR_FILE_NOT_FOUND.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:58 +01:00
Simon Rozman
0ef8578c81 api: add skeleton for wintun.dll
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:58 +01:00