diff --git a/src/core/connection.c b/src/core/connection.c index 235c6292c5..2957974b8e 100644 --- a/src/core/connection.c +++ b/src/core/connection.c @@ -6040,6 +6040,17 @@ QuicConnParamSet( #endif break; + case QUIC_PARAM_CONN_KEEP_ALIVE_PADDING: + + if (BufferLength != sizeof(Connection->KeepAlivePadding)) { + Status = QUIC_STATUS_INVALID_PARAMETER; + break; + } + + Connection->KeepAlivePadding = *(uint16_t*)Buffer; + Status = QUIC_STATUS_SUCCESS; + break; + default: Status = QUIC_STATUS_INVALID_PARAMETER; break; diff --git a/src/core/connection.h b/src/core/connection.h index 92a20cadf5..3e0380c81f 100644 --- a/src/core/connection.h +++ b/src/core/connection.h @@ -579,6 +579,11 @@ typedef struct QUIC_CONNECTION { // uint32_t PreviousQuicVersion; + // + // The size of the keep alive padding. + // + uint16_t KeepAlivePadding; + } QUIC_CONNECTION; typedef struct QUIC_SERIALIZED_RESUMPTION_STATE { diff --git a/src/core/send.c b/src/core/send.c index 4447f14feb..c8bd7f9ed6 100644 --- a/src/core/send.c +++ b/src/core/send.c @@ -855,7 +855,15 @@ QuicSendWriteFrames( if (Builder->DatagramLength < AvailableBufferLength) { Builder->Datagram->Buffer[Builder->DatagramLength++] = QUIC_FRAME_PING; Send->SendFlags &= ~QUIC_CONN_SEND_FLAG_PING; - Builder->MinimumDatagramLength = (uint16_t)Builder->Datagram->Length; + if (Connection->KeepAlivePadding) { + Builder->MinimumDatagramLength = + Builder->DatagramLength + Connection->KeepAlivePadding + Builder->EncryptionOverhead; + if (Builder->MinimumDatagramLength > (uint16_t)Builder->Datagram->Length) { + Builder->MinimumDatagramLength = (uint16_t)Builder->Datagram->Length; + } + } else { + Builder->MinimumDatagramLength = (uint16_t)Builder->Datagram->Length; + } if (QuicPacketBuilderAddFrame(Builder, QUIC_FRAME_PING, TRUE)) { return TRUE; } diff --git a/src/inc/msquic.hpp b/src/inc/msquic.hpp index 9c93785f48..cf1360333d 100644 --- a/src/inc/msquic.hpp +++ b/src/inc/msquic.hpp @@ -21,6 +21,7 @@ Supported Platforms: #pragma once #include "msquic.h" +#include "msquicp.h" #ifdef _KERNEL_MODE #include #else @@ -862,6 +863,17 @@ struct MsQuicConnection { Statistics); } + QUIC_STATUS + SetKeepAlivePadding(_In_ uint16_t Value) noexcept { + return + MsQuic->SetParam( + Handle, + QUIC_PARAM_LEVEL_CONNECTION, + QUIC_PARAM_CONN_KEEP_ALIVE_PADDING, + sizeof(Value), + &Value); + } + QUIC_STATUS GetInitStatus() const noexcept { return InitStatus; } bool IsValid() const { return QUIC_SUCCEEDED(InitStatus); } MsQuicConnection(MsQuicConnection& other) = delete; diff --git a/src/inc/msquicp.h b/src/inc/msquicp.h index 4cfdfe2750..fbc94986b4 100644 --- a/src/inc/msquicp.h +++ b/src/inc/msquicp.h @@ -133,6 +133,7 @@ typedef struct CXPLAT_TLS_SECRETS { #define QUIC_PARAM_CONN_FORCE_CID_UPDATE 0x15000002 // No payload #define QUIC_PARAM_CONN_TEST_TRANSPORT_PARAMETER 0x15000003 // QUIC_PRIVATE_TRANSPORT_PARAMETER #define QUIC_PARAM_CONN_TLS_SECRETS 0x15000004 // CXPLAT_TLS_SECRETS (SSLKEYLOGFILE compatible) +#define QUIC_PARAM_CONN_KEEP_ALIVE_PADDING 0x15000005 // uint16_t #if defined(__cplusplus) } diff --git a/src/test/MsQuicTests.h b/src/test/MsQuicTests.h index 2b1d145870..9eaa3c6515 100644 --- a/src/test/MsQuicTests.h +++ b/src/test/MsQuicTests.h @@ -230,12 +230,14 @@ QuicTestConnectExpiredClientCertificate( void QuicTestNatPortRebind( - _In_ int Family + _In_ int Family, + _In_ uint16_t KeepAlivePaddingSize ); void QuicTestNatAddrRebind( - _In_ int Family + _In_ int Family, + _In_ uint16_t KeepAlivePaddingSize ); void @@ -728,13 +730,18 @@ typedef struct { QUIC_CTL_CODE(40, METHOD_BUFFERED, FILE_WRITE_DATA) // int - Family +typedef struct { + int Family; + uint16_t Padding; +} QUIC_RUN_REBIND_PARAMS; + #define IOCTL_QUIC_RUN_NAT_PORT_REBIND \ QUIC_CTL_CODE(41, METHOD_BUFFERED, FILE_WRITE_DATA) - // int - Family + // QUIC_RUN_REBIND_PARAMS #define IOCTL_QUIC_RUN_NAT_ADDR_REBIND \ QUIC_CTL_CODE(42, METHOD_BUFFERED, FILE_WRITE_DATA) - // int - Family + // QUIC_RUN_REBIND_PARAMS #define IOCTL_QUIC_RUN_CHANGE_MAX_STREAM_ID \ QUIC_CTL_CODE(43, METHOD_BUFFERED, FILE_WRITE_DATA) diff --git a/src/test/bin/quic_gtest.cpp b/src/test/bin/quic_gtest.cpp index 0e112114f2..6443126f4f 100644 --- a/src/test/bin/quic_gtest.cpp +++ b/src/test/bin/quic_gtest.cpp @@ -975,21 +975,55 @@ TEST_P(WithFamilyArgs, ServerRejected) { TEST_P(WithFamilyArgs, RebindPort) { TestLoggerT Logger("QuicTestNatPortRebind", GetParam()); if (TestingKernelMode) { - ASSERT_TRUE(DriverClient.Run(IOCTL_QUIC_RUN_NAT_PORT_REBIND, GetParam().Family)); + QUIC_RUN_REBIND_PARAMS Params = { + GetParam().Family, + 0 + }; + ASSERT_TRUE(DriverClient.Run(IOCTL_QUIC_RUN_NAT_PORT_REBIND, Params)); } else { - QuicTestNatPortRebind(GetParam().Family); + QuicTestNatPortRebind(GetParam().Family, 0); } } +/*TEST_P(WithRebindPaddingArgs, RebindPortPadded) { + TestLoggerT Logger("QuicTestNatPortRebind(pad)", GetParam()); + if (TestingKernelMode) { + QUIC_RUN_REBIND_PARAMS Params = { + GetParam().Family, + GetParam().Padding + }; + ASSERT_TRUE(DriverClient.Run(IOCTL_QUIC_RUN_NAT_PORT_REBIND, Params)); + } else { + QuicTestNatPortRebind(GetParam().Family, GetParam().Padding); + } +}*/ + TEST_P(WithFamilyArgs, RebindAddr) { TestLoggerT Logger("QuicTestNatAddrRebind", GetParam()); if (TestingKernelMode) { - ASSERT_TRUE(DriverClient.Run(IOCTL_QUIC_RUN_NAT_ADDR_REBIND, GetParam().Family)); + QUIC_RUN_REBIND_PARAMS Params = { + GetParam().Family, + 0 + }; + ASSERT_TRUE(DriverClient.Run(IOCTL_QUIC_RUN_NAT_ADDR_REBIND, Params)); } else { - QuicTestNatAddrRebind(GetParam().Family); + QuicTestNatAddrRebind(GetParam().Family, 0); } } +/*TEST_P(WithRebindPaddingArgs, RebindAddrPadded) { + TestLoggerT Logger("QuicTestNatAddrRebind(pad)", GetParam()); + if (TestingKernelMode) { + QUIC_RUN_REBIND_PARAMS Params = { + GetParam().Family, + GetParam().Padding + }; + ASSERT_TRUE(DriverClient.Run(IOCTL_QUIC_RUN_NAT_PORT_REBIND, Params)); + } else { + QuicTestNatAddrRebind(GetParam().Family, GetParam().Padding); + } +}*/ + TEST_P(WithFamilyArgs, PathValidationTimeout) { TestLoggerT Logger("QuicTestPathValidationTimeout", GetParam()); if (TestingKernelMode) { @@ -1510,6 +1544,11 @@ INSTANTIATE_TEST_SUITE_P( WithMtuArgs, ::testing::ValuesIn(MtuArgs::Generate())); +/*INSTANTIATE_TEST_SUITE_P( + Basic, + WithRebindPaddingArgs, + ::testing::ValuesIn(RebindPaddingArgs::Generate()));*/ + #endif // QUIC_TEST_DATAPATH_HOOKS_ENABLED INSTANTIATE_TEST_SUITE_P( diff --git a/src/test/bin/quic_gtest.h b/src/test/bin/quic_gtest.h index 93cdddb507..1d6f4d8982 100644 --- a/src/test/bin/quic_gtest.h +++ b/src/test/bin/quic_gtest.h @@ -668,3 +668,24 @@ std::ostream& operator << (std::ostream& o, const ValidateStreamEventArgs& args) class WithValidateStreamEventArgs : public testing::Test, public testing::WithParamInterface { }; + +struct RebindPaddingArgs { + int Family; + uint16_t Padding; + static ::std::vector Generate() { + ::std::vector list; + for (int Family : { 4, 6 }) + for (uint16_t Padding = 1; Padding < 50; ++Padding) + list.push_back({ Family, Padding }); + return list; + } +}; + +std::ostream& operator << (std::ostream& o, const RebindPaddingArgs& args) { + return o << (args.Family == 4 ? "v4" : "v6") << "/" + << args.Padding; +} + +class WithRebindPaddingArgs : public testing::Test, + public testing::WithParamInterface { +}; diff --git a/src/test/bin/winkernel/control.cpp b/src/test/bin/winkernel/control.cpp index 39b6ad0ecd..b069aad3c0 100644 --- a/src/test/bin/winkernel/control.cpp +++ b/src/test/bin/winkernel/control.cpp @@ -411,8 +411,8 @@ size_t QUIC_IOCTL_BUFFER_SIZES[] = 0, sizeof(QUIC_RUN_DATAGRAM_NEGOTIATION), sizeof(INT32), - sizeof(INT32), - sizeof(INT32), + sizeof(QUIC_RUN_REBIND_PARAMS), + sizeof(QUIC_RUN_REBIND_PARAMS), sizeof(INT32), sizeof(INT32), 0, @@ -473,6 +473,7 @@ typedef union { QUIC_RUN_KEY_UPDATE_RANDOM_LOSS_PARAMS KeyUpdateRandomLossParams; QUIC_RUN_MTU_DISCOVERY_PARAMS MtuDiscoveryParams; uint32_t Test; + QUIC_RUN_REBIND_PARAMS RebindParams; } QUIC_IOCTL_PARAMS; @@ -838,14 +839,16 @@ QuicTestCtlEvtIoDeviceControl( CXPLAT_FRE_ASSERT(Params != nullptr); QuicTestCtlRun( QuicTestNatPortRebind( - Params->Family)); + Params->RebindParams.Family, + Params->RebindParams.Padding)); break; case IOCTL_QUIC_RUN_NAT_ADDR_REBIND: CXPLAT_FRE_ASSERT(Params != nullptr); QuicTestCtlRun( QuicTestNatAddrRebind( - Params->Family)); + Params->RebindParams.Family, + Params->RebindParams.Padding)); break; case IOCTL_QUIC_RUN_CHANGE_MAX_STREAM_ID: diff --git a/src/test/lib/HandshakeTest.cpp b/src/test/lib/HandshakeTest.cpp index 042291b2b7..dd4e9b1d57 100644 --- a/src/test/lib/HandshakeTest.cpp +++ b/src/test/lib/HandshakeTest.cpp @@ -305,194 +305,123 @@ QuicTestConnect( } } +struct RebindContext { + bool Connected {false}; + CxPlatEvent HandshakeCompleteEvent; + CxPlatEvent PeerAddrChangedEvent; + QuicAddr PeerAddr; + static QUIC_STATUS ConnCallback(_In_ MsQuicConnection*, _In_opt_ void* Context, _Inout_ QUIC_CONNECTION_EVENT* Event) { + auto This = static_cast(Context); + if (Event->Type == QUIC_CONNECTION_EVENT_SHUTDOWN_COMPLETE) { + This->PeerAddrChangedEvent.Set(); + This->HandshakeCompleteEvent.Set(); + } else if (Event->Type == QUIC_CONNECTION_EVENT_CONNECTED) { + This->Connected = true; + This->HandshakeCompleteEvent.Set(); + } else if (Event->Type == QUIC_CONNECTION_EVENT_PEER_ADDRESS_CHANGED) { + This->PeerAddr.SockAddr = *Event->PEER_ADDRESS_CHANGED.Address; + This->PeerAddrChangedEvent.Set(); + } + return QUIC_STATUS_SUCCESS; + } +}; + void QuicTestNatPortRebind( - _In_ int Family + _In_ int Family, + _In_ uint16_t KeepAlivePaddingSize ) { + RebindContext Context; MsQuicRegistration Registration(true); TEST_TRUE(Registration.IsValid()); - MsQuicAlpn Alpn("MsQuicTest"); - - MsQuicConfiguration ServerConfiguration(Registration, Alpn, ServerSelfSignedCredConfig); + MsQuicConfiguration ServerConfiguration(Registration, "MsQuicTest", ServerSelfSignedCredConfig); TEST_TRUE(ServerConfiguration.IsValid()); MsQuicCredentialConfig ClientCredConfig; - MsQuicConfiguration ClientConfiguration(Registration, Alpn, ClientCredConfig); + MsQuicConfiguration ClientConfiguration(Registration, "MsQuicTest", ClientCredConfig); TEST_TRUE(ClientConfiguration.IsValid()); - { - TestListener Listener(Registration, ListenerAcceptConnection, ServerConfiguration); - TEST_TRUE(Listener.IsValid()); - - QUIC_ADDRESS_FAMILY QuicAddrFamily = (Family == 4) ? QUIC_ADDRESS_FAMILY_INET : QUIC_ADDRESS_FAMILY_INET6; - QuicAddr ServerLocalAddr(QuicAddrFamily); - TEST_QUIC_SUCCEEDED(Listener.Start(Alpn, &ServerLocalAddr.SockAddr)); - TEST_QUIC_SUCCEEDED(Listener.GetLocalAddr(ServerLocalAddr)); - - { - UniquePtr Server; - ServerAcceptContext ServerAcceptCtx((TestConnection**)&Server); - Listener.Context = &ServerAcceptCtx; - - { - TestConnection Client(Registration); - TEST_TRUE(Client.IsValid()); - - TEST_QUIC_SUCCEEDED( - Client.Start( - ClientConfiguration, - QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), - ServerLocalAddr.GetPort())); - - if (!Client.WaitForConnectionComplete()) { - return; - } - TEST_TRUE(Client.GetIsConnected()); + MsQuicAutoAcceptListener Listener(Registration, ServerConfiguration, RebindContext::ConnCallback, &Context); + TEST_QUIC_SUCCEEDED(Listener.GetInitStatus()); + QUIC_ADDRESS_FAMILY QuicAddrFamily = (Family == 4) ? QUIC_ADDRESS_FAMILY_INET : QUIC_ADDRESS_FAMILY_INET6; + QuicAddr ServerLocalAddr(QuicAddrFamily); + TEST_QUIC_SUCCEEDED(Listener.Start("MsQuicTest", &ServerLocalAddr.SockAddr)); + TEST_QUIC_SUCCEEDED(Listener.GetLocalAddr(ServerLocalAddr)); - TEST_NOT_EQUAL(nullptr, Server); - if (!Server->WaitForConnectionComplete()) { - return; - } - TEST_TRUE(Server->GetIsConnected()); + MsQuicConnection Connection(Registration); + TEST_QUIC_SUCCEEDED(Connection.GetInitStatus()); - QuicAddr OrigLocalAddr; - TEST_QUIC_SUCCEEDED(Client.GetLocalAddr(OrigLocalAddr)); - QuicAddr NewLocalAddr(OrigLocalAddr, 1); - CxPlatSleep(100); + TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_TRUE(Connection.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); + TEST_TRUE(Context.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); + TEST_TRUE(Context.Connected); + CxPlatSleep(10); - ReplaceAddressHelper AddrHelper(OrigLocalAddr.SockAddr, NewLocalAddr.SockAddr); - TEST_FALSE(Client.GetIsShutdown()); - Client.SetKeepAlive(25); + QuicAddr OrigLocalAddr; + TEST_QUIC_SUCCEEDED(Connection.GetLocalAddr(OrigLocalAddr)); + ReplaceAddressHelper AddrHelper(OrigLocalAddr.SockAddr); - bool ServerAddressUpdated = false; - uint32_t Try = 0; - do { - if (Try != 0) { - CxPlatSleep(200); - } - QuicAddr ServerRemoteAddr; - TEST_QUIC_SUCCEEDED(Server->GetRemoteAddr(ServerRemoteAddr)); - if (Server->GetPeerAddrChanged() && - QuicAddrCompare(&NewLocalAddr.SockAddr, &ServerRemoteAddr.SockAddr)) { - ServerAddressUpdated = true; - break; - } - } while (++Try <= 3); - TEST_TRUE(ServerAddressUpdated); + AddrHelper.IncrementPort(); + if (KeepAlivePaddingSize) { + Connection.SetKeepAlivePadding(KeepAlivePaddingSize); + } + Connection.SetSettings(MsQuicSettings{}.SetKeepAlive(25)); - Client.Shutdown(QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, QUIC_TEST_NO_ERROR); - if (!Client.WaitForShutdownComplete()) { - return; - } + TEST_TRUE(Context.PeerAddrChangedEvent.WaitTimeout(1000)) + TEST_TRUE(QuicAddrCompare(&AddrHelper.New, &Context.PeerAddr.SockAddr)); - TEST_FALSE(Client.GetPeerClosed()); - TEST_FALSE(Client.GetTransportClosed()); - } - - TEST_TRUE(Server->GetPeerClosed()); - TEST_EQUAL(Server->GetPeerCloseErrorCode(), QUIC_TEST_NO_ERROR); - } - } + Connection.Shutdown(1); } void QuicTestNatAddrRebind( - _In_ int Family + _In_ int Family, + _In_ uint16_t KeepAlivePaddingSize ) { - MsQuicRegistration Registration; + RebindContext Context; + MsQuicRegistration Registration(true); TEST_TRUE(Registration.IsValid()); - MsQuicAlpn Alpn("MsQuicTest"); - - MsQuicSettings Settings; - Settings.SetIdleTimeoutMs(10000); - - MsQuicConfiguration ServerConfiguration(Registration, Alpn, Settings, ServerSelfSignedCredConfig); + MsQuicConfiguration ServerConfiguration(Registration, "MsQuicTest", ServerSelfSignedCredConfig); TEST_TRUE(ServerConfiguration.IsValid()); MsQuicCredentialConfig ClientCredConfig; - MsQuicConfiguration ClientConfiguration(Registration, Alpn, Settings, ClientCredConfig); + MsQuicConfiguration ClientConfiguration(Registration, "MsQuicTest", ClientCredConfig); TEST_TRUE(ClientConfiguration.IsValid()); - { - TestListener Listener(Registration, ListenerAcceptConnection, ServerConfiguration); - TEST_TRUE(Listener.IsValid()); - - QUIC_ADDRESS_FAMILY QuicAddrFamily = (Family == 4) ? QUIC_ADDRESS_FAMILY_INET : QUIC_ADDRESS_FAMILY_INET6; - QuicAddr ServerLocalAddr(QuicAddrFamily); - TEST_QUIC_SUCCEEDED(Listener.Start(Alpn, &ServerLocalAddr.SockAddr)); - TEST_QUIC_SUCCEEDED(Listener.GetLocalAddr(ServerLocalAddr)); - - { - UniquePtr Server; - ServerAcceptContext ServerAcceptCtx((TestConnection**)&Server); - Listener.Context = &ServerAcceptCtx; - - { - TestConnection Client(Registration); - TEST_TRUE(Client.IsValid()); - - TEST_QUIC_SUCCEEDED( - Client.Start( - ClientConfiguration, - QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), - ServerLocalAddr.GetPort())); - - if (!Client.WaitForConnectionComplete()) { - return; - } - TEST_TRUE(Client.GetIsConnected()); - - TEST_NOT_EQUAL(nullptr, Server); - if (!Server->WaitForConnectionComplete()) { - return; - } - TEST_TRUE(Server->GetIsConnected()); + MsQuicAutoAcceptListener Listener(Registration, ServerConfiguration, RebindContext::ConnCallback, &Context); + TEST_QUIC_SUCCEEDED(Listener.GetInitStatus()); + QUIC_ADDRESS_FAMILY QuicAddrFamily = (Family == 4) ? QUIC_ADDRESS_FAMILY_INET : QUIC_ADDRESS_FAMILY_INET6; + QuicAddr ServerLocalAddr(QuicAddrFamily); + TEST_QUIC_SUCCEEDED(Listener.Start("MsQuicTest", &ServerLocalAddr.SockAddr)); + TEST_QUIC_SUCCEEDED(Listener.GetLocalAddr(ServerLocalAddr)); - QuicAddr OrigLocalAddr; - TEST_QUIC_SUCCEEDED(Client.GetLocalAddr(OrigLocalAddr)); - QuicAddr NewLocalAddr(OrigLocalAddr, 1); - NewLocalAddr.IncrementAddr(); - CxPlatSleep(100); + MsQuicConnection Connection(Registration); + TEST_QUIC_SUCCEEDED(Connection.GetInitStatus()); - ReplaceAddressHelper AddrHelper(OrigLocalAddr.SockAddr, NewLocalAddr.SockAddr); - TEST_FALSE(Client.GetIsShutdown()); - Client.SetKeepAlive(25); + TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_TRUE(Connection.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); + TEST_TRUE(Context.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); + TEST_TRUE(Context.Connected); + CxPlatSleep(10); - bool ServerAddressUpdated = false; - uint32_t Try = 0; - do { - if (Try != 0) { - CxPlatSleep(200); - } - QuicAddr ServerRemoteAddr; - TEST_QUIC_SUCCEEDED(Server->GetRemoteAddr(ServerRemoteAddr)); - if (Server->GetPeerAddrChanged() && - QuicAddrCompare(&NewLocalAddr.SockAddr, &ServerRemoteAddr.SockAddr)) { - ServerAddressUpdated = true; - break; - } - } while (++Try <= 3); - TEST_TRUE(ServerAddressUpdated); + QuicAddr OrigLocalAddr; + TEST_QUIC_SUCCEEDED(Connection.GetLocalAddr(OrigLocalAddr)); + ReplaceAddressHelper AddrHelper(OrigLocalAddr.SockAddr, OrigLocalAddr.SockAddr); - Client.Shutdown(QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, QUIC_TEST_NO_ERROR); - if (!Client.WaitForShutdownComplete()) { - return; - } + AddrHelper.IncrementAddr(); + if (KeepAlivePaddingSize) { + Connection.SetKeepAlivePadding(KeepAlivePaddingSize); + } + Connection.SetSettings(MsQuicSettings{}.SetKeepAlive(1)); - TEST_FALSE(Client.GetPeerClosed()); - TEST_FALSE(Client.GetTransportClosed()); - } + TEST_TRUE(Context.PeerAddrChangedEvent.WaitTimeout(1000)) + TEST_TRUE(QuicAddrCompare(&AddrHelper.New, &Context.PeerAddr.SockAddr)); - TEST_TRUE(Server->GetPeerClosed()); - TEST_EQUAL(Server->GetPeerCloseErrorCode(), QUIC_TEST_NO_ERROR); - } - } + Connection.Shutdown(1); } void diff --git a/src/test/lib/TestHelpers.h b/src/test/lib/TestHelpers.h index 614cfa25e8..1fa92c32a3 100644 --- a/src/test/lib/TestHelpers.h +++ b/src/test/lib/TestHelpers.h @@ -524,6 +524,10 @@ struct ReplaceAddressHelper : public DatapathHook { QUIC_ADDR Original; QUIC_ADDR New; + ReplaceAddressHelper(const QUIC_ADDR& OrigAddr) : + Original(OrigAddr), New(OrigAddr) { + DatapathHooks::Instance->AddHook(this); + } ReplaceAddressHelper(const QUIC_ADDR& OrigAddr, const QUIC_ADDR& NewAddr) : Original(OrigAddr), New(NewAddr) { DatapathHooks::Instance->AddHook(this); @@ -531,6 +535,13 @@ struct ReplaceAddressHelper : public DatapathHook ~ReplaceAddressHelper() { DatapathHooks::Instance->RemoveHook(this); } + void IncrementPort() { + CXPLAT_DBG_ASSERT(QuicAddrGetPort(&New) != 0xFFFF); + QuicAddrSetPort(&New, (uint16_t)1 + QuicAddrGetPort(&New)); + } + void IncrementAddr() { + QuicAddrIncrement(&New); + } _IRQL_requires_max_(DISPATCH_LEVEL) BOOLEAN Receive(