Changed `QuicCryptoServerConfig::ValidateSourceAddressTokens()`
to take `cached_network_params` as a reference.

PiperOrigin-RevId: 983506580
diff --git a/quiche/quic/core/crypto/quic_crypto_server_config.cc b/quiche/quic/core/crypto/quic_crypto_server_config.cc
index a83871c..53380bf 100644
--- a/quiche/quic/core/crypto/quic_crypto_server_config.cc
+++ b/quiche/quic/core/crypto/quic_crypto_server_config.cc
@@ -1226,7 +1226,7 @@
       if (source_address_token_error == HANDSHAKE_OK) {
         source_address_token_error = ValidateSourceAddressTokens(
             info->source_address_tokens, info->client_ip, info->now,
-            &client_hello_state->cached_network_params);
+            client_hello_state->cached_network_params);
       }
       info->valid_source_address_token =
           (source_address_token_error == HANDSHAKE_OK);
@@ -1726,15 +1726,14 @@
 
 HandshakeFailureReason QuicCryptoServerConfig::ValidateSourceAddressTokens(
     const SourceAddressTokens& source_address_tokens, const QuicIpAddress& ip,
-    QuicWallTime now, CachedNetworkParameters* cached_network_params) const {
+    QuicWallTime now, CachedNetworkParameters& cached_network_params) const {
   HandshakeFailureReason reason =
       SOURCE_ADDRESS_TOKEN_DIFFERENT_IP_ADDRESS_FAILURE;
   for (const SourceAddressToken& token : source_address_tokens.tokens()) {
     reason = ValidateSingleSourceAddressToken(token, ip, now);
     if (reason == HANDSHAKE_OK) {
-      if (cached_network_params != nullptr &&
-          token.has_cached_network_parameters()) {
-        *cached_network_params = token.cached_network_parameters();
+      if (token.has_cached_network_parameters()) {
+        cached_network_params = token.cached_network_parameters();
       }
       break;
     }
diff --git a/quiche/quic/core/crypto/quic_crypto_server_config.h b/quiche/quic/core/crypto/quic_crypto_server_config.h
index 82204a5..5e9c78d 100644
--- a/quiche/quic/core/crypto/quic_crypto_server_config.h
+++ b/quiche/quic/core/crypto/quic_crypto_server_config.h
@@ -429,7 +429,7 @@
   // token contains a CachedNetworkParameters proto.
   HandshakeFailureReason ValidateSourceAddressTokens(
       const SourceAddressTokens& tokens, const QuicIpAddress& ip,
-      QuicWallTime now, CachedNetworkParameters* cached_network_params) const;
+      QuicWallTime now, CachedNetworkParameters& cached_network_params) const;
 
   // Callers retain the ownership of |rejection_observer| which must outlive the
   // config.
diff --git a/quiche/quic/core/crypto/quic_crypto_server_config_test.cc b/quiche/quic/core/crypto/quic_crypto_server_config_test.cc
index 5f7cc48..16c5091 100644
--- a/quiche/quic/core/crypto/quic_crypto_server_config_test.cc
+++ b/quiche/quic/core/crypto/quic_crypto_server_config_test.cc
@@ -182,12 +182,13 @@
   HandshakeFailureReason ValidateSourceAddressTokens(std::string config_id,
                                                      absl::string_view srct,
                                                      const QuicIpAddress& ip) {
-    return ValidateSourceAddressTokens(config_id, srct, ip, nullptr);
+    CachedNetworkParameters dummy;
+    return ValidateSourceAddressTokens(config_id, srct, ip, dummy);
   }
 
   HandshakeFailureReason ValidateSourceAddressTokens(
       std::string config_id, absl::string_view srct, const QuicIpAddress& ip,
-      CachedNetworkParameters* cached_network_params) {
+      CachedNetworkParameters& cached_network_params) {
     return peer_.ValidateSourceAddressTokens(
         config_id, srct, ip, clock_.WallNow(), cached_network_params);
   }
@@ -255,7 +256,7 @@
   EXPECT_THAT(cached_network_params_output,
               Not(SerializedProtoEquals(cached_network_params_input)));
   ValidateSourceAddressTokens(kPrimary, token4_with_cached_network_params, ip4_,
-                              &cached_network_params_output);
+                              cached_network_params_output);
   EXPECT_THAT(cached_network_params_output,
               SerializedProtoEquals(cached_network_params_input));
 }
diff --git a/quiche/quic/core/tls_server_handshaker.cc b/quiche/quic/core/tls_server_handshaker.cc
index ad694d0..c9c1add 100644
--- a/quiche/quic/core/tls_server_handshaker.cc
+++ b/quiche/quic/core/tls_server_handshaker.cc
@@ -407,7 +407,7 @@
   auto cached_network_params = std::make_unique<CachedNetworkParameters>();
   reason = crypto_config_->ValidateSourceAddressTokens(
       tokens, session()->connection()->effective_peer_address().host(),
-      session()->connection()->clock()->WallNow(), cached_network_params.get());
+      session()->connection()->clock()->WallNow(), *cached_network_params);
   if (reason != HANDSHAKE_OK) {
     QUIC_DLOG(WARNING) << "Failed to validate source address token: "
                        << CryptoUtils::HandshakeFailureReasonToString(reason);
diff --git a/quiche/quic/test_tools/quic_crypto_server_config_peer.cc b/quiche/quic/test_tools/quic_crypto_server_config_peer.cc
index ac754f7..1850aa2 100644
--- a/quiche/quic/test_tools/quic_crypto_server_config_peer.cc
+++ b/quiche/quic/test_tools/quic_crypto_server_config_peer.cc
@@ -55,7 +55,7 @@
 
 HandshakeFailureReason QuicCryptoServerConfigPeer::ValidateSourceAddressTokens(
     std::string config_id, absl::string_view srct, const QuicIpAddress& ip,
-    QuicWallTime now, CachedNetworkParameters* cached_network_params) {
+    QuicWallTime now, CachedNetworkParameters& cached_network_params) {
   SourceAddressTokens tokens;
   HandshakeFailureReason reason = server_config_->ParseSourceAddressToken(
       *GetConfig(config_id)->source_address_token_boxer, srct, tokens);
diff --git a/quiche/quic/test_tools/quic_crypto_server_config_peer.h b/quiche/quic/test_tools/quic_crypto_server_config_peer.h
index cfd7756..0330eed 100644
--- a/quiche/quic/test_tools/quic_crypto_server_config_peer.h
+++ b/quiche/quic/test_tools/quic_crypto_server_config_peer.h
@@ -41,7 +41,7 @@
   // Attempts to validate the tokens in |srct|.
   HandshakeFailureReason ValidateSourceAddressTokens(
       std::string config_id, absl::string_view srct, const QuicIpAddress& ip,
-      QuicWallTime now, CachedNetworkParameters* cached_network_params);
+      QuicWallTime now, CachedNetworkParameters& cached_network_params);
 
   // Attempts to validate the single source address token in |token|.
   HandshakeFailureReason ValidateSingleSourceAddressToken(