Add ipv6_only to QuicUdpSocketApi::Create.

This is necessary for iOS compatibility - setting IP_PKTINFO on an IPv6 socket will always fail.  ipv6_only will cause IP_PKTINFO to be skipped for IPv6 sockets.

Testing is also expanded to cover forcing IPv6 on all platforms, as well as to ensure that ipv6_only does not cause breakages on other platforms.

Add ipv6_only for quicudpsocketapi::create.  this does not change default behavior.

PiperOrigin-RevId: 313669717
Change-Id: I0e33b5ff94ceb299e69a50976062f04b4a3452bb
diff --git a/quic/core/quic_udp_socket.h b/quic/core/quic_udp_socket.h
index 04f8435..258de08 100644
--- a/quic/core/quic_udp_socket.h
+++ b/quic/core/quic_udp_socket.h
@@ -163,10 +163,14 @@
  public:
   // Creates a non-blocking udp socket, sets the receive/send buffer and enable
   // receiving of self ip addresses on read.
-  // Return kQuicInvalidSocketFd if failed.
+  // If address_family == AF_INET6 and ipv6_only is true, receiving of IPv4 self
+  // addresses is disabled. This is only necessary for IPv6 sockets on iOS - all
+  // other platforms can ignore this parameter. Return kQuicInvalidSocketFd if
+  // failed.
   QuicUdpSocketFd Create(int address_family,
                          int receive_buffer_size,
-                         int send_buffer_size);
+                         int send_buffer_size,
+                         bool ipv6_only = false);
 
   // Closes |fd|. No-op if |fd| equals to kQuicInvalidSocketFd.
   void Destroy(QuicUdpSocketFd fd);
@@ -238,7 +242,8 @@
   bool SetupSocket(QuicUdpSocketFd fd,
                    int address_family,
                    int receive_buffer_size,
-                   int send_buffer_size);
+                   int send_buffer_size,
+                   bool ipv6_only);
   bool EnableReceiveSelfIpAddressForV4(QuicUdpSocketFd fd);
   bool EnableReceiveSelfIpAddressForV6(QuicUdpSocketFd fd);
 };