Skip to content

[Network] Implement Xcode 16.0 beta 1-6 changes. #21075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Network/NWEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ public enum NWParametersExpiredDnsBehavior {
Default = 0,
Allow = 1,
Prohibit = 2,
[Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)]
Persistent = 3,
}

// this maps to `nw_path_status_t` in Network/Headers/path.h (and not the enum from NetworkExtension)
Expand Down
29 changes: 29 additions & 0 deletions src/Network/NWListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,35 @@ public NWListener (NativeHandle handle, bool owns) : base (handle, owns)
return new NWListener (handle, owns: true);
}

#if __MACOS__ && NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("maccatalyst")]
[DllImport (Constants.NetworkLibrary)]
extern static IntPtr nw_listener_create_with_launchd_key (/* nw_parameters_t */ IntPtr nwparameters, /* const char */ IntPtr launchd_key);

/// <summary>Creates an <see cref="NWListener" /> instance from a launchd key.</summary>
/// <param name="parameters">The parameters to use for the listener, including the protocols to use.</param>
/// <param name="launchd_key">The name of the socket entry as specified in the launchd.plist.</param>
/// <returns>A new <see cref="NWListener" /> instance, or null if not successful.</returns>
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("maccatalyst")]
public static NWListener? Create (NWParameters parameters, string launchd_key)
{
if (launchd_key is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (launchd_key));

using var launchd_key_ptr = new TransientString (launchd_key);
var handle = nw_listener_create_with_launchd_key (parameters.GetNonNullHandle (nameof (parameters)), launchd_key_ptr);
if (handle == IntPtr.Zero)
return null;
return new NWListener (handle, owns: true);
}
#endif // __MACOS__ && NET

[DllImport (Constants.NetworkLibrary)]
extern static void nw_listener_set_queue (IntPtr listener, IntPtr queue);

Expand Down
9 changes: 9 additions & 0 deletions src/Network/NWQuicMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ public ushort KeepaliveInterval {
set => nw_quic_set_keepalive_interval (GetCheckedHandle (), value);
}

/// <summary>
/// Set the default keepalive value. The current default is every 20 seconds, but this is subject to change.
/// </summary>
public void SetDefaultKeepAlive ()
{
// #define NW_QUIC_CONNECTION_DEFAULT_KEEPALIVE UINT16_MAX
KeepaliveInterval = ushort.MaxValue;
}

[DllImport (Constants.NetworkLibrary, EntryPoint = "nw_quic_get_application_error_reason")]
static extern IntPtr nw_quic_get_application_error_reason_ptr (OS_nw_protocol_metadata metadata);

Expand Down
1 change: 1 addition & 0 deletions tests/cecil-tests/Documentation.KnownFailures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15330,6 +15330,7 @@ F:Network.NWParametersAttribution.Developer
F:Network.NWParametersAttribution.User
F:Network.NWParametersExpiredDnsBehavior.Allow
F:Network.NWParametersExpiredDnsBehavior.Default
F:Network.NWParametersExpiredDnsBehavior.Persistent
F:Network.NWParametersExpiredDnsBehavior.Prohibit
F:Network.NWPathStatus.Invalid
F:Network.NWPathStatus.Satisfiable
Expand Down
10 changes: 10 additions & 0 deletions tests/monotouch-test/Network/NWListenerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ public void SetNewConnectionGroupHandlerTest ()
});
});
}

#if __MACOS__ && NET
[Test]
public void TestCreateLaunchd ()
{
using var parameters = NWParameters.CreateTcp ();
using var instance = NWListener.Create (parameters, "xamarinlaunchdkey");
Assert.IsNotNull (instance, "Create");
}
#endif
}
}
#endif

This file was deleted.

Loading