UsbDk: Redirections collection management
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This commit is contained in:
parent
bfa21156bb
commit
838d1e3662
3 changed files with 76 additions and 0 deletions
|
|
@ -71,6 +71,18 @@ void CUsbDkControlDeviceQueue::DeviceControl(WDFQUEUE Queue,
|
|||
ResetDevice(WdfRequest, Queue);
|
||||
break;
|
||||
}
|
||||
case IOCTL_USBDK_ADD_REDIRECT:
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_CONTROLDEVICE, "Called IOCTL_USBDK_ADD_REDIRECT\n");
|
||||
AddRedirect(WdfRequest, Queue);
|
||||
break;
|
||||
}
|
||||
case IOCTL_USBDK_REMOVE_REDIRECT:
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_CONTROLDEVICE, "Called IOCTL_USBDK_REMOVE_REDIRECT\n");
|
||||
RemoveRedirect(WdfRequest, Queue);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_CONTROLDEVICE, "Wrong IoControlCode 0x%X\n", IoControlCode);
|
||||
|
|
@ -154,6 +166,18 @@ void CUsbDkControlDeviceQueue::ResetDevice(CWdfRequest &Request, WDFQUEUE Queue)
|
|||
}
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void CUsbDkControlDeviceQueue::AddRedirect(CWdfRequest &Request, WDFQUEUE Queue)
|
||||
{
|
||||
DoUSBDeviceOp(Request, Queue, &CUsbDkControlDevice::AddRedirect);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void CUsbDkControlDeviceQueue::RemoveRedirect(CWdfRequest &Request, WDFQUEUE Queue)
|
||||
{
|
||||
DoUSBDeviceOp(Request, Queue, &CUsbDkControlDevice::RemoveRedirect);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
|
||||
ULONG CUsbDkControlDevice::CountDevices()
|
||||
{
|
||||
ULONG numberDevices = 0;
|
||||
|
|
@ -301,6 +325,48 @@ bool CUsbDkControlDevice::Allocate()
|
|||
return true;
|
||||
}
|
||||
|
||||
NTSTATUS CUsbDkControlDevice::AddRedirect(const USB_DK_DEVICE_ID &DeviceId)
|
||||
{
|
||||
CObjHolder<CUsbDkRedirection> newRedir(new CUsbDkRedirection());
|
||||
|
||||
if (!newRedir)
|
||||
{
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
auto status = newRedir->Create(DeviceId);
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
if (!m_Redirections.Add(newRedir))
|
||||
{
|
||||
return STATUS_OBJECT_NAME_COLLISION;
|
||||
}
|
||||
|
||||
newRedir.detach();
|
||||
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_CONTROLDEVICE, "%!FUNC! Success. New redirections list:");
|
||||
m_Redirections.Dump();
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS CUsbDkControlDevice::RemoveRedirect(const USB_DK_DEVICE_ID &DeviceId)
|
||||
{
|
||||
auto res = m_Redirections.Delete(&DeviceId);
|
||||
|
||||
if (res)
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_CONTROLDEVICE, "%!FUNC! Success. New redirections list:");
|
||||
m_Redirections.Dump();
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
NTSTATUS CUsbDkRedirection::Create(const USB_DK_DEVICE_ID &Id)
|
||||
{
|
||||
auto status = m_DeviceID.Create(Id.DeviceID);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue