Driver: Simplify fort_callout_stream_classify_v4(), Part 2

This commit is contained in:
Nodir Temirkhodjaev 2021-12-12 11:54:49 +03:00
parent e8ba893eaf
commit 0263f0a1b9

View File

@ -279,6 +279,15 @@ static BOOL fort_callout_stream_classify_v4_fragment(const FWPS_INCOMING_VALUES0
const FWPS_INCOMING_METADATA_VALUES0 *inMetaValues, FWPS_STREAM_CALLOUT_IO_PACKET0 *packet,
const FWPS_FILTER0 *filter, UINT64 flowContext)
{
const FWPS_STREAM_DATA0 *streamData = packet->streamData;
const UINT32 streamFlags = streamData->flags;
if ((streamFlags
& (FWPS_STREAM_FLAG_SEND | FWPS_STREAM_FLAG_SEND_EXPEDITED
| FWPS_STREAM_FLAG_SEND_DISCONNECT))
!= FWPS_STREAM_FLAG_SEND)
return FALSE;
PFORT_FLOW flow = (PFORT_FLOW) flowContext;
const UCHAR flow_flags = fort_flow_flags(flow);
@ -287,10 +296,7 @@ static BOOL fort_callout_stream_classify_v4_fragment(const FWPS_INCOMING_VALUES0
(flow_flags & (FORT_FLOW_FRAGMENT | FORT_FLOW_FRAGMENT_DEFER | FORT_FLOW_FRAGMENTED));
if (fragment_flags != 0 && !(fragment_flags & FORT_FLOW_FRAGMENTED)) {
const FWPS_STREAM_DATA0 *streamData = packet->streamData;
const UINT32 streamFlags = streamData->flags;
const UINT32 dataSize = (UINT32) streamData->dataLength;
const BOOL inbound = (streamFlags & FWPS_STREAM_FLAG_RECEIVE) != 0;
const UCHAR fragment_size = 3;
@ -328,8 +334,7 @@ static void NTAPI fort_callout_stream_classify_v4(const FWPS_INCOMING_VALUES0 *i
/* Flush flow's deferred TCP packets on FIN */
#if 0
if (streamFlags & (FWPS_STREAM_FLAG_RECEIVE_DISCONNECT
| FWPS_STREAM_FLAG_SEND_DISCONNECT)) {
if (streamFlags & (FWPS_STREAM_FLAG_RECEIVE_DISCONNECT | FWPS_STREAM_FLAG_SEND_DISCONNECT)) {
PFORT_FLOW flow = (PFORT_FLOW) flowContext;
const UCHAR flow_flags = fort_flow_flags(flow);
@ -347,11 +352,7 @@ static void NTAPI fort_callout_stream_classify_v4(const FWPS_INCOMING_VALUES0 *i
#endif
/* Fragment first TCP packet */
if ((streamFlags
& (FWPS_STREAM_FLAG_SEND | FWPS_STREAM_FLAG_SEND_EXPEDITED
| FWPS_STREAM_FLAG_SEND_DISCONNECT))
== FWPS_STREAM_FLAG_SEND
&& fort_callout_stream_classify_v4_fragment(
if (fort_callout_stream_classify_v4_fragment(
inFixedValues, inMetaValues, packet, filter, flowContext))
goto drop;