Driver: fortcout: Simplify fort_callout_install()

This commit is contained in:
Nodir Temirkhodjaev 2023-01-15 12:15:54 +03:00
parent 7a647c0683
commit 3a57c68b52

View File

@ -589,7 +589,8 @@ static void NTAPI fort_callout_transport_delete(
UNUSED(flowContext); UNUSED(flowContext);
} }
FORT_API NTSTATUS fort_callout_install(PDEVICE_OBJECT device) inline static NTSTATUS fort_callout_register(
PDEVICE_OBJECT device, const FWPS_CALLOUT0 *callouts, int count)
{ {
PFORT_STAT stat = &fort_device()->stat; PFORT_STAT stat = &fort_device()->stat;
@ -608,6 +609,20 @@ FORT_API NTSTATUS fort_callout_install(PDEVICE_OBJECT device)
&stat->out_transport6_id, &stat->out_transport6_id,
}; };
for (int i = 0; i < count; ++i) {
const NTSTATUS status = FwpsCalloutRegister0(device, &callouts[i], calloutIds[i]);
if (!NT_SUCCESS(status)) {
LOG("Callout Register: Error: %x\n", status);
TRACE(FORT_CALLOUT_REGISTER_ERROR, status, i, 0);
return status;
}
}
return STATUS_SUCCESS;
}
FORT_API NTSTATUS fort_callout_install(PDEVICE_OBJECT device)
{
const FWPS_CALLOUT0 callouts[] = { const FWPS_CALLOUT0 callouts[] = {
/* IPv4 connect callout */ /* IPv4 connect callout */
{ {
@ -699,16 +714,8 @@ FORT_API NTSTATUS fort_callout_install(PDEVICE_OBJECT device)
}, },
}; };
for (int i = 0; i < sizeof(callouts) / sizeof(callouts[0]); ++i) { return fort_callout_register(
const NTSTATUS status = FwpsCalloutRegister0(device, &callouts[i], calloutIds[i]); device, callouts, /*count=*/sizeof(callouts) / sizeof(callouts[0]));
if (!NT_SUCCESS(status)) {
LOG("Callout Register: Error: %x\n", status);
TRACE(FORT_CALLOUT_REGISTER_ERROR, status, i, 0);
return status;
}
}
return STATUS_SUCCESS;
} }
FORT_API void fort_callout_remove(void) FORT_API void fort_callout_remove(void)