Title: [280484] trunk/Source/WebKit
Revision
280484
Author
[email protected]
Date
2021-07-30 11:08:21 -0700 (Fri, 30 Jul 2021)

Log Message

softlink nw_parameters_allow_sharing_port_with_listener
https://bugs.webkit.org/show_bug.cgi?id=228636

Reviewed by Eric Carlson.

* NetworkProcess/webrtc/NetworkRTCUDPSocketCocoa.mm:
(WebKit::NetworkRTCUDPSocketCocoaConnections::createNWConnection):
This helps compiling/running WebKit on older OSes.
Also make use of nw_endpoint_create_host_with_numeric_port to remove the need for string to int conversion.
* Platform/spi/Cocoa/NWParametersSPI.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (280483 => 280484)


--- trunk/Source/WebKit/ChangeLog	2021-07-30 17:46:35 UTC (rev 280483)
+++ trunk/Source/WebKit/ChangeLog	2021-07-30 18:08:21 UTC (rev 280484)
@@ -1,5 +1,18 @@
 2021-07-30  Youenn Fablet  <[email protected]>
 
+        softlink nw_parameters_allow_sharing_port_with_listener
+        https://bugs.webkit.org/show_bug.cgi?id=228636
+
+        Reviewed by Eric Carlson.
+
+        * NetworkProcess/webrtc/NetworkRTCUDPSocketCocoa.mm:
+        (WebKit::NetworkRTCUDPSocketCocoaConnections::createNWConnection):
+        This helps compiling/running WebKit on older OSes.
+        Also make use of nw_endpoint_create_host_with_numeric_port to remove the need for string to int conversion.
+        * Platform/spi/Cocoa/NWParametersSPI.h:
+
+2021-07-30  Youenn Fablet  <[email protected]>
+
         Attribute nw connections to the source application
         https://bugs.webkit.org/show_bug.cgi?id=228641
         <rdar://81039713>

Modified: trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCUDPSocketCocoa.mm (280483 => 280484)


--- trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCUDPSocketCocoa.mm	2021-07-30 17:46:35 UTC (rev 280483)
+++ trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCUDPSocketCocoa.mm	2021-07-30 18:08:21 UTC (rev 280484)
@@ -45,6 +45,9 @@
 SOFT_LINK_CLASS(libnetworkextension, NEHelperTrackerAppInfoRef)
 SOFT_LINK_CLASS(libnetworkextension, NEHelperTrackerDomainContextRef)
 SOFT_LINK(libnetworkextension, NEHelperTrackerGetDisposition, NEHelperTrackerDisposition_t*, (NEHelperTrackerAppInfoRef *app_info_ref, CFArrayRef domains, NEHelperTrackerDomainContextRef *trackerDomainContextRef, CFIndex *trackerDomainIndex), (app_info_ref, domains, trackerDomainContextRef, trackerDomainIndex))
+
+SOFT_LINK_LIBRARY_OPTIONAL(libnetwork)
+SOFT_LINK_OPTIONAL(libnetwork, nw_parameters_allow_sharing_port_with_listener, void, __cdecl, (nw_parameters_t, nw_listener_t))
 #endif
 
 namespace WebKit {
@@ -169,7 +172,7 @@
         auto hostAddress = address.ipaddr().ToString();
         if (address.ipaddr().IsNil())
             hostAddress = address.hostname();
-        auto localEndpoint = adoptNS(nw_endpoint_create_host(hostAddress.c_str(), "0"));
+        auto localEndpoint = adoptNS(nw_endpoint_create_host_with_numeric_port(hostAddress.c_str(), 0));
         m_address = { nw_endpoint_get_hostname(localEndpoint.get()), nw_endpoint_get_port(localEndpoint.get()) };
         nw_parameters_set_local_endpoint(parameters.get(), localEndpoint.get());
     }
@@ -288,15 +291,16 @@
         auto hostAddress = m_address.ipaddr().ToString();
         if (m_address.ipaddr().IsNil())
             hostAddress = m_address.hostname();
-#if defined(NW_HAS_SHARE_LISTENER_PORT) && NW_HAS_SHARE_LISTENER_PORT
-        nw_parameters_allow_sharing_port_with_listener(parameters.get(), m_nwListener.get());
-        auto portString = String::number(m_address.port());
-        auto portValue = portString.utf8().data();
-#else
-        // rdar://80176676: we workaround local loop port reuse by using 0 instead of m_address.port().
-        auto portValue = "0";
+
+        // rdar://80176676: we workaround local loop port reuse by using 0 instead of m_address.port() when nw_parameters_allow_sharing_port_with_listener is not available.
+        uint16_t port = 0;
+#if HAVE(NWPARAMETERS_TRACKER_API)
+        if (nw_parameters_allow_sharing_port_with_listenerPtr()) {
+            nw_parameters_allow_sharing_port_with_listenerPtr()(parameters.get(), m_nwListener.get());
+            port = m_address.port();
+        }
 #endif
-        auto localEndpoint = adoptNS(nw_endpoint_create_host(hostAddress.c_str(), portValue));
+        auto localEndpoint = adoptNS(nw_endpoint_create_host_with_numeric_port(hostAddress.c_str(), port));
         nw_parameters_set_local_endpoint(parameters.get(), localEndpoint.get());
     }
     configureParameters(parameters.get(), remoteAddress.family() == AF_INET ? nw_ip_version_4 : nw_ip_version_6);

Modified: trunk/Source/WebKit/Platform/spi/Cocoa/NWParametersSPI.h (280483 => 280484)


--- trunk/Source/WebKit/Platform/spi/Cocoa/NWParametersSPI.h	2021-07-30 17:46:35 UTC (rev 280483)
+++ trunk/Source/WebKit/Platform/spi/Cocoa/NWParametersSPI.h	2021-07-30 18:08:21 UTC (rev 280484)
@@ -35,6 +35,7 @@
 
 void nw_parameters_set_account_id(nw_parameters_t, const char * account_id);
 void nw_parameters_set_source_application(nw_parameters_t, audit_token_t);
+nw_endpoint_t nw_endpoint_create_host_with_numeric_port(const char* hostname, uint16_t port_host_order);
 
 #if HAVE(NWPARAMETERS_TRACKER_API)
 void nw_parameters_set_is_third_party_web_content(nw_parameters_t, bool is_third_party_web_content);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to