Skip to content

Commit

Permalink
Implement OVPN_IOCTL_GET_VERSION
Browse files Browse the repository at this point in the history
This allows client to get the driver version.

Bump version to 1.0.0

Signed-off-by: Lev Stipakov <[email protected]>
  • Loading branch information
lstipakov committed Oct 8, 2023
1 parent 4cca1af commit 1b8b417
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
24 changes: 24 additions & 0 deletions Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,26 @@ OvpnEvtIoWrite(WDFQUEUE queue, WDFREQUEST request, size_t length)
ExReleaseSpinLockShared(&device->SpinLock, kiqrl);
}

NTSTATUS
OvpnGetVersion(WDFREQUEST request, _Out_ ULONG_PTR* bytesReturned)
{
*bytesReturned = 0;

NTSTATUS status;
POVPN_VERSION version = NULL;
GOTO_IF_NOT_NT_SUCCESS(done, status, WdfRequestRetrieveOutputBuffer(request, sizeof(OVPN_VERSION), (PVOID*)&version, NULL));

version->Major = OVPN_DCO_VERSION_MAJOR;
version->Minor = OVPN_DCO_VERSION_MINOR;
version->Patch = OVPN_DCO_VERSION_PATCH;

*bytesReturned = sizeof(OVPN_VERSION);

done:
return status;
}


EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL OvpnEvtIoDeviceControl;

_Use_decl_annotations_
Expand Down Expand Up @@ -264,6 +284,10 @@ OvpnEvtIoDeviceControl(WDFQUEUE queue, WDFREQUEST request, size_t outputBufferLe
ExReleaseSpinLockExclusive(&device->SpinLock, kirql);
break;

case OVPN_IOCTL_GET_VERSION:
status = OvpnGetVersion(request, &bytesReturned);
break;

default:
LOG_WARN("Unknown <ioControlCode>", TraceLoggingValue(ioControlCode, "ioControlCode"));
status = STATUS_INVALID_DEVICE_REQUEST;
Expand Down
6 changes: 3 additions & 3 deletions PropertySheet.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros">
<OVPN_DCO_VERSION_MAJOR>0</OVPN_DCO_VERSION_MAJOR>
<OVPN_DCO_VERSION_MINOR>9</OVPN_DCO_VERSION_MINOR>
<OVPN_DCO_VERSION_PATCH>4</OVPN_DCO_VERSION_PATCH>
<OVPN_DCO_VERSION_MAJOR>1</OVPN_DCO_VERSION_MAJOR>
<OVPN_DCO_VERSION_MINOR>0</OVPN_DCO_VERSION_MINOR>
<OVPN_DCO_VERSION_PATCH>0</OVPN_DCO_VERSION_PATCH>
</PropertyGroup>
<PropertyGroup />
<ItemDefinitionGroup>
Expand Down
7 changes: 7 additions & 0 deletions uapi/ovpn-dco.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,17 @@ typedef struct _OVPN_SET_PEER {
LONG MSS;
} OVPN_SET_PEER, * POVPN_SET_PEER;

typedef struct _OVPN_VERSION {
LONG Major;
LONG Minor;
LONG Patch;
} OVPN_VERSION, * POVPN_VERSION;

#define OVPN_IOCTL_NEW_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define OVPN_IOCTL_GET_STATS CTL_CODE(FILE_DEVICE_UNKNOWN, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define OVPN_IOCTL_NEW_KEY CTL_CODE(FILE_DEVICE_UNKNOWN, 3, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define OVPN_IOCTL_SWAP_KEYS CTL_CODE(FILE_DEVICE_UNKNOWN, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define OVPN_IOCTL_SET_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 5, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define OVPN_IOCTL_START_VPN CTL_CODE(FILE_DEVICE_UNKNOWN, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define OVPN_IOCTL_DEL_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define OVPN_IOCTL_GET_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)

0 comments on commit 1b8b417

Please sign in to comment.