2020-07-29 10:10:42 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018-2020 WireGuard LLC. All Rights Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-10-17 15:11:34 +02:00
|
|
|
#include "wintun.h"
|
2020-10-31 11:55:26 +01:00
|
|
|
#include <IPExport.h>
|
2020-10-15 11:32:06 +02:00
|
|
|
#include <SetupAPI.h>
|
2020-10-31 11:55:26 +01:00
|
|
|
#include <Windows.h>
|
2020-07-29 10:10:42 +02:00
|
|
|
|
|
|
|
#define MAX_INSTANCE_ID MAX_PATH /* TODO: Is MAX_PATH always enough? */
|
2020-10-30 09:53:09 +01:00
|
|
|
#define WINTUN_HWID L"Wintun"
|
2020-07-29 10:10:42 +02:00
|
|
|
|
2020-10-15 11:32:06 +02:00
|
|
|
void
|
2020-10-30 06:03:21 +01:00
|
|
|
AdapterInit(void);
|
2020-10-15 11:32:06 +02:00
|
|
|
|
2020-10-17 15:11:34 +02:00
|
|
|
/**
|
|
|
|
* Wintun adapter descriptor.
|
|
|
|
*/
|
2020-07-29 10:10:42 +02:00
|
|
|
typedef struct _WINTUN_ADAPTER
|
|
|
|
{
|
|
|
|
GUID CfgInstanceID;
|
|
|
|
WCHAR DevInstanceID[MAX_INSTANCE_ID];
|
|
|
|
DWORD LuidIndex;
|
|
|
|
DWORD IfType;
|
2020-10-31 08:53:32 +01:00
|
|
|
WCHAR Pool[WINTUN_MAX_POOL];
|
2020-07-29 10:10:42 +02:00
|
|
|
} WINTUN_ADAPTER;
|
|
|
|
|
2020-10-15 12:52:01 +02:00
|
|
|
/**
|
2020-10-17 15:11:34 +02:00
|
|
|
* @copydoc WINTUN_FREE_ADAPTER_FUNC
|
2020-10-15 12:52:01 +02:00
|
|
|
*/
|
2020-07-29 10:10:42 +02:00
|
|
|
void WINAPI
|
|
|
|
WintunFreeAdapter(_In_ WINTUN_ADAPTER *Adapter);
|
|
|
|
|
2020-10-15 12:52:01 +02:00
|
|
|
/**
|
2020-10-17 15:11:34 +02:00
|
|
|
* @copydoc WINTUN_CREATE_ADAPTER_FUNC
|
2020-10-15 12:52:01 +02:00
|
|
|
*/
|
2020-11-03 12:29:34 +01:00
|
|
|
_Return_type_success_(return != NULL) WINTUN_ADAPTER *WINAPI WintunCreateAdapter(
|
2020-10-31 18:13:36 +01:00
|
|
|
_In_z_ const WCHAR *Pool,
|
|
|
|
_In_z_ const WCHAR *Name,
|
2020-07-29 10:10:42 +02:00
|
|
|
_In_opt_ const GUID *RequestedGUID,
|
2020-10-31 15:40:01 +01:00
|
|
|
_Out_opt_ BOOL *RebootRequired);
|
2020-07-29 10:10:42 +02:00
|
|
|
|
2020-10-15 12:52:01 +02:00
|
|
|
/**
|
2020-10-17 15:11:34 +02:00
|
|
|
* @copydoc WINTUN_DELETE_ADAPTER_FUNC
|
2020-10-15 12:52:01 +02:00
|
|
|
*/
|
2020-11-03 12:29:34 +01:00
|
|
|
_Return_type_success_(return != FALSE) BOOL WINAPI WintunDeleteAdapter(
|
|
|
|
_In_ const WINTUN_ADAPTER *Adapter,
|
|
|
|
_In_ BOOL ForceCloseSessions,
|
|
|
|
_Out_opt_ BOOL *RebootRequired);
|
2020-11-02 16:28:51 +01:00
|
|
|
|
|
|
|
/**
|
2020-11-03 12:27:42 +01:00
|
|
|
* @copydoc WINTUN_DELETE_POOL_DRIVER_FUNC
|
2020-11-02 16:28:51 +01:00
|
|
|
*/
|
2020-11-03 12:29:34 +01:00
|
|
|
_Return_type_success_(return != FALSE) BOOL WINAPI
|
|
|
|
WintunDeletePoolDriver(_In_z_ const WCHAR *Pool, _Out_opt_ BOOL *RebootRequired);
|
2020-11-05 15:25:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a handle to the adapter device object.
|
|
|
|
*
|
|
|
|
* @param Adapter Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter.
|
|
|
|
*
|
|
|
|
* @return If the function succeeds, the return value is adapter device object handle. Must be released with
|
|
|
|
* CloseHandle. If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error
|
|
|
|
* information, call GetLastError.
|
|
|
|
*/
|
|
|
|
_Return_type_success_(return != INVALID_HANDLE_VALUE) HANDLE WINAPI
|
|
|
|
AdapterOpenDeviceObject(_In_ const WINTUN_ADAPTER *Adapter);
|