Skip to content

Commit

Permalink
[Network] Implement Xcode 16.0 beta 1-6 changes. (#21075)
Browse files Browse the repository at this point in the history
Note: there were no changes in beta 2, beta 3, beta 4, beta 5 or beta 6.
  • Loading branch information
rolfbjarne authored Aug 26, 2024
1 parent adc67f1 commit 0aed4d8
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 1 deletion.
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 @@ -15538,6 +15538,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.

8 comments on commit 0aed4d8

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.