objc2_network_extension/generated/mod.rs
1// This file has been automatically generated by `objc2`'s `header-translator`.
2// DO NOT EDIT
3
4#![allow(unused_imports)]
5#![allow(deprecated)]
6#![allow(non_snake_case)]
7#![allow(non_camel_case_types)]
8#![allow(non_upper_case_globals)]
9#![allow(missing_docs)]
10#![allow(clippy::too_many_arguments)]
11#![allow(clippy::type_complexity)]
12#![allow(clippy::upper_case_acronyms)]
13#![allow(clippy::identity_op)]
14#![allow(clippy::missing_safety_doc)]
15#![allow(clippy::doc_lazy_continuation)]
16#![allow(rustdoc::broken_intra_doc_links)]
17#![allow(rustdoc::bare_urls)]
18#![allow(rustdoc::invalid_html_tags)]
19
20#[link(name = "NetworkExtension", kind = "framework")]
21extern "C" {}
22
23use core::ffi::*;
24use core::ptr::NonNull;
25#[cfg(feature = "dispatch2")]
26use dispatch2::*;
27use objc2::__framework_prelude::*;
28#[cfg(feature = "objc2-accessory-setup-kit")]
29#[cfg(target_os = "ios")]
30use objc2_accessory_setup_kit::*;
31use objc2_foundation::*;
32#[cfg(feature = "objc2-security")]
33use objc2_security::*;
34
35use crate::*;
36
37/// Flow error codes
38///
39/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neappproxyflowerror?language=objc)
40// NS_ENUM
41#[repr(transparent)]
42#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
43pub struct NEAppProxyFlowError(pub NSInteger);
44impl NEAppProxyFlowError {
45 #[doc(alias = "NEAppProxyFlowErrorNotConnected")]
46 pub const NotConnected: Self = Self(1);
47 #[doc(alias = "NEAppProxyFlowErrorPeerReset")]
48 pub const PeerReset: Self = Self(2);
49 #[doc(alias = "NEAppProxyFlowErrorHostUnreachable")]
50 pub const HostUnreachable: Self = Self(3);
51 #[doc(alias = "NEAppProxyFlowErrorInvalidArgument")]
52 pub const InvalidArgument: Self = Self(4);
53 #[doc(alias = "NEAppProxyFlowErrorAborted")]
54 pub const Aborted: Self = Self(5);
55 #[doc(alias = "NEAppProxyFlowErrorRefused")]
56 pub const Refused: Self = Self(6);
57 #[doc(alias = "NEAppProxyFlowErrorTimedOut")]
58 pub const TimedOut: Self = Self(7);
59 #[doc(alias = "NEAppProxyFlowErrorInternal")]
60 pub const Internal: Self = Self(8);
61 #[doc(alias = "NEAppProxyFlowErrorDatagramTooLarge")]
62 pub const DatagramTooLarge: Self = Self(9);
63 #[doc(alias = "NEAppProxyFlowErrorReadAlreadyPending")]
64 pub const ReadAlreadyPending: Self = Self(10);
65}
66
67unsafe impl Encode for NEAppProxyFlowError {
68 const ENCODING: Encoding = NSInteger::ENCODING;
69}
70
71unsafe impl RefEncode for NEAppProxyFlowError {
72 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
73}
74
75extern "C" {
76 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/neappproxyerrordomain?language=objc)
77 pub static NEAppProxyErrorDomain: &'static NSString;
78}
79
80extern_class!(
81 /// The NEAppProxyFlow class is an abstract base class that declares the programmatic interface for a flow of network data.
82 ///
83 /// NEAppProxyFlow is part of NetworkExtension.framework.
84 ///
85 /// Instances of this class are thread safe.
86 ///
87 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neappproxyflow?language=objc)
88 #[unsafe(super(NSObject))]
89 #[derive(Debug, PartialEq, Eq, Hash)]
90 pub struct NEAppProxyFlow;
91);
92
93extern_conformance!(
94 unsafe impl NSObjectProtocol for NEAppProxyFlow {}
95);
96
97impl NEAppProxyFlow {
98 extern_methods!(
99 #[cfg(feature = "block2")]
100 /// This function is used by an NEProvider implementation to indicate that it is ready to handle flow data.
101 ///
102 /// Parameter `localEndpoint`: The address and port that should be used as the local endpoint of the socket associated with this flow. If the source application already specified a local endpoint by binding the socket then this parameter is ignored.
103 ///
104 /// Parameter `completionHandler`: A block that is called when the process of opening flow is complete. A nil value passed to this block indicates that the flow was opened successfully. A non-nil NSError value indicates that the flow failed to open successfully.
105 #[deprecated]
106 #[unsafe(method(openWithLocalEndpoint:completionHandler:))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn openWithLocalEndpoint_completionHandler(
109 &self,
110 local_endpoint: Option<&NWHostEndpoint>,
111 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
112 );
113
114 /// This function is used by an NEProvider implementation to indicate that it does not want to receive any more data from the flow.
115 ///
116 /// Parameter `error`: An error in NEAppProxyErrorDomain that should be passed to the flow's source application.
117 #[unsafe(method(closeReadWithError:))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn closeReadWithError(&self, error: Option<&NSError>);
120
121 /// This functions is used by an NEProvider implementation to indicate that it does not have any more data to write to the flow.
122 ///
123 /// Parameter `error`: An error in NEAppProxyErrorDomain that should be passed to the flow's source application.
124 #[unsafe(method(closeWriteWithError:))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn closeWriteWithError(&self, error: Option<&NSError>);
127
128 /// An NEFlowMetaData object containing meta data for the flow.
129 #[unsafe(method(metaData))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn metaData(&self) -> Retained<NEFlowMetaData>;
132
133 /// If the flow was created by passing a hostname to a "connect by name" API such as NSURLSession or Network.framework, this property is set to the
134 /// remote hostname.
135 #[unsafe(method(remoteHostname))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn remoteHostname(&self) -> Option<Retained<NSString>>;
138
139 /// YES if the flow was bound by the application to a specific interface (contained in the networkInterface property), NO otherwise.
140 #[unsafe(method(isBound))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn isBound(&self) -> bool;
143 );
144}
145
146/// Methods declared on superclass `NSObject`.
147impl NEAppProxyFlow {
148 extern_methods!(
149 #[unsafe(method(init))]
150 #[unsafe(method_family = init)]
151 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
152
153 #[unsafe(method(new))]
154 #[unsafe(method_family = new)]
155 pub unsafe fn new() -> Retained<Self>;
156 );
157}
158
159/// Provider stop reasons
160///
161/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neproviderstopreason?language=objc)
162// NS_ENUM
163#[repr(transparent)]
164#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
165pub struct NEProviderStopReason(pub NSInteger);
166impl NEProviderStopReason {
167 #[doc(alias = "NEProviderStopReasonNone")]
168 pub const None: Self = Self(0);
169 #[doc(alias = "NEProviderStopReasonUserInitiated")]
170 pub const UserInitiated: Self = Self(1);
171 #[doc(alias = "NEProviderStopReasonProviderFailed")]
172 pub const ProviderFailed: Self = Self(2);
173 #[doc(alias = "NEProviderStopReasonNoNetworkAvailable")]
174 pub const NoNetworkAvailable: Self = Self(3);
175 #[doc(alias = "NEProviderStopReasonUnrecoverableNetworkChange")]
176 pub const UnrecoverableNetworkChange: Self = Self(4);
177 #[doc(alias = "NEProviderStopReasonProviderDisabled")]
178 pub const ProviderDisabled: Self = Self(5);
179 #[doc(alias = "NEProviderStopReasonAuthenticationCanceled")]
180 pub const AuthenticationCanceled: Self = Self(6);
181 #[doc(alias = "NEProviderStopReasonConfigurationFailed")]
182 pub const ConfigurationFailed: Self = Self(7);
183 #[doc(alias = "NEProviderStopReasonIdleTimeout")]
184 pub const IdleTimeout: Self = Self(8);
185 #[doc(alias = "NEProviderStopReasonConfigurationDisabled")]
186 pub const ConfigurationDisabled: Self = Self(9);
187 #[doc(alias = "NEProviderStopReasonConfigurationRemoved")]
188 pub const ConfigurationRemoved: Self = Self(10);
189 #[doc(alias = "NEProviderStopReasonSuperceded")]
190 pub const Superceded: Self = Self(11);
191 #[doc(alias = "NEProviderStopReasonUserLogout")]
192 pub const UserLogout: Self = Self(12);
193 #[doc(alias = "NEProviderStopReasonUserSwitch")]
194 pub const UserSwitch: Self = Self(13);
195 #[doc(alias = "NEProviderStopReasonConnectionFailed")]
196 pub const ConnectionFailed: Self = Self(14);
197 #[doc(alias = "NEProviderStopReasonSleep")]
198 pub const Sleep: Self = Self(15);
199 #[doc(alias = "NEProviderStopReasonAppUpdate")]
200 pub const AppUpdate: Self = Self(16);
201 #[doc(alias = "NEProviderStopReasonInternalError")]
202 pub const InternalError: Self = Self(17);
203}
204
205unsafe impl Encode for NEProviderStopReason {
206 const ENCODING: Encoding = NSInteger::ENCODING;
207}
208
209unsafe impl RefEncode for NEProviderStopReason {
210 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
211}
212
213extern_class!(
214 /// The NEProvider class declares the programmatic interface that is common for all Network Extension providers.
215 ///
216 /// See the sub classes of NEProvider for more details. Developers of Network Extension providers should create sub classes of the sub classes of NEProvider.
217 ///
218 /// Instances of this class are thread safe.
219 ///
220 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neprovider?language=objc)
221 #[unsafe(super(NSObject))]
222 #[derive(Debug, PartialEq, Eq, Hash)]
223 pub struct NEProvider;
224);
225
226extern_conformance!(
227 unsafe impl NSObjectProtocol for NEProvider {}
228);
229
230impl NEProvider {
231 extern_methods!(
232 #[cfg(feature = "block2")]
233 /// This function is called by the framework when the system is about to go to sleep. Subclass developers can override this method to implement custom behavior such as closing connections or pausing some network activity.
234 ///
235 /// Parameter `completionHandler`: When the method is finished handling the sleep event it must execute this completion handler.
236 #[unsafe(method(sleepWithCompletionHandler:))]
237 #[unsafe(method_family = none)]
238 pub unsafe fn sleepWithCompletionHandler(
239 &self,
240 completion_handler: &block2::DynBlock<dyn Fn()>,
241 );
242
243 /// This function is called by the framework immediately after the system wakes up from sleep. Subclass developers can override this method to implement custom behavior such as re-establishing connections or resuming some network activity.
244 #[unsafe(method(wake))]
245 #[unsafe(method_family = none)]
246 pub unsafe fn wake(&self);
247
248 /// This function can be called by subclass implementations to create a TCP connection to a given network endpoint. This function should not be overridden by subclasses.
249 ///
250 /// Parameter `remoteEndpoint`: An NWEndpoint object that specifies the remote network endpoint to connect to.
251 ///
252 /// Parameter `enableTLS`: A flag indicating if a TLS session should be negotiated on the connection.
253 ///
254 /// Parameter `TLSParameters`: A set of optional TLS parameters. Only valid if enableTLS is YES. If TLSParameters is nil, the default system parameters will be used for TLS negotiation.
255 ///
256 /// Parameter `delegate`: An object to use as the connections delegate. This object should conform to the NWTCPConnectionAuthenticationDelegate protocol.
257 ///
258 /// Returns: An NWTCPConnection object.
259 ///
260 /// # Safety
261 ///
262 /// `delegate` should be of the correct type.
263 #[deprecated = "Use nw_connection_t in Network framework instead"]
264 #[unsafe(method(createTCPConnectionToEndpoint:enableTLS:TLSParameters:delegate:))]
265 #[unsafe(method_family = none)]
266 pub unsafe fn createTCPConnectionToEndpoint_enableTLS_TLSParameters_delegate(
267 &self,
268 remote_endpoint: &NWEndpoint,
269 enable_tls: bool,
270 tls_parameters: Option<&NWTLSParameters>,
271 delegate: Option<&AnyObject>,
272 ) -> Retained<NWTCPConnection>;
273
274 /// This function can be called by subclass implementations to create a UDP session between a local network endpoint and a remote network endpoint. This function should not be overridden by subclasses.
275 ///
276 /// Parameter `remoteEndpoint`: An NWEndpoint object that specifies the remote endpoint to which UDP datagrams will be sent by the UDP session.
277 ///
278 /// Parameter `localEndpoint`: An NWHostEndpoint object that specifies the local IP address endpoint to use as the source endpoint of the UDP session.
279 ///
280 /// Returns: An NWUDPSession object.
281 #[deprecated = "Use nw_connection_t in Network framework instead"]
282 #[unsafe(method(createUDPSessionToEndpoint:fromEndpoint:))]
283 #[unsafe(method_family = none)]
284 pub unsafe fn createUDPSessionToEndpoint_fromEndpoint(
285 &self,
286 remote_endpoint: &NWEndpoint,
287 local_endpoint: Option<&NWHostEndpoint>,
288 ) -> Retained<NWUDPSession>;
289
290 #[cfg(feature = "block2")]
291 /// This method can be called by subclass implementations to display a message to the user.
292 ///
293 /// Parameter `message`: The message to be displayed.
294 ///
295 /// Parameter `completionHandler`: A block that is executed when the user acknowledges the message. If this method is called on a NEFilterDataProvider instance or the message cannot be displayed, then the completion handler block will be executed immediately with success parameter set to NO. If the message was successfully displayed to the user, then the completion handler block is executed with the success parameter set to YES when the user dismisses the message.
296 #[deprecated]
297 #[unsafe(method(displayMessage:completionHandler:))]
298 #[unsafe(method_family = none)]
299 pub unsafe fn displayMessage_completionHandler(
300 &self,
301 message: &NSString,
302 completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
303 );
304
305 /// Start the Network Extension machinery in a system extension (.system bundle). This class method will cause the calling system extension to start handling
306 /// requests from nesessionmanager to instantiate appropriate NEProvider sub-class instances. The system extension must declare a mapping of Network Extension extension points to
307 /// NEProvider sub-class instances in its Info.plist:
308 /// Key: NetworkExtension
309 /// Type: Dictionary containing information about the NetworkExtension capabilities of the system extension.
310 ///
311 /// Key: NEProviderClasses
312 /// Type: Dictionary mapping NetworkExtension extension point identifiers to NEProvider sub-classes
313 ///
314 /// Example:
315 ///
316 /// <key
317 /// >NetworkExtension
318 /// </key
319 /// >
320 /// <dict
321 /// >
322 /// <key
323 /// >NEProviderClasses
324 /// </key
325 /// >
326 /// <dict
327 /// >
328 /// <key
329 /// >com.apple.networkextension.app-proxy
330 /// </key
331 /// >
332 /// <string
333 /// >$(PRODUCT_MODULE_NAME).AppProxyProvider
334 /// </string
335 /// >
336 /// <key
337 /// >com.apple.networkextension.filter-data
338 /// </key
339 /// >
340 /// <string
341 /// >$(PRODUCT_MODULE_NAME).FilterDataProvider
342 /// </string
343 /// >
344 /// </dict
345 /// >
346 /// </dict
347 /// >
348 ///
349 /// This method should be called as early as possible after the system extension starts.
350 #[unsafe(method(startSystemExtensionMode))]
351 #[unsafe(method_family = none)]
352 pub unsafe fn startSystemExtensionMode();
353
354 /// The current default path for connections created by the provider. Use KVO to watch for network changes.
355 #[deprecated = "Use nw_path_monitor_t in Network framework instead"]
356 #[unsafe(method(defaultPath))]
357 #[unsafe(method_family = none)]
358 pub unsafe fn defaultPath(&self) -> Option<Retained<NWPath>>;
359 );
360}
361
362/// Methods declared on superclass `NSObject`.
363impl NEProvider {
364 extern_methods!(
365 #[unsafe(method(init))]
366 #[unsafe(method_family = init)]
367 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
368
369 #[unsafe(method(new))]
370 #[unsafe(method_family = new)]
371 pub unsafe fn new() -> Retained<Self>;
372 );
373}
374
375/// Tunnel Provider error codes
376///
377/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/netunnelprovidererror?language=objc)
378// NS_ENUM
379#[repr(transparent)]
380#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
381pub struct NETunnelProviderError(pub NSInteger);
382impl NETunnelProviderError {
383 #[doc(alias = "NETunnelProviderErrorNetworkSettingsInvalid")]
384 pub const NetworkSettingsInvalid: Self = Self(1);
385 #[doc(alias = "NETunnelProviderErrorNetworkSettingsCanceled")]
386 pub const NetworkSettingsCanceled: Self = Self(2);
387 #[doc(alias = "NETunnelProviderErrorNetworkSettingsFailed")]
388 pub const NetworkSettingsFailed: Self = Self(3);
389}
390
391unsafe impl Encode for NETunnelProviderError {
392 const ENCODING: Encoding = NSInteger::ENCODING;
393}
394
395unsafe impl RefEncode for NETunnelProviderError {
396 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
397}
398
399/// Network traffic routing methods.
400///
401/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/netunnelproviderroutingmethod?language=objc)
402// NS_ENUM
403#[repr(transparent)]
404#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
405pub struct NETunnelProviderRoutingMethod(pub NSInteger);
406impl NETunnelProviderRoutingMethod {
407 #[doc(alias = "NETunnelProviderRoutingMethodDestinationIP")]
408 pub const DestinationIP: Self = Self(1);
409 #[doc(alias = "NETunnelProviderRoutingMethodSourceApplication")]
410 pub const SourceApplication: Self = Self(2);
411 #[doc(alias = "NETunnelProviderRoutingMethodNetworkRule")]
412 pub const NetworkRule: Self = Self(3);
413}
414
415unsafe impl Encode for NETunnelProviderRoutingMethod {
416 const ENCODING: Encoding = NSInteger::ENCODING;
417}
418
419unsafe impl RefEncode for NETunnelProviderRoutingMethod {
420 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
421}
422
423extern "C" {
424 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/netunnelprovidererrordomain?language=objc)
425 pub static NETunnelProviderErrorDomain: &'static NSString;
426}
427
428extern_class!(
429 /// The NETunnelProvider class declares the programmatic interface for an object that provides a network tunnel service.
430 ///
431 /// Instances of this class are thread safe.
432 ///
433 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/netunnelprovider?language=objc)
434 #[unsafe(super(NEProvider, NSObject))]
435 #[derive(Debug, PartialEq, Eq, Hash)]
436 pub struct NETunnelProvider;
437);
438
439extern_conformance!(
440 unsafe impl NSObjectProtocol for NETunnelProvider {}
441);
442
443impl NETunnelProvider {
444 extern_methods!(
445 #[cfg(feature = "block2")]
446 /// This function is called by the framework when the container app sends a message to the provider. Subclasses should override this method to handle the message and optionally send a response.
447 ///
448 /// Parameter `messageData`: An NSData object containing the message sent by the container app.
449 ///
450 /// Parameter `completionHandler`: A block that the method can execute to send a response to the container app. If this parameter is non-nil then the method implementation should always execute the block. If this parameter is nil then the method implementation should treat this as an indication that the container app is not expecting a response.
451 #[unsafe(method(handleAppMessage:completionHandler:))]
452 #[unsafe(method_family = none)]
453 pub unsafe fn handleAppMessage_completionHandler(
454 &self,
455 message_data: &NSData,
456 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSData)>>,
457 );
458
459 #[cfg(feature = "block2")]
460 /// This function is called by tunnel provider implementations to set the network settings of the tunnel, including IP routes, DNS servers, and virtual interface addresses depending on the tunnel type. Subclasses should not override this method. This method can be called multiple times during the lifetime of a particular tunnel. It is not necessary to call this function with nil to clear out the existing settings before calling this function with a non-nil configuration.
461 ///
462 /// Parameter `tunnelNetworkSettings`: An NETunnelNetworkSettings object containing all of the desired network settings for the tunnel. Pass nil to clear out the current network settings.
463 ///
464 /// Parameter `completionHandler`: A block that will be called by the framework when the process of setting or clearing the network settings is complete. If an error occurred during the process of setting or clearing the IP network settings then a non-nill NSError object will be passed to this block containing error details.
465 #[unsafe(method(setTunnelNetworkSettings:completionHandler:))]
466 #[unsafe(method_family = none)]
467 pub unsafe fn setTunnelNetworkSettings_completionHandler(
468 &self,
469 tunnel_network_settings: Option<&NETunnelNetworkSettings>,
470 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
471 );
472
473 /// An NEVPNProtocol object containing the provider's current configuration. The value of this property may change during the lifetime of the tunnel provided by this NETunnelProvider, KVO can be used to detect when changes occur. For different protocol types, this property will contain the corresponding subclass. For NEVPNProtocolTypePlugin protocol type, this property will contain the NETunnelProviderProtocol subclass. For NEVPNProtocolTypeIKEv2 protocol type, this property will contain the NEVPNProtocolIKEv2 subclass.
474 #[unsafe(method(protocolConfiguration))]
475 #[unsafe(method_family = none)]
476 pub unsafe fn protocolConfiguration(&self) -> Retained<NEVPNProtocol>;
477
478 /// An array of NEAppRule objects specifying which applications are currently being routed through the tunnel provided by this NETunnelProvider. If application-based routing is not enabled for the tunnel, then this property is set to nil.
479 #[unsafe(method(appRules))]
480 #[unsafe(method_family = none)]
481 pub unsafe fn appRules(&self) -> Option<Retained<NSArray<NEAppRule>>>;
482
483 /// The method by which network traffic is routed to the tunnel. The default is NETunnelProviderRoutingMethodDestinationIP.
484 #[unsafe(method(routingMethod))]
485 #[unsafe(method_family = none)]
486 pub unsafe fn routingMethod(&self) -> NETunnelProviderRoutingMethod;
487
488 /// A flag that indicates to the framework if this NETunnelProvider is currently re-establishing the tunnel. Setting this flag will cause the session status visible to the user to change to "Reasserting". Clearing this flag will change the user-visible status of the session back to "Connected". Setting and clearing this flag only has an effect if the session is in the "Connected" state.
489 #[unsafe(method(reasserting))]
490 #[unsafe(method_family = none)]
491 pub unsafe fn reasserting(&self) -> bool;
492
493 /// Setter for [`reasserting`][Self::reasserting].
494 #[unsafe(method(setReasserting:))]
495 #[unsafe(method_family = none)]
496 pub unsafe fn setReasserting(&self, reasserting: bool);
497 );
498}
499
500/// Methods declared on superclass `NSObject`.
501impl NETunnelProvider {
502 extern_methods!(
503 #[unsafe(method(init))]
504 #[unsafe(method_family = init)]
505 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
506
507 #[unsafe(method(new))]
508 #[unsafe(method_family = new)]
509 pub unsafe fn new() -> Retained<Self>;
510 );
511}
512
513extern_class!(
514 /// The NEAppProxyProvider class declares the programmatic interface for an object that implements the client side of a custom network proxy solution.
515 ///
516 /// NEAppProxyProvider is part of NetworkExtension.framework
517 ///
518 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neappproxyprovider?language=objc)
519 #[unsafe(super(NETunnelProvider, NEProvider, NSObject))]
520 #[derive(Debug, PartialEq, Eq, Hash)]
521 pub struct NEAppProxyProvider;
522);
523
524extern_conformance!(
525 unsafe impl NSObjectProtocol for NEAppProxyProvider {}
526);
527
528impl NEAppProxyProvider {
529 extern_methods!(
530 #[cfg(feature = "block2")]
531 /// This function is called by the framework when a new proxy instance is being created. Subclasses must override this method to perform whatever steps are necessary to ready the proxy for handling flows of network data.
532 ///
533 /// Parameter `options`: A dictionary containing keys and values passed by the provider's containing app. If the containing app did not start the proxy then this parameter will be nil.
534 ///
535 /// Parameter `completionHandler`: A block that must be called when the process of starting the proxy is complete. If the proxy cannot be started then the subclass' implementation of this method must pass a non-nil NSError object to this block. A value of nil passed to the completion handler indicates that the proxy was successfully started.
536 ///
537 /// # Safety
538 ///
539 /// `options` generic should be of the correct type.
540 #[unsafe(method(startProxyWithOptions:completionHandler:))]
541 #[unsafe(method_family = none)]
542 pub unsafe fn startProxyWithOptions_completionHandler(
543 &self,
544 options: Option<&NSDictionary<NSString, AnyObject>>,
545 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
546 );
547
548 #[cfg(feature = "block2")]
549 /// This function is called by the framework when the proxy is being stopped. Subclasses must override this method to perform whatever steps are necessary to stop the proxy.
550 ///
551 /// Parameter `reason`: An NEProviderStopReason indicating why the proxy is being stopped.
552 ///
553 /// Parameter `completionHandler`: A block that must be called when the proxy is completely stopped.
554 #[unsafe(method(stopProxyWithReason:completionHandler:))]
555 #[unsafe(method_family = none)]
556 pub unsafe fn stopProxyWithReason_completionHandler(
557 &self,
558 reason: NEProviderStopReason,
559 completion_handler: &block2::DynBlock<dyn Fn()>,
560 );
561
562 /// This function is called by proxy provider implementations to stop the proxy when a network error is encountered that renders the proxy no longer viable. Subclasses should not override this method.
563 ///
564 /// Parameter `error`: An NSError object containing details about the error that the proxy provider implementation encountered.
565 #[unsafe(method(cancelProxyWithError:))]
566 #[unsafe(method_family = none)]
567 pub unsafe fn cancelProxyWithError(&self, error: Option<&NSError>);
568
569 /// This function is called by the framework to deliver a new network data flow to the proxy provider implementation. Subclasses must override this method to perform whatever steps are necessary to ready the proxy to receive data from the flow. The proxy provider implementation indicates that the proxy is ready to handle flow data by calling -[NEAppProxyFlow openWithLocalFlowEndpoint:completionHandler:] on the flow. If the proxy implementation decides to not handle the flow and instead terminate it, the subclass implementation of this method should return NO. If the proxy implementation decides to handle the flow, the subclass implementation of this method should return YES. In this case the proxy implementation is responsible for retaining the NEAppProxyFlow object.
570 ///
571 /// Parameter `flow`: The new flow
572 ///
573 /// Returns: YES if the proxy implementation has retained the flow and intends to handle the flow data. NO if the proxy implementation has not retained the flow and will not handle the flow data. In NETransparentProxyProvider sub-classes returning NO causes the flow to be handled by the networking stack without any proxy. In all other cases the flow is terminated when NO is returned.
574 #[unsafe(method(handleNewFlow:))]
575 #[unsafe(method_family = none)]
576 pub unsafe fn handleNewFlow(&self, flow: &NEAppProxyFlow) -> bool;
577
578 /// This function is called by the framework to deliver a new UDP data flow to the proxy provider implementation. Subclasses can override this method to perform whatever steps are necessary to ready the proxy to receive
579 /// data from the flow. The proxy provider implementation indicates that the proxy is ready to handle flow data by calling -[NEAppProxyFlow openWithLocalEndpoint:completionHandler:] on the flow. If the proxy implementation decides
580 /// to not handle the flow and instead terminate it, the subclass implementation of this method should return NO. If the proxy implementation decides to handle the flow, the subclass implementation of this method should return YES.
581 /// In this case the proxy implementation is responsible for retaining the NEAppProxyUDPFlow object.
582 /// The default implementation of this method calls -[NEAppProxyProvider handleNewFlow:] and returns its result.
583 ///
584 /// Parameter `flow`: The new UDP flow
585 ///
586 /// Parameter `remoteEndpoint`: The initial remote endpoint provided by the proxied app when the flow was opened.
587 ///
588 /// Returns: YES if the proxy implementation has retained the flow and intends to handle the flow data. NO if the proxy implementation has not retained the flow and will not handle the flow data. In NETransparentProxyProvider sub-classes returning NO causes the flow to be handled by the networking stack without any proxy. In all other cases the flow is terminated when NO is returned.
589 #[deprecated]
590 #[unsafe(method(handleNewUDPFlow:initialRemoteEndpoint:))]
591 #[unsafe(method_family = none)]
592 pub unsafe fn handleNewUDPFlow_initialRemoteEndpoint(
593 &self,
594 flow: &NEAppProxyUDPFlow,
595 remote_endpoint: &NWEndpoint,
596 ) -> bool;
597 );
598}
599
600/// Methods declared on superclass `NSObject`.
601impl NEAppProxyProvider {
602 extern_methods!(
603 #[unsafe(method(init))]
604 #[unsafe(method_family = init)]
605 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
606
607 #[unsafe(method(new))]
608 #[unsafe(method_family = new)]
609 pub unsafe fn new() -> Retained<Self>;
610 );
611}
612
613/// VPN error codes
614///
615/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnerror?language=objc)
616// NS_ENUM
617#[repr(transparent)]
618#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
619pub struct NEVPNError(pub NSInteger);
620impl NEVPNError {
621 #[doc(alias = "NEVPNErrorConfigurationInvalid")]
622 pub const ConfigurationInvalid: Self = Self(1);
623 #[doc(alias = "NEVPNErrorConfigurationDisabled")]
624 pub const ConfigurationDisabled: Self = Self(2);
625 #[doc(alias = "NEVPNErrorConnectionFailed")]
626 pub const ConnectionFailed: Self = Self(3);
627 #[doc(alias = "NEVPNErrorConfigurationStale")]
628 pub const ConfigurationStale: Self = Self(4);
629 #[doc(alias = "NEVPNErrorConfigurationReadWriteFailed")]
630 pub const ConfigurationReadWriteFailed: Self = Self(5);
631 #[doc(alias = "NEVPNErrorConfigurationUnknown")]
632 pub const ConfigurationUnknown: Self = Self(6);
633}
634
635unsafe impl Encode for NEVPNError {
636 const ENCODING: Encoding = NSInteger::ENCODING;
637}
638
639unsafe impl RefEncode for NEVPNError {
640 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
641}
642
643extern "C" {
644 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnerrordomain?language=objc)
645 pub static NEVPNErrorDomain: &'static NSString;
646}
647
648extern "C" {
649 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnconfigurationchangenotification?language=objc)
650 pub static NEVPNConfigurationChangeNotification: &'static NSString;
651}
652
653extern_class!(
654 /// The NEVPNManager class declares the programmatic interface for an object that manages Virtual Private Network (VPN) configurations.
655 ///
656 /// NEVPNManager declares methods and properties for configuring and controlling a VPN.
657 ///
658 /// Instances of this class are thread safe.
659 ///
660 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnmanager?language=objc)
661 #[unsafe(super(NSObject))]
662 #[derive(Debug, PartialEq, Eq, Hash)]
663 pub struct NEVPNManager;
664);
665
666extern_conformance!(
667 unsafe impl NSObjectProtocol for NEVPNManager {}
668);
669
670impl NEVPNManager {
671 extern_methods!(
672 /// Returns: The singleton NEVPNManager object for the calling process.
673 #[unsafe(method(sharedManager))]
674 #[unsafe(method_family = none)]
675 pub unsafe fn sharedManager() -> Retained<NEVPNManager>;
676
677 #[cfg(feature = "block2")]
678 /// This function loads the current VPN configuration from the caller's VPN preferences.
679 ///
680 /// Parameter `completionHandler`: A block that will be called on the main thread when the load operation is completed. The NSError passed to this block will be nil if the load operation succeeded, non-nil otherwise.
681 #[unsafe(method(loadFromPreferencesWithCompletionHandler:))]
682 #[unsafe(method_family = none)]
683 pub unsafe fn loadFromPreferencesWithCompletionHandler(
684 &self,
685 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
686 );
687
688 #[cfg(feature = "block2")]
689 /// This function removes the VPN configuration from the caller's VPN preferences. If the VPN is enabled, has VPN On Demand enabled, and has VPN On Demand rules, the VPN is disabled and the VPN On Demand rules are de-activated.
690 ///
691 /// Parameter `completionHandler`: A block that will be called on the main thread when the remove operation is completed. The NSError passed to this block will be nil if the remove operation succeeded, non-nil otherwise.
692 #[unsafe(method(removeFromPreferencesWithCompletionHandler:))]
693 #[unsafe(method_family = none)]
694 pub unsafe fn removeFromPreferencesWithCompletionHandler(
695 &self,
696 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
697 );
698
699 #[cfg(feature = "block2")]
700 /// This function saves the VPN configuration in the caller's VPN preferences. If the VPN is enabled, has VPN On Demand enabled, and has VPN On Demand rules, the VPN On Demand rules are activated.
701 ///
702 ///
703 /// Parameter `completionHandler`: A block that will be called on the main thread when the save operation is completed. The NSError passed to this block will be nil if the save operation succeeded, non-nil otherwise.
704 #[unsafe(method(saveToPreferencesWithCompletionHandler:))]
705 #[unsafe(method_family = none)]
706 pub unsafe fn saveToPreferencesWithCompletionHandler(
707 &self,
708 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
709 );
710
711 #[cfg(feature = "objc2-security")]
712 /// This function sets an authorization object that can be used to obtain the authorization rights necessary to modify the system VPN configuration.
713 ///
714 /// Parameter `authorization`: The AuthorizationRef to use to obtain rights.
715 ///
716 /// # Safety
717 ///
718 /// `authorization` must be a valid pointer.
719 #[unsafe(method(setAuthorization:))]
720 #[unsafe(method_family = none)]
721 pub unsafe fn setAuthorization(&self, authorization: AuthorizationRef);
722
723 /// An array of NEOnDemandRule objects.
724 #[unsafe(method(onDemandRules))]
725 #[unsafe(method_family = none)]
726 pub unsafe fn onDemandRules(&self) -> Option<Retained<NSArray<NEOnDemandRule>>>;
727
728 /// Setter for [`onDemandRules`][Self::onDemandRules].
729 ///
730 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
731 #[unsafe(method(setOnDemandRules:))]
732 #[unsafe(method_family = none)]
733 pub unsafe fn setOnDemandRules(&self, on_demand_rules: Option<&NSArray<NEOnDemandRule>>);
734
735 /// Toggles VPN On Demand.
736 #[unsafe(method(isOnDemandEnabled))]
737 #[unsafe(method_family = none)]
738 pub unsafe fn isOnDemandEnabled(&self) -> bool;
739
740 /// Setter for [`isOnDemandEnabled`][Self::isOnDemandEnabled].
741 #[unsafe(method(setOnDemandEnabled:))]
742 #[unsafe(method_family = none)]
743 pub unsafe fn setOnDemandEnabled(&self, on_demand_enabled: bool);
744
745 /// A string containing a description of the VPN.
746 #[unsafe(method(localizedDescription))]
747 #[unsafe(method_family = none)]
748 pub unsafe fn localizedDescription(&self) -> Option<Retained<NSString>>;
749
750 /// Setter for [`localizedDescription`][Self::localizedDescription].
751 ///
752 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
753 #[unsafe(method(setLocalizedDescription:))]
754 #[unsafe(method_family = none)]
755 pub unsafe fn setLocalizedDescription(&self, localized_description: Option<&NSString>);
756
757 /// An NEVPNProtocol object containing the protocol-specific portion of the VPN configuration.
758 #[deprecated]
759 #[unsafe(method(protocol))]
760 #[unsafe(method_family = none)]
761 pub unsafe fn protocol(&self) -> Option<Retained<NEVPNProtocol>>;
762
763 /// Setter for [`protocol`][Self::protocol].
764 #[deprecated]
765 #[unsafe(method(setProtocol:))]
766 #[unsafe(method_family = none)]
767 pub unsafe fn setProtocol(&self, protocol: Option<&NEVPNProtocol>);
768
769 /// An NEVPNProtocol object containing the protocol-specific portion of the VPN configuration.
770 #[unsafe(method(protocolConfiguration))]
771 #[unsafe(method_family = none)]
772 pub unsafe fn protocolConfiguration(&self) -> Option<Retained<NEVPNProtocol>>;
773
774 /// Setter for [`protocolConfiguration`][Self::protocolConfiguration].
775 #[unsafe(method(setProtocolConfiguration:))]
776 #[unsafe(method_family = none)]
777 pub unsafe fn setProtocolConfiguration(
778 &self,
779 protocol_configuration: Option<&NEVPNProtocol>,
780 );
781
782 /// The NEVPNConnection object used for controlling the VPN tunnel.
783 #[unsafe(method(connection))]
784 #[unsafe(method_family = none)]
785 pub unsafe fn connection(&self) -> Retained<NEVPNConnection>;
786
787 /// Toggles the enabled status of the VPN. Setting this property will disable VPN configurations of other apps. This property will be set to NO when other VPN configurations are enabled.
788 #[unsafe(method(isEnabled))]
789 #[unsafe(method_family = none)]
790 pub unsafe fn isEnabled(&self) -> bool;
791
792 /// Setter for [`isEnabled`][Self::isEnabled].
793 #[unsafe(method(setEnabled:))]
794 #[unsafe(method_family = none)]
795 pub unsafe fn setEnabled(&self, enabled: bool);
796 );
797}
798
799/// Methods declared on superclass `NSObject`.
800impl NEVPNManager {
801 extern_methods!(
802 #[unsafe(method(init))]
803 #[unsafe(method_family = init)]
804 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
805
806 #[unsafe(method(new))]
807 #[unsafe(method_family = new)]
808 pub unsafe fn new() -> Retained<Self>;
809 );
810}
811
812extern_class!(
813 /// The NETunnelProviderManager class declares the programmatic interface for an object that is used to configure and control network tunnels provided by NETunnelProviders.
814 ///
815 /// Instances of this class are thread safe.
816 ///
817 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/netunnelprovidermanager?language=objc)
818 #[unsafe(super(NEVPNManager, NSObject))]
819 #[derive(Debug, PartialEq, Eq, Hash)]
820 pub struct NETunnelProviderManager;
821);
822
823extern_conformance!(
824 unsafe impl NSObjectProtocol for NETunnelProviderManager {}
825);
826
827impl NETunnelProviderManager {
828 extern_methods!(
829 #[cfg(feature = "block2")]
830 /// This function asynchronously reads all of the NETunnelProvider configurations created by the calling app that have previously been saved to disk and returns them as NETunnelProviderManager objects.
831 ///
832 /// Parameter `completionHandler`: A block that takes an array NETunnelProviderManager objects. The array passed to the block may be empty if no NETunnelProvider configurations were successfully read from the disk. The NSError passed to this block will be nil if the load operation succeeded, non-nil otherwise.
833 #[unsafe(method(loadAllFromPreferencesWithCompletionHandler:))]
834 #[unsafe(method_family = none)]
835 pub unsafe fn loadAllFromPreferencesWithCompletionHandler(
836 completion_handler: &block2::DynBlock<
837 dyn Fn(*mut NSArray<NETunnelProviderManager>, *mut NSError),
838 >,
839 );
840
841 /// Create a NETunnelProviderManager instance that is used to manage a per-app VPN configuration.
842 #[unsafe(method(forPerAppVPN))]
843 #[unsafe(method_family = none)]
844 pub unsafe fn forPerAppVPN() -> Retained<Self>;
845
846 /// This function returns an array of NEAppRule objects.
847 #[unsafe(method(copyAppRules))]
848 #[unsafe(method_family = copy)]
849 pub unsafe fn copyAppRules(&self) -> Option<Retained<NSArray<NEAppRule>>>;
850
851 /// The method by which network traffic is routed to the tunnel. The default is NETunnelProviderRoutingMethodDestinationIP.
852 #[unsafe(method(routingMethod))]
853 #[unsafe(method_family = none)]
854 pub unsafe fn routingMethod(&self) -> NETunnelProviderRoutingMethod;
855
856 /// An array of domain strings. Only applies to per-app VPN configurations. When the per-app VPN is enabled and the user navigates in Safari to a web site within one of these domains,
857 /// the web site network traffic is routed through the per-app VPN.
858 #[unsafe(method(safariDomains))]
859 #[unsafe(method_family = none)]
860 pub unsafe fn safariDomains(&self) -> Retained<NSArray<NSString>>;
861
862 /// Setter for [`safariDomains`][Self::safariDomains].
863 ///
864 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
865 #[unsafe(method(setSafariDomains:))]
866 #[unsafe(method_family = none)]
867 pub unsafe fn setSafariDomains(&self, safari_domains: &NSArray<NSString>);
868
869 /// An array of domain strings. Only applies to per-app VPN configurations. When the per-app VPN is enabled, connections from the Mail app to mail servers within
870 /// one of these domains are routed through the per-app VPN.
871 #[unsafe(method(mailDomains))]
872 #[unsafe(method_family = none)]
873 pub unsafe fn mailDomains(&self) -> Retained<NSArray<NSString>>;
874
875 /// Setter for [`mailDomains`][Self::mailDomains].
876 ///
877 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
878 #[unsafe(method(setMailDomains:))]
879 #[unsafe(method_family = none)]
880 pub unsafe fn setMailDomains(&self, mail_domains: &NSArray<NSString>);
881
882 /// An array of domain strings. Only applies to per-app VPN configurations. When the per-app VPN is enabled, connections from the Calendar app to calendar servers within one of
883 /// these domains are routed through the per-app VPN.
884 #[unsafe(method(calendarDomains))]
885 #[unsafe(method_family = none)]
886 pub unsafe fn calendarDomains(&self) -> Retained<NSArray<NSString>>;
887
888 /// Setter for [`calendarDomains`][Self::calendarDomains].
889 ///
890 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
891 #[unsafe(method(setCalendarDomains:))]
892 #[unsafe(method_family = none)]
893 pub unsafe fn setCalendarDomains(&self, calendar_domains: &NSArray<NSString>);
894
895 /// An array of domain strings. Only applies to per-app VPN configurations. When the per-app VPN is enabled, connections from the Contacts app to contacts servers within one of these
896 /// domains are routed through the per-app VPN.
897 #[unsafe(method(contactsDomains))]
898 #[unsafe(method_family = none)]
899 pub unsafe fn contactsDomains(&self) -> Retained<NSArray<NSString>>;
900
901 /// Setter for [`contactsDomains`][Self::contactsDomains].
902 ///
903 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
904 #[unsafe(method(setContactsDomains:))]
905 #[unsafe(method_family = none)]
906 pub unsafe fn setContactsDomains(&self, contacts_domains: &NSArray<NSString>);
907
908 #[unsafe(method(appRules))]
909 #[unsafe(method_family = none)]
910 pub unsafe fn appRules(&self) -> Retained<NSArray<NEAppRule>>;
911
912 /// Setter for [`appRules`][Self::appRules].
913 ///
914 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
915 #[unsafe(method(setAppRules:))]
916 #[unsafe(method_family = none)]
917 pub unsafe fn setAppRules(&self, app_rules: &NSArray<NEAppRule>);
918
919 /// per-app VPN.
920 #[unsafe(method(excludedDomains))]
921 #[unsafe(method_family = none)]
922 pub unsafe fn excludedDomains(&self) -> Retained<NSArray<NSString>>;
923
924 /// Setter for [`excludedDomains`][Self::excludedDomains].
925 ///
926 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
927 #[unsafe(method(setExcludedDomains:))]
928 #[unsafe(method_family = none)]
929 pub unsafe fn setExcludedDomains(&self, excluded_domains: &NSArray<NSString>);
930
931 #[unsafe(method(associatedDomains))]
932 #[unsafe(method_family = none)]
933 pub unsafe fn associatedDomains(&self) -> Retained<NSArray<NSString>>;
934
935 /// Setter for [`associatedDomains`][Self::associatedDomains].
936 ///
937 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
938 #[unsafe(method(setAssociatedDomains:))]
939 #[unsafe(method_family = none)]
940 pub unsafe fn setAssociatedDomains(&self, associated_domains: &NSArray<NSString>);
941 );
942}
943
944/// Methods declared on superclass `NSObject`.
945impl NETunnelProviderManager {
946 extern_methods!(
947 #[unsafe(method(init))]
948 #[unsafe(method_family = init)]
949 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
950
951 #[unsafe(method(new))]
952 #[unsafe(method_family = new)]
953 pub unsafe fn new() -> Retained<Self>;
954 );
955}
956
957extern_class!(
958 /// The NEAppProxyProviderManager class declares the programmatic interface for an object that is used to configure and control network tunnels provided by NEAppProxyProviders.
959 ///
960 /// Instances of this class are thread safe.
961 ///
962 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neappproxyprovidermanager?language=objc)
963 #[unsafe(super(NETunnelProviderManager, NEVPNManager, NSObject))]
964 #[derive(Debug, PartialEq, Eq, Hash)]
965 pub struct NEAppProxyProviderManager;
966);
967
968extern_conformance!(
969 unsafe impl NSObjectProtocol for NEAppProxyProviderManager {}
970);
971
972impl NEAppProxyProviderManager {
973 extern_methods!(
974 #[cfg(feature = "block2")]
975 /// This function asynchronously reads all of the NEAppProxy configurations associated with the calling app that have previously been saved to disk and returns them as NEAppProxyProviderManager objects.
976 ///
977 /// Parameter `completionHandler`: A block that takes an array NEAppProxyProviderManager objects. The array passed to the block may be empty if no NETunnelProvider configurations were successfully read from the disk. The NSError passed to this block will be nil if the load operation succeeded, non-nil otherwise.
978 #[unsafe(method(loadAllFromPreferencesWithCompletionHandler:))]
979 #[unsafe(method_family = none)]
980 pub unsafe fn loadAllFromPreferencesWithCompletionHandler(
981 completion_handler: &block2::DynBlock<
982 dyn Fn(*mut NSArray<NEAppProxyProviderManager>, *mut NSError),
983 >,
984 );
985 );
986}
987
988/// Methods declared on superclass `NETunnelProviderManager`.
989impl NEAppProxyProviderManager {
990 extern_methods!(
991 /// Create a NETunnelProviderManager instance that is used to manage a per-app VPN configuration.
992 #[unsafe(method(forPerAppVPN))]
993 #[unsafe(method_family = none)]
994 pub unsafe fn forPerAppVPN() -> Retained<Self>;
995 );
996}
997
998/// Methods declared on superclass `NSObject`.
999impl NEAppProxyProviderManager {
1000 extern_methods!(
1001 #[unsafe(method(init))]
1002 #[unsafe(method_family = init)]
1003 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1004
1005 #[unsafe(method(new))]
1006 #[unsafe(method_family = new)]
1007 pub unsafe fn new() -> Retained<Self>;
1008 );
1009}
1010
1011extern_class!(
1012 /// The NEAppProxyTCPFlow class declares the programmatic interface of an object that is used by NEAppProxyProvider implementations to proxy the payload of TCP connections.
1013 ///
1014 /// NEAppProxyTCPFlow is part of NetworkExtension.framework
1015 ///
1016 /// Instances of this class are thread safe.
1017 ///
1018 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neappproxytcpflow?language=objc)
1019 #[unsafe(super(NEAppProxyFlow, NSObject))]
1020 #[derive(Debug, PartialEq, Eq, Hash)]
1021 pub struct NEAppProxyTCPFlow;
1022);
1023
1024extern_conformance!(
1025 unsafe impl NSObjectProtocol for NEAppProxyTCPFlow {}
1026);
1027
1028impl NEAppProxyTCPFlow {
1029 extern_methods!(
1030 #[cfg(feature = "block2")]
1031 /// Read data from the flow.
1032 ///
1033 /// Parameter `completionHandler`: A block that will be executed when some data is read from the flow. The block is passed either the data that was read or a non-nil error if an error occurred. If data has a length of 0 then no data can be subsequently read from the flow. The completion handler is only called for the single read operation that was initiated by calling this method. If the caller wants to read more data then it should call this method again to schedule another read operation and another execution of the completion handler block.
1034 #[unsafe(method(readDataWithCompletionHandler:))]
1035 #[unsafe(method_family = none)]
1036 pub unsafe fn readDataWithCompletionHandler(
1037 &self,
1038 completion_handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
1039 );
1040
1041 #[cfg(feature = "block2")]
1042 /// Write data to the flow.
1043 ///
1044 /// Parameter `data`: The data to write.
1045 ///
1046 /// Parameter `completionHandler`: A block that will be executed when the data is written into the associated socket's receive buffer. The caller should use this callback as an indication that it is possible to write more data to the flow without using up excessive buffer memory. If an error occurs while writing the data then a non-nil NSError object is passed to the block.
1047 #[unsafe(method(writeData:withCompletionHandler:))]
1048 #[unsafe(method_family = none)]
1049 pub unsafe fn writeData_withCompletionHandler(
1050 &self,
1051 data: &NSData,
1052 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
1053 );
1054
1055 /// An NWEndpoint object containing information about the intended remote endpoint of the flow.
1056 #[deprecated]
1057 #[unsafe(method(remoteEndpoint))]
1058 #[unsafe(method_family = none)]
1059 pub unsafe fn remoteEndpoint(&self) -> Retained<NWEndpoint>;
1060 );
1061}
1062
1063/// Methods declared on superclass `NSObject`.
1064impl NEAppProxyTCPFlow {
1065 extern_methods!(
1066 #[unsafe(method(init))]
1067 #[unsafe(method_family = init)]
1068 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1069
1070 #[unsafe(method(new))]
1071 #[unsafe(method_family = new)]
1072 pub unsafe fn new() -> Retained<Self>;
1073 );
1074}
1075
1076extern_class!(
1077 /// The NEAppProxyUDPFlow class declares the programmatic interface of an object that is used by NEAppProxyProvider implementations to proxy the payload of UDP datagrams.
1078 ///
1079 /// NEAppProxyUDPFlow is part of NetworkExtension.framework.
1080 ///
1081 /// Instances of this class are thread safe.
1082 ///
1083 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neappproxyudpflow?language=objc)
1084 #[unsafe(super(NEAppProxyFlow, NSObject))]
1085 #[derive(Debug, PartialEq, Eq, Hash)]
1086 pub struct NEAppProxyUDPFlow;
1087);
1088
1089extern_conformance!(
1090 unsafe impl NSObjectProtocol for NEAppProxyUDPFlow {}
1091);
1092
1093impl NEAppProxyUDPFlow {
1094 extern_methods!(
1095 #[cfg(feature = "block2")]
1096 /// Read datagrams from the flow.
1097 ///
1098 /// Parameter `completionHandler`: A block that will be executed when datagrams have been read from the flow. The block takes the datagrams that were read, the destination endpoints of the datagrams, and an NSError. If an error occurred while reading then the error parameter will be non-nil.
1099 #[deprecated]
1100 #[unsafe(method(readDatagramsWithCompletionHandler:))]
1101 #[unsafe(method_family = none)]
1102 pub unsafe fn readDatagramsWithCompletionHandler(
1103 &self,
1104 completion_handler: &block2::DynBlock<
1105 dyn Fn(*mut NSArray<NSData>, *mut NSArray<NWEndpoint>, *mut NSError),
1106 >,
1107 );
1108
1109 #[cfg(feature = "block2")]
1110 /// Write datagrams to the flow.
1111 ///
1112 /// Parameter `datagrams`: An array of NSData objects containing the data to be written.
1113 ///
1114 /// Parameter `remoteEndpoints`: The source endpoints of the datagrams.
1115 ///
1116 /// Parameter `completionHandler`: A block that will be executed when the datagrams have been written to the corresponding socket's receive buffer.
1117 #[deprecated]
1118 #[unsafe(method(writeDatagrams:sentByEndpoints:completionHandler:))]
1119 #[unsafe(method_family = none)]
1120 pub unsafe fn writeDatagrams_sentByEndpoints_completionHandler(
1121 &self,
1122 datagrams: &NSArray<NSData>,
1123 remote_endpoints: &NSArray<NWEndpoint>,
1124 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
1125 );
1126
1127 /// An NWEndpoint object containing the local endpoint of the flow's corresponding socket.
1128 #[deprecated]
1129 #[unsafe(method(localEndpoint))]
1130 #[unsafe(method_family = none)]
1131 pub unsafe fn localEndpoint(&self) -> Option<Retained<NWEndpoint>>;
1132 );
1133}
1134
1135/// Methods declared on superclass `NSObject`.
1136impl NEAppProxyUDPFlow {
1137 extern_methods!(
1138 #[unsafe(method(init))]
1139 #[unsafe(method_family = init)]
1140 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1141
1142 #[unsafe(method(new))]
1143 #[unsafe(method_family = new)]
1144 pub unsafe fn new() -> Retained<Self>;
1145 );
1146}
1147
1148extern_class!(
1149 /// The NEAppRule class declares the programmatic interface for an object that contains the match conditions for a rule that is used to match network traffic originated by applications.
1150 ///
1151 /// NEAppRule is used in the context of a Network Extension configuration to specify what traffic should be made available to the Network Extension.
1152 ///
1153 /// Instances of this class are thread safe.
1154 ///
1155 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neapprule?language=objc)
1156 #[unsafe(super(NSObject))]
1157 #[derive(Debug, PartialEq, Eq, Hash)]
1158 pub struct NEAppRule;
1159);
1160
1161extern_conformance!(
1162 unsafe impl NSCoding for NEAppRule {}
1163);
1164
1165extern_conformance!(
1166 unsafe impl NSCopying for NEAppRule {}
1167);
1168
1169unsafe impl CopyingHelper for NEAppRule {
1170 type Result = Self;
1171}
1172
1173extern_conformance!(
1174 unsafe impl NSObjectProtocol for NEAppRule {}
1175);
1176
1177extern_conformance!(
1178 unsafe impl NSSecureCoding for NEAppRule {}
1179);
1180
1181impl NEAppRule {
1182 extern_methods!(
1183 /// Initializes a newly-allocated NEAppRule object.
1184 ///
1185 /// Parameter `signingIdentifier`: The signing identifier of the executable that matches the rule.
1186 #[unsafe(method(initWithSigningIdentifier:))]
1187 #[unsafe(method_family = init)]
1188 pub unsafe fn initWithSigningIdentifier(
1189 this: Allocated<Self>,
1190 signing_identifier: &NSString,
1191 ) -> Retained<Self>;
1192
1193 /// Initializes a newly-allocated NEAppRule object.
1194 ///
1195 /// Parameter `signingIdentifier`: The signing identifier of the executable that matches the rule.
1196 ///
1197 /// Parameter `designatedRequirement`: The designated requirement of the executable that matches the rule.
1198 #[unsafe(method(initWithSigningIdentifier:designatedRequirement:))]
1199 #[unsafe(method_family = init)]
1200 pub unsafe fn initWithSigningIdentifier_designatedRequirement(
1201 this: Allocated<Self>,
1202 signing_identifier: &NSString,
1203 designated_requirement: &NSString,
1204 ) -> Retained<Self>;
1205
1206 /// A string containing a signing identifier. If the code signature of the executable being evaluated has a signing identifier equal to this string and all other conditions of the rule match, then the rule matches.
1207 #[unsafe(method(matchSigningIdentifier))]
1208 #[unsafe(method_family = none)]
1209 pub unsafe fn matchSigningIdentifier(&self) -> Retained<NSString>;
1210
1211 /// A string containing a designated requirement. If the code signature of the exectuable being evaluated has a designated requirement equal to this string and all other conditions of the rule match, then the rule matches. This property is required on Mac OS X.
1212 #[unsafe(method(matchDesignatedRequirement))]
1213 #[unsafe(method_family = none)]
1214 pub unsafe fn matchDesignatedRequirement(&self) -> Retained<NSString>;
1215
1216 /// A string containing a file system path. If the file system path of the executable being evaluated is equal to this string and all other conditions of the rule match, then the rule matches. This property is optional.
1217 #[unsafe(method(matchPath))]
1218 #[unsafe(method_family = none)]
1219 pub unsafe fn matchPath(&self) -> Option<Retained<NSString>>;
1220
1221 /// Setter for [`matchPath`][Self::matchPath].
1222 ///
1223 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1224 #[unsafe(method(setMatchPath:))]
1225 #[unsafe(method_family = none)]
1226 pub unsafe fn setMatchPath(&self, match_path: Option<&NSString>);
1227
1228 /// An array of strings. This property is actually read-only. If the destination host of the network traffic being evaluated has a suffix equal to one of the strings in this array and all other conditions of the rule match, then the rule matches. This property is optional.
1229 #[unsafe(method(matchDomains))]
1230 #[unsafe(method_family = none)]
1231 pub unsafe fn matchDomains(&self) -> Option<Retained<NSArray>>;
1232
1233 /// Setter for [`matchDomains`][Self::matchDomains].
1234 ///
1235 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1236 ///
1237 /// # Safety
1238 ///
1239 /// `match_domains` generic should be of the correct type.
1240 #[unsafe(method(setMatchDomains:))]
1241 #[unsafe(method_family = none)]
1242 pub unsafe fn setMatchDomains(&self, match_domains: Option<&NSArray>);
1243
1244 /// An array of NEAppRule objects. Use this property to restrict this rule to only match network traffic that is generated by one or more "helper tool" processes that are spawned by the app that matches this rule.
1245 /// For example, to match network traffic generated by the "curl" command line tool when the tool is run from Terminal.app, create an NEAppRule for Terminal.app and set the app rule's matchTools property to an array that
1246 /// contains an NEAppRule for the "curl" command line tool.
1247 /// Set this property to nil (which is the default) to match all network traffic generated by the matching app and all helper tool processes spawned by the matching app.
1248 #[unsafe(method(matchTools))]
1249 #[unsafe(method_family = none)]
1250 pub unsafe fn matchTools(&self) -> Option<Retained<NSArray<NEAppRule>>>;
1251
1252 /// Setter for [`matchTools`][Self::matchTools].
1253 ///
1254 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1255 #[unsafe(method(setMatchTools:))]
1256 #[unsafe(method_family = none)]
1257 pub unsafe fn setMatchTools(&self, match_tools: Option<&NSArray<NEAppRule>>);
1258 );
1259}
1260
1261/// Methods declared on superclass `NSObject`.
1262impl NEAppRule {
1263 extern_methods!(
1264 #[unsafe(method(init))]
1265 #[unsafe(method_family = init)]
1266 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1267
1268 #[unsafe(method(new))]
1269 #[unsafe(method_family = new)]
1270 pub unsafe fn new() -> Retained<Self>;
1271 );
1272}
1273
1274/// DNS proxy error codes
1275///
1276/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nednsproxymanagererror?language=objc)
1277// NS_ENUM
1278#[repr(transparent)]
1279#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1280pub struct NEDNSProxyManagerError(pub NSInteger);
1281impl NEDNSProxyManagerError {
1282 #[doc(alias = "NEDNSProxyManagerErrorConfigurationInvalid")]
1283 pub const ConfigurationInvalid: Self = Self(1);
1284 #[doc(alias = "NEDNSProxyManagerErrorConfigurationDisabled")]
1285 pub const ConfigurationDisabled: Self = Self(2);
1286 #[doc(alias = "NEDNSProxyManagerErrorConfigurationStale")]
1287 pub const ConfigurationStale: Self = Self(3);
1288 #[doc(alias = "NEDNSProxyManagerErrorConfigurationCannotBeRemoved")]
1289 pub const ConfigurationCannotBeRemoved: Self = Self(4);
1290}
1291
1292unsafe impl Encode for NEDNSProxyManagerError {
1293 const ENCODING: Encoding = NSInteger::ENCODING;
1294}
1295
1296unsafe impl RefEncode for NEDNSProxyManagerError {
1297 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1298}
1299
1300extern "C" {
1301 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nednsproxyerrordomain?language=objc)
1302 pub static NEDNSProxyErrorDomain: &'static NSString;
1303}
1304
1305extern "C" {
1306 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nednsproxyconfigurationdidchangenotification?language=objc)
1307 pub static NEDNSProxyConfigurationDidChangeNotification: &'static NSString;
1308}
1309
1310extern_class!(
1311 /// The NEDNSProxyManager class declares the programmatic interface for an object that manages DNS proxy configurations.
1312 ///
1313 /// NEDNSProxyManager declares methods and properties for configuring and controlling a DNS proxy.
1314 ///
1315 /// Instances of this class are thread safe.
1316 ///
1317 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nednsproxymanager?language=objc)
1318 #[unsafe(super(NSObject))]
1319 #[derive(Debug, PartialEq, Eq, Hash)]
1320 pub struct NEDNSProxyManager;
1321);
1322
1323extern_conformance!(
1324 unsafe impl NSObjectProtocol for NEDNSProxyManager {}
1325);
1326
1327impl NEDNSProxyManager {
1328 extern_methods!(
1329 /// Returns: The singleton NEDNSProxyManager object for the calling process.
1330 #[unsafe(method(sharedManager))]
1331 #[unsafe(method_family = none)]
1332 pub unsafe fn sharedManager() -> Retained<NEDNSProxyManager>;
1333
1334 #[cfg(feature = "block2")]
1335 /// This function loads the current DNS proxy configuration from the caller's DNS proxy preferences.
1336 ///
1337 /// Parameter `completionHandler`: A block that will be called when the load operation is completed. The NSError passed to this block will be nil if the load operation succeeded, non-nil otherwise.
1338 #[unsafe(method(loadFromPreferencesWithCompletionHandler:))]
1339 #[unsafe(method_family = none)]
1340 pub unsafe fn loadFromPreferencesWithCompletionHandler(
1341 &self,
1342 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
1343 );
1344
1345 #[cfg(feature = "block2")]
1346 /// This function removes the DNS proxy configuration from the caller's DNS proxy preferences. If the DNS proxy is enabled, the DNS proxy becomes disabled.
1347 ///
1348 /// Parameter `completionHandler`: A block that will be called when the remove operation is completed. The NSError passed to this block will be nil if the remove operation succeeded, non-nil otherwise.
1349 #[unsafe(method(removeFromPreferencesWithCompletionHandler:))]
1350 #[unsafe(method_family = none)]
1351 pub unsafe fn removeFromPreferencesWithCompletionHandler(
1352 &self,
1353 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
1354 );
1355
1356 #[cfg(feature = "block2")]
1357 /// This function saves the DNS proxy configuration in the caller's DNS proxy preferences. If the DNS proxy is enabled, it will become active.
1358 ///
1359 /// Parameter `completionHandler`: A block that will be called when the save operation is completed. The NSError passed to this block will be nil if the save operation succeeded, non-nil otherwise.
1360 #[unsafe(method(saveToPreferencesWithCompletionHandler:))]
1361 #[unsafe(method_family = none)]
1362 pub unsafe fn saveToPreferencesWithCompletionHandler(
1363 &self,
1364 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
1365 );
1366
1367 /// A string containing a description of the DNS proxy.
1368 #[unsafe(method(localizedDescription))]
1369 #[unsafe(method_family = none)]
1370 pub unsafe fn localizedDescription(&self) -> Option<Retained<NSString>>;
1371
1372 /// Setter for [`localizedDescription`][Self::localizedDescription].
1373 ///
1374 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1375 #[unsafe(method(setLocalizedDescription:))]
1376 #[unsafe(method_family = none)]
1377 pub unsafe fn setLocalizedDescription(&self, localized_description: Option<&NSString>);
1378
1379 /// An NEDNSProxyProviderProtocol object containing the provider-specific portion of the DNS proxy configuration.
1380 #[unsafe(method(providerProtocol))]
1381 #[unsafe(method_family = none)]
1382 pub unsafe fn providerProtocol(&self) -> Option<Retained<NEDNSProxyProviderProtocol>>;
1383
1384 /// Setter for [`providerProtocol`][Self::providerProtocol].
1385 #[unsafe(method(setProviderProtocol:))]
1386 #[unsafe(method_family = none)]
1387 pub unsafe fn setProviderProtocol(
1388 &self,
1389 provider_protocol: Option<&NEDNSProxyProviderProtocol>,
1390 );
1391
1392 /// Toggles the enabled status of the DNS proxy. Setting this property will disable DNS proxy configurations of other apps. This property will be set to NO when other DNS proxy configurations are enabled.
1393 #[unsafe(method(isEnabled))]
1394 #[unsafe(method_family = none)]
1395 pub unsafe fn isEnabled(&self) -> bool;
1396
1397 /// Setter for [`isEnabled`][Self::isEnabled].
1398 #[unsafe(method(setEnabled:))]
1399 #[unsafe(method_family = none)]
1400 pub unsafe fn setEnabled(&self, enabled: bool);
1401 );
1402}
1403
1404/// Methods declared on superclass `NSObject`.
1405impl NEDNSProxyManager {
1406 extern_methods!(
1407 #[unsafe(method(init))]
1408 #[unsafe(method_family = init)]
1409 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1410
1411 #[unsafe(method(new))]
1412 #[unsafe(method_family = new)]
1413 pub unsafe fn new() -> Retained<Self>;
1414 );
1415}
1416
1417extern_class!(
1418 /// The NEDNSProxyProvider class declares the programmatic interface for an object that implements the client side of a custom DNS proxy solution.
1419 ///
1420 /// NEDNSProxyProvider is part of NetworkExtension.framework
1421 ///
1422 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nednsproxyprovider?language=objc)
1423 #[unsafe(super(NEProvider, NSObject))]
1424 #[derive(Debug, PartialEq, Eq, Hash)]
1425 pub struct NEDNSProxyProvider;
1426);
1427
1428extern_conformance!(
1429 unsafe impl NSObjectProtocol for NEDNSProxyProvider {}
1430);
1431
1432impl NEDNSProxyProvider {
1433 extern_methods!(
1434 #[cfg(feature = "block2")]
1435 /// This function is called by the framework when a new proxy instance is being created. Subclasses must override this method to perform whatever steps are necessary to ready the proxy for handling flows of network data.
1436 ///
1437 /// Parameter `options`: A dictionary containing keys and values passed by the provider's containing app. If the containing app did not start the proxy then this parameter will be nil.
1438 ///
1439 /// Parameter `completionHandler`: A block that must be called when the process of starting the proxy is complete. If the proxy cannot be started then the subclass' implementation of this method must pass a non-nil NSError object to this block. A value of nil passed to the completion handler indicates that the proxy was successfully started.
1440 ///
1441 /// # Safety
1442 ///
1443 /// `options` generic should be of the correct type.
1444 #[unsafe(method(startProxyWithOptions:completionHandler:))]
1445 #[unsafe(method_family = none)]
1446 pub unsafe fn startProxyWithOptions_completionHandler(
1447 &self,
1448 options: Option<&NSDictionary<NSString, AnyObject>>,
1449 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
1450 );
1451
1452 #[cfg(feature = "block2")]
1453 /// This function is called by the framework when the proxy is being stopped. Subclasses must override this method to perform whatever steps are necessary to stop the proxy.
1454 ///
1455 /// Parameter `reason`: An NEProviderStopReason indicating why the proxy is being stopped.
1456 ///
1457 /// Parameter `completionHandler`: A block that must be called when the proxy is completely stopped.
1458 #[unsafe(method(stopProxyWithReason:completionHandler:))]
1459 #[unsafe(method_family = none)]
1460 pub unsafe fn stopProxyWithReason_completionHandler(
1461 &self,
1462 reason: NEProviderStopReason,
1463 completion_handler: &block2::DynBlock<dyn Fn()>,
1464 );
1465
1466 /// This function is called by proxy provider implementations to stop the proxy when a network error is encountered that renders the proxy no longer viable. Subclasses should not override this method.
1467 ///
1468 /// Parameter `error`: An NSError object containing details about the error that the proxy provider implementation encountered.
1469 #[unsafe(method(cancelProxyWithError:))]
1470 #[unsafe(method_family = none)]
1471 pub unsafe fn cancelProxyWithError(&self, error: Option<&NSError>);
1472
1473 /// This function is called by the framework to deliver a new network data flow to the proxy provider implementation. Subclasses must override this method to perform whatever steps are necessary to ready the proxy to receive data from the flow. The proxy provider implementation indicates that the proxy is ready to handle flow data by calling -[NEAppProxyFlow openWithLocalFlowEndpoint:completionHandler:] on the flow. If the proxy implementation decides to not handle the flow and instead terminate it, the subclass implementation of this method should return NO. If the proxy implementation decides to handle the flow, the subclass implementation of this method should return YES. In this case the proxy implementation is responsible for retaining the NEAppProxyFlow object.
1474 ///
1475 /// Parameter `flow`: The new flow
1476 ///
1477 /// Returns: YES if the proxy implementation has retained the flow and intends to handle the flow data. NO if the proxy implementation has not retained the flow and will not handle the flow data. In this case the flow is terminated.
1478 #[unsafe(method(handleNewFlow:))]
1479 #[unsafe(method_family = none)]
1480 pub unsafe fn handleNewFlow(&self, flow: &NEAppProxyFlow) -> bool;
1481
1482 /// This function is called by the framework to deliver a new UDP data flow to the proxy provider implementation. Subclasses can override this method to perform whatever steps are necessary to ready the proxy to receive
1483 /// data from the flow. The proxy provider implementation indicates that the proxy is ready to handle flow data by calling -[NEAppProxyFlow openWithLocalEndpoint:completionHandler:] on the flow. If the proxy implementation decides
1484 /// to not handle the flow and instead terminate it, the subclass implementation of this method should return NO. If the proxy implementation decides to handle the flow, the subclass implementation of this method should return YES.
1485 /// In this case the proxy implementation is responsible for retaining the NEAppProxyUDPFlow object.
1486 /// The default implementation of this method calls -[NEAppProxyProvider handleNewFlow:] and returns its result.
1487 ///
1488 /// Parameter `flow`: The new UDP flow
1489 ///
1490 /// Parameter `remoteEndpoint`: The initial remote endpoint provided by the proxied app when the flow was opened.
1491 ///
1492 /// Returns: YES if the proxy implementation has retained the flow and intends to handle the flow data. NO if the proxy implementation has not retained the flow and will not handle the flow data. In this case the flow is terminated.
1493 #[deprecated]
1494 #[unsafe(method(handleNewUDPFlow:initialRemoteEndpoint:))]
1495 #[unsafe(method_family = none)]
1496 pub unsafe fn handleNewUDPFlow_initialRemoteEndpoint(
1497 &self,
1498 flow: &NEAppProxyUDPFlow,
1499 remote_endpoint: &NWEndpoint,
1500 ) -> bool;
1501
1502 /// The current system DNS settings. Use KVO to watch for changes.
1503 #[unsafe(method(systemDNSSettings))]
1504 #[unsafe(method_family = none)]
1505 pub unsafe fn systemDNSSettings(&self) -> Option<Retained<NSArray<NEDNSSettings>>>;
1506 );
1507}
1508
1509/// Methods declared on superclass `NSObject`.
1510impl NEDNSProxyProvider {
1511 extern_methods!(
1512 #[unsafe(method(init))]
1513 #[unsafe(method_family = init)]
1514 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1515
1516 #[unsafe(method(new))]
1517 #[unsafe(method_family = new)]
1518 pub unsafe fn new() -> Retained<Self>;
1519 );
1520}
1521
1522extern_class!(
1523 /// The NEProxyServer class declares the programmatic interface for an object that contains settings for a proxy server.
1524 ///
1525 /// Instances of this class are thread safe.
1526 ///
1527 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neproxyserver?language=objc)
1528 #[unsafe(super(NSObject))]
1529 #[derive(Debug, PartialEq, Eq, Hash)]
1530 pub struct NEProxyServer;
1531);
1532
1533extern_conformance!(
1534 unsafe impl NSCoding for NEProxyServer {}
1535);
1536
1537extern_conformance!(
1538 unsafe impl NSCopying for NEProxyServer {}
1539);
1540
1541unsafe impl CopyingHelper for NEProxyServer {
1542 type Result = Self;
1543}
1544
1545extern_conformance!(
1546 unsafe impl NSObjectProtocol for NEProxyServer {}
1547);
1548
1549extern_conformance!(
1550 unsafe impl NSSecureCoding for NEProxyServer {}
1551);
1552
1553impl NEProxyServer {
1554 extern_methods!(
1555 /// This function initializes a newly-allocated NEProxyServer object
1556 ///
1557 /// Parameter `address`: The string representation of the proxy server IP address.
1558 ///
1559 /// Parameter `port`: The TCP port of the proxy server.
1560 #[unsafe(method(initWithAddress:port:))]
1561 #[unsafe(method_family = init)]
1562 pub unsafe fn initWithAddress_port(
1563 this: Allocated<Self>,
1564 address: &NSString,
1565 port: NSInteger,
1566 ) -> Retained<Self>;
1567
1568 /// The string representation of the proxy server IP address.
1569 #[unsafe(method(address))]
1570 #[unsafe(method_family = none)]
1571 pub unsafe fn address(&self) -> Retained<NSString>;
1572
1573 /// The TCP port of the proxy server.
1574 #[unsafe(method(port))]
1575 #[unsafe(method_family = none)]
1576 pub unsafe fn port(&self) -> NSInteger;
1577
1578 /// A flag indicating if the server requires authentication credentials.
1579 #[unsafe(method(authenticationRequired))]
1580 #[unsafe(method_family = none)]
1581 pub unsafe fn authenticationRequired(&self) -> bool;
1582
1583 /// Setter for [`authenticationRequired`][Self::authenticationRequired].
1584 #[unsafe(method(setAuthenticationRequired:))]
1585 #[unsafe(method_family = none)]
1586 pub unsafe fn setAuthenticationRequired(&self, authentication_required: bool);
1587
1588 /// The username portion of the authentication credential to use when communicating with the proxy server.
1589 #[unsafe(method(username))]
1590 #[unsafe(method_family = none)]
1591 pub unsafe fn username(&self) -> Option<Retained<NSString>>;
1592
1593 /// Setter for [`username`][Self::username].
1594 ///
1595 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1596 #[unsafe(method(setUsername:))]
1597 #[unsafe(method_family = none)]
1598 pub unsafe fn setUsername(&self, username: Option<&NSString>);
1599
1600 /// The password portion of the authentication credential to use when communicating with the proxy server. This property is only saved persistently if the username property is non-nil and non-empty and if the authenticationRequired flag is set.
1601 #[unsafe(method(password))]
1602 #[unsafe(method_family = none)]
1603 pub unsafe fn password(&self) -> Option<Retained<NSString>>;
1604
1605 /// Setter for [`password`][Self::password].
1606 ///
1607 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1608 #[unsafe(method(setPassword:))]
1609 #[unsafe(method_family = none)]
1610 pub unsafe fn setPassword(&self, password: Option<&NSString>);
1611 );
1612}
1613
1614/// Methods declared on superclass `NSObject`.
1615impl NEProxyServer {
1616 extern_methods!(
1617 #[unsafe(method(init))]
1618 #[unsafe(method_family = init)]
1619 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1620
1621 #[unsafe(method(new))]
1622 #[unsafe(method_family = new)]
1623 pub unsafe fn new() -> Retained<Self>;
1624 );
1625}
1626
1627extern_class!(
1628 /// The NEProxySettings class declares the programmatic interface for an object that contains proxy settings.
1629 ///
1630 /// NEProxySettings is used in the context of a Network Extension configuration to specify the proxy that should be used for network traffic when the Network Extension is active.
1631 ///
1632 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neproxysettings?language=objc)
1633 #[unsafe(super(NSObject))]
1634 #[derive(Debug, PartialEq, Eq, Hash)]
1635 pub struct NEProxySettings;
1636);
1637
1638extern_conformance!(
1639 unsafe impl NSCoding for NEProxySettings {}
1640);
1641
1642extern_conformance!(
1643 unsafe impl NSCopying for NEProxySettings {}
1644);
1645
1646unsafe impl CopyingHelper for NEProxySettings {
1647 type Result = Self;
1648}
1649
1650extern_conformance!(
1651 unsafe impl NSObjectProtocol for NEProxySettings {}
1652);
1653
1654extern_conformance!(
1655 unsafe impl NSSecureCoding for NEProxySettings {}
1656);
1657
1658impl NEProxySettings {
1659 extern_methods!(
1660 /// A boolean indicating if proxy auto-configuration is enabled.
1661 #[unsafe(method(autoProxyConfigurationEnabled))]
1662 #[unsafe(method_family = none)]
1663 pub unsafe fn autoProxyConfigurationEnabled(&self) -> bool;
1664
1665 /// Setter for [`autoProxyConfigurationEnabled`][Self::autoProxyConfigurationEnabled].
1666 #[unsafe(method(setAutoProxyConfigurationEnabled:))]
1667 #[unsafe(method_family = none)]
1668 pub unsafe fn setAutoProxyConfigurationEnabled(
1669 &self,
1670 auto_proxy_configuration_enabled: bool,
1671 );
1672
1673 /// A URL specifying where the PAC script is located.
1674 #[unsafe(method(proxyAutoConfigurationURL))]
1675 #[unsafe(method_family = none)]
1676 pub unsafe fn proxyAutoConfigurationURL(&self) -> Option<Retained<NSURL>>;
1677
1678 /// Setter for [`proxyAutoConfigurationURL`][Self::proxyAutoConfigurationURL].
1679 ///
1680 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1681 #[unsafe(method(setProxyAutoConfigurationURL:))]
1682 #[unsafe(method_family = none)]
1683 pub unsafe fn setProxyAutoConfigurationURL(
1684 &self,
1685 proxy_auto_configuration_url: Option<&NSURL>,
1686 );
1687
1688 /// A string containing the PAC JavaScript source code.
1689 #[unsafe(method(proxyAutoConfigurationJavaScript))]
1690 #[unsafe(method_family = none)]
1691 pub unsafe fn proxyAutoConfigurationJavaScript(&self) -> Option<Retained<NSString>>;
1692
1693 /// Setter for [`proxyAutoConfigurationJavaScript`][Self::proxyAutoConfigurationJavaScript].
1694 ///
1695 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1696 #[unsafe(method(setProxyAutoConfigurationJavaScript:))]
1697 #[unsafe(method_family = none)]
1698 pub unsafe fn setProxyAutoConfigurationJavaScript(
1699 &self,
1700 proxy_auto_configuration_java_script: Option<&NSString>,
1701 );
1702
1703 /// A boolean indicating if the static HTTP proxy is enabled.
1704 #[unsafe(method(HTTPEnabled))]
1705 #[unsafe(method_family = none)]
1706 pub unsafe fn HTTPEnabled(&self) -> bool;
1707
1708 /// Setter for [`HTTPEnabled`][Self::HTTPEnabled].
1709 #[unsafe(method(setHTTPEnabled:))]
1710 #[unsafe(method_family = none)]
1711 pub unsafe fn setHTTPEnabled(&self, http_enabled: bool);
1712
1713 /// A NEProxyServer object containing the HTTP proxy server settings.
1714 #[unsafe(method(HTTPServer))]
1715 #[unsafe(method_family = none)]
1716 pub unsafe fn HTTPServer(&self) -> Option<Retained<NEProxyServer>>;
1717
1718 /// Setter for [`HTTPServer`][Self::HTTPServer].
1719 ///
1720 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1721 #[unsafe(method(setHTTPServer:))]
1722 #[unsafe(method_family = none)]
1723 pub unsafe fn setHTTPServer(&self, http_server: Option<&NEProxyServer>);
1724
1725 /// A boolean indicating if the static HTTPS proxy is enabled.
1726 #[unsafe(method(HTTPSEnabled))]
1727 #[unsafe(method_family = none)]
1728 pub unsafe fn HTTPSEnabled(&self) -> bool;
1729
1730 /// Setter for [`HTTPSEnabled`][Self::HTTPSEnabled].
1731 #[unsafe(method(setHTTPSEnabled:))]
1732 #[unsafe(method_family = none)]
1733 pub unsafe fn setHTTPSEnabled(&self, https_enabled: bool);
1734
1735 /// A NEProxyServer object containing the HTTPS proxy server settings.
1736 #[unsafe(method(HTTPSServer))]
1737 #[unsafe(method_family = none)]
1738 pub unsafe fn HTTPSServer(&self) -> Option<Retained<NEProxyServer>>;
1739
1740 /// Setter for [`HTTPSServer`][Self::HTTPSServer].
1741 ///
1742 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1743 #[unsafe(method(setHTTPSServer:))]
1744 #[unsafe(method_family = none)]
1745 pub unsafe fn setHTTPSServer(&self, https_server: Option<&NEProxyServer>);
1746
1747 /// A flag indicating if the proxy settings should not be used for network destinations specified using single-label host names.
1748 #[unsafe(method(excludeSimpleHostnames))]
1749 #[unsafe(method_family = none)]
1750 pub unsafe fn excludeSimpleHostnames(&self) -> bool;
1751
1752 /// Setter for [`excludeSimpleHostnames`][Self::excludeSimpleHostnames].
1753 #[unsafe(method(setExcludeSimpleHostnames:))]
1754 #[unsafe(method_family = none)]
1755 pub unsafe fn setExcludeSimpleHostnames(&self, exclude_simple_hostnames: bool);
1756
1757 /// An array of domain strings. If the destination host name of a connection shares a suffix with one of these strings then the proxy settings will not be used for the connection.
1758 #[unsafe(method(exceptionList))]
1759 #[unsafe(method_family = none)]
1760 pub unsafe fn exceptionList(&self) -> Option<Retained<NSArray<NSString>>>;
1761
1762 /// Setter for [`exceptionList`][Self::exceptionList].
1763 ///
1764 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1765 #[unsafe(method(setExceptionList:))]
1766 #[unsafe(method_family = none)]
1767 pub unsafe fn setExceptionList(&self, exception_list: Option<&NSArray<NSString>>);
1768
1769 /// An array of domain strings. If the destination host name of a connection shares a suffix with one of these strings then the proxy settings will be used for the connection. Otherwise the proxy settings will not be used. If this property is nil then all connections to which the Network Extension applies will use the proxy settings.
1770 #[unsafe(method(matchDomains))]
1771 #[unsafe(method_family = none)]
1772 pub unsafe fn matchDomains(&self) -> Option<Retained<NSArray<NSString>>>;
1773
1774 /// Setter for [`matchDomains`][Self::matchDomains].
1775 ///
1776 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1777 #[unsafe(method(setMatchDomains:))]
1778 #[unsafe(method_family = none)]
1779 pub unsafe fn setMatchDomains(&self, match_domains: Option<&NSArray<NSString>>);
1780 );
1781}
1782
1783/// Methods declared on superclass `NSObject`.
1784impl NEProxySettings {
1785 extern_methods!(
1786 #[unsafe(method(init))]
1787 #[unsafe(method_family = init)]
1788 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1789
1790 #[unsafe(method(new))]
1791 #[unsafe(method_family = new)]
1792 pub unsafe fn new() -> Retained<Self>;
1793 );
1794}
1795
1796extern_class!(
1797 /// The NEVPNProtocol class declares the programmatic interface of an object that manages the protocol-specific portion of a VPN configuration.
1798 ///
1799 /// NEVPNProtocol is an abstract base class from which other protocol-specific classes are derived.
1800 ///
1801 /// Instances of this class are thread safe.
1802 ///
1803 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnprotocol?language=objc)
1804 #[unsafe(super(NSObject))]
1805 #[derive(Debug, PartialEq, Eq, Hash)]
1806 pub struct NEVPNProtocol;
1807);
1808
1809extern_conformance!(
1810 unsafe impl NSCoding for NEVPNProtocol {}
1811);
1812
1813extern_conformance!(
1814 unsafe impl NSCopying for NEVPNProtocol {}
1815);
1816
1817unsafe impl CopyingHelper for NEVPNProtocol {
1818 type Result = Self;
1819}
1820
1821extern_conformance!(
1822 unsafe impl NSObjectProtocol for NEVPNProtocol {}
1823);
1824
1825extern_conformance!(
1826 unsafe impl NSSecureCoding for NEVPNProtocol {}
1827);
1828
1829impl NEVPNProtocol {
1830 extern_methods!(
1831 /// The VPN server. Depending on the protocol, may be an IP address, host name, or URL.
1832 #[unsafe(method(serverAddress))]
1833 #[unsafe(method_family = none)]
1834 pub unsafe fn serverAddress(&self) -> Option<Retained<NSString>>;
1835
1836 /// Setter for [`serverAddress`][Self::serverAddress].
1837 ///
1838 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1839 #[unsafe(method(setServerAddress:))]
1840 #[unsafe(method_family = none)]
1841 pub unsafe fn setServerAddress(&self, server_address: Option<&NSString>);
1842
1843 /// The username component of the VPN authentication credential.
1844 #[unsafe(method(username))]
1845 #[unsafe(method_family = none)]
1846 pub unsafe fn username(&self) -> Option<Retained<NSString>>;
1847
1848 /// Setter for [`username`][Self::username].
1849 ///
1850 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1851 #[unsafe(method(setUsername:))]
1852 #[unsafe(method_family = none)]
1853 pub unsafe fn setUsername(&self, username: Option<&NSString>);
1854
1855 /// The password component of the VPN authentication credential. The value is a persistent reference to a keychain item with the kSecClassGenericPassword class.
1856 #[unsafe(method(passwordReference))]
1857 #[unsafe(method_family = none)]
1858 pub unsafe fn passwordReference(&self) -> Option<Retained<NSData>>;
1859
1860 /// Setter for [`passwordReference`][Self::passwordReference].
1861 ///
1862 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1863 #[unsafe(method(setPasswordReference:))]
1864 #[unsafe(method_family = none)]
1865 pub unsafe fn setPasswordReference(&self, password_reference: Option<&NSData>);
1866
1867 /// The certificate and private key component of the VPN authentication credential. The value is a persistent reference to a keychain item with the kSecClassIdentity class.
1868 #[unsafe(method(identityReference))]
1869 #[unsafe(method_family = none)]
1870 pub unsafe fn identityReference(&self) -> Option<Retained<NSData>>;
1871
1872 /// Setter for [`identityReference`][Self::identityReference].
1873 ///
1874 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1875 #[unsafe(method(setIdentityReference:))]
1876 #[unsafe(method_family = none)]
1877 pub unsafe fn setIdentityReference(&self, identity_reference: Option<&NSData>);
1878
1879 /// The PKCS12 data for the VPN authentication identity. The value is a NSData in PKCS12 format.
1880 #[unsafe(method(identityData))]
1881 #[unsafe(method_family = none)]
1882 pub unsafe fn identityData(&self) -> Option<Retained<NSData>>;
1883
1884 /// Setter for [`identityData`][Self::identityData].
1885 ///
1886 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1887 #[unsafe(method(setIdentityData:))]
1888 #[unsafe(method_family = none)]
1889 pub unsafe fn setIdentityData(&self, identity_data: Option<&NSData>);
1890
1891 /// The password to be used to decrypt the PKCS12 identity data.
1892 #[unsafe(method(identityDataPassword))]
1893 #[unsafe(method_family = none)]
1894 pub unsafe fn identityDataPassword(&self) -> Option<Retained<NSString>>;
1895
1896 /// Setter for [`identityDataPassword`][Self::identityDataPassword].
1897 ///
1898 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1899 #[unsafe(method(setIdentityDataPassword:))]
1900 #[unsafe(method_family = none)]
1901 pub unsafe fn setIdentityDataPassword(&self, identity_data_password: Option<&NSString>);
1902
1903 /// If YES, the VPN connection will be disconnected when the device goes to sleep. The default is NO.
1904 #[unsafe(method(disconnectOnSleep))]
1905 #[unsafe(method_family = none)]
1906 pub unsafe fn disconnectOnSleep(&self) -> bool;
1907
1908 /// Setter for [`disconnectOnSleep`][Self::disconnectOnSleep].
1909 #[unsafe(method(setDisconnectOnSleep:))]
1910 #[unsafe(method_family = none)]
1911 pub unsafe fn setDisconnectOnSleep(&self, disconnect_on_sleep: bool);
1912
1913 /// An NEProxySettings object containing the proxy settings to use for connections routed through the tunnel.
1914 #[unsafe(method(proxySettings))]
1915 #[unsafe(method_family = none)]
1916 pub unsafe fn proxySettings(&self) -> Option<Retained<NEProxySettings>>;
1917
1918 /// Setter for [`proxySettings`][Self::proxySettings].
1919 ///
1920 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1921 #[unsafe(method(setProxySettings:))]
1922 #[unsafe(method_family = none)]
1923 pub unsafe fn setProxySettings(&self, proxy_settings: Option<&NEProxySettings>);
1924
1925 /// If this property is set to YES then all network traffic is routed through the tunnel, with some exclusions. Several of the exclusions
1926 /// can be controlled with the excludeLocalNetworks, excludeCellularServices, excludeAPNs and excludeDeviceCommunication properties. See the documentation for those properties.
1927 /// The following traffic is always excluded from the tunnel:
1928 /// - Traffic necessary for connecting and maintaining the device's network connection, such as DHCP.
1929 /// - Traffic necessary for connecting to captive networks.
1930 /// - Certain cellular services traffic that is not routable over the internet and is instead directly routed to the cellular network. See the
1931 /// excludeCellularServices property for more details.
1932 /// - Network communication with a companion device such as a watchOS device.
1933 /// The default value of this property is NO.
1934 #[unsafe(method(includeAllNetworks))]
1935 #[unsafe(method_family = none)]
1936 pub unsafe fn includeAllNetworks(&self) -> bool;
1937
1938 /// Setter for [`includeAllNetworks`][Self::includeAllNetworks].
1939 #[unsafe(method(setIncludeAllNetworks:))]
1940 #[unsafe(method_family = none)]
1941 pub unsafe fn setIncludeAllNetworks(&self, include_all_networks: bool);
1942
1943 /// If YES, all traffic destined for local networks will be excluded from the tunnel. The default is NO on macOS and YES on iOS.
1944 #[unsafe(method(excludeLocalNetworks))]
1945 #[unsafe(method_family = none)]
1946 pub unsafe fn excludeLocalNetworks(&self) -> bool;
1947
1948 /// Setter for [`excludeLocalNetworks`][Self::excludeLocalNetworks].
1949 #[unsafe(method(setExcludeLocalNetworks:))]
1950 #[unsafe(method_family = none)]
1951 pub unsafe fn setExcludeLocalNetworks(&self, exclude_local_networks: bool);
1952
1953 /// If includeAllNetworks is set to YES and this property is set to YES, then internet-routable network traffic for cellular services
1954 /// (VoLTE, Wi-Fi Calling, IMS, MMS, Visual Voicemail, etc.) is excluded from the tunnel. Note that some cellular carriers route cellular services traffic
1955 /// directly to the carrier network, bypassing the internet. Such cellular services traffic is always excluded from the tunnel. The default value of this
1956 /// property is YES.
1957 #[unsafe(method(excludeCellularServices))]
1958 #[unsafe(method_family = none)]
1959 pub unsafe fn excludeCellularServices(&self) -> bool;
1960
1961 /// Setter for [`excludeCellularServices`][Self::excludeCellularServices].
1962 #[unsafe(method(setExcludeCellularServices:))]
1963 #[unsafe(method_family = none)]
1964 pub unsafe fn setExcludeCellularServices(&self, exclude_cellular_services: bool);
1965
1966 /// If includeAllNetworks is set to YES and this property is set to YES, then network traffic for the Apple Push Notification service (APNs)
1967 /// is excluded from the tunnel. The default value of this property is YES.
1968 #[unsafe(method(excludeAPNs))]
1969 #[unsafe(method_family = none)]
1970 pub unsafe fn excludeAPNs(&self) -> bool;
1971
1972 /// Setter for [`excludeAPNs`][Self::excludeAPNs].
1973 #[unsafe(method(setExcludeAPNs:))]
1974 #[unsafe(method_family = none)]
1975 pub unsafe fn setExcludeAPNs(&self, exclude_ap_ns: bool);
1976
1977 /// If includeAllNetworks is set to YES and this property is set to YES, then network traffic used for communicating with devices connected via USB or Wi-Fi is excluded
1978 /// from the tunnel. For example, Xcode uses a network tunnel to communicate with connected development devices like iPhone, iPad and TV. The default value of this
1979 /// property is YES.
1980 #[unsafe(method(excludeDeviceCommunication))]
1981 #[unsafe(method_family = none)]
1982 pub unsafe fn excludeDeviceCommunication(&self) -> bool;
1983
1984 /// Setter for [`excludeDeviceCommunication`][Self::excludeDeviceCommunication].
1985 #[unsafe(method(setExcludeDeviceCommunication:))]
1986 #[unsafe(method_family = none)]
1987 pub unsafe fn setExcludeDeviceCommunication(&self, exclude_device_communication: bool);
1988
1989 /// If YES, route rules for this tunnel will take precendence over any locally-defined routes. The default is NO.
1990 #[unsafe(method(enforceRoutes))]
1991 #[unsafe(method_family = none)]
1992 pub unsafe fn enforceRoutes(&self) -> bool;
1993
1994 /// Setter for [`enforceRoutes`][Self::enforceRoutes].
1995 #[unsafe(method(setEnforceRoutes:))]
1996 #[unsafe(method_family = none)]
1997 pub unsafe fn setEnforceRoutes(&self, enforce_routes: bool);
1998
1999 /// Identification string of the associated Cellular slice. If present, VPN tunnel will be scoped to the associated Cellular slice whenever slice is active.
2000 /// Otherwise, VPN tunnel will fallback onto the primary interface.
2001 #[unsafe(method(sliceUUID))]
2002 #[unsafe(method_family = none)]
2003 pub unsafe fn sliceUUID(&self) -> Option<Retained<NSString>>;
2004
2005 /// Setter for [`sliceUUID`][Self::sliceUUID].
2006 ///
2007 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2008 #[unsafe(method(setSliceUUID:))]
2009 #[unsafe(method_family = none)]
2010 pub unsafe fn setSliceUUID(&self, slice_uuid: Option<&NSString>);
2011 );
2012}
2013
2014/// Methods declared on superclass `NSObject`.
2015impl NEVPNProtocol {
2016 extern_methods!(
2017 #[unsafe(method(init))]
2018 #[unsafe(method_family = init)]
2019 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
2020
2021 #[unsafe(method(new))]
2022 #[unsafe(method_family = new)]
2023 pub unsafe fn new() -> Retained<Self>;
2024 );
2025}
2026
2027extern_class!(
2028 /// The NEDNSProxyProviderProtocol class declares the programmatic interface for an object that contains NEDNSProxyProvider-specific configuration settings.
2029 ///
2030 /// Instances of this class are thread safe.
2031 ///
2032 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nednsproxyproviderprotocol?language=objc)
2033 #[unsafe(super(NEVPNProtocol, NSObject))]
2034 #[derive(Debug, PartialEq, Eq, Hash)]
2035 pub struct NEDNSProxyProviderProtocol;
2036);
2037
2038extern_conformance!(
2039 unsafe impl NSCoding for NEDNSProxyProviderProtocol {}
2040);
2041
2042extern_conformance!(
2043 unsafe impl NSCopying for NEDNSProxyProviderProtocol {}
2044);
2045
2046unsafe impl CopyingHelper for NEDNSProxyProviderProtocol {
2047 type Result = Self;
2048}
2049
2050extern_conformance!(
2051 unsafe impl NSObjectProtocol for NEDNSProxyProviderProtocol {}
2052);
2053
2054extern_conformance!(
2055 unsafe impl NSSecureCoding for NEDNSProxyProviderProtocol {}
2056);
2057
2058impl NEDNSProxyProviderProtocol {
2059 extern_methods!(
2060 /// A dictionary containing NEDNSProxyProvider vendor-specific configuration parameters. This dictionary is passed as-is to NEDNSProxyProviders when a DNS proxy is started.
2061 #[unsafe(method(providerConfiguration))]
2062 #[unsafe(method_family = none)]
2063 pub unsafe fn providerConfiguration(
2064 &self,
2065 ) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
2066
2067 /// Setter for [`providerConfiguration`][Self::providerConfiguration].
2068 ///
2069 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2070 ///
2071 /// # Safety
2072 ///
2073 /// `provider_configuration` generic should be of the correct type.
2074 #[unsafe(method(setProviderConfiguration:))]
2075 #[unsafe(method_family = none)]
2076 pub unsafe fn setProviderConfiguration(
2077 &self,
2078 provider_configuration: Option<&NSDictionary<NSString, AnyObject>>,
2079 );
2080
2081 /// A string containing the bundle identifier of the NEDNSProxyProvider to be used by this configuration.
2082 #[unsafe(method(providerBundleIdentifier))]
2083 #[unsafe(method_family = none)]
2084 pub unsafe fn providerBundleIdentifier(&self) -> Option<Retained<NSString>>;
2085
2086 /// Setter for [`providerBundleIdentifier`][Self::providerBundleIdentifier].
2087 ///
2088 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2089 #[unsafe(method(setProviderBundleIdentifier:))]
2090 #[unsafe(method_family = none)]
2091 pub unsafe fn setProviderBundleIdentifier(
2092 &self,
2093 provider_bundle_identifier: Option<&NSString>,
2094 );
2095 );
2096}
2097
2098/// Methods declared on superclass `NSObject`.
2099impl NEDNSProxyProviderProtocol {
2100 extern_methods!(
2101 #[unsafe(method(init))]
2102 #[unsafe(method_family = init)]
2103 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
2104
2105 #[unsafe(method(new))]
2106 #[unsafe(method_family = new)]
2107 pub unsafe fn new() -> Retained<Self>;
2108 );
2109}
2110
2111/// DNS protocol variants
2112///
2113/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nednsprotocol?language=objc)
2114// NS_ENUM
2115#[repr(transparent)]
2116#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
2117pub struct NEDNSProtocol(pub NSInteger);
2118impl NEDNSProtocol {
2119 #[doc(alias = "NEDNSProtocolCleartext")]
2120 pub const Cleartext: Self = Self(1);
2121 #[doc(alias = "NEDNSProtocolTLS")]
2122 pub const TLS: Self = Self(2);
2123 #[doc(alias = "NEDNSProtocolHTTPS")]
2124 pub const HTTPS: Self = Self(3);
2125}
2126
2127unsafe impl Encode for NEDNSProtocol {
2128 const ENCODING: Encoding = NSInteger::ENCODING;
2129}
2130
2131unsafe impl RefEncode for NEDNSProtocol {
2132 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
2133}
2134
2135extern_class!(
2136 /// The NEDNSSettings class declares the programmatic interface for an object that contains DNS settings.
2137 ///
2138 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nednssettings?language=objc)
2139 #[unsafe(super(NSObject))]
2140 #[derive(Debug, PartialEq, Eq, Hash)]
2141 pub struct NEDNSSettings;
2142);
2143
2144extern_conformance!(
2145 unsafe impl NSCoding for NEDNSSettings {}
2146);
2147
2148extern_conformance!(
2149 unsafe impl NSCopying for NEDNSSettings {}
2150);
2151
2152unsafe impl CopyingHelper for NEDNSSettings {
2153 type Result = Self;
2154}
2155
2156extern_conformance!(
2157 unsafe impl NSObjectProtocol for NEDNSSettings {}
2158);
2159
2160extern_conformance!(
2161 unsafe impl NSSecureCoding for NEDNSSettings {}
2162);
2163
2164impl NEDNSSettings {
2165 extern_methods!(
2166 /// The DNS protocol used by the settings.
2167 #[unsafe(method(dnsProtocol))]
2168 #[unsafe(method_family = none)]
2169 pub unsafe fn dnsProtocol(&self) -> NEDNSProtocol;
2170
2171 /// Initialize a newly-allocated NEDNSSettings object.
2172 ///
2173 /// Parameter `servers`: An array of DNS server IP address strings.
2174 #[unsafe(method(initWithServers:))]
2175 #[unsafe(method_family = init)]
2176 pub unsafe fn initWithServers(
2177 this: Allocated<Self>,
2178 servers: &NSArray<NSString>,
2179 ) -> Retained<Self>;
2180
2181 /// An array of DNS server address strings.
2182 #[unsafe(method(servers))]
2183 #[unsafe(method_family = none)]
2184 pub unsafe fn servers(&self) -> Retained<NSArray<NSString>>;
2185
2186 /// An array of DNS server search domain strings.
2187 #[unsafe(method(searchDomains))]
2188 #[unsafe(method_family = none)]
2189 pub unsafe fn searchDomains(&self) -> Option<Retained<NSArray<NSString>>>;
2190
2191 /// Setter for [`searchDomains`][Self::searchDomains].
2192 ///
2193 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2194 #[unsafe(method(setSearchDomains:))]
2195 #[unsafe(method_family = none)]
2196 pub unsafe fn setSearchDomains(&self, search_domains: Option<&NSArray<NSString>>);
2197
2198 /// A string containing the DNS domain.
2199 #[unsafe(method(domainName))]
2200 #[unsafe(method_family = none)]
2201 pub unsafe fn domainName(&self) -> Option<Retained<NSString>>;
2202
2203 /// Setter for [`domainName`][Self::domainName].
2204 ///
2205 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2206 #[unsafe(method(setDomainName:))]
2207 #[unsafe(method_family = none)]
2208 pub unsafe fn setDomainName(&self, domain_name: Option<&NSString>);
2209
2210 /// An array of strings containing domain strings. If this property is non-nil, the DNS settings will only be used to resolve host names within the specified domains.
2211 #[unsafe(method(matchDomains))]
2212 #[unsafe(method_family = none)]
2213 pub unsafe fn matchDomains(&self) -> Option<Retained<NSArray<NSString>>>;
2214
2215 /// Setter for [`matchDomains`][Self::matchDomains].
2216 ///
2217 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2218 #[unsafe(method(setMatchDomains:))]
2219 #[unsafe(method_family = none)]
2220 pub unsafe fn setMatchDomains(&self, match_domains: Option<&NSArray<NSString>>);
2221
2222 /// A boolean indicating if the match domains should be appended to the search domain list. Default is NO (match domains will be appended to the search domain list).
2223 #[unsafe(method(matchDomainsNoSearch))]
2224 #[unsafe(method_family = none)]
2225 pub unsafe fn matchDomainsNoSearch(&self) -> bool;
2226
2227 /// Setter for [`matchDomainsNoSearch`][Self::matchDomainsNoSearch].
2228 #[unsafe(method(setMatchDomainsNoSearch:))]
2229 #[unsafe(method_family = none)]
2230 pub unsafe fn setMatchDomainsNoSearch(&self, match_domains_no_search: bool);
2231
2232 /// A boolean indicating if failover to the default system resolver is permitted on resolution failure.
2233 #[unsafe(method(allowFailover))]
2234 #[unsafe(method_family = none)]
2235 pub unsafe fn allowFailover(&self) -> bool;
2236
2237 /// Setter for [`allowFailover`][Self::allowFailover].
2238 #[unsafe(method(setAllowFailover:))]
2239 #[unsafe(method_family = none)]
2240 pub unsafe fn setAllowFailover(&self, allow_failover: bool);
2241 );
2242}
2243
2244/// Methods declared on superclass `NSObject`.
2245impl NEDNSSettings {
2246 extern_methods!(
2247 #[unsafe(method(init))]
2248 #[unsafe(method_family = init)]
2249 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
2250
2251 #[unsafe(method(new))]
2252 #[unsafe(method_family = new)]
2253 pub unsafe fn new() -> Retained<Self>;
2254 );
2255}
2256
2257extern_class!(
2258 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nednsovertlssettings?language=objc)
2259 #[unsafe(super(NEDNSSettings, NSObject))]
2260 #[derive(Debug, PartialEq, Eq, Hash)]
2261 pub struct NEDNSOverTLSSettings;
2262);
2263
2264extern_conformance!(
2265 unsafe impl NSCoding for NEDNSOverTLSSettings {}
2266);
2267
2268extern_conformance!(
2269 unsafe impl NSCopying for NEDNSOverTLSSettings {}
2270);
2271
2272unsafe impl CopyingHelper for NEDNSOverTLSSettings {
2273 type Result = Self;
2274}
2275
2276extern_conformance!(
2277 unsafe impl NSObjectProtocol for NEDNSOverTLSSettings {}
2278);
2279
2280extern_conformance!(
2281 unsafe impl NSSecureCoding for NEDNSOverTLSSettings {}
2282);
2283
2284impl NEDNSOverTLSSettings {
2285 extern_methods!(
2286 /// The name of the server to use for TLS certificate validation.
2287 #[unsafe(method(serverName))]
2288 #[unsafe(method_family = none)]
2289 pub unsafe fn serverName(&self) -> Option<Retained<NSString>>;
2290
2291 /// Setter for [`serverName`][Self::serverName].
2292 ///
2293 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2294 #[unsafe(method(setServerName:))]
2295 #[unsafe(method_family = none)]
2296 pub unsafe fn setServerName(&self, server_name: Option<&NSString>);
2297
2298 /// The optional certificate identity keychain reference to use as a TLS client certificate.
2299 #[unsafe(method(identityReference))]
2300 #[unsafe(method_family = none)]
2301 pub unsafe fn identityReference(&self) -> Option<Retained<NSData>>;
2302
2303 /// Setter for [`identityReference`][Self::identityReference].
2304 ///
2305 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2306 #[unsafe(method(setIdentityReference:))]
2307 #[unsafe(method_family = none)]
2308 pub unsafe fn setIdentityReference(&self, identity_reference: Option<&NSData>);
2309 );
2310}
2311
2312/// Methods declared on superclass `NEDNSSettings`.
2313impl NEDNSOverTLSSettings {
2314 extern_methods!(
2315 /// Initialize a newly-allocated NEDNSSettings object.
2316 ///
2317 /// Parameter `servers`: An array of DNS server IP address strings.
2318 #[unsafe(method(initWithServers:))]
2319 #[unsafe(method_family = init)]
2320 pub unsafe fn initWithServers(
2321 this: Allocated<Self>,
2322 servers: &NSArray<NSString>,
2323 ) -> Retained<Self>;
2324 );
2325}
2326
2327/// Methods declared on superclass `NSObject`.
2328impl NEDNSOverTLSSettings {
2329 extern_methods!(
2330 #[unsafe(method(init))]
2331 #[unsafe(method_family = init)]
2332 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
2333
2334 #[unsafe(method(new))]
2335 #[unsafe(method_family = new)]
2336 pub unsafe fn new() -> Retained<Self>;
2337 );
2338}
2339
2340extern_class!(
2341 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nednsoverhttpssettings?language=objc)
2342 #[unsafe(super(NEDNSSettings, NSObject))]
2343 #[derive(Debug, PartialEq, Eq, Hash)]
2344 pub struct NEDNSOverHTTPSSettings;
2345);
2346
2347extern_conformance!(
2348 unsafe impl NSCoding for NEDNSOverHTTPSSettings {}
2349);
2350
2351extern_conformance!(
2352 unsafe impl NSCopying for NEDNSOverHTTPSSettings {}
2353);
2354
2355unsafe impl CopyingHelper for NEDNSOverHTTPSSettings {
2356 type Result = Self;
2357}
2358
2359extern_conformance!(
2360 unsafe impl NSObjectProtocol for NEDNSOverHTTPSSettings {}
2361);
2362
2363extern_conformance!(
2364 unsafe impl NSSecureCoding for NEDNSOverHTTPSSettings {}
2365);
2366
2367impl NEDNSOverHTTPSSettings {
2368 extern_methods!(
2369 /// The URL to which to make DNS-over-HTTPS requests. The format should be an HTTPS URL with the path indicating the location of the DNS-over-HTTPS server, such as: "https://dnsserver.example.net/dns-query".
2370 #[unsafe(method(serverURL))]
2371 #[unsafe(method_family = none)]
2372 pub unsafe fn serverURL(&self) -> Option<Retained<NSURL>>;
2373
2374 /// Setter for [`serverURL`][Self::serverURL].
2375 ///
2376 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2377 #[unsafe(method(setServerURL:))]
2378 #[unsafe(method_family = none)]
2379 pub unsafe fn setServerURL(&self, server_url: Option<&NSURL>);
2380
2381 /// The optional certificate identity keychain reference to use as a TLS client certificate.
2382 #[unsafe(method(identityReference))]
2383 #[unsafe(method_family = none)]
2384 pub unsafe fn identityReference(&self) -> Option<Retained<NSData>>;
2385
2386 /// Setter for [`identityReference`][Self::identityReference].
2387 ///
2388 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2389 #[unsafe(method(setIdentityReference:))]
2390 #[unsafe(method_family = none)]
2391 pub unsafe fn setIdentityReference(&self, identity_reference: Option<&NSData>);
2392 );
2393}
2394
2395/// Methods declared on superclass `NEDNSSettings`.
2396impl NEDNSOverHTTPSSettings {
2397 extern_methods!(
2398 /// Initialize a newly-allocated NEDNSSettings object.
2399 ///
2400 /// Parameter `servers`: An array of DNS server IP address strings.
2401 #[unsafe(method(initWithServers:))]
2402 #[unsafe(method_family = init)]
2403 pub unsafe fn initWithServers(
2404 this: Allocated<Self>,
2405 servers: &NSArray<NSString>,
2406 ) -> Retained<Self>;
2407 );
2408}
2409
2410/// Methods declared on superclass `NSObject`.
2411impl NEDNSOverHTTPSSettings {
2412 extern_methods!(
2413 #[unsafe(method(init))]
2414 #[unsafe(method_family = init)]
2415 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
2416
2417 #[unsafe(method(new))]
2418 #[unsafe(method_family = new)]
2419 pub unsafe fn new() -> Retained<Self>;
2420 );
2421}
2422
2423/// DNS Settings Manager error codes
2424///
2425/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nednssettingsmanagererror?language=objc)
2426// NS_ENUM
2427#[repr(transparent)]
2428#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
2429pub struct NEDNSSettingsManagerError(pub NSInteger);
2430impl NEDNSSettingsManagerError {
2431 #[doc(alias = "NEDNSSettingsManagerErrorConfigurationInvalid")]
2432 pub const ConfigurationInvalid: Self = Self(1);
2433 #[doc(alias = "NEDNSSettingsManagerErrorConfigurationDisabled")]
2434 pub const ConfigurationDisabled: Self = Self(2);
2435 #[doc(alias = "NEDNSSettingsManagerErrorConfigurationStale")]
2436 pub const ConfigurationStale: Self = Self(3);
2437 #[doc(alias = "NEDNSSettingsManagerErrorConfigurationCannotBeRemoved")]
2438 pub const ConfigurationCannotBeRemoved: Self = Self(4);
2439}
2440
2441unsafe impl Encode for NEDNSSettingsManagerError {
2442 const ENCODING: Encoding = NSInteger::ENCODING;
2443}
2444
2445unsafe impl RefEncode for NEDNSSettingsManagerError {
2446 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
2447}
2448
2449extern "C" {
2450 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nednssettingserrordomain?language=objc)
2451 pub static NEDNSSettingsErrorDomain: &'static NSString;
2452}
2453
2454extern "C" {
2455 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nednssettingsconfigurationdidchangenotification?language=objc)
2456 pub static NEDNSSettingsConfigurationDidChangeNotification: &'static NSString;
2457}
2458
2459extern_class!(
2460 /// The NEDNSSettingsManager class declares the programmatic interface for an object that manages DNS settings configurations.
2461 ///
2462 /// NEDNSSettingsManager declares methods and properties for configuring and controlling DNS settings on the system.
2463 ///
2464 /// Instances of this class are thread safe.
2465 ///
2466 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nednssettingsmanager?language=objc)
2467 #[unsafe(super(NSObject))]
2468 #[derive(Debug, PartialEq, Eq, Hash)]
2469 pub struct NEDNSSettingsManager;
2470);
2471
2472extern_conformance!(
2473 unsafe impl NSObjectProtocol for NEDNSSettingsManager {}
2474);
2475
2476impl NEDNSSettingsManager {
2477 extern_methods!(
2478 /// Returns: The singleton NEDNSSettingsManager object for the calling process.
2479 #[unsafe(method(sharedManager))]
2480 #[unsafe(method_family = none)]
2481 pub unsafe fn sharedManager() -> Retained<NEDNSSettingsManager>;
2482
2483 #[cfg(feature = "block2")]
2484 /// This function loads the current DNS settings configuration from the caller's DNS settings preferences.
2485 ///
2486 /// Parameter `completionHandler`: A block that will be called when the load operation is completed. The NSError passed to this block will be nil if the load operation succeeded, non-nil otherwise.
2487 #[unsafe(method(loadFromPreferencesWithCompletionHandler:))]
2488 #[unsafe(method_family = none)]
2489 pub unsafe fn loadFromPreferencesWithCompletionHandler(
2490 &self,
2491 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
2492 );
2493
2494 #[cfg(feature = "block2")]
2495 /// This function removes the DNS settings configuration from the caller's DNS settings preferences. If the DNS settings are enabled, the DNS settings becomes disabled.
2496 ///
2497 /// Parameter `completionHandler`: A block that will be called when the remove operation is completed. The NSError passed to this block will be nil if the remove operation succeeded, non-nil otherwise.
2498 #[unsafe(method(removeFromPreferencesWithCompletionHandler:))]
2499 #[unsafe(method_family = none)]
2500 pub unsafe fn removeFromPreferencesWithCompletionHandler(
2501 &self,
2502 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
2503 );
2504
2505 #[cfg(feature = "block2")]
2506 /// This function saves the DNS settingsconfiguration in the caller's DNS settings preferences. If the DNS settings are enabled, they will become active.
2507 ///
2508 /// Parameter `completionHandler`: A block that will be called when the save operation is completed. The NSError passed to this block will be nil if the save operation succeeded, non-nil otherwise.
2509 #[unsafe(method(saveToPreferencesWithCompletionHandler:))]
2510 #[unsafe(method_family = none)]
2511 pub unsafe fn saveToPreferencesWithCompletionHandler(
2512 &self,
2513 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
2514 );
2515
2516 /// A string containing a description of the DNS settings.
2517 #[unsafe(method(localizedDescription))]
2518 #[unsafe(method_family = none)]
2519 pub unsafe fn localizedDescription(&self) -> Option<Retained<NSString>>;
2520
2521 /// Setter for [`localizedDescription`][Self::localizedDescription].
2522 ///
2523 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2524 #[unsafe(method(setLocalizedDescription:))]
2525 #[unsafe(method_family = none)]
2526 pub unsafe fn setLocalizedDescription(&self, localized_description: Option<&NSString>);
2527
2528 /// An NEDNSSettings object containing the DNS resolver configuration to apply to the system.
2529 #[unsafe(method(dnsSettings))]
2530 #[unsafe(method_family = none)]
2531 pub unsafe fn dnsSettings(&self) -> Option<Retained<NEDNSSettings>>;
2532
2533 /// Setter for [`dnsSettings`][Self::dnsSettings].
2534 #[unsafe(method(setDnsSettings:))]
2535 #[unsafe(method_family = none)]
2536 pub unsafe fn setDnsSettings(&self, dns_settings: Option<&NEDNSSettings>);
2537
2538 /// An array of NEOnDemandRule objects. If nil, the associated DNS settings will always apply. If non-nil, the array describes the networks on which the DNS configuration should take effect or not.
2539 #[unsafe(method(onDemandRules))]
2540 #[unsafe(method_family = none)]
2541 pub unsafe fn onDemandRules(&self) -> Option<Retained<NSArray<NEOnDemandRule>>>;
2542
2543 /// Setter for [`onDemandRules`][Self::onDemandRules].
2544 ///
2545 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2546 #[unsafe(method(setOnDemandRules:))]
2547 #[unsafe(method_family = none)]
2548 pub unsafe fn setOnDemandRules(&self, on_demand_rules: Option<&NSArray<NEOnDemandRule>>);
2549
2550 /// Checks the enabled status of the DNS settings. DNS settings must be enabled by the user in Settings or System Preferences.
2551 #[unsafe(method(isEnabled))]
2552 #[unsafe(method_family = none)]
2553 pub unsafe fn isEnabled(&self) -> bool;
2554 );
2555}
2556
2557/// Methods declared on superclass `NSObject`.
2558impl NEDNSSettingsManager {
2559 extern_methods!(
2560 #[unsafe(method(init))]
2561 #[unsafe(method_family = init)]
2562 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
2563
2564 #[unsafe(method(new))]
2565 #[unsafe(method_family = new)]
2566 pub unsafe fn new() -> Retained<Self>;
2567 );
2568}
2569
2570/// IP protocols
2571///
2572/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nenetworkruleprotocol?language=objc)
2573// NS_ENUM
2574#[repr(transparent)]
2575#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
2576pub struct NENetworkRuleProtocol(pub NSInteger);
2577impl NENetworkRuleProtocol {
2578 #[doc(alias = "NENetworkRuleProtocolAny")]
2579 pub const Any: Self = Self(0);
2580 #[doc(alias = "NENetworkRuleProtocolTCP")]
2581 pub const TCP: Self = Self(1);
2582 #[doc(alias = "NENetworkRuleProtocolUDP")]
2583 pub const UDP: Self = Self(2);
2584}
2585
2586unsafe impl Encode for NENetworkRuleProtocol {
2587 const ENCODING: Encoding = NSInteger::ENCODING;
2588}
2589
2590unsafe impl RefEncode for NENetworkRuleProtocol {
2591 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
2592}
2593
2594/// The direction of network traffic
2595///
2596/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/netrafficdirection?language=objc)
2597// NS_ENUM
2598#[repr(transparent)]
2599#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
2600pub struct NETrafficDirection(pub NSInteger);
2601impl NETrafficDirection {
2602 #[doc(alias = "NETrafficDirectionAny")]
2603 pub const Any: Self = Self(0);
2604 #[doc(alias = "NETrafficDirectionInbound")]
2605 pub const Inbound: Self = Self(1);
2606 #[doc(alias = "NETrafficDirectionOutbound")]
2607 pub const Outbound: Self = Self(2);
2608}
2609
2610unsafe impl Encode for NETrafficDirection {
2611 const ENCODING: Encoding = NSInteger::ENCODING;
2612}
2613
2614unsafe impl RefEncode for NETrafficDirection {
2615 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
2616}
2617
2618extern_class!(
2619 /// The NENetworkRule class declares the programmatic interface of an object that contains a specification of a rule that matches the attributes of network traffic.
2620 ///
2621 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nenetworkrule?language=objc)
2622 #[unsafe(super(NSObject))]
2623 #[derive(Debug, PartialEq, Eq, Hash)]
2624 pub struct NENetworkRule;
2625);
2626
2627extern_conformance!(
2628 unsafe impl NSCoding for NENetworkRule {}
2629);
2630
2631extern_conformance!(
2632 unsafe impl NSCopying for NENetworkRule {}
2633);
2634
2635unsafe impl CopyingHelper for NENetworkRule {
2636 type Result = Self;
2637}
2638
2639extern_conformance!(
2640 unsafe impl NSObjectProtocol for NENetworkRule {}
2641);
2642
2643extern_conformance!(
2644 unsafe impl NSSecureCoding for NENetworkRule {}
2645);
2646
2647impl NENetworkRule {
2648 extern_methods!(
2649 /// Initialize a newly-allocated NENetworkRule object that matches network traffic destined for a host within a specific network.
2650 ///
2651 /// Parameter `networkEndpoint`: An endpoint object that contains the port and address or network that the rule matches. This endpoint must contain an address, not a hostname.
2652 /// If the address is a wildcard address (0.0.0.0 or ::) then the rule will match all destinations except for loopback (127.0.0.1 or ::1). To match loopback traffic set the address to the loopback address.
2653 /// If the port string of the endpoint is "0" or is the empty string, then the rule will match traffic on any port destined for the given address or network.
2654 ///
2655 /// Parameter `destinationPrefix`: An integer that in combination with the address in the endpoint specifies the destination network that the rule matches.
2656 ///
2657 /// Parameter `protocol`: A NENetworkRuleProtocol value indicating the protocol that the rule matches.
2658 ///
2659 /// Returns: The initialized NENetworkRule instance.
2660 #[deprecated]
2661 #[unsafe(method(initWithDestinationNetwork:prefix:protocol:))]
2662 #[unsafe(method_family = init)]
2663 pub unsafe fn initWithDestinationNetwork_prefix_protocol(
2664 this: Allocated<Self>,
2665 network_endpoint: &NWHostEndpoint,
2666 destination_prefix: NSUInteger,
2667 protocol: NENetworkRuleProtocol,
2668 ) -> Retained<Self>;
2669
2670 /// Initialize a newly-allocated NENetworkRule object that matches network traffic destined for a host within a specific DNS domain.
2671 ///
2672 /// Parameter `hostEndpoint`: An endpoint object that contains the port and hostname or domain that the rule matches. This endpoint must contain a hostname, not an address.
2673 /// If the port string of the NWHostEndpoint is "0" or is the empty string, then the rule will match traffic on any port destined for the given hostname or domain.
2674 /// If the hostname string of the endpoint consists of a single label, then the rule will match traffic destined to the specific host with that single label as its name.
2675 /// If the hostname string of the endpoint consists of 2 or more labels, then the rule will match traffic destined to hosts within the domain specified by the hostname string.
2676 /// Examples:
2677 /// [[NENetworkRule alloc] initWithDestinationHost:[NWHostEndpoint endpointWithHostname:
2678 /// "
2679 /// com" port:@"0"] protocol:NENetworkRuleProtocolAny] - matches all TCP and UDP traffic to the host named "com".
2680 /// [[NENetworkRule alloc] initWithDestinationHost:[NWHostEndpoint endpointWithHostname:
2681 /// "
2682 /// example.com" port:@"0"] protocol:NENetworkRuleProtocolAny] - matches all TCP and UDP traffic to hosts in the "example.com" DNS domain, including all DNS queries for names in the example.com DNS domain.
2683 /// [[NENetworkRule alloc] initWithDestinationHost:[NWHostEndpoint endpointWithHostname:
2684 /// "
2685 /// example.com" port:@"53"] protocol:NENetworkRuleProtocolAny] - matches all DNS queries/responses for hosts in the "example.com" domain.
2686 /// [[NENetworkRule alloc] initWithDestinationHost:[NWHostEndpoint endpointWithHostname:
2687 /// "
2688 /// example.com" port:@"443"] protocol:NENetworkRuleProtocolTCP] - matches all TCP port 443 traffic to hosts in the "example.com" domain.
2689 ///
2690 /// Parameter `protocol`: A NENetworkRuleProtocol value indicating the protocol that the rule matches.
2691 ///
2692 /// Returns: The initialized NENetworkRule instance.
2693 #[deprecated]
2694 #[unsafe(method(initWithDestinationHost:protocol:))]
2695 #[unsafe(method_family = init)]
2696 pub unsafe fn initWithDestinationHost_protocol(
2697 this: Allocated<Self>,
2698 host_endpoint: &NWHostEndpoint,
2699 protocol: NENetworkRuleProtocol,
2700 ) -> Retained<Self>;
2701
2702 /// Initialize a newly-allocated NENetworkRule object that matches traffic by remote network, local network, protocol, and direction. If both remoteNetwork and localNetwork are nil
2703 /// then the rule will match all traffic of the given protocol and direction, except for loopback traffic. To match loopback traffic create a NENetworkRule with remoteNetwork and/or localNetwork properties that
2704 /// explicitly match traffic to the loopback address (127.0.0.1 or ::1).
2705 ///
2706 /// Parameter `remoteNetwork`: An endpoint object that contains the remote port and the remote address or network that the rule matches. This endpoint must contain an address, not a hostname.
2707 /// If the address is a wildcard address (0.0.0.0 or ::) then the rule will match all destinations except for loopback (127.0.0.1 or ::1). To match loopback traffic set the address to the loopback address.
2708 /// If the port string of the endpoint is "0" or is the empty string, then the rule will match traffic on any port coming from the remote network.
2709 /// Pass nil to cause the rule to match any remote network.
2710 ///
2711 /// Parameter `remotePrefix`: An integer that in combination with the address in remoteNetwork specifies the remote network that the rule matches.
2712 ///
2713 /// Parameter `localNetwork`: An endpoint object that contains the local port and the local address or network that the rule matches. This endpoint must contain an address, not a hostname.
2714 /// If the address is a wildcard address (0.0.0.0 or ::) then the rule will match all local networks except for loopback (127.0.0.1 or ::1). To match loopback traffic set the address to the loopback address.
2715 /// If the port string of the endpoint is "0" or is the empty string, then the rule will match traffic on any port coming from the local network.
2716 /// Pass nil to cause the rule to match any local network.
2717 ///
2718 /// Parameter `localPrefix`: An integer that in combination with the address in localNetwork specifies the local network that the rule matches. This parameter
2719 /// is ignored if localNetwork is nil.
2720 ///
2721 /// Parameter `protocol`: A NENetworkRuleProtocol value indicating the protocol that the rule matches.
2722 ///
2723 /// Parameter `direction`: A NETrafficDirection value indicating the direction of network traffic that the rule matches.
2724 ///
2725 /// Returns: The initialized NENetworkRule instance.
2726 #[deprecated]
2727 #[unsafe(method(initWithRemoteNetwork:remotePrefix:localNetwork:localPrefix:protocol:direction:))]
2728 #[unsafe(method_family = init)]
2729 pub unsafe fn initWithRemoteNetwork_remotePrefix_localNetwork_localPrefix_protocol_direction(
2730 this: Allocated<Self>,
2731 remote_network: Option<&NWHostEndpoint>,
2732 remote_prefix: NSUInteger,
2733 local_network: Option<&NWHostEndpoint>,
2734 local_prefix: NSUInteger,
2735 protocol: NENetworkRuleProtocol,
2736 direction: NETrafficDirection,
2737 ) -> Retained<Self>;
2738
2739 /// The remote endpoint that the rule matches.
2740 #[deprecated]
2741 #[unsafe(method(matchRemoteEndpoint))]
2742 #[unsafe(method_family = none)]
2743 pub unsafe fn matchRemoteEndpoint(&self) -> Option<Retained<NWHostEndpoint>>;
2744
2745 /// A number that specifies the remote sub-network that the rule matches. This property is set to NSNotFound for rules where matchRemoteEndpoint does not contain an IP address.
2746 #[unsafe(method(matchRemotePrefix))]
2747 #[unsafe(method_family = none)]
2748 pub unsafe fn matchRemotePrefix(&self) -> NSUInteger;
2749
2750 /// The local network that the rule matches.
2751 #[deprecated]
2752 #[unsafe(method(matchLocalNetwork))]
2753 #[unsafe(method_family = none)]
2754 pub unsafe fn matchLocalNetwork(&self) -> Option<Retained<NWHostEndpoint>>;
2755
2756 /// A number that specifies the local sub-network that the rule matches. This property is set to NSNotFound for rules with a nil matchLocalNetwork property.
2757 #[unsafe(method(matchLocalPrefix))]
2758 #[unsafe(method_family = none)]
2759 pub unsafe fn matchLocalPrefix(&self) -> NSUInteger;
2760
2761 /// A NENetworkRuleProtocol value containing the protocol that the rule matches.
2762 #[unsafe(method(matchProtocol))]
2763 #[unsafe(method_family = none)]
2764 pub unsafe fn matchProtocol(&self) -> NENetworkRuleProtocol;
2765
2766 /// A NETrafficDirection value indicating the network traffic direction that the rule matches.
2767 #[unsafe(method(matchDirection))]
2768 #[unsafe(method_family = none)]
2769 pub unsafe fn matchDirection(&self) -> NETrafficDirection;
2770 );
2771}
2772
2773/// Methods declared on superclass `NSObject`.
2774impl NENetworkRule {
2775 extern_methods!(
2776 #[unsafe(method(init))]
2777 #[unsafe(method_family = init)]
2778 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
2779
2780 #[unsafe(method(new))]
2781 #[unsafe(method_family = new)]
2782 pub unsafe fn new() -> Retained<Self>;
2783 );
2784}
2785
2786extern_class!(
2787 /// The NEFilterFlow class declares the programmatic interface of an object that represents a flow of network data to be filtered.
2788 ///
2789 /// NEFilterFlow is part of NetworkExtension.framework
2790 ///
2791 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterflow?language=objc)
2792 #[unsafe(super(NSObject))]
2793 #[derive(Debug, PartialEq, Eq, Hash)]
2794 pub struct NEFilterFlow;
2795);
2796
2797extern_conformance!(
2798 unsafe impl NSCoding for NEFilterFlow {}
2799);
2800
2801extern_conformance!(
2802 unsafe impl NSCopying for NEFilterFlow {}
2803);
2804
2805unsafe impl CopyingHelper for NEFilterFlow {
2806 type Result = Self;
2807}
2808
2809extern_conformance!(
2810 unsafe impl NSObjectProtocol for NEFilterFlow {}
2811);
2812
2813extern_conformance!(
2814 unsafe impl NSSecureCoding for NEFilterFlow {}
2815);
2816
2817impl NEFilterFlow {
2818 extern_methods!(
2819 /// The flow's HTTP request URL. Will be nil if the flow did not originate from WebKit.
2820 #[unsafe(method(URL))]
2821 #[unsafe(method_family = none)]
2822 pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;
2823
2824 /// A byte string that uniquely identifies the binary for each build of the source application of the flow.
2825 #[unsafe(method(sourceAppUniqueIdentifier))]
2826 #[unsafe(method_family = none)]
2827 pub unsafe fn sourceAppUniqueIdentifier(&self) -> Option<Retained<NSData>>;
2828
2829 /// A string containing the identifier of the source application of the flow. This identifier stays the same for all versions and builds of the application. This identifier is unique among all applications.
2830 #[unsafe(method(sourceAppIdentifier))]
2831 #[unsafe(method_family = none)]
2832 pub unsafe fn sourceAppIdentifier(&self) -> Option<Retained<NSString>>;
2833
2834 /// The short version string of the source application. Will be nil if the app info is unavailable.
2835 #[unsafe(method(sourceAppVersion))]
2836 #[unsafe(method_family = none)]
2837 pub unsafe fn sourceAppVersion(&self) -> Option<Retained<NSString>>;
2838
2839 /// Initial direction of the flow (outgoing or incoming flow)
2840 #[unsafe(method(direction))]
2841 #[unsafe(method_family = none)]
2842 pub unsafe fn direction(&self) -> NETrafficDirection;
2843
2844 /// Audit token of the source application of the flow.
2845 #[unsafe(method(sourceAppAuditToken))]
2846 #[unsafe(method_family = none)]
2847 pub unsafe fn sourceAppAuditToken(&self) -> Option<Retained<NSData>>;
2848
2849 /// The audit token of the process that created the flow. In cases where the connection was created by a system process on behalf of the source application,
2850 /// sourceProcessAuditToken will be different from sourceAppAuditToken and will contain the audit token of the system process. In cases where the source application directly
2851 /// created the connection sourceAppAuditToken and sourceProcessAuditToken will be identical.
2852 #[unsafe(method(sourceProcessAuditToken))]
2853 #[unsafe(method_family = none)]
2854 pub unsafe fn sourceProcessAuditToken(&self) -> Option<Retained<NSData>>;
2855
2856 /// The unique identifier of the flow.
2857 #[unsafe(method(identifier))]
2858 #[unsafe(method_family = none)]
2859 pub unsafe fn identifier(&self) -> Retained<NSUUID>;
2860 );
2861}
2862
2863/// Methods declared on superclass `NSObject`.
2864impl NEFilterFlow {
2865 extern_methods!(
2866 #[unsafe(method(init))]
2867 #[unsafe(method_family = init)]
2868 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
2869
2870 #[unsafe(method(new))]
2871 #[unsafe(method_family = new)]
2872 pub unsafe fn new() -> Retained<Self>;
2873 );
2874}
2875
2876extern_class!(
2877 /// The NEFilterBrowserFlow class declares the programmatic interface of an object that represents a flow of network data to be filtered, which is originated from NEFilterSource.
2878 ///
2879 /// NEFilterBrowserFlow is part of NetworkExtension.framework
2880 ///
2881 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterbrowserflow?language=objc)
2882 #[unsafe(super(NEFilterFlow, NSObject))]
2883 #[derive(Debug, PartialEq, Eq, Hash)]
2884 pub struct NEFilterBrowserFlow;
2885);
2886
2887extern_conformance!(
2888 unsafe impl NSCoding for NEFilterBrowserFlow {}
2889);
2890
2891extern_conformance!(
2892 unsafe impl NSCopying for NEFilterBrowserFlow {}
2893);
2894
2895unsafe impl CopyingHelper for NEFilterBrowserFlow {
2896 type Result = Self;
2897}
2898
2899extern_conformance!(
2900 unsafe impl NSObjectProtocol for NEFilterBrowserFlow {}
2901);
2902
2903extern_conformance!(
2904 unsafe impl NSSecureCoding for NEFilterBrowserFlow {}
2905);
2906
2907impl NEFilterBrowserFlow {
2908 extern_methods!(
2909 /// The NSURLRequest of the flow. This property is always nil for the control providers.
2910 #[unsafe(method(request))]
2911 #[unsafe(method_family = none)]
2912 pub unsafe fn request(&self) -> Option<Retained<NSURLRequest>>;
2913
2914 /// The NSURLResponse of the flow. This will be nil until the request is sent to the server and the response headers are received. And this property is always nil for the control providers.
2915 #[unsafe(method(response))]
2916 #[unsafe(method_family = none)]
2917 pub unsafe fn response(&self) -> Option<Retained<NSURLResponse>>;
2918
2919 /// The parent URL for the current flow which is created to load the sub frames because the flow with the parent URL was allowed. Will be nil if the parent flow does not exist.
2920 #[unsafe(method(parentURL))]
2921 #[unsafe(method_family = none)]
2922 pub unsafe fn parentURL(&self) -> Option<Retained<NSURL>>;
2923 );
2924}
2925
2926/// Methods declared on superclass `NSObject`.
2927impl NEFilterBrowserFlow {
2928 extern_methods!(
2929 #[unsafe(method(init))]
2930 #[unsafe(method_family = init)]
2931 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
2932
2933 #[unsafe(method(new))]
2934 #[unsafe(method_family = new)]
2935 pub unsafe fn new() -> Retained<Self>;
2936 );
2937}
2938
2939extern_class!(
2940 /// The NEFilterSocketFlow class declares the programmatic interface of an object that represents a flow of network data to be filtered, which is originated from the socket.
2941 ///
2942 /// NEFilterSocketFlow is part of NetworkExtension.framework
2943 ///
2944 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefiltersocketflow?language=objc)
2945 #[unsafe(super(NEFilterFlow, NSObject))]
2946 #[derive(Debug, PartialEq, Eq, Hash)]
2947 pub struct NEFilterSocketFlow;
2948);
2949
2950extern_conformance!(
2951 unsafe impl NSCoding for NEFilterSocketFlow {}
2952);
2953
2954extern_conformance!(
2955 unsafe impl NSCopying for NEFilterSocketFlow {}
2956);
2957
2958unsafe impl CopyingHelper for NEFilterSocketFlow {
2959 type Result = Self;
2960}
2961
2962extern_conformance!(
2963 unsafe impl NSObjectProtocol for NEFilterSocketFlow {}
2964);
2965
2966extern_conformance!(
2967 unsafe impl NSSecureCoding for NEFilterSocketFlow {}
2968);
2969
2970impl NEFilterSocketFlow {
2971 extern_methods!(
2972 /// The flow's remote endpoint. This endpoint object may be nil when [NEFilterDataProvider handleNewFlow:] is invoked and if so will be populated upon receiving network data.
2973 /// In such a case, filtering on the flow may still be performed based on its socket type, socket family or socket protocol.
2974 #[deprecated]
2975 #[unsafe(method(remoteEndpoint))]
2976 #[unsafe(method_family = none)]
2977 pub unsafe fn remoteEndpoint(&self) -> Option<Retained<NWEndpoint>>;
2978
2979 /// The flow's remote hostname. This property is only non-nil if the flow was created using Network.framework or NSURLSession.
2980 #[unsafe(method(remoteHostname))]
2981 #[unsafe(method_family = none)]
2982 pub unsafe fn remoteHostname(&self) -> Option<Retained<NSString>>;
2983
2984 /// The flow's local endpoint. This endpoint object may be nil when [NEFilterDataProvider handleNewFlow:] is invoked and if so will be populated upon receiving network data.
2985 /// In such a case, filtering on the flow may still be performed based on its socket type, socket family or socket protocol.
2986 #[deprecated]
2987 #[unsafe(method(localEndpoint))]
2988 #[unsafe(method_family = none)]
2989 pub unsafe fn localEndpoint(&self) -> Option<Retained<NWEndpoint>>;
2990
2991 /// Socket family of the socket flow, such as PF_INET.
2992 #[unsafe(method(socketFamily))]
2993 #[unsafe(method_family = none)]
2994 pub unsafe fn socketFamily(&self) -> c_int;
2995
2996 /// Socket type of the socket flow, such as SOCK_STREAM.
2997 #[unsafe(method(socketType))]
2998 #[unsafe(method_family = none)]
2999 pub unsafe fn socketType(&self) -> c_int;
3000
3001 /// Socket protocol of the socket flow, such as IPPROTO_TCP.
3002 #[unsafe(method(socketProtocol))]
3003 #[unsafe(method_family = none)]
3004 pub unsafe fn socketProtocol(&self) -> c_int;
3005 );
3006}
3007
3008/// Methods declared on superclass `NSObject`.
3009impl NEFilterSocketFlow {
3010 extern_methods!(
3011 #[unsafe(method(init))]
3012 #[unsafe(method_family = init)]
3013 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
3014
3015 #[unsafe(method(new))]
3016 #[unsafe(method_family = new)]
3017 pub unsafe fn new() -> Retained<Self>;
3018 );
3019}
3020
3021extern "C" {
3022 /// Key to specify in the NSDictionary which is returned as a value in remediationMap.
3023 /// This key is used to indicate the Remediation URL. The URL should follow the scheme
3024 /// http or https to be used by the content filter.
3025 ///
3026 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterproviderremediationmapremediationurls?language=objc)
3027 pub static NEFilterProviderRemediationMapRemediationURLs: &'static NSString;
3028}
3029
3030extern "C" {
3031 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterproviderremediationmapremediationbuttontexts?language=objc)
3032 pub static NEFilterProviderRemediationMapRemediationButtonTexts: &'static NSString;
3033}
3034
3035extern_class!(
3036 /// The NEFilterProvider class is an abstract base class that declares the programmatic interface of an
3037 /// object that implements a socket filter.
3038 ///
3039 /// NEFilterProvider is part of NetworkExtension.framework
3040 ///
3041 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterprovider?language=objc)
3042 #[unsafe(super(NEProvider, NSObject))]
3043 #[derive(Debug, PartialEq, Eq, Hash)]
3044 pub struct NEFilterProvider;
3045);
3046
3047extern_conformance!(
3048 unsafe impl NSObjectProtocol for NEFilterProvider {}
3049);
3050
3051impl NEFilterProvider {
3052 extern_methods!(
3053 #[cfg(feature = "block2")]
3054 /// This function is called by the framework when the content filter is being started. Subclasses must
3055 /// override this method and perform whatever steps are necessary to start the filter.
3056 ///
3057 /// Parameter `completionHandler`: A block that must be called when the process of starting the filter is complete. If the
3058 /// filter was started successfully, subclass implementations must pass the nil value to this block. If an error occurred
3059 /// while starting the filter, sublcass implementations must pass a non-nil NSError containing more details about the error.
3060 #[unsafe(method(startFilterWithCompletionHandler:))]
3061 #[unsafe(method_family = none)]
3062 pub unsafe fn startFilterWithCompletionHandler(
3063 &self,
3064 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
3065 );
3066
3067 #[cfg(feature = "block2")]
3068 /// This function is called by the framework when the content filter is being stopped. Subclasses must
3069 /// override this method and perform whatever steps are necessary to stop the filter.
3070 ///
3071 /// Parameter `reason`: An NEProviderStopReason indicating why the filter is being stopped.
3072 ///
3073 /// Parameter `completionHandler`: A block that must be called when the process of stopping the filter is complete.
3074 #[unsafe(method(stopFilterWithReason:completionHandler:))]
3075 #[unsafe(method_family = none)]
3076 pub unsafe fn stopFilterWithReason_completionHandler(
3077 &self,
3078 reason: NEProviderStopReason,
3079 completion_handler: &block2::DynBlock<dyn Fn()>,
3080 );
3081
3082 /// An NEContentFilterConfiguration object containing the current filter configuration. The value of this
3083 /// property can change during the lifetime of a filter. Filter implementations can use KVO to be notified when the
3084 /// configuration changes.
3085 #[unsafe(method(filterConfiguration))]
3086 #[unsafe(method_family = none)]
3087 pub unsafe fn filterConfiguration(&self) -> Retained<NEFilterProviderConfiguration>;
3088
3089 /// This function is called by the framework when the data provider extension returns a verdict with the report property set to True.
3090 /// Subclass implementations may override this method to handle the flow report.
3091 ///
3092 /// Parameter `report`: The report being delivered.
3093 #[unsafe(method(handleReport:))]
3094 #[unsafe(method_family = none)]
3095 pub unsafe fn handleReport(&self, report: &NEFilterReport);
3096 );
3097}
3098
3099/// Methods declared on superclass `NSObject`.
3100impl NEFilterProvider {
3101 extern_methods!(
3102 #[unsafe(method(init))]
3103 #[unsafe(method_family = init)]
3104 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
3105
3106 #[unsafe(method(new))]
3107 #[unsafe(method_family = new)]
3108 pub unsafe fn new() -> Retained<Self>;
3109 );
3110}
3111
3112/// A NEFilterReportFrequency controls the frequency of periodic reports.
3113///
3114/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterreportfrequency?language=objc)
3115// NS_ENUM
3116#[repr(transparent)]
3117#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
3118pub struct NEFilterReportFrequency(pub NSInteger);
3119impl NEFilterReportFrequency {
3120 #[doc(alias = "NEFilterReportFrequencyNone")]
3121 pub const None: Self = Self(0);
3122 #[doc(alias = "NEFilterReportFrequencyLow")]
3123 pub const Low: Self = Self(1);
3124 #[doc(alias = "NEFilterReportFrequencyMedium")]
3125 pub const Medium: Self = Self(2);
3126 #[doc(alias = "NEFilterReportFrequencyHigh")]
3127 pub const High: Self = Self(3);
3128}
3129
3130unsafe impl Encode for NEFilterReportFrequency {
3131 const ENCODING: Encoding = NSInteger::ENCODING;
3132}
3133
3134unsafe impl RefEncode for NEFilterReportFrequency {
3135 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
3136}
3137
3138extern_class!(
3139 /// The NEFilterVerdict class declares the programmatic interface for an object that is the verdict for a
3140 /// flow of network data.
3141 ///
3142 /// NEFilterVerdict is part of NetworkExtension.framework
3143 ///
3144 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterverdict?language=objc)
3145 #[unsafe(super(NSObject))]
3146 #[derive(Debug, PartialEq, Eq, Hash)]
3147 pub struct NEFilterVerdict;
3148);
3149
3150extern_conformance!(
3151 unsafe impl NSCoding for NEFilterVerdict {}
3152);
3153
3154extern_conformance!(
3155 unsafe impl NSCopying for NEFilterVerdict {}
3156);
3157
3158unsafe impl CopyingHelper for NEFilterVerdict {
3159 type Result = Self;
3160}
3161
3162extern_conformance!(
3163 unsafe impl NSObjectProtocol for NEFilterVerdict {}
3164);
3165
3166extern_conformance!(
3167 unsafe impl NSSecureCoding for NEFilterVerdict {}
3168);
3169
3170impl NEFilterVerdict {
3171 extern_methods!(
3172 /// Whether or not to send a report to the control provider's -[NEFilterProvider handleReport:]
3173 /// method when processing this verdict and when the flow is closed. Since the data provider does not need to wait
3174 /// for a response from the control provider before continuing to process the flow, this is a more efficient way to
3175 /// report a flow to the control provider than returning a "need rules" verdict. If the verdict originates in the
3176 /// control provider, this property has no effect. This property applies when the action taken upon a flow is allow,
3177 /// deny, remediate, or filterData (filterData for new flows only). Setting this flag on a verdict for a socket
3178 /// flow will also cause the data provider's -[NEFilterProvider handleReport:] method to be called when the flow
3179 /// is closed.
3180 #[unsafe(method(shouldReport))]
3181 #[unsafe(method_family = none)]
3182 pub unsafe fn shouldReport(&self) -> bool;
3183
3184 /// Setter for [`shouldReport`][Self::shouldReport].
3185 #[unsafe(method(setShouldReport:))]
3186 #[unsafe(method_family = none)]
3187 pub unsafe fn setShouldReport(&self, should_report: bool);
3188 );
3189}
3190
3191/// Methods declared on superclass `NSObject`.
3192impl NEFilterVerdict {
3193 extern_methods!(
3194 #[unsafe(method(init))]
3195 #[unsafe(method_family = init)]
3196 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
3197
3198 #[unsafe(method(new))]
3199 #[unsafe(method_family = new)]
3200 pub unsafe fn new() -> Retained<Self>;
3201 );
3202}
3203
3204extern_class!(
3205 /// The NEFilterNewFlowVerdict declares the programmatic interface of an object that is the verdict for a
3206 /// new flow of network data before any of the flow's data has been seen by the filter.
3207 ///
3208 /// NEFilterNewFlowVerdict is part of NetworkExtension.framework
3209 ///
3210 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilternewflowverdict?language=objc)
3211 #[unsafe(super(NEFilterVerdict, NSObject))]
3212 #[derive(Debug, PartialEq, Eq, Hash)]
3213 pub struct NEFilterNewFlowVerdict;
3214);
3215
3216extern_conformance!(
3217 unsafe impl NSCoding for NEFilterNewFlowVerdict {}
3218);
3219
3220extern_conformance!(
3221 unsafe impl NSCopying for NEFilterNewFlowVerdict {}
3222);
3223
3224unsafe impl CopyingHelper for NEFilterNewFlowVerdict {
3225 type Result = Self;
3226}
3227
3228extern_conformance!(
3229 unsafe impl NSObjectProtocol for NEFilterNewFlowVerdict {}
3230);
3231
3232extern_conformance!(
3233 unsafe impl NSSecureCoding for NEFilterNewFlowVerdict {}
3234);
3235
3236impl NEFilterNewFlowVerdict {
3237 extern_methods!(
3238 /// The frequency at which the data provider's -[NEFilterProvider handleReport:] method is called with a NEFilterReport instance with an event of NEFilterReportEventFlowStatistics.
3239 /// The default value is NEFilterReportFrequencyNone, so by default no statistics are reported.
3240 #[unsafe(method(statisticsReportFrequency))]
3241 #[unsafe(method_family = none)]
3242 pub unsafe fn statisticsReportFrequency(&self) -> NEFilterReportFrequency;
3243
3244 /// Setter for [`statisticsReportFrequency`][Self::statisticsReportFrequency].
3245 #[unsafe(method(setStatisticsReportFrequency:))]
3246 #[unsafe(method_family = none)]
3247 pub unsafe fn setStatisticsReportFrequency(
3248 &self,
3249 statistics_report_frequency: NEFilterReportFrequency,
3250 );
3251
3252 /// This class method returns a verdict indicating that control provider needs to be asked how to handle
3253 /// the new flow. The control provider can either drop or allow the flow, or update the rules and ask the data provider
3254 /// to decide on the new flow again.
3255 ///
3256 /// Returns: The NEFilterNewFlowVerdict object.
3257 #[unsafe(method(needRulesVerdict))]
3258 #[unsafe(method_family = none)]
3259 pub unsafe fn needRulesVerdict() -> Retained<NEFilterNewFlowVerdict>;
3260
3261 /// This class method returns a verdict indicating that the flow should be allowed.
3262 ///
3263 /// Returns: The NEFilterNewFlowVerdict object.
3264 #[unsafe(method(allowVerdict))]
3265 #[unsafe(method_family = none)]
3266 pub unsafe fn allowVerdict() -> Retained<NEFilterNewFlowVerdict>;
3267
3268 /// This class method returns a verdict indicating that the flow should be dropped.
3269 ///
3270 /// Returns: The NEFilterNewFlowVerdict object.
3271 #[unsafe(method(dropVerdict))]
3272 #[unsafe(method_family = none)]
3273 pub unsafe fn dropVerdict() -> Retained<NEFilterNewFlowVerdict>;
3274
3275 /// This class method returns a verdict indicating that a "content blocked" page should be displayed to
3276 /// the user. The block page should contain a link to the given URL.
3277 ///
3278 /// Parameter `remediationURLMapKey`: Remediation map key used by data plugin to get remediation url
3279 ///
3280 /// Returns: The NEFilterNewFlowVerdict object.
3281 #[unsafe(method(remediateVerdictWithRemediationURLMapKey:remediationButtonTextMapKey:))]
3282 #[unsafe(method_family = none)]
3283 pub unsafe fn remediateVerdictWithRemediationURLMapKey_remediationButtonTextMapKey(
3284 remediation_url_map_key: &NSString,
3285 remediation_button_text_map_key: &NSString,
3286 ) -> Retained<NEFilterNewFlowVerdict>;
3287
3288 /// This class method returns a verdict indicating that safe search URL for the new should be specified
3289 ///
3290 /// Parameter `urlAppendMapKey`: URL Append map key to be used by the data plugin to notify what the url should be appended with
3291 ///
3292 /// Returns: The NEFilterNewFlowVerdict object.
3293 #[unsafe(method(URLAppendStringVerdictWithMapKey:))]
3294 #[unsafe(method_family = none)]
3295 pub unsafe fn URLAppendStringVerdictWithMapKey(
3296 url_append_map_key: &NSString,
3297 ) -> Retained<NEFilterNewFlowVerdict>;
3298
3299 /// This class method returns a new flow verdict indicating that the filter needs to make a decision about
3300 /// a new flow after seeing a portion of the flow's data.
3301 ///
3302 /// Parameter `filterInbound`: A boolean indicating if the filter needs to see inbound data
3303 ///
3304 /// Parameter `peekInboundBytes`: The number of inbound bytes that the filter needs to see in the subsequent call to
3305 /// -[NEFilterDataProvider handleInboundDataFromFlow:readBytesStartOffset:readBytes:].
3306 ///
3307 /// Parameter `filterOutbound`: boolean indicating if the filter needs to see outbound data
3308 ///
3309 /// Parameter `peekOutboundBytes`: The number of outbound bytes that the filter needs to see in the subsequent call to
3310 /// -[NEFilterDataProvider handleOutboundDataFromFlow:readBytesStartOffset:readBytes:].
3311 ///
3312 /// Returns: The new flow verdict.
3313 #[unsafe(method(filterDataVerdictWithFilterInbound:peekInboundBytes:filterOutbound:peekOutboundBytes:))]
3314 #[unsafe(method_family = none)]
3315 pub unsafe fn filterDataVerdictWithFilterInbound_peekInboundBytes_filterOutbound_peekOutboundBytes(
3316 filter_inbound: bool,
3317 peek_inbound_bytes: NSUInteger,
3318 filter_outbound: bool,
3319 peek_outbound_bytes: NSUInteger,
3320 ) -> Retained<NEFilterNewFlowVerdict>;
3321
3322 /// This class method returns a verdict indicating that none of the data provider's handler callbacks shall be called for the flow until after the flow is resumed
3323 /// by a call to -[NEFilterDataProvider resumeFlow:withVerdict:]. TCP flows may be paused indefinitely. UDP flows will be dropped if not resumed within 10 seconds of
3324 /// being paused. It is invalid to pause a flow that is already paused.
3325 ///
3326 /// Returns: The NEFilterNewFlowVerdict object.
3327 #[unsafe(method(pauseVerdict))]
3328 #[unsafe(method_family = none)]
3329 pub unsafe fn pauseVerdict() -> Retained<NEFilterNewFlowVerdict>;
3330 );
3331}
3332
3333/// Methods declared on superclass `NSObject`.
3334impl NEFilterNewFlowVerdict {
3335 extern_methods!(
3336 #[unsafe(method(init))]
3337 #[unsafe(method_family = init)]
3338 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
3339
3340 #[unsafe(method(new))]
3341 #[unsafe(method_family = new)]
3342 pub unsafe fn new() -> Retained<Self>;
3343 );
3344}
3345
3346extern_class!(
3347 /// The NEFilterControlVerdict declares the programmatic interface of an object that is the verdict for a
3348 /// new flow of network data by the control provider.
3349 ///
3350 /// NEFilterControlVerdict is part of NetworkExtension.framework
3351 ///
3352 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefiltercontrolverdict?language=objc)
3353 #[unsafe(super(NEFilterNewFlowVerdict, NEFilterVerdict, NSObject))]
3354 #[derive(Debug, PartialEq, Eq, Hash)]
3355 pub struct NEFilterControlVerdict;
3356);
3357
3358extern_conformance!(
3359 unsafe impl NSCoding for NEFilterControlVerdict {}
3360);
3361
3362extern_conformance!(
3363 unsafe impl NSCopying for NEFilterControlVerdict {}
3364);
3365
3366unsafe impl CopyingHelper for NEFilterControlVerdict {
3367 type Result = Self;
3368}
3369
3370extern_conformance!(
3371 unsafe impl NSObjectProtocol for NEFilterControlVerdict {}
3372);
3373
3374extern_conformance!(
3375 unsafe impl NSSecureCoding for NEFilterControlVerdict {}
3376);
3377
3378impl NEFilterControlVerdict {
3379 extern_methods!(
3380 /// This class method returns a verdict indicating that the flow should be allowed to go through, and also
3381 /// tell the data provider whether to update its rules or not.
3382 ///
3383 /// Parameter `updateRules`: YES if the control provider has updated the rules and wants to communicate that to the data provider
3384 ///
3385 /// Returns: The NEFilterControlVerdict object.
3386 #[unsafe(method(allowVerdictWithUpdateRules:))]
3387 #[unsafe(method_family = none)]
3388 pub unsafe fn allowVerdictWithUpdateRules(
3389 update_rules: bool,
3390 ) -> Retained<NEFilterControlVerdict>;
3391
3392 /// This class method returns a verdict indicating that the flow should be dropped, and also tell the data
3393 /// provider whether to update its rules or not.
3394 ///
3395 /// Parameter `updateRules`: YES if the control provider has updated the rules and wants to communicate that to the data provider
3396 ///
3397 /// Returns: The NEFilterControlVerdict object.
3398 #[unsafe(method(dropVerdictWithUpdateRules:))]
3399 #[unsafe(method_family = none)]
3400 pub unsafe fn dropVerdictWithUpdateRules(
3401 update_rules: bool,
3402 ) -> Retained<NEFilterControlVerdict>;
3403
3404 /// This class method returns a verdict indicating that the flow should be handled by the data provider,
3405 /// and the rules needed by the data provider have been set.
3406 ///
3407 /// Returns: The NEFilterControlVerdict object.
3408 #[unsafe(method(updateRules))]
3409 #[unsafe(method_family = none)]
3410 pub unsafe fn updateRules() -> Retained<NEFilterControlVerdict>;
3411 );
3412}
3413
3414/// Methods declared on superclass `NSObject`.
3415impl NEFilterControlVerdict {
3416 extern_methods!(
3417 #[unsafe(method(init))]
3418 #[unsafe(method_family = init)]
3419 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
3420
3421 #[unsafe(method(new))]
3422 #[unsafe(method_family = new)]
3423 pub unsafe fn new() -> Retained<Self>;
3424 );
3425}
3426
3427/// A NEFilterAction represents the possible actions taken upon a NEFilterFlow that can be reported by the
3428/// data provider extension to the control provider extension.
3429///
3430/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilteraction?language=objc)
3431// NS_ENUM
3432#[repr(transparent)]
3433#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
3434pub struct NEFilterAction(pub NSInteger);
3435impl NEFilterAction {
3436 #[doc(alias = "NEFilterActionInvalid")]
3437 pub const Invalid: Self = Self(0);
3438 #[doc(alias = "NEFilterActionAllow")]
3439 pub const Allow: Self = Self(1);
3440 #[doc(alias = "NEFilterActionDrop")]
3441 pub const Drop: Self = Self(2);
3442 #[doc(alias = "NEFilterActionRemediate")]
3443 pub const Remediate: Self = Self(3);
3444 #[doc(alias = "NEFilterActionFilterData")]
3445 pub const FilterData: Self = Self(4);
3446}
3447
3448unsafe impl Encode for NEFilterAction {
3449 const ENCODING: Encoding = NSInteger::ENCODING;
3450}
3451
3452unsafe impl RefEncode for NEFilterAction {
3453 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
3454}
3455
3456/// A NEFilterReportEvent represents the event that is being reported by the NEFilterReport.
3457///
3458/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterreportevent?language=objc)
3459// NS_ENUM
3460#[repr(transparent)]
3461#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
3462pub struct NEFilterReportEvent(pub NSInteger);
3463impl NEFilterReportEvent {
3464 #[doc(alias = "NEFilterReportEventNewFlow")]
3465 pub const NewFlow: Self = Self(1);
3466 #[doc(alias = "NEFilterReportEventDataDecision")]
3467 pub const DataDecision: Self = Self(2);
3468 #[doc(alias = "NEFilterReportEventFlowClosed")]
3469 pub const FlowClosed: Self = Self(3);
3470 #[doc(alias = "NEFilterReportEventStatistics")]
3471 pub const Statistics: Self = Self(4);
3472}
3473
3474unsafe impl Encode for NEFilterReportEvent {
3475 const ENCODING: Encoding = NSInteger::ENCODING;
3476}
3477
3478unsafe impl RefEncode for NEFilterReportEvent {
3479 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
3480}
3481
3482extern_class!(
3483 /// The NEFilterReport declares the programmatic interface of an object that is a report of actions taken by
3484 /// the data provider.
3485 ///
3486 /// NEFilterReport is part of NetworkExtension.framework
3487 ///
3488 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterreport?language=objc)
3489 #[unsafe(super(NSObject))]
3490 #[derive(Debug, PartialEq, Eq, Hash)]
3491 pub struct NEFilterReport;
3492);
3493
3494extern_conformance!(
3495 unsafe impl NSCoding for NEFilterReport {}
3496);
3497
3498extern_conformance!(
3499 unsafe impl NSCopying for NEFilterReport {}
3500);
3501
3502unsafe impl CopyingHelper for NEFilterReport {
3503 type Result = Self;
3504}
3505
3506extern_conformance!(
3507 unsafe impl NSObjectProtocol for NEFilterReport {}
3508);
3509
3510extern_conformance!(
3511 unsafe impl NSSecureCoding for NEFilterReport {}
3512);
3513
3514impl NEFilterReport {
3515 extern_methods!(
3516 /// The flow on which the described action was taken.
3517 #[unsafe(method(flow))]
3518 #[unsafe(method_family = none)]
3519 pub unsafe fn flow(&self) -> Option<Retained<NEFilterFlow>>;
3520
3521 /// The action taken upon the reported flow.
3522 #[unsafe(method(action))]
3523 #[unsafe(method_family = none)]
3524 pub unsafe fn action(&self) -> NEFilterAction;
3525
3526 /// The type of event that the report is reporting.
3527 #[unsafe(method(event))]
3528 #[unsafe(method_family = none)]
3529 pub unsafe fn event(&self) -> NEFilterReportEvent;
3530
3531 /// The number of inbound bytes received from the flow. This property is only non-zero when the report event is NEFilterReportEventFlowClosed or NEFilterReportEventFlowStatistics.
3532 #[unsafe(method(bytesInboundCount))]
3533 #[unsafe(method_family = none)]
3534 pub unsafe fn bytesInboundCount(&self) -> NSUInteger;
3535
3536 /// The number of outbound bytes sent on the flow. This property is only non-zero when the report event is NEFilterReportEventFlowClosed or NEFilterReportEventFlowStatistics.
3537 #[unsafe(method(bytesOutboundCount))]
3538 #[unsafe(method_family = none)]
3539 pub unsafe fn bytesOutboundCount(&self) -> NSUInteger;
3540 );
3541}
3542
3543/// Methods declared on superclass `NSObject`.
3544impl NEFilterReport {
3545 extern_methods!(
3546 #[unsafe(method(init))]
3547 #[unsafe(method_family = init)]
3548 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
3549
3550 #[unsafe(method(new))]
3551 #[unsafe(method_family = new)]
3552 pub unsafe fn new() -> Retained<Self>;
3553 );
3554}
3555
3556extern_class!(
3557 /// The NEFilterControlProvider class declares the programmatic interface for an object that is responsible for installing filtering rules on the device.
3558 ///
3559 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefiltercontrolprovider?language=objc)
3560 #[unsafe(super(NEFilterProvider, NEProvider, NSObject))]
3561 #[derive(Debug, PartialEq, Eq, Hash)]
3562 pub struct NEFilterControlProvider;
3563);
3564
3565extern_conformance!(
3566 unsafe impl NSObjectProtocol for NEFilterControlProvider {}
3567);
3568
3569impl NEFilterControlProvider {
3570 extern_methods!(
3571 /// A dictionary containing custom strings to be inserted into the "content blocked" page displayed in WebKit. Each key in this dictionary corresponds to a string in the "content blocked" page. The value of each key is a dictionary that maps keys to the custom strings to be inserted into the "content blocked" page. The keys for the sub-dictionaries are defined by the control provider. When the data provider creates a "remediate" verdict using [NEFilterDataVerdict remediateVerdictWithRemediationURLMapKey:remediationButtonTextMapKey:], it passes the key corresponding to the custom string to be inserted into the "content blocked" page.
3572 ///
3573 /// Here is a sample remediationMap dictionary:
3574 ///
3575 /// remediationMap =
3576 /// @
3577 /// { NEFilterProviderRemediationMapRemediationURLs :
3578 /// @
3579 /// {
3580 /// "
3581 /// RemediateKey1" : @"http://www.remediation_url_1.com",
3582 /// "
3583 /// RemediateKey2" : @"http://www.remediation_url_2.com"
3584 /// },
3585 /// NEFilterProviderRemediationMapRemediationButtonTexts :
3586 /// @
3587 /// {
3588 /// "
3589 /// RemediationButtonText1" : @"Remediate URL"
3590 /// }
3591 /// };
3592 #[unsafe(method(remediationMap))]
3593 #[unsafe(method_family = none)]
3594 pub unsafe fn remediationMap(
3595 &self,
3596 ) -> Option<Retained<NSDictionary<NSString, NSDictionary<NSString, NSObject>>>>;
3597
3598 /// Setter for [`remediationMap`][Self::remediationMap].
3599 ///
3600 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
3601 ///
3602 /// # Safety
3603 ///
3604 /// `remediation_map` generic generic should be of the correct type.
3605 #[unsafe(method(setRemediationMap:))]
3606 #[unsafe(method_family = none)]
3607 pub unsafe fn setRemediationMap(
3608 &self,
3609 remediation_map: Option<&NSDictionary<NSString, NSDictionary<NSString, NSObject>>>,
3610 );
3611
3612 /// A dictionary containing strings to be appended to URLs.
3613 #[unsafe(method(URLAppendStringMap))]
3614 #[unsafe(method_family = none)]
3615 pub unsafe fn URLAppendStringMap(
3616 &self,
3617 ) -> Option<Retained<NSDictionary<NSString, NSString>>>;
3618
3619 /// Setter for [`URLAppendStringMap`][Self::URLAppendStringMap].
3620 ///
3621 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
3622 #[unsafe(method(setURLAppendStringMap:))]
3623 #[unsafe(method_family = none)]
3624 pub unsafe fn setURLAppendStringMap(
3625 &self,
3626 url_append_string_map: Option<&NSDictionary<NSString, NSString>>,
3627 );
3628
3629 #[cfg(feature = "block2")]
3630 /// This function is called by the framework when the NEFilterDataProvider indicates that the filtering verdict for the given flow is NEFilterRemediateVerdictNeedRules. Subclass implementations must override this method and implement whatever steps are necessary to remediate the given flow.
3631 ///
3632 /// Parameter `flow`: An NEFilterFlow object containing details about the flow that requires remediation.
3633 ///
3634 /// Parameter `completionHandler`: A block that must be called when the NEFilterControlProvider is ready for the NEFilterDataProvider to re-process the new flow. NEFilterControlVerdict stores the verdict through which the control provider determines if a flow needs to be dropped or allowed. The verdict also indicates if the control plugin wants the data plugin to update its rules and handle the verdict.
3635 #[unsafe(method(handleRemediationForFlow:completionHandler:))]
3636 #[unsafe(method_family = none)]
3637 pub unsafe fn handleRemediationForFlow_completionHandler(
3638 &self,
3639 flow: &NEFilterFlow,
3640 completion_handler: &block2::DynBlock<dyn Fn(NonNull<NEFilterControlVerdict>)>,
3641 );
3642
3643 #[cfg(feature = "block2")]
3644 /// This function is called by the framework when the NEFilterDataProvider indicates that the filtering verdict for the given flow is NEFilterNewFlowVerdictNeedRules. Subclass implementations must override this method and implement whatever steps are necessary to fetch new rules pertaining to the given flow and place them on disk in a location accessible by the NEFilterDataProvider.
3645 ///
3646 /// Parameter `flow`: An NEFilterFlow object containing details about the flow that requires a rules update.
3647 ///
3648 /// Parameter `completionHandler`: A block that must be called when the NEFilterControlProvider is ready for the NEFilterDataProvider to re-process the new flow. NEFilterControlVerdict stores the verdict through which the control provider determines if a flow needs to be dropped or allowed. The verdict also indicates if the control plugin wants the data plugin to update its rules and handle the verdict.
3649 #[unsafe(method(handleNewFlow:completionHandler:))]
3650 #[unsafe(method_family = none)]
3651 pub unsafe fn handleNewFlow_completionHandler(
3652 &self,
3653 flow: &NEFilterFlow,
3654 completion_handler: &block2::DynBlock<dyn Fn(NonNull<NEFilterControlVerdict>)>,
3655 );
3656
3657 /// This function is called by filter control implementations to notify the data provider "out of band" that the rules changed.
3658 #[unsafe(method(notifyRulesChanged))]
3659 #[unsafe(method_family = none)]
3660 pub unsafe fn notifyRulesChanged(&self);
3661 );
3662}
3663
3664/// Methods declared on superclass `NSObject`.
3665impl NEFilterControlProvider {
3666 extern_methods!(
3667 #[unsafe(method(init))]
3668 #[unsafe(method_family = init)]
3669 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
3670
3671 #[unsafe(method(new))]
3672 #[unsafe(method_family = new)]
3673 pub unsafe fn new() -> Retained<Self>;
3674 );
3675}
3676
3677/// Attribute flags describing data
3678///
3679/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterdataattribute?language=objc)
3680// NS_ENUM
3681#[repr(transparent)]
3682#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
3683pub struct NEFilterDataAttribute(pub NSInteger);
3684impl NEFilterDataAttribute {
3685 #[doc(alias = "NEFilterDataAttributeHasIPHeader")]
3686 pub const HasIPHeader: Self = Self(0x00000001);
3687}
3688
3689unsafe impl Encode for NEFilterDataAttribute {
3690 const ENCODING: Encoding = NSInteger::ENCODING;
3691}
3692
3693unsafe impl RefEncode for NEFilterDataAttribute {
3694 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
3695}
3696
3697extern_class!(
3698 /// The NEFilterDataProvider class declares the programmatic interface for an object that evaluates network data flows based on a set of locally-available rules and makes decisions about whether to block or allow the flows.
3699 ///
3700 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterdataprovider?language=objc)
3701 #[unsafe(super(NEFilterProvider, NEProvider, NSObject))]
3702 #[derive(Debug, PartialEq, Eq, Hash)]
3703 pub struct NEFilterDataProvider;
3704);
3705
3706extern_conformance!(
3707 unsafe impl NSObjectProtocol for NEFilterDataProvider {}
3708);
3709
3710impl NEFilterDataProvider {
3711 extern_methods!(
3712 /// This function is called by the framework when a filtering decision needs to be made about a new network data flow. Subclasses must override this method to implement the steps necessary to match the flow against some locally stored rules and return an appropriate verdict.
3713 ///
3714 /// Parameter `flow`: An NEFilterFlow object containing details about the new flow.
3715 ///
3716 /// Returns: An NEFilterNewFlowVerdict object containing the verdict for the new flow.
3717 #[unsafe(method(handleNewFlow:))]
3718 #[unsafe(method_family = none)]
3719 pub unsafe fn handleNewFlow(&self, flow: &NEFilterFlow)
3720 -> Retained<NEFilterNewFlowVerdict>;
3721
3722 /// This function is called by the framework when a filtering decision needs to be made about some inbound data that the filter previously requested access to via the NEFilterFlowDataVerdict or the NEFilterNewFlowVerdict. Subclasses must override this method.
3723 ///
3724 /// Parameter `flow`: The NEFilterFlow from which the data was read.
3725 ///
3726 /// Parameter `offset`: The offset in bytes from the start of the flow's inbound data at which readBytes begins.
3727 ///
3728 /// Parameter `readBytes`: The data that was read. For non-UDP/TCP flows, since data may optionally include the IP header, readBytes includes a 4-bytes NEFilterDataAttribute field preceding the user data. Handler must examine the NEFilterDataAttribute field and handle the data accordingly.
3729 ///
3730 /// Returns: An NEFilterFlowDataVerdict containing the verdict for the flow.
3731 #[unsafe(method(handleInboundDataFromFlow:readBytesStartOffset:readBytes:))]
3732 #[unsafe(method_family = none)]
3733 pub unsafe fn handleInboundDataFromFlow_readBytesStartOffset_readBytes(
3734 &self,
3735 flow: &NEFilterFlow,
3736 offset: NSUInteger,
3737 read_bytes: &NSData,
3738 ) -> Retained<NEFilterDataVerdict>;
3739
3740 /// This function is called by the framework when a filtering decision needs to be made about some outbound data that the filter previously requested access to via the NEFilterFlowDataVerdict or the NEFilterNewFlowVerdict. Subclasses must override this method.
3741 ///
3742 /// Parameter `flow`: The NEFilterFlow from which the data was read.
3743 ///
3744 /// Parameter `offset`: The offset in bytes from the start of the flow's outbound data at which readBytes begins.
3745 ///
3746 /// Parameter `readBytes`: The data that was read. For non-UDP/TCP flows, since data may optionally include the IP header, readBytes includes a 4-bytes NEFilterDataAttribute field preceding the user data. Handler must examine the NEFilterDataAttribute field and handle the data accordingly.
3747 ///
3748 /// Returns: An NEFilterFlowDataVerdict containing the verdict for the flow.
3749 #[unsafe(method(handleOutboundDataFromFlow:readBytesStartOffset:readBytes:))]
3750 #[unsafe(method_family = none)]
3751 pub unsafe fn handleOutboundDataFromFlow_readBytesStartOffset_readBytes(
3752 &self,
3753 flow: &NEFilterFlow,
3754 offset: NSUInteger,
3755 read_bytes: &NSData,
3756 ) -> Retained<NEFilterDataVerdict>;
3757
3758 /// This function is called by the framework after all of the inbound data for a flow has been seen by the filter. Subclasses must override this method to return an appropriate pass/block result.
3759 ///
3760 /// Parameter `flow`: The flow
3761 ///
3762 /// Returns: The final NEFilterFlowDataVerdict verdict for the flow.
3763 #[unsafe(method(handleInboundDataCompleteForFlow:))]
3764 #[unsafe(method_family = none)]
3765 pub unsafe fn handleInboundDataCompleteForFlow(
3766 &self,
3767 flow: &NEFilterFlow,
3768 ) -> Retained<NEFilterDataVerdict>;
3769
3770 /// This function is called by the framework after all of the outbound data for a flow has been seen by the filter. Subclasses must override this method to return an appropriate pass/block result.
3771 ///
3772 /// Parameter `flow`: The flow
3773 ///
3774 /// Returns: The final NEFilterFlowDataVerdict verdict for the flow.
3775 #[unsafe(method(handleOutboundDataCompleteForFlow:))]
3776 #[unsafe(method_family = none)]
3777 pub unsafe fn handleOutboundDataCompleteForFlow(
3778 &self,
3779 flow: &NEFilterFlow,
3780 ) -> Retained<NEFilterDataVerdict>;
3781
3782 /// This function is called by the framework after the user requests remediation for a blocked flow. Subclasses must override this method to return an appropriate pass/block result.
3783 ///
3784 /// Parameter `flow`: The flow
3785 ///
3786 /// Returns: The final NEFilterRemediationVerdict verdict for the flow.
3787 #[unsafe(method(handleRemediationForFlow:))]
3788 #[unsafe(method_family = none)]
3789 pub unsafe fn handleRemediationForFlow(
3790 &self,
3791 flow: &NEFilterFlow,
3792 ) -> Retained<NEFilterRemediationVerdict>;
3793
3794 /// This function is called by the framework when -[NEFilterControlProvider notifyRulesChanged] is called. Subclasses should override this method to reload new rules from disk.
3795 #[unsafe(method(handleRulesChanged))]
3796 #[unsafe(method_family = none)]
3797 pub unsafe fn handleRulesChanged(&self);
3798
3799 #[cfg(feature = "block2")]
3800 /// The provider calls this function to apply the current set of filtering rules associated with the provider and also change the default filtering action.
3801 ///
3802 /// Parameter `settings`: A NEFilterSettings object containing the filter settings to apply to the system. Pass nil to revert to the default settings, which are an
3803 /// empty list of rules and a default action of NEFilterActionFilterData.
3804 ///
3805 /// Parameter `completionHandler`: A block that will be executed when the settings have been applied to the system. If an error occurs then the error parameter will be non-nil.
3806 #[unsafe(method(applySettings:completionHandler:))]
3807 #[unsafe(method_family = none)]
3808 pub unsafe fn applySettings_completionHandler(
3809 &self,
3810 settings: Option<&NEFilterSettings>,
3811 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
3812 );
3813
3814 /// This function is called by the provider to resume a flow that was previously paused by the provider returning a pause verdict.
3815 ///
3816 /// Parameter `flow`: The flow to resume
3817 ///
3818 /// Parameter `verdict`: The next NEFilterDataVerdict for the flow. This verdict is used as the verdict corresponding to the
3819 /// flow handler callback (handleNewFlow:, handleInboundDataFromFlow:, etc.) that returned the pause verdict that
3820 /// paused the flow. This must be either a NEFilterDataVerdict or a NEFilterNewFlowVerdict. It is invalid to resume
3821 /// a flow that is not paused.
3822 #[unsafe(method(resumeFlow:withVerdict:))]
3823 #[unsafe(method_family = none)]
3824 pub unsafe fn resumeFlow_withVerdict(&self, flow: &NEFilterFlow, verdict: &NEFilterVerdict);
3825
3826 /// This function is called by the provider to update the verdict for a flow outside the context of any NEFilterDataProvider callback.
3827 ///
3828 /// Parameter `flow`: The NEFilterSocketFlow to update the verdict for.
3829 ///
3830 /// Parameter `verdict`: The NEFilterDataVerdict. Must be a +[NEFilterDataVerdict allowVerdict], a +[NEFilterDataVerdict dropVerdict], or a +[NEFilterDataVerdict dataVerdictWithPassBytes:peekBytes:].
3831 ///
3832 /// Parameter `direction`: The direction to which the verdict applies. Pass NETrafficDirectionAny to update the verdict for both the inbound and outbound directions. This parameter is ignored if the verdict is +[NEFilterDataVerdict dropVerdict].
3833 #[unsafe(method(updateFlow:usingVerdict:forDirection:))]
3834 #[unsafe(method_family = none)]
3835 pub unsafe fn updateFlow_usingVerdict_forDirection(
3836 &self,
3837 flow: &NEFilterSocketFlow,
3838 verdict: &NEFilterDataVerdict,
3839 direction: NETrafficDirection,
3840 );
3841 );
3842}
3843
3844/// Methods declared on superclass `NSObject`.
3845impl NEFilterDataProvider {
3846 extern_methods!(
3847 #[unsafe(method(init))]
3848 #[unsafe(method_family = init)]
3849 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
3850
3851 #[unsafe(method(new))]
3852 #[unsafe(method_family = new)]
3853 pub unsafe fn new() -> Retained<Self>;
3854 );
3855}
3856
3857extern_class!(
3858 /// The NEFilterDataVerdict class declares the programmatic interface of an object that is the verdict for a flow of network data after some of the data has been seen by the filter.
3859 ///
3860 /// NEFilterDataVerdict is part of NetworkExtension.framework
3861 ///
3862 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterdataverdict?language=objc)
3863 #[unsafe(super(NEFilterVerdict, NSObject))]
3864 #[derive(Debug, PartialEq, Eq, Hash)]
3865 pub struct NEFilterDataVerdict;
3866);
3867
3868extern_conformance!(
3869 unsafe impl NSCoding for NEFilterDataVerdict {}
3870);
3871
3872extern_conformance!(
3873 unsafe impl NSCopying for NEFilterDataVerdict {}
3874);
3875
3876unsafe impl CopyingHelper for NEFilterDataVerdict {
3877 type Result = Self;
3878}
3879
3880extern_conformance!(
3881 unsafe impl NSObjectProtocol for NEFilterDataVerdict {}
3882);
3883
3884extern_conformance!(
3885 unsafe impl NSSecureCoding for NEFilterDataVerdict {}
3886);
3887
3888impl NEFilterDataVerdict {
3889 extern_methods!(
3890 /// The frequency at which the data provider's -[NEFilterProvider handleReport:] method is called with a NEFilterReport instance with an event of NEFilterReportEventFlowStatistics.
3891 /// The default value is NEFilterReportFrequencyNone, so by default no statistics are reported.
3892 #[unsafe(method(statisticsReportFrequency))]
3893 #[unsafe(method_family = none)]
3894 pub unsafe fn statisticsReportFrequency(&self) -> NEFilterReportFrequency;
3895
3896 /// Setter for [`statisticsReportFrequency`][Self::statisticsReportFrequency].
3897 #[unsafe(method(setStatisticsReportFrequency:))]
3898 #[unsafe(method_family = none)]
3899 pub unsafe fn setStatisticsReportFrequency(
3900 &self,
3901 statistics_report_frequency: NEFilterReportFrequency,
3902 );
3903
3904 /// This class method returns a verdict indicating that the flow should be allowed.
3905 ///
3906 /// Returns: The NEFilterDataVerdict object.
3907 #[unsafe(method(allowVerdict))]
3908 #[unsafe(method_family = none)]
3909 pub unsafe fn allowVerdict() -> Retained<NEFilterDataVerdict>;
3910
3911 /// This class method returns a verdict indicating that the flow should be dropped.
3912 ///
3913 /// Returns: The NEFilterDataVerdict object.
3914 #[unsafe(method(dropVerdict))]
3915 #[unsafe(method_family = none)]
3916 pub unsafe fn dropVerdict() -> Retained<NEFilterDataVerdict>;
3917
3918 /// This class method returns a verdict indicating that a "content blocked" page should be displayed to the user. The block page should contain a link to the given URL.
3919 ///
3920 /// Parameter `remediationURLMapKey`: Remediation map key used by data plugin to get remediation url. Passing nil will result into data provider being notified with the callback handleRemediationForFlow:
3921 ///
3922 /// Parameter `remediationButtonTextMapKey`: Remediation button map key used by the data plugin to get the remediation button text. Passing nil will set the button text to "Request Access"
3923 ///
3924 /// Returns: The NEFilterDataVerdict object.
3925 #[unsafe(method(remediateVerdictWithRemediationURLMapKey:remediationButtonTextMapKey:))]
3926 #[unsafe(method_family = none)]
3927 pub unsafe fn remediateVerdictWithRemediationURLMapKey_remediationButtonTextMapKey(
3928 remediation_url_map_key: Option<&NSString>,
3929 remediation_button_text_map_key: Option<&NSString>,
3930 ) -> Retained<NEFilterDataVerdict>;
3931
3932 /// This class method returns a data verdict indicating that the filter is passing a given number of bytes through the filter and needs to see a given number of bytes after the bytes that are passed.
3933 ///
3934 /// Parameter `passBytes`: The number of bytes to pass through the filter.
3935 ///
3936 /// Parameter `peekBytes`: The number of bytes after the end of the bytes passed that the filter wants to see in the next call to -[NEFilterDataProvider handleOutboundDataFromFlow:readBytesStartOffset:readBytes:] or -[NEFilterDataProvider handleInboundDataFromFlow:readBytesStartOffset:readBytes:].
3937 ///
3938 /// Returns: The data flow verdict.
3939 #[unsafe(method(dataVerdictWithPassBytes:peekBytes:))]
3940 #[unsafe(method_family = none)]
3941 pub unsafe fn dataVerdictWithPassBytes_peekBytes(
3942 pass_bytes: NSUInteger,
3943 peek_bytes: NSUInteger,
3944 ) -> Retained<NEFilterDataVerdict>;
3945
3946 /// This class method returns a verdict indicating that control provider needs to be asked how to handle the data flow. The control provider can either drop or allow the flow, or update the rules and ask the data provider to decide on the data flow again.
3947 ///
3948 /// Returns: The NEFilterDataVerdict object.
3949 #[unsafe(method(needRulesVerdict))]
3950 #[unsafe(method_family = none)]
3951 pub unsafe fn needRulesVerdict() -> Retained<NEFilterDataVerdict>;
3952
3953 /// This class method returns a verdict indicating that none of the data provider's handler callbacks shall be called for the flow until after the flow is resumed
3954 /// by a call to -[NEFilterDataProvider resumeFlow:withVerdict:]. TCP flows may be paused indefinitely. UDP flows will be dropped if not resumed within 10 seconds of
3955 /// being paused. It is invalid to pause a flow that is already paused.
3956 ///
3957 /// Returns: The NEFilterDataVerdict object.
3958 #[unsafe(method(pauseVerdict))]
3959 #[unsafe(method_family = none)]
3960 pub unsafe fn pauseVerdict() -> Retained<NEFilterDataVerdict>;
3961 );
3962}
3963
3964/// Methods declared on superclass `NSObject`.
3965impl NEFilterDataVerdict {
3966 extern_methods!(
3967 #[unsafe(method(init))]
3968 #[unsafe(method_family = init)]
3969 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
3970
3971 #[unsafe(method(new))]
3972 #[unsafe(method_family = new)]
3973 pub unsafe fn new() -> Retained<Self>;
3974 );
3975}
3976
3977extern_class!(
3978 /// The NEFilterRemediationVerdict class declares the programmatic interface of an object that is the verdict for a flow which has been blocked by the filter, but the user has made a request for remediation.
3979 ///
3980 /// NEFilterRemediationVerdict is part of NetworkExtension.framework
3981 ///
3982 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterremediationverdict?language=objc)
3983 #[unsafe(super(NEFilterVerdict, NSObject))]
3984 #[derive(Debug, PartialEq, Eq, Hash)]
3985 pub struct NEFilterRemediationVerdict;
3986);
3987
3988extern_conformance!(
3989 unsafe impl NSCoding for NEFilterRemediationVerdict {}
3990);
3991
3992extern_conformance!(
3993 unsafe impl NSCopying for NEFilterRemediationVerdict {}
3994);
3995
3996unsafe impl CopyingHelper for NEFilterRemediationVerdict {
3997 type Result = Self;
3998}
3999
4000extern_conformance!(
4001 unsafe impl NSObjectProtocol for NEFilterRemediationVerdict {}
4002);
4003
4004extern_conformance!(
4005 unsafe impl NSSecureCoding for NEFilterRemediationVerdict {}
4006);
4007
4008impl NEFilterRemediationVerdict {
4009 extern_methods!(
4010 /// This class method returns a verdict indicating that the flow should be allowed.
4011 ///
4012 /// Returns: The NEFilterRemediationVerdict object.
4013 #[unsafe(method(allowVerdict))]
4014 #[unsafe(method_family = none)]
4015 pub unsafe fn allowVerdict() -> Retained<NEFilterRemediationVerdict>;
4016
4017 /// This class method returns a verdict indicating that the flow should be dropped.
4018 ///
4019 /// Returns: The NEFilterRemediationVerdict object.
4020 #[unsafe(method(dropVerdict))]
4021 #[unsafe(method_family = none)]
4022 pub unsafe fn dropVerdict() -> Retained<NEFilterRemediationVerdict>;
4023
4024 /// This class method returns a verdict indicating that control provider needs to be asked how to handle the remediation. The control provider can either drop or allow the flow, or update the rules and ask the data provider to decide on the data flow again.
4025 ///
4026 /// Returns: The NEFilterRemediationVerdict object.
4027 #[unsafe(method(needRulesVerdict))]
4028 #[unsafe(method_family = none)]
4029 pub unsafe fn needRulesVerdict() -> Retained<NEFilterRemediationVerdict>;
4030 );
4031}
4032
4033/// Methods declared on superclass `NSObject`.
4034impl NEFilterRemediationVerdict {
4035 extern_methods!(
4036 #[unsafe(method(init))]
4037 #[unsafe(method_family = init)]
4038 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
4039
4040 #[unsafe(method(new))]
4041 #[unsafe(method_family = new)]
4042 pub unsafe fn new() -> Retained<Self>;
4043 );
4044}
4045
4046/// Filter error codes
4047///
4048/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefiltermanagererror?language=objc)
4049// NS_ENUM
4050#[repr(transparent)]
4051#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
4052pub struct NEFilterManagerError(pub NSInteger);
4053impl NEFilterManagerError {
4054 #[doc(alias = "NEFilterManagerErrorConfigurationInvalid")]
4055 pub const ConfigurationInvalid: Self = Self(1);
4056 #[doc(alias = "NEFilterManagerErrorConfigurationDisabled")]
4057 pub const ConfigurationDisabled: Self = Self(2);
4058 #[doc(alias = "NEFilterManagerErrorConfigurationStale")]
4059 pub const ConfigurationStale: Self = Self(3);
4060 #[doc(alias = "NEFilterManagerErrorConfigurationCannotBeRemoved")]
4061 pub const ConfigurationCannotBeRemoved: Self = Self(4);
4062 #[doc(alias = "NEFilterManagerErrorConfigurationPermissionDenied")]
4063 pub const ConfigurationPermissionDenied: Self = Self(5);
4064 #[doc(alias = "NEFilterManagerErrorConfigurationInternalError")]
4065 pub const ConfigurationInternalError: Self = Self(6);
4066}
4067
4068unsafe impl Encode for NEFilterManagerError {
4069 const ENCODING: Encoding = NSInteger::ENCODING;
4070}
4071
4072unsafe impl RefEncode for NEFilterManagerError {
4073 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
4074}
4075
4076extern "C" {
4077 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefiltererrordomain?language=objc)
4078 pub static NEFilterErrorDomain: &'static NSString;
4079}
4080
4081extern "C" {
4082 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterconfigurationdidchangenotification?language=objc)
4083 pub static NEFilterConfigurationDidChangeNotification: &'static NSString;
4084}
4085
4086/// Filter grade
4087///
4088/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefiltermanagergrade?language=objc)
4089// NS_ENUM
4090#[repr(transparent)]
4091#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
4092pub struct NEFilterManagerGrade(pub NSInteger);
4093impl NEFilterManagerGrade {
4094 #[doc(alias = "NEFilterManagerGradeFirewall")]
4095 pub const Firewall: Self = Self(1);
4096 #[doc(alias = "NEFilterManagerGradeInspector")]
4097 pub const Inspector: Self = Self(2);
4098}
4099
4100unsafe impl Encode for NEFilterManagerGrade {
4101 const ENCODING: Encoding = NSInteger::ENCODING;
4102}
4103
4104unsafe impl RefEncode for NEFilterManagerGrade {
4105 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
4106}
4107
4108extern_class!(
4109 /// The NEFilterManager class declares the programmatic interface for an object that manages content filtering configurations.
4110 ///
4111 /// NEFilterManager declares methods and properties for configuring and controlling a filter.
4112 ///
4113 /// Instances of this class are thread safe.
4114 ///
4115 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefiltermanager?language=objc)
4116 #[unsafe(super(NSObject))]
4117 #[derive(Debug, PartialEq, Eq, Hash)]
4118 pub struct NEFilterManager;
4119);
4120
4121extern_conformance!(
4122 unsafe impl NSObjectProtocol for NEFilterManager {}
4123);
4124
4125impl NEFilterManager {
4126 extern_methods!(
4127 /// Returns: The singleton NEFilterManager object for the calling process.
4128 #[unsafe(method(sharedManager))]
4129 #[unsafe(method_family = none)]
4130 pub unsafe fn sharedManager() -> Retained<NEFilterManager>;
4131
4132 #[cfg(feature = "block2")]
4133 /// This function loads the current filter configuration from the caller's filter preferences.
4134 ///
4135 /// Parameter `completionHandler`: A block that will be called when the load operation is completed. The NSError passed to this block will be nil if the load operation succeeded, non-nil otherwise.
4136 #[unsafe(method(loadFromPreferencesWithCompletionHandler:))]
4137 #[unsafe(method_family = none)]
4138 pub unsafe fn loadFromPreferencesWithCompletionHandler(
4139 &self,
4140 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
4141 );
4142
4143 #[cfg(feature = "block2")]
4144 /// This function removes the filter configuration from the caller's filter preferences. If the filter is enabled, the filter becomes disabled.
4145 ///
4146 /// Parameter `completionHandler`: A block that will be called when the remove operation is completed. The NSError passed to this block will be nil if the remove operation succeeded, non-nil otherwise.
4147 #[unsafe(method(removeFromPreferencesWithCompletionHandler:))]
4148 #[unsafe(method_family = none)]
4149 pub unsafe fn removeFromPreferencesWithCompletionHandler(
4150 &self,
4151 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
4152 );
4153
4154 #[cfg(feature = "block2")]
4155 /// This function saves the filter configuration in the caller's filter preferences. If the filter is enabled, it will become active.
4156 ///
4157 /// Parameter `completionHandler`: A block that will be called when the save operation is completed. The NSError passed to this block will be nil if the save operation succeeded, non-nil otherwise.
4158 #[unsafe(method(saveToPreferencesWithCompletionHandler:))]
4159 #[unsafe(method_family = none)]
4160 pub unsafe fn saveToPreferencesWithCompletionHandler(
4161 &self,
4162 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
4163 );
4164
4165 /// A string containing a description of the filter.
4166 #[unsafe(method(localizedDescription))]
4167 #[unsafe(method_family = none)]
4168 pub unsafe fn localizedDescription(&self) -> Option<Retained<NSString>>;
4169
4170 /// Setter for [`localizedDescription`][Self::localizedDescription].
4171 ///
4172 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
4173 #[unsafe(method(setLocalizedDescription:))]
4174 #[unsafe(method_family = none)]
4175 pub unsafe fn setLocalizedDescription(&self, localized_description: Option<&NSString>);
4176
4177 /// An NEFilterProviderConfiguration object containing the provider-specific portion of the filter configuration.
4178 #[unsafe(method(providerConfiguration))]
4179 #[unsafe(method_family = none)]
4180 pub unsafe fn providerConfiguration(
4181 &self,
4182 ) -> Option<Retained<NEFilterProviderConfiguration>>;
4183
4184 /// Setter for [`providerConfiguration`][Self::providerConfiguration].
4185 #[unsafe(method(setProviderConfiguration:))]
4186 #[unsafe(method_family = none)]
4187 pub unsafe fn setProviderConfiguration(
4188 &self,
4189 provider_configuration: Option<&NEFilterProviderConfiguration>,
4190 );
4191
4192 /// Toggles the enabled status of the filter. On iOS, setting this property will disable filter configurations of other apps, and this property will be set to NO when other filter configurations are enabled.
4193 /// On macOS, up to 4 filter configurations of the same grade can be enabled simultaneously.
4194 #[unsafe(method(isEnabled))]
4195 #[unsafe(method_family = none)]
4196 pub unsafe fn isEnabled(&self) -> bool;
4197
4198 /// Setter for [`isEnabled`][Self::isEnabled].
4199 #[unsafe(method(setEnabled:))]
4200 #[unsafe(method_family = none)]
4201 pub unsafe fn setEnabled(&self, enabled: bool);
4202
4203 /// The grade of the filter. The default grade is NEFilterManagerGradeFirewall.
4204 #[unsafe(method(grade))]
4205 #[unsafe(method_family = none)]
4206 pub unsafe fn grade(&self) -> NEFilterManagerGrade;
4207
4208 /// Setter for [`grade`][Self::grade].
4209 #[unsafe(method(setGrade:))]
4210 #[unsafe(method_family = none)]
4211 pub unsafe fn setGrade(&self, grade: NEFilterManagerGrade);
4212
4213 /// Causes the content filter to disable any other installed encrypted DNS settings, including iCloud Private Relay system-wide DNS encryption. This should only be used if
4214 /// the content filter expects to intercept cleartext UDP DNS packets.
4215 #[unsafe(method(disableEncryptedDNSSettings))]
4216 #[unsafe(method_family = none)]
4217 pub unsafe fn disableEncryptedDNSSettings(&self) -> bool;
4218
4219 /// Setter for [`disableEncryptedDNSSettings`][Self::disableEncryptedDNSSettings].
4220 #[unsafe(method(setDisableEncryptedDNSSettings:))]
4221 #[unsafe(method_family = none)]
4222 pub unsafe fn setDisableEncryptedDNSSettings(&self, disable_encrypted_dns_settings: bool);
4223 );
4224}
4225
4226/// Methods declared on superclass `NSObject`.
4227impl NEFilterManager {
4228 extern_methods!(
4229 #[unsafe(method(init))]
4230 #[unsafe(method_family = init)]
4231 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
4232
4233 #[unsafe(method(new))]
4234 #[unsafe(method_family = new)]
4235 pub unsafe fn new() -> Retained<Self>;
4236 );
4237}
4238
4239extern_class!(
4240 /// The NEFilterPacketContext class identifies the current filtering context.
4241 ///
4242 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterpacketcontext?language=objc)
4243 #[unsafe(super(NSObject))]
4244 #[derive(Debug, PartialEq, Eq, Hash)]
4245 pub struct NEFilterPacketContext;
4246);
4247
4248extern_conformance!(
4249 unsafe impl NSObjectProtocol for NEFilterPacketContext {}
4250);
4251
4252impl NEFilterPacketContext {
4253 extern_methods!();
4254}
4255
4256/// Methods declared on superclass `NSObject`.
4257impl NEFilterPacketContext {
4258 extern_methods!(
4259 #[unsafe(method(init))]
4260 #[unsafe(method_family = init)]
4261 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
4262
4263 #[unsafe(method(new))]
4264 #[unsafe(method_family = new)]
4265 pub unsafe fn new() -> Retained<Self>;
4266 );
4267}
4268
4269/// Verdict for a packet
4270///
4271/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterpacketproviderverdict?language=objc)
4272// NS_ENUM
4273#[repr(transparent)]
4274#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
4275pub struct NEFilterPacketProviderVerdict(pub NSInteger);
4276impl NEFilterPacketProviderVerdict {
4277 #[doc(alias = "NEFilterPacketProviderVerdictAllow")]
4278 pub const Allow: Self = Self(0);
4279 #[doc(alias = "NEFilterPacketProviderVerdictDrop")]
4280 pub const Drop: Self = Self(1);
4281 #[doc(alias = "NEFilterPacketProviderVerdictDelay")]
4282 pub const Delay: Self = Self(2);
4283}
4284
4285unsafe impl Encode for NEFilterPacketProviderVerdict {
4286 const ENCODING: Encoding = NSInteger::ENCODING;
4287}
4288
4289unsafe impl RefEncode for NEFilterPacketProviderVerdict {
4290 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
4291}
4292
4293extern_class!(
4294 /// The NEFilterPacketProvider class declares the programmatic interface for an object that evaluates network packets decisions about whether to block, allow, or delay the packets.
4295 ///
4296 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterpacketprovider?language=objc)
4297 #[unsafe(super(NEFilterProvider, NEProvider, NSObject))]
4298 #[derive(Debug, PartialEq, Eq, Hash)]
4299 pub struct NEFilterPacketProvider;
4300);
4301
4302extern_conformance!(
4303 unsafe impl NSObjectProtocol for NEFilterPacketProvider {}
4304);
4305
4306impl NEFilterPacketProvider {
4307 extern_methods!(
4308 /// This function is used to delay a packet currently presented by packetHandler.
4309 /// This function is only valid within the packetHandler block and a verdict of
4310 /// NEFilterPacketProviderVerdictDelay must be returned after a packet is delayed. A delayed
4311 /// packet will be prevented from continuing its journey through the networking stack until
4312 /// it is either allowed by calling allow() or is dropped by being released.
4313 ///
4314 /// Parameter `context`: The context of the current packet filter which is passed to the packetHandler block.
4315 /// The packetHandler block must pass this context when calling delayCurrentPacket().
4316 #[unsafe(method(delayCurrentPacket:))]
4317 #[unsafe(method_family = none)]
4318 pub unsafe fn delayCurrentPacket(
4319 &self,
4320 context: &NEFilterPacketContext,
4321 ) -> Retained<NEPacket>;
4322
4323 /// This function is used to allow a previously-delayed packet to continue its journey into or out of the networking stack.
4324 ///
4325 /// Parameter `packet`: A NEPacket object that contains the data of the packet that was previously delayed by the NEFilterPacketProvider.
4326 #[unsafe(method(allowPacket:))]
4327 #[unsafe(method_family = none)]
4328 pub unsafe fn allowPacket(&self, packet: &NEPacket);
4329 );
4330}
4331
4332/// Methods declared on superclass `NSObject`.
4333impl NEFilterPacketProvider {
4334 extern_methods!(
4335 #[unsafe(method(init))]
4336 #[unsafe(method_family = init)]
4337 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
4338
4339 #[unsafe(method(new))]
4340 #[unsafe(method_family = new)]
4341 pub unsafe fn new() -> Retained<Self>;
4342 );
4343}
4344
4345extern_class!(
4346 /// The NEFilterProviderConfiguration class declares the programmatic interface of an object that configures a plugin-based content filter.
4347 ///
4348 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterproviderconfiguration?language=objc)
4349 #[unsafe(super(NSObject))]
4350 #[derive(Debug, PartialEq, Eq, Hash)]
4351 pub struct NEFilterProviderConfiguration;
4352);
4353
4354extern_conformance!(
4355 unsafe impl NSCoding for NEFilterProviderConfiguration {}
4356);
4357
4358extern_conformance!(
4359 unsafe impl NSCopying for NEFilterProviderConfiguration {}
4360);
4361
4362unsafe impl CopyingHelper for NEFilterProviderConfiguration {
4363 type Result = Self;
4364}
4365
4366extern_conformance!(
4367 unsafe impl NSObjectProtocol for NEFilterProviderConfiguration {}
4368);
4369
4370extern_conformance!(
4371 unsafe impl NSSecureCoding for NEFilterProviderConfiguration {}
4372);
4373
4374impl NEFilterProviderConfiguration {
4375 extern_methods!(
4376 /// If YES, the filter plugin will be allowed to filter browser traffic. If NO, the filter plugin will not see any browser flows. Defaults to NO. At least one of filterBrowsers and filterSockets should be set to YES to make the filter take effect.
4377 #[deprecated = "filterBrowsers is not supported on macOS"]
4378 #[unsafe(method(filterBrowsers))]
4379 #[unsafe(method_family = none)]
4380 pub unsafe fn filterBrowsers(&self) -> bool;
4381
4382 /// Setter for [`filterBrowsers`][Self::filterBrowsers].
4383 #[deprecated = "filterBrowsers is not supported on macOS"]
4384 #[unsafe(method(setFilterBrowsers:))]
4385 #[unsafe(method_family = none)]
4386 pub unsafe fn setFilterBrowsers(&self, filter_browsers: bool);
4387
4388 /// If YES, the filter plugin will be allowed to filter socket traffic. If NO, the filter plugin will not see any socket flows. Defaults to NO. At least one of filterBrowsers and filterSockets should be set to YES to make the filter take effect.
4389 #[unsafe(method(filterSockets))]
4390 #[unsafe(method_family = none)]
4391 pub unsafe fn filterSockets(&self) -> bool;
4392
4393 /// Setter for [`filterSockets`][Self::filterSockets].
4394 #[unsafe(method(setFilterSockets:))]
4395 #[unsafe(method_family = none)]
4396 pub unsafe fn setFilterSockets(&self, filter_sockets: bool);
4397
4398 /// If YES, a NEFilterPacketProvider will be instantiated and will be allowed to filter packets.
4399 #[unsafe(method(filterPackets))]
4400 #[unsafe(method_family = none)]
4401 pub unsafe fn filterPackets(&self) -> bool;
4402
4403 /// Setter for [`filterPackets`][Self::filterPackets].
4404 #[unsafe(method(setFilterPackets:))]
4405 #[unsafe(method_family = none)]
4406 pub unsafe fn setFilterPackets(&self, filter_packets: bool);
4407
4408 /// An optional dictionary of plugin-specific keys to be passed to the plugin.
4409 #[unsafe(method(vendorConfiguration))]
4410 #[unsafe(method_family = none)]
4411 pub unsafe fn vendorConfiguration(
4412 &self,
4413 ) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
4414
4415 /// Setter for [`vendorConfiguration`][Self::vendorConfiguration].
4416 ///
4417 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
4418 ///
4419 /// # Safety
4420 ///
4421 /// `vendor_configuration` generic should be of the correct type.
4422 #[unsafe(method(setVendorConfiguration:))]
4423 #[unsafe(method_family = none)]
4424 pub unsafe fn setVendorConfiguration(
4425 &self,
4426 vendor_configuration: Option<&NSDictionary<NSString, AnyObject>>,
4427 );
4428
4429 /// The optional address of the server used to support the filter.
4430 #[unsafe(method(serverAddress))]
4431 #[unsafe(method_family = none)]
4432 pub unsafe fn serverAddress(&self) -> Option<Retained<NSString>>;
4433
4434 /// Setter for [`serverAddress`][Self::serverAddress].
4435 ///
4436 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
4437 #[unsafe(method(setServerAddress:))]
4438 #[unsafe(method_family = none)]
4439 pub unsafe fn setServerAddress(&self, server_address: Option<&NSString>);
4440
4441 /// The optional username associated with the filter.
4442 #[unsafe(method(username))]
4443 #[unsafe(method_family = none)]
4444 pub unsafe fn username(&self) -> Option<Retained<NSString>>;
4445
4446 /// Setter for [`username`][Self::username].
4447 ///
4448 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
4449 #[unsafe(method(setUsername:))]
4450 #[unsafe(method_family = none)]
4451 pub unsafe fn setUsername(&self, username: Option<&NSString>);
4452
4453 /// The optional organization associated with the filter.
4454 #[unsafe(method(organization))]
4455 #[unsafe(method_family = none)]
4456 pub unsafe fn organization(&self) -> Option<Retained<NSString>>;
4457
4458 /// Setter for [`organization`][Self::organization].
4459 ///
4460 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
4461 #[unsafe(method(setOrganization:))]
4462 #[unsafe(method_family = none)]
4463 pub unsafe fn setOrganization(&self, organization: Option<&NSString>);
4464
4465 /// The optional password keychain reference associated with the filter.
4466 #[unsafe(method(passwordReference))]
4467 #[unsafe(method_family = none)]
4468 pub unsafe fn passwordReference(&self) -> Option<Retained<NSData>>;
4469
4470 /// Setter for [`passwordReference`][Self::passwordReference].
4471 ///
4472 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
4473 #[unsafe(method(setPasswordReference:))]
4474 #[unsafe(method_family = none)]
4475 pub unsafe fn setPasswordReference(&self, password_reference: Option<&NSData>);
4476
4477 /// The optional certificate identity keychain reference associated with the filter.
4478 #[unsafe(method(identityReference))]
4479 #[unsafe(method_family = none)]
4480 pub unsafe fn identityReference(&self) -> Option<Retained<NSData>>;
4481
4482 /// Setter for [`identityReference`][Self::identityReference].
4483 ///
4484 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
4485 #[unsafe(method(setIdentityReference:))]
4486 #[unsafe(method_family = none)]
4487 pub unsafe fn setIdentityReference(&self, identity_reference: Option<&NSData>);
4488
4489 /// A string containing the bundle identifier of the NEFilterDataProvider app extension or system extension.
4490 /// If this property is nil, then the bundle identifier of the NEFilterDataProvider extension in the calling app's
4491 /// bundle is used, and if the calling app's bundle contains more than one NEFilterDataProvider extension then which one will
4492 /// be used is undefined.
4493 #[unsafe(method(filterDataProviderBundleIdentifier))]
4494 #[unsafe(method_family = none)]
4495 pub unsafe fn filterDataProviderBundleIdentifier(&self) -> Option<Retained<NSString>>;
4496
4497 /// Setter for [`filterDataProviderBundleIdentifier`][Self::filterDataProviderBundleIdentifier].
4498 ///
4499 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
4500 #[unsafe(method(setFilterDataProviderBundleIdentifier:))]
4501 #[unsafe(method_family = none)]
4502 pub unsafe fn setFilterDataProviderBundleIdentifier(
4503 &self,
4504 filter_data_provider_bundle_identifier: Option<&NSString>,
4505 );
4506
4507 /// A string containing the bundle identifier of the NEFilterPacketProvider app extension or system extension.
4508 /// If this property is nil, then the bundle identifier of the NEFilterPacketProvider extension in the calling app's
4509 /// bundle is used, and if the calling app's bundle contains more than one NEFilterPacketProvider extension then which one will
4510 /// be used is undefined.
4511 #[unsafe(method(filterPacketProviderBundleIdentifier))]
4512 #[unsafe(method_family = none)]
4513 pub unsafe fn filterPacketProviderBundleIdentifier(&self) -> Option<Retained<NSString>>;
4514
4515 /// Setter for [`filterPacketProviderBundleIdentifier`][Self::filterPacketProviderBundleIdentifier].
4516 ///
4517 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
4518 #[unsafe(method(setFilterPacketProviderBundleIdentifier:))]
4519 #[unsafe(method_family = none)]
4520 pub unsafe fn setFilterPacketProviderBundleIdentifier(
4521 &self,
4522 filter_packet_provider_bundle_identifier: Option<&NSString>,
4523 );
4524 );
4525}
4526
4527/// Methods declared on superclass `NSObject`.
4528impl NEFilterProviderConfiguration {
4529 extern_methods!(
4530 #[unsafe(method(init))]
4531 #[unsafe(method_family = init)]
4532 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
4533
4534 #[unsafe(method(new))]
4535 #[unsafe(method_family = new)]
4536 pub unsafe fn new() -> Retained<Self>;
4537 );
4538}
4539
4540extern_class!(
4541 /// The NEFilterRule class declares the programmatic interface of an object that defines a rule for matching network traffic and the action to take when the rule matches.
4542 ///
4543 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefilterrule?language=objc)
4544 #[unsafe(super(NSObject))]
4545 #[derive(Debug, PartialEq, Eq, Hash)]
4546 pub struct NEFilterRule;
4547);
4548
4549extern_conformance!(
4550 unsafe impl NSCoding for NEFilterRule {}
4551);
4552
4553extern_conformance!(
4554 unsafe impl NSCopying for NEFilterRule {}
4555);
4556
4557unsafe impl CopyingHelper for NEFilterRule {
4558 type Result = Self;
4559}
4560
4561extern_conformance!(
4562 unsafe impl NSObjectProtocol for NEFilterRule {}
4563);
4564
4565extern_conformance!(
4566 unsafe impl NSSecureCoding for NEFilterRule {}
4567);
4568
4569impl NEFilterRule {
4570 extern_methods!(
4571 /// Initialize a newly-allocated NEFilterRule object
4572 ///
4573 /// Parameter `networkRule`: A NENetworkRule object that defines the network traffic characteristics that this rule matches.
4574 ///
4575 /// Parameter `action`: The action to take when this rule matches.
4576 #[unsafe(method(initWithNetworkRule:action:))]
4577 #[unsafe(method_family = init)]
4578 pub unsafe fn initWithNetworkRule_action(
4579 this: Allocated<Self>,
4580 network_rule: &NENetworkRule,
4581 action: NEFilterAction,
4582 ) -> Retained<Self>;
4583
4584 /// The NENetworkRule that defines the network traffic characteristics that this rule matches.
4585 #[unsafe(method(networkRule))]
4586 #[unsafe(method_family = none)]
4587 pub unsafe fn networkRule(&self) -> Retained<NENetworkRule>;
4588
4589 /// The action to take when this rule matches network traffic.
4590 #[unsafe(method(action))]
4591 #[unsafe(method_family = none)]
4592 pub unsafe fn action(&self) -> NEFilterAction;
4593 );
4594}
4595
4596/// Methods declared on superclass `NSObject`.
4597impl NEFilterRule {
4598 extern_methods!(
4599 #[unsafe(method(init))]
4600 #[unsafe(method_family = init)]
4601 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
4602
4603 #[unsafe(method(new))]
4604 #[unsafe(method_family = new)]
4605 pub unsafe fn new() -> Retained<Self>;
4606 );
4607}
4608
4609extern_class!(
4610 /// The NEFilterSettings class declares the programmatic interface for an object that contains filter settings.
4611 ///
4612 /// NEFilterSettings is used by NEFilterDataProviders to communicate the desired settings for the filter to the framework. The framework takes care of applying the contained settings to the system.
4613 ///
4614 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nefiltersettings?language=objc)
4615 #[unsafe(super(NSObject))]
4616 #[derive(Debug, PartialEq, Eq, Hash)]
4617 pub struct NEFilterSettings;
4618);
4619
4620extern_conformance!(
4621 unsafe impl NSCoding for NEFilterSettings {}
4622);
4623
4624extern_conformance!(
4625 unsafe impl NSCopying for NEFilterSettings {}
4626);
4627
4628unsafe impl CopyingHelper for NEFilterSettings {
4629 type Result = Self;
4630}
4631
4632extern_conformance!(
4633 unsafe impl NSObjectProtocol for NEFilterSettings {}
4634);
4635
4636extern_conformance!(
4637 unsafe impl NSSecureCoding for NEFilterSettings {}
4638);
4639
4640impl NEFilterSettings {
4641 extern_methods!(
4642 /// Initialize a newly-allocated NEFilterSettings object with a set of filtering rules and a default filter action to takke if none
4643 /// of the rules match.
4644 ///
4645 /// Parameter `rules`: An NSArray containing an ordered list of NEFilterRule objects. The maximum number of rules that this array can contain is 1000.
4646 ///
4647 /// Parameter `defaultAction`: The NEFilterAction to take for flows of network (non-loopback) data that do not match any of the specified rules. The default defaultAction is
4648 /// NEFilterActionFilterData. If defaultAction is NEFilterActionAllow or NEFilterActionDrop, then the rules array must contain at least one NEFilterRule.
4649 /// The default action for loopback traffic is NEFilterActionAllow and cannot be changed. To filter loopback traffic you must include rules in the rules array that specifically match loopback traffic
4650 /// and have an action of NEFilterActionFilterData.
4651 ///
4652 /// Returns: the newly-initialized NEFilterSettings object.
4653 #[unsafe(method(initWithRules:defaultAction:))]
4654 #[unsafe(method_family = init)]
4655 pub unsafe fn initWithRules_defaultAction(
4656 this: Allocated<Self>,
4657 rules: &NSArray<NEFilterRule>,
4658 default_action: NEFilterAction,
4659 ) -> Retained<Self>;
4660
4661 /// An NSArray containing an ordered list of NEFilterRuleObjects. After the NEFilterSettings are applied to the system,
4662 /// each network flow is matched against these rules in order, and the NEFilterAction of the first rule that matches is taken:
4663 /// NEFilterActionAllow: Allow the flow of data to proceed on its journey through the networking stack without consulting this provider.
4664 /// NEFilterActionDrop: Drop the flow without consulting this provider.
4665 /// NEFilterActionFilterData: Call this provider's handleNewFlow: method with the flow.
4666 #[unsafe(method(rules))]
4667 #[unsafe(method_family = none)]
4668 pub unsafe fn rules(&self) -> Retained<NSArray<NEFilterRule>>;
4669
4670 /// An NEFilterAction containing the default action to take for flows of network data that do not match any of the specified rules.
4671 #[unsafe(method(defaultAction))]
4672 #[unsafe(method_family = none)]
4673 pub unsafe fn defaultAction(&self) -> NEFilterAction;
4674 );
4675}
4676
4677/// Methods declared on superclass `NSObject`.
4678impl NEFilterSettings {
4679 extern_methods!(
4680 #[unsafe(method(init))]
4681 #[unsafe(method_family = init)]
4682 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
4683
4684 #[unsafe(method(new))]
4685 #[unsafe(method_family = new)]
4686 pub unsafe fn new() -> Retained<Self>;
4687 );
4688}
4689
4690extern_class!(
4691 /// The NEFlowMetaData class declares the programmatic interface for an object that contains extra information about a flow.
4692 ///
4693 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neflowmetadata?language=objc)
4694 #[unsafe(super(NSObject))]
4695 #[derive(Debug, PartialEq, Eq, Hash)]
4696 pub struct NEFlowMetaData;
4697);
4698
4699extern_conformance!(
4700 unsafe impl NSCoding for NEFlowMetaData {}
4701);
4702
4703extern_conformance!(
4704 unsafe impl NSCopying for NEFlowMetaData {}
4705);
4706
4707unsafe impl CopyingHelper for NEFlowMetaData {
4708 type Result = Self;
4709}
4710
4711extern_conformance!(
4712 unsafe impl NSObjectProtocol for NEFlowMetaData {}
4713);
4714
4715extern_conformance!(
4716 unsafe impl NSSecureCoding for NEFlowMetaData {}
4717);
4718
4719impl NEFlowMetaData {
4720 extern_methods!(
4721 /// A byte string that uniquely identifies the binary for each build of the source application of the flow. The data object may be empty in cases where the flow originates from a system process.
4722 #[unsafe(method(sourceAppUniqueIdentifier))]
4723 #[unsafe(method_family = none)]
4724 pub unsafe fn sourceAppUniqueIdentifier(&self) -> Retained<NSData>;
4725
4726 /// A string containing the signing identifier (almost always equivalent to the bundle identifier) of the source app of the flow. The string may be empty in cases where the flow originates from a system process.
4727 #[unsafe(method(sourceAppSigningIdentifier))]
4728 #[unsafe(method_family = none)]
4729 pub unsafe fn sourceAppSigningIdentifier(&self) -> Retained<NSString>;
4730
4731 /// Audit token of the source application of the flow.
4732 #[unsafe(method(sourceAppAuditToken))]
4733 #[unsafe(method_family = none)]
4734 pub unsafe fn sourceAppAuditToken(&self) -> Option<Retained<NSData>>;
4735
4736 /// The identifier of the content filter flow corresponding to this flow.
4737 #[unsafe(method(filterFlowIdentifier))]
4738 #[unsafe(method_family = none)]
4739 pub unsafe fn filterFlowIdentifier(&self) -> Option<Retained<NSUUID>>;
4740 );
4741}
4742
4743/// Methods declared on superclass `NSObject`.
4744impl NEFlowMetaData {
4745 extern_methods!(
4746 #[unsafe(method(init))]
4747 #[unsafe(method_family = init)]
4748 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
4749
4750 #[unsafe(method(new))]
4751 #[unsafe(method_family = new)]
4752 pub unsafe fn new() -> Retained<Self>;
4753 );
4754}
4755
4756/// Wi-Fi network security type
4757///
4758/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspotnetworksecuritytype?language=objc)
4759// NS_ENUM
4760#[repr(transparent)]
4761#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
4762pub struct NEHotspotNetworkSecurityType(pub NSInteger);
4763impl NEHotspotNetworkSecurityType {
4764 #[doc(alias = "NEHotspotNetworkSecurityTypeOpen")]
4765 pub const Open: Self = Self(0);
4766 #[doc(alias = "NEHotspotNetworkSecurityTypeWEP")]
4767 pub const WEP: Self = Self(1);
4768 #[doc(alias = "NEHotspotNetworkSecurityTypePersonal")]
4769 pub const Personal: Self = Self(2);
4770 #[doc(alias = "NEHotspotNetworkSecurityTypeEnterprise")]
4771 pub const Enterprise: Self = Self(3);
4772 #[doc(alias = "NEHotspotNetworkSecurityTypeUnknown")]
4773 pub const Unknown: Self = Self(4);
4774}
4775
4776unsafe impl Encode for NEHotspotNetworkSecurityType {
4777 const ENCODING: Encoding = NSInteger::ENCODING;
4778}
4779
4780unsafe impl RefEncode for NEHotspotNetworkSecurityType {
4781 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
4782}
4783
4784extern_class!(
4785 /// The NEHotspotNetwork class provides a class method to get the SSID and BSSID of
4786 /// the current Wi-Fi network.
4787 ///
4788 /// NEHotspotNetwork is part of NetworkExtension.framework
4789 ///
4790 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspotnetwork?language=objc)
4791 #[unsafe(super(NSObject))]
4792 #[derive(Debug, PartialEq, Eq, Hash)]
4793 pub struct NEHotspotNetwork;
4794);
4795
4796extern_conformance!(
4797 unsafe impl NSObjectProtocol for NEHotspotNetwork {}
4798);
4799
4800impl NEHotspotNetwork {
4801 extern_methods!(
4802 /// The SSID of the Wi-Fi network.
4803 #[unsafe(method(SSID))]
4804 #[unsafe(method_family = none)]
4805 pub unsafe fn SSID(&self) -> Retained<NSString>;
4806
4807 /// The BSSID of the Wi-Fi network.
4808 #[unsafe(method(BSSID))]
4809 #[unsafe(method_family = none)]
4810 pub unsafe fn BSSID(&self) -> Retained<NSString>;
4811
4812 /// The security type of the Wi-Fi network.
4813 #[unsafe(method(securityType))]
4814 #[unsafe(method_family = none)]
4815 pub unsafe fn securityType(&self) -> NEHotspotNetworkSecurityType;
4816
4817 #[cfg(feature = "block2")]
4818 /// This method returns SSID, BSSID and security type of the current Wi-Fi network when the
4819 /// requesting application meets one of following 4 requirements -.
4820 /// 1. application is using CoreLocation API and has user's authorization to access precise location.
4821 /// 2. application has used NEHotspotConfiguration API to configure the current Wi-Fi network.
4822 /// 3. application has active VPN configurations installed.
4823 /// 4. application has active NEDNSSettingsManager configuration installed.
4824 /// An application will receive nil if it fails to meet any of the above 4 requirements.
4825 /// An application will receive nil if does not have the "com.apple.developer.networking.wifi-info" entitlement.
4826 ///
4827 /// Parameter `completionHandler`: A block that will be executed when current Wi-Fi network details are
4828 /// obtained from the system. The NEHotspotNetwork object passed to this block will be nil if the requesting
4829 /// application fails to meet above requirements, non-nil otherwise. NEHotspotNetwork object contains only valid
4830 /// SSID, BSSID and security type values, when the block is passed non-nil object.This block is executed on application's
4831 /// main queue.
4832 #[unsafe(method(fetchCurrentWithCompletionHandler:))]
4833 #[unsafe(method_family = none)]
4834 pub unsafe fn fetchCurrentWithCompletionHandler(
4835 completion_handler: &block2::DynBlock<dyn Fn(*mut NEHotspotNetwork)>,
4836 );
4837 );
4838}
4839
4840/// Methods declared on superclass `NSObject`.
4841impl NEHotspotNetwork {
4842 extern_methods!(
4843 #[unsafe(method(init))]
4844 #[unsafe(method_family = init)]
4845 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
4846
4847 #[unsafe(method(new))]
4848 #[unsafe(method_family = new)]
4849 pub unsafe fn new() -> Retained<Self>;
4850 );
4851}
4852
4853/// The type of the NEHotspotHelperCommand object.
4854///
4855/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspothelpercommandtype?language=objc)
4856// NS_ENUM
4857#[repr(transparent)]
4858#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
4859pub struct NEHotspotHelperCommandType(pub NSInteger);
4860impl NEHotspotHelperCommandType {
4861 #[doc(alias = "kNEHotspotHelperCommandTypeNone")]
4862 pub const None: Self = Self(0);
4863 #[doc(alias = "kNEHotspotHelperCommandTypeFilterScanList")]
4864 pub const FilterScanList: Self = Self(1);
4865 #[doc(alias = "kNEHotspotHelperCommandTypeEvaluate")]
4866 pub const Evaluate: Self = Self(2);
4867 #[doc(alias = "kNEHotspotHelperCommandTypeAuthenticate")]
4868 pub const Authenticate: Self = Self(3);
4869 #[doc(alias = "kNEHotspotHelperCommandTypePresentUI")]
4870 pub const PresentUI: Self = Self(4);
4871 #[doc(alias = "kNEHotspotHelperCommandTypeMaintain")]
4872 pub const Maintain: Self = Self(5);
4873 #[doc(alias = "kNEHotspotHelperCommandTypeLogoff")]
4874 pub const Logoff: Self = Self(6);
4875}
4876
4877unsafe impl Encode for NEHotspotHelperCommandType {
4878 const ENCODING: Encoding = NSInteger::ENCODING;
4879}
4880
4881unsafe impl RefEncode for NEHotspotHelperCommandType {
4882 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
4883}
4884
4885/// The result of processing the NEHotspotHelperCommand.
4886///
4887/// The HotspotHelper provides the result of
4888/// processing the NEHotspotHelperCommand when it instantiates
4889/// its NEHotspotHelperResponse.
4890///
4891///
4892///
4893/// interaction. This result is only valid in response to a command with type
4894/// kNEHotspotHelperCommandTypeAuthenticate.
4895///
4896/// recognize the command type.
4897///
4898/// authentication again. This result is only valid in response to a
4899/// command with type kNEHotspotHelperCommandTypeMaintain.
4900///
4901/// authenticate, the helper determined that it can't perform the
4902/// authentication. This result is only valid in response to commands of type
4903/// kNEHotspotHelperCommandTypeAuthenticate and
4904/// kNEHotspotHelperCommandTypePresentUI.
4905///
4906/// it is temporarily unable to perform the authentication.
4907/// This result is only valid in response to commands of type
4908/// kNEHotspotHelperCommandTypeAuthenticate and
4909/// kNEHotspotHelperCommandTypePresentUI.
4910///
4911/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspothelperresult?language=objc)
4912// NS_ENUM
4913#[repr(transparent)]
4914#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
4915pub struct NEHotspotHelperResult(pub NSInteger);
4916impl NEHotspotHelperResult {
4917 #[doc(alias = "kNEHotspotHelperResultSuccess")]
4918 pub const Success: Self = Self(0);
4919 #[doc(alias = "kNEHotspotHelperResultFailure")]
4920 pub const Failure: Self = Self(1);
4921 #[doc(alias = "kNEHotspotHelperResultUIRequired")]
4922 pub const UIRequired: Self = Self(2);
4923 #[doc(alias = "kNEHotspotHelperResultCommandNotRecognized")]
4924 pub const CommandNotRecognized: Self = Self(3);
4925 #[doc(alias = "kNEHotspotHelperResultAuthenticationRequired")]
4926 pub const AuthenticationRequired: Self = Self(4);
4927 #[doc(alias = "kNEHotspotHelperResultUnsupportedNetwork")]
4928 pub const UnsupportedNetwork: Self = Self(5);
4929 #[doc(alias = "kNEHotspotHelperResultTemporaryFailure")]
4930 pub const TemporaryFailure: Self = Self(6);
4931}
4932
4933unsafe impl Encode for NEHotspotHelperResult {
4934 const ENCODING: Encoding = NSInteger::ENCODING;
4935}
4936
4937unsafe impl RefEncode for NEHotspotHelperResult {
4938 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
4939}
4940
4941/// The HotspotHelper's confidence in its ability to handle the network.
4942///
4943/// The HotspotHelper indicates its confidence in being able to handle the
4944/// given hotspot network.
4945///
4946/// the network.
4947///
4948/// in being able to handle the network.
4949///
4950/// in being able to handle the network.
4951///
4952/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspothelperconfidence?language=objc)
4953// NS_ENUM
4954#[repr(transparent)]
4955#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
4956pub struct NEHotspotHelperConfidence(pub NSInteger);
4957impl NEHotspotHelperConfidence {
4958 #[doc(alias = "kNEHotspotHelperConfidenceNone")]
4959 pub const None: Self = Self(0);
4960 #[doc(alias = "kNEHotspotHelperConfidenceLow")]
4961 pub const Low: Self = Self(1);
4962 #[doc(alias = "kNEHotspotHelperConfidenceHigh")]
4963 pub const High: Self = Self(2);
4964}
4965
4966unsafe impl Encode for NEHotspotHelperConfidence {
4967 const ENCODING: Encoding = NSInteger::ENCODING;
4968}
4969
4970unsafe impl RefEncode for NEHotspotHelperConfidence {
4971 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
4972}
4973
4974/// HotspotHelper.
4975///
4976/// Extends NEHotspotNetwork class to support conveying information about the
4977/// network to the HotspotHelper. When the HotspotHelper is asked to evaluate
4978/// the current network or filter the Wi-Fi scan list, it annotates the NEHotspotNetwork
4979/// via the setConfidence method.
4980impl NEHotspotNetwork {
4981 extern_methods!(
4982 /// The signal strength for the Wi-Fi network. The value lies within
4983 /// the range 0.0 (weak/no signal) to 1.0 (strong signal).
4984 #[unsafe(method(signalStrength))]
4985 #[unsafe(method_family = none)]
4986 pub unsafe fn signalStrength(&self) -> c_double;
4987
4988 /// Indicates whether the network is secure
4989 #[unsafe(method(isSecure))]
4990 #[unsafe(method_family = none)]
4991 pub unsafe fn isSecure(&self) -> bool;
4992
4993 /// Indicates whether the network was joined automatically
4994 /// (YES) or joined by the user (NO).
4995 #[unsafe(method(didAutoJoin))]
4996 #[unsafe(method_family = none)]
4997 pub unsafe fn didAutoJoin(&self) -> bool;
4998
4999 /// Indicates whether the network was just joined. Useful in the
5000 /// Maintaining state to differentiate whether the Maintain command
5001 /// is for the initial join, or the subsequent periodic callback.
5002 #[unsafe(method(didJustJoin))]
5003 #[unsafe(method_family = none)]
5004 pub unsafe fn didJustJoin(&self) -> bool;
5005
5006 /// Indicates whether the HotspotHelper is the chosen helper for
5007 /// the network. The NEHotspotNetwork must have been instantiated via a
5008 /// call to the +[NEHotspotHelper supportedNetworkInterfaces] method. This
5009 /// is useful to restore state after the HotspotHelper application is quit
5010 /// and restarted.
5011 #[unsafe(method(isChosenHelper))]
5012 #[unsafe(method_family = none)]
5013 pub unsafe fn isChosenHelper(&self) -> bool;
5014
5015 /// Indicate the confidence in being able to handle the network.
5016 ///
5017 /// Use this method to indicate the confidence in being able to
5018 /// successfully authenticate to the given network. Used in the response
5019 /// to the kNEHotspotHelperCommandTypeEvaluate and
5020 /// kNEHotspotHelperCommandTypeFilterScanList commands.
5021 #[unsafe(method(setConfidence:))]
5022 #[unsafe(method_family = none)]
5023 pub unsafe fn setConfidence(&self, confidence: NEHotspotHelperConfidence);
5024
5025 /// Provide the password for a secure network
5026 ///
5027 /// The HotspotHelper may set a password for a secure network. The format
5028 /// password string must adhere to IEEE 802.11 guidelines appropriate for
5029 /// the particular security scheme.
5030 ///
5031 /// Used only in the response to the kNEHotspotHelperCommandTypeFilterScanList
5032 /// command.
5033 #[unsafe(method(setPassword:))]
5034 #[unsafe(method_family = none)]
5035 pub unsafe fn setPassword(&self, password: &NSString);
5036 );
5037}
5038
5039extern_class!(
5040 /// An NEHotspotHelperCommand object is provided to the helper's
5041 /// command handler block. The HotspotHelper processes the command
5042 /// instantiates an NEHotspotHelperResponse object, sets the annotated
5043 /// network or networkList (Evaluate/FilterScanList only),
5044 /// then delivers it.
5045 ///
5046 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspothelpercommand?language=objc)
5047 #[unsafe(super(NSObject))]
5048 #[derive(Debug, PartialEq, Eq, Hash)]
5049 pub struct NEHotspotHelperCommand;
5050);
5051
5052extern_conformance!(
5053 unsafe impl NSObjectProtocol for NEHotspotHelperCommand {}
5054);
5055
5056impl NEHotspotHelperCommand {
5057 extern_methods!(
5058 /// The type of the command.
5059 #[unsafe(method(commandType))]
5060 #[unsafe(method_family = none)]
5061 pub unsafe fn commandType(&self) -> NEHotspotHelperCommandType;
5062
5063 /// The network associated with the command. May be nil.
5064 #[unsafe(method(network))]
5065 #[unsafe(method_family = none)]
5066 pub unsafe fn network(&self) -> Option<Retained<NEHotspotNetwork>>;
5067
5068 /// The list of networks associated with a command. Will be nil unless
5069 /// the command type is kNEHotspotHelperCommandTypeFilterScanList.
5070 /// This property returns an NSArray of NEHotspotNetwork.
5071 #[unsafe(method(networkList))]
5072 #[unsafe(method_family = none)]
5073 pub unsafe fn networkList(&self) -> Option<Retained<NSArray<NEHotspotNetwork>>>;
5074
5075 /// Create a response to the command.
5076 ///
5077 /// Instantiate an NEHotspotHelperResponse for the command.
5078 ///
5079 /// Returns: NEHotspotHelperResponse with the specified result.
5080 #[unsafe(method(createResponse:))]
5081 #[unsafe(method_family = none)]
5082 pub unsafe fn createResponse(
5083 &self,
5084 result: NEHotspotHelperResult,
5085 ) -> Retained<NEHotspotHelperResponse>;
5086
5087 /// Create a new TCP connection over the interface associated with the command.
5088 ///
5089 /// Instantiate an NWTCPConnection to the specified endpoint
5090 /// bound to the network interface associated with the command.
5091 ///
5092 /// Returns: non-nil NWTCPConnection object if successful, nil otherwise
5093 #[deprecated = "Use the `interface` property with `nw_parameters_require_interface`"]
5094 #[unsafe(method(createTCPConnection:))]
5095 #[unsafe(method_family = none)]
5096 pub unsafe fn createTCPConnection(
5097 &self,
5098 endpoint: &NWEndpoint,
5099 ) -> Retained<NWTCPConnection>;
5100
5101 /// Create a new UDP session over the interface associated with the command.
5102 ///
5103 /// Instantiate an NWUDPSession to the specified endpoint
5104 /// bound to the network interface associated with the command.
5105 ///
5106 /// Returns: non-nil NWUDPSession object if successful, nil otherwise
5107 #[deprecated = "Use the `interface` property with `nw_parameters_require_interface`"]
5108 #[unsafe(method(createUDPSession:))]
5109 #[unsafe(method_family = none)]
5110 pub unsafe fn createUDPSession(&self, endpoint: &NWEndpoint) -> Retained<NWUDPSession>;
5111 );
5112}
5113
5114/// Methods declared on superclass `NSObject`.
5115impl NEHotspotHelperCommand {
5116 extern_methods!(
5117 #[unsafe(method(init))]
5118 #[unsafe(method_family = init)]
5119 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
5120
5121 #[unsafe(method(new))]
5122 #[unsafe(method_family = new)]
5123 pub unsafe fn new() -> Retained<Self>;
5124 );
5125}
5126
5127extern_class!(
5128 /// The HotspotHelper creates an NEHotspotHelperResponse object to provide
5129 /// the results of running the corresponding NEHotspotHelperCommand.
5130 ///
5131 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspothelperresponse?language=objc)
5132 #[unsafe(super(NSObject))]
5133 #[derive(Debug, PartialEq, Eq, Hash)]
5134 pub struct NEHotspotHelperResponse;
5135);
5136
5137extern_conformance!(
5138 unsafe impl NSObjectProtocol for NEHotspotHelperResponse {}
5139);
5140
5141impl NEHotspotHelperResponse {
5142 extern_methods!(
5143 /// Set the network that conveys the confidence level.
5144 ///
5145 /// Provide the annotated NEHotspotNetwork object in the response to the
5146 /// kNEHotspotHelperCommandTypeEvaluate command. The helper sets the
5147 /// confidence in the network object to indicate its ability to handle
5148 /// the current network.
5149 #[unsafe(method(setNetwork:))]
5150 #[unsafe(method_family = none)]
5151 pub unsafe fn setNetwork(&self, network: &NEHotspotNetwork);
5152
5153 /// Set the list of handled networks.
5154 ///
5155 /// Provide an NSArray of annotated NEHotspotNetwork objects in response
5156 /// to the kNEHotspotHelperCommandTypeFilterScanList command.
5157 /// The helper provides the list of network objects that it is capable of
5158 /// handling with at least low confidence. Networks that it has no
5159 /// confidence in handling should not be specified.
5160 #[unsafe(method(setNetworkList:))]
5161 #[unsafe(method_family = none)]
5162 pub unsafe fn setNetworkList(&self, network_list: &NSArray<NEHotspotNetwork>);
5163
5164 /// Delivers the response to the command.
5165 ///
5166 /// Deliver the NEHotspotHelperResponse to the HotspotHelper infrastructure.
5167 #[deprecated = "Use handleCommand in NEHotspotEvaluationProvider or NEHotspotAuthenticationProvider API"]
5168 #[unsafe(method(deliver))]
5169 #[unsafe(method_family = none)]
5170 pub unsafe fn deliver(&self);
5171 );
5172}
5173
5174/// Methods declared on superclass `NSObject`.
5175impl NEHotspotHelperResponse {
5176 extern_methods!(
5177 #[unsafe(method(init))]
5178 #[unsafe(method_family = init)]
5179 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
5180
5181 #[unsafe(method(new))]
5182 #[unsafe(method_family = new)]
5183 pub unsafe fn new() -> Retained<Self>;
5184 );
5185}
5186
5187/// The type definition for the HotspotHelper's command handler block.
5188///
5189/// The application provides a block of this type when it
5190/// invokes the +[NEHotspotHelper registerWithOptions:queue:handler] method.
5191/// The block is invoked every time there is a command to be processed.
5192///
5193/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspothelperhandler?language=objc)
5194#[cfg(feature = "block2")]
5195pub type NEHotspotHelperHandler = *mut block2::DynBlock<dyn Fn(NonNull<NEHotspotHelperCommand>)>;
5196
5197extern "C" {
5198 /// The string displayed in Wi-Fi Settings for a network handled by
5199 /// the application.
5200 ///
5201 /// This key specifies the display name for the application, if an alternate
5202 /// name is desired. If this property is not specified, the application's
5203 /// name is used.
5204 ///
5205 /// This name appears in Settings -> Wi-Fi underneath the Wi-Fi network
5206 /// name if the helper indicated that it was able to handle the network.
5207 ///
5208 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/knehotspothelperoptiondisplayname?language=objc)
5209 pub static kNEHotspotHelperOptionDisplayName: &'static NSString;
5210}
5211
5212extern_class!(
5213 /// The NEHotspotHelper class allows an application to register itself as a
5214 /// HotspotHelper.
5215 ///
5216 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspothelper?language=objc)
5217 #[unsafe(super(NSObject))]
5218 #[derive(Debug, PartialEq, Eq, Hash)]
5219 #[deprecated = "Use NEHotspotManager API"]
5220 pub struct NEHotspotHelper;
5221);
5222
5223extern_conformance!(
5224 unsafe impl NSObjectProtocol for NEHotspotHelper {}
5225);
5226
5227impl NEHotspotHelper {
5228 extern_methods!(
5229 #[cfg(all(feature = "block2", feature = "dispatch2"))]
5230 /// Register the application as a HotspotHelper.
5231 ///
5232 /// Once this API is invoked successfully, the application becomes
5233 /// eligible to be launched in the background and participate in
5234 /// various hotspot related functions.
5235 ///
5236 /// This function should be called once when the application starts up.
5237 /// Invoking it again will have no effect and result in FALSE being returned.
5238 ///
5239 /// The 'options' dictionary may be nil, or contain the single property
5240 /// kNEHotspotHelperOptionDisplayName.
5241 ///
5242 ///
5243 /// Parameter `options`: If not nil, 'options' is an NSDictionary containing
5244 /// kNEHotspotHelperOption* keys (currently just
5245 /// kNEHotspotHelperOptionDisplayName).
5246 ///
5247 /// Parameter `queue`: The dispatch_queue_t to invoke the handle block on.
5248 ///
5249 /// Parameter `handler`: The NEHotspotHelperHandler block to execute to process
5250 /// helper commands.
5251 ///
5252 /// Returns: YES if the registration was successful, NO otherwise.
5253 ///
5254 /// Note: Notes
5255 ///
5256 /// Note: 1
5257 /// The application's Info.plist MUST include a UIBackgroundModes array
5258 /// containing 'network-authentication'.
5259 ///
5260 /// Note: 2
5261 /// The application MUST set 'com.apple.developer.networking.HotspotHelper'
5262 /// as one of its entitlements. The value of the entitlement is a boolean
5263 /// value true.
5264 ///
5265 /// # Safety
5266 ///
5267 /// - `options` generic should be of the correct type.
5268 /// - `queue` possibly has additional threading requirements.
5269 /// - `handler` must be a valid pointer.
5270 #[deprecated = "Use NEHotspotManager API"]
5271 #[unsafe(method(registerWithOptions:queue:handler:))]
5272 #[unsafe(method_family = none)]
5273 pub unsafe fn registerWithOptions_queue_handler(
5274 options: Option<&NSDictionary<NSString, NSObject>>,
5275 queue: &DispatchQueue,
5276 handler: NEHotspotHelperHandler,
5277 ) -> bool;
5278
5279 /// Terminate the authentication session.
5280 ///
5281 /// The application invokes this method when it wants to logoff from the
5282 /// current network. Invoking this method causes an NEHotspotHelperCommand
5283 /// of type kNEHotspotHelperCommandTypeLogoff to be issued to the application's
5284 /// 'handler' block (see +[NEHotspotHelper registerWithOptions:queue:handler]).
5285 ///
5286 /// 'network' must correspond to the currently associated Wi-Fi network
5287 /// i.e. it must have come from the NEHotspotHelperCommand's 'network' property
5288 /// or from the +[NEHotspotHelper supportedInterfaces] method.
5289 ///
5290 /// Returns: YES if the logoff command was successfully queued, NO otherwise.
5291 ///
5292 /// Note: Notes
5293 ///
5294 /// Note: 1
5295 /// The application MUST NOT actually logoff from the network until it
5296 /// receives the command to logoff.
5297 ///
5298 /// Note: 2
5299 /// After the application invokes -[NEHotspotHelperResponse deliver] indicating
5300 /// kNEHotspotHelperResultSuccess, the Wi-Fi network is disassociated.
5301 #[deprecated = "Use NEHotspotManager API"]
5302 #[unsafe(method(logoff:))]
5303 #[unsafe(method_family = none)]
5304 pub unsafe fn logoff(network: &NEHotspotNetwork) -> bool;
5305
5306 /// Return the list of network interfaces managed by the
5307 /// HotspotHelper infrastructure.
5308 ///
5309 /// Each network interface is represented by an NEHotspotNetwork object.
5310 /// Currently, the returned array contains exactly one NEHotspotNetwork
5311 /// object representing the Wi-Fi interface.
5312 ///
5313 /// The main purpose of this method is to allow a HotspotHelper to provide
5314 /// accurate status in its UI at times when it has not been given a command
5315 /// to process. This method coupled with -[NEHotspotNetwork isChosenHelper]
5316 /// allows the application to know whether it is the one that is handling
5317 /// the current network.
5318 ///
5319 /// Returns: nil if no network interfaces are being managed,
5320 /// non-nil NSArray of NEHotspotNetwork objects otherwise.
5321 #[deprecated = "Use NEHotspotManager API"]
5322 #[unsafe(method(supportedNetworkInterfaces))]
5323 #[unsafe(method_family = none)]
5324 pub unsafe fn supportedNetworkInterfaces() -> Option<Retained<NSArray>>;
5325 );
5326}
5327
5328/// Methods declared on superclass `NSObject`.
5329impl NEHotspotHelper {
5330 extern_methods!(
5331 #[unsafe(method(init))]
5332 #[unsafe(method_family = init)]
5333 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
5334
5335 #[unsafe(method(new))]
5336 #[unsafe(method_family = new)]
5337 pub unsafe fn new() -> Retained<Self>;
5338 );
5339}
5340
5341mod private_NSMutableURLRequestNEHotspotHelper {
5342 pub trait Sealed {}
5343}
5344
5345/// Category "NEHotspotHelper" on [`NSMutableURLRequest`].
5346///
5347/// Extend NSMutableURLRequest to include a method to bind the
5348/// request to the network interface associated with the specified
5349/// NEHotspotHelperCommand object.
5350#[doc(alias = "NEHotspotHelper")]
5351pub unsafe trait NSMutableURLRequestNEHotspotHelper:
5352 ClassType + Sized + private_NSMutableURLRequestNEHotspotHelper::Sealed
5353{
5354 extern_methods!(
5355 /// Binds the NSMutableURLRequest to the network interface associated with
5356 /// the NEHotspotHelperCommand object.
5357 #[unsafe(method(bindToHotspotHelperCommand:))]
5358 #[unsafe(method_family = none)]
5359 unsafe fn bindToHotspotHelperCommand(&self, command: &NEHotspotHelperCommand);
5360 );
5361}
5362
5363impl private_NSMutableURLRequestNEHotspotHelper::Sealed for NSMutableURLRequest {}
5364unsafe impl NSMutableURLRequestNEHotspotHelper for NSMutableURLRequest {}
5365
5366/// EAP Type.
5367///
5368/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspotconfigurationeaptype?language=objc)
5369// NS_ENUM
5370#[repr(transparent)]
5371#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
5372pub struct NEHotspotConfigurationEAPType(pub NSInteger);
5373impl NEHotspotConfigurationEAPType {
5374 #[doc(alias = "NEHotspotConfigurationEAPTypeEAPTLS")]
5375 pub const EAPTLS: Self = Self(13);
5376 #[doc(alias = "NEHotspotConfigurationEAPTypeEAPTTLS")]
5377 pub const EAPTTLS: Self = Self(21);
5378 #[doc(alias = "NEHotspotConfigurationEAPTypeEAPPEAP")]
5379 pub const EAPPEAP: Self = Self(25);
5380 #[doc(alias = "NEHotspotConfigurationEAPTypeEAPFAST")]
5381 pub const EAPFAST: Self = Self(43);
5382}
5383
5384unsafe impl Encode for NEHotspotConfigurationEAPType {
5385 const ENCODING: Encoding = NSInteger::ENCODING;
5386}
5387
5388unsafe impl RefEncode for NEHotspotConfigurationEAPType {
5389 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
5390}
5391
5392/// TTLS Inner Authentication Type.
5393///
5394/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspotconfigurationttlsinnerauthenticationtype?language=objc)
5395// NS_ENUM
5396#[repr(transparent)]
5397#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
5398pub struct NEHotspotConfigurationTTLSInnerAuthenticationType(pub NSInteger);
5399impl NEHotspotConfigurationTTLSInnerAuthenticationType {
5400 #[doc(alias = "NEHotspotConfigurationEAPTTLSInnerAuthenticationPAP")]
5401 pub const EAPTTLSInnerAuthenticationPAP: Self = Self(0);
5402 #[doc(alias = "NEHotspotConfigurationEAPTTLSInnerAuthenticationCHAP")]
5403 pub const EAPTTLSInnerAuthenticationCHAP: Self = Self(1);
5404 #[doc(alias = "NEHotspotConfigurationEAPTTLSInnerAuthenticationMSCHAP")]
5405 pub const EAPTTLSInnerAuthenticationMSCHAP: Self = Self(2);
5406 #[doc(alias = "NEHotspotConfigurationEAPTTLSInnerAuthenticationMSCHAPv2")]
5407 pub const EAPTTLSInnerAuthenticationMSCHAPv2: Self = Self(3);
5408 #[doc(alias = "NEHotspotConfigurationEAPTTLSInnerAuthenticationEAP")]
5409 pub const EAPTTLSInnerAuthenticationEAP: Self = Self(4);
5410}
5411
5412unsafe impl Encode for NEHotspotConfigurationTTLSInnerAuthenticationType {
5413 const ENCODING: Encoding = NSInteger::ENCODING;
5414}
5415
5416unsafe impl RefEncode for NEHotspotConfigurationTTLSInnerAuthenticationType {
5417 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
5418}
5419
5420/// TLS version to use during TLS handshke.
5421///
5422/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspotconfigurationeaptlsversion?language=objc)
5423// NS_ENUM
5424#[repr(transparent)]
5425#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
5426pub struct NEHotspotConfigurationEAPTLSVersion(pub NSInteger);
5427impl NEHotspotConfigurationEAPTLSVersion {
5428 #[doc(alias = "NEHotspotConfigurationEAPTLSVersion_1_0")]
5429 pub const Version_1_0: Self = Self(0);
5430 #[doc(alias = "NEHotspotConfigurationEAPTLSVersion_1_1")]
5431 pub const Version_1_1: Self = Self(1);
5432 #[doc(alias = "NEHotspotConfigurationEAPTLSVersion_1_2")]
5433 pub const Version_1_2: Self = Self(2);
5434}
5435
5436unsafe impl Encode for NEHotspotConfigurationEAPTLSVersion {
5437 const ENCODING: Encoding = NSInteger::ENCODING;
5438}
5439
5440unsafe impl RefEncode for NEHotspotConfigurationEAPTLSVersion {
5441 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
5442}
5443
5444extern_class!(
5445 /// NEHotspotHS20Settings class provides a set of properties that are required
5446 /// to discover and negotiate Hotspot 2.0 Wi-Fi networks.
5447 ///
5448 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspoths20settings?language=objc)
5449 #[unsafe(super(NSObject))]
5450 #[derive(Debug, PartialEq, Eq, Hash)]
5451 pub struct NEHotspotHS20Settings;
5452);
5453
5454extern_conformance!(
5455 unsafe impl NSCoding for NEHotspotHS20Settings {}
5456);
5457
5458extern_conformance!(
5459 unsafe impl NSCopying for NEHotspotHS20Settings {}
5460);
5461
5462unsafe impl CopyingHelper for NEHotspotHS20Settings {
5463 type Result = Self;
5464}
5465
5466extern_conformance!(
5467 unsafe impl NSObjectProtocol for NEHotspotHS20Settings {}
5468);
5469
5470extern_conformance!(
5471 unsafe impl NSSecureCoding for NEHotspotHS20Settings {}
5472);
5473
5474impl NEHotspotHS20Settings {
5475 extern_methods!(
5476 /// Domain Name of Legacy Hotspot or Hotspot 2.0 Wi-Fi Network.
5477 /// This Domain Name is used for Wi-Fi Hotspot 2.0 negotiation.
5478 #[unsafe(method(domainName))]
5479 #[unsafe(method_family = none)]
5480 pub unsafe fn domainName(&self) -> Retained<NSString>;
5481
5482 /// If set to YES, allows connection to networks of roaming service
5483 /// providers. Defaults to NO.
5484 #[unsafe(method(isRoamingEnabled))]
5485 #[unsafe(method_family = none)]
5486 pub unsafe fn isRoamingEnabled(&self) -> bool;
5487
5488 /// Setter for [`isRoamingEnabled`][Self::isRoamingEnabled].
5489 #[unsafe(method(setRoamingEnabled:))]
5490 #[unsafe(method_family = none)]
5491 pub unsafe fn setRoamingEnabled(&self, roaming_enabled: bool);
5492
5493 /// Array of Roaming Consortium Organization Identifiers used
5494 /// for Wi-Fi Hotspot 2.0 negotiation.
5495 #[unsafe(method(roamingConsortiumOIs))]
5496 #[unsafe(method_family = none)]
5497 pub unsafe fn roamingConsortiumOIs(&self) -> Retained<NSArray<NSString>>;
5498
5499 /// Setter for [`roamingConsortiumOIs`][Self::roamingConsortiumOIs].
5500 ///
5501 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
5502 #[unsafe(method(setRoamingConsortiumOIs:))]
5503 #[unsafe(method_family = none)]
5504 pub unsafe fn setRoamingConsortiumOIs(&self, roaming_consortium_o_is: &NSArray<NSString>);
5505
5506 /// Array of Network Access Identifier Realm names used for
5507 /// Wi-Fi Hotspot 2.0 negotiation.
5508 #[unsafe(method(naiRealmNames))]
5509 #[unsafe(method_family = none)]
5510 pub unsafe fn naiRealmNames(&self) -> Retained<NSArray<NSString>>;
5511
5512 /// Setter for [`naiRealmNames`][Self::naiRealmNames].
5513 ///
5514 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
5515 #[unsafe(method(setNaiRealmNames:))]
5516 #[unsafe(method_family = none)]
5517 pub unsafe fn setNaiRealmNames(&self, nai_realm_names: &NSArray<NSString>);
5518
5519 /// Array of Mobile Country Code (MCC)/Mobile Network Code (MNC)
5520 /// pairs used for Wi-Fi Hotspot 2.0 negotiation. Each string must contain
5521 /// exactly six digits.
5522 #[unsafe(method(MCCAndMNCs))]
5523 #[unsafe(method_family = none)]
5524 pub unsafe fn MCCAndMNCs(&self) -> Retained<NSArray<NSString>>;
5525
5526 /// Setter for [`MCCAndMNCs`][Self::MCCAndMNCs].
5527 ///
5528 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
5529 #[unsafe(method(setMCCAndMNCs:))]
5530 #[unsafe(method_family = none)]
5531 pub unsafe fn setMCCAndMNCs(&self, mcc_and_mn_cs: &NSArray<NSString>);
5532
5533 /// A designated initializer to instantiate a new NEHotspotHSSettings object.
5534 /// This initializer is used to configure Legacy Hotspot or HS2.0 Wi-Fi Networks.
5535 ///
5536 ///
5537 /// Parameter `domainName`: The domain name of HS2.0 Wi-Fi Network
5538 ///
5539 /// Parameter `roamingEnabled`: If YES, allows connections to networks of roaming service providers.
5540 #[unsafe(method(initWithDomainName:roamingEnabled:))]
5541 #[unsafe(method_family = init)]
5542 pub unsafe fn initWithDomainName_roamingEnabled(
5543 this: Allocated<Self>,
5544 domain_name: &NSString,
5545 roaming_enabled: bool,
5546 ) -> Retained<Self>;
5547 );
5548}
5549
5550/// Methods declared on superclass `NSObject`.
5551impl NEHotspotHS20Settings {
5552 extern_methods!(
5553 #[unsafe(method(init))]
5554 #[unsafe(method_family = init)]
5555 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
5556
5557 #[unsafe(method(new))]
5558 #[unsafe(method_family = new)]
5559 pub unsafe fn new() -> Retained<Self>;
5560 );
5561}
5562
5563extern_class!(
5564 /// NEHotspotEAPSettings class provides a set of properties that are required
5565 /// to configure a WPA/WPA2 Enterprise or Hotspot 2.0 Wi-Fi networks.
5566 ///
5567 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspoteapsettings?language=objc)
5568 #[unsafe(super(NSObject))]
5569 #[derive(Debug, PartialEq, Eq, Hash)]
5570 pub struct NEHotspotEAPSettings;
5571);
5572
5573extern_conformance!(
5574 unsafe impl NSCoding for NEHotspotEAPSettings {}
5575);
5576
5577extern_conformance!(
5578 unsafe impl NSCopying for NEHotspotEAPSettings {}
5579);
5580
5581unsafe impl CopyingHelper for NEHotspotEAPSettings {
5582 type Result = Self;
5583}
5584
5585extern_conformance!(
5586 unsafe impl NSObjectProtocol for NEHotspotEAPSettings {}
5587);
5588
5589extern_conformance!(
5590 unsafe impl NSSecureCoding for NEHotspotEAPSettings {}
5591);
5592
5593impl NEHotspotEAPSettings {
5594 extern_methods!(
5595 /// Array of supported EAP Types. Refer to NEHotspotConfigurationEAPType
5596 /// for valid values.
5597 #[unsafe(method(supportedEAPTypes))]
5598 #[unsafe(method_family = none)]
5599 pub unsafe fn supportedEAPTypes(&self) -> Retained<NSArray<NSNumber>>;
5600
5601 /// Setter for [`supportedEAPTypes`][Self::supportedEAPTypes].
5602 ///
5603 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
5604 #[unsafe(method(setSupportedEAPTypes:))]
5605 #[unsafe(method_family = none)]
5606 pub unsafe fn setSupportedEAPTypes(&self, supported_eap_types: &NSArray<NSNumber>);
5607
5608 /// A UTF-8 encoded string containing username component of the user authentication
5609 /// credentials. Length of this property must be between 1 and 253 characters.
5610 #[unsafe(method(username))]
5611 #[unsafe(method_family = none)]
5612 pub unsafe fn username(&self) -> Retained<NSString>;
5613
5614 /// Setter for [`username`][Self::username].
5615 ///
5616 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
5617 #[unsafe(method(setUsername:))]
5618 #[unsafe(method_family = none)]
5619 pub unsafe fn setUsername(&self, username: &NSString);
5620
5621 /// Identity string to be used in EAP-Response/Identity of the outer phase. This key is only
5622 /// relevant to TTLS, PEAP, and EAP-FAST.
5623 #[unsafe(method(outerIdentity))]
5624 #[unsafe(method_family = none)]
5625 pub unsafe fn outerIdentity(&self) -> Retained<NSString>;
5626
5627 /// Setter for [`outerIdentity`][Self::outerIdentity].
5628 ///
5629 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
5630 #[unsafe(method(setOuterIdentity:))]
5631 #[unsafe(method_family = none)]
5632 pub unsafe fn setOuterIdentity(&self, outer_identity: &NSString);
5633
5634 /// Specifies the inner authentication used by the TTLS module.
5635 /// Possible values are PAP, CHAP, MSCHAP, MSCHAPv2, and EAP. Defaults to EAP.
5636 #[unsafe(method(ttlsInnerAuthenticationType))]
5637 #[unsafe(method_family = none)]
5638 pub unsafe fn ttlsInnerAuthenticationType(
5639 &self,
5640 ) -> NEHotspotConfigurationTTLSInnerAuthenticationType;
5641
5642 /// Setter for [`ttlsInnerAuthenticationType`][Self::ttlsInnerAuthenticationType].
5643 #[unsafe(method(setTtlsInnerAuthenticationType:))]
5644 #[unsafe(method_family = none)]
5645 pub unsafe fn setTtlsInnerAuthenticationType(
5646 &self,
5647 ttls_inner_authentication_type: NEHotspotConfigurationTTLSInnerAuthenticationType,
5648 );
5649
5650 /// The password component of the 802.1X authentication credential.
5651 /// Length of this property must be between 1 and 64 characters.
5652 #[unsafe(method(password))]
5653 #[unsafe(method_family = none)]
5654 pub unsafe fn password(&self) -> Retained<NSString>;
5655
5656 /// Setter for [`password`][Self::password].
5657 ///
5658 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
5659 #[unsafe(method(setPassword:))]
5660 #[unsafe(method_family = none)]
5661 pub unsafe fn setPassword(&self, password: &NSString);
5662
5663 /// Array of server certificate common names that will be used to verify server's certificate.
5664 /// The string could have wildcards to specify the name, such as "*.mycompany.net". If a server presents
5665 /// a certificate with DNSName or Common Name that isn't in this list, it won't be trusted.
5666 #[unsafe(method(trustedServerNames))]
5667 #[unsafe(method_family = none)]
5668 pub unsafe fn trustedServerNames(&self) -> Retained<NSArray<NSString>>;
5669
5670 /// Setter for [`trustedServerNames`][Self::trustedServerNames].
5671 ///
5672 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
5673 #[unsafe(method(setTrustedServerNames:))]
5674 #[unsafe(method_family = none)]
5675 pub unsafe fn setTrustedServerNames(&self, trusted_server_names: &NSArray<NSString>);
5676
5677 /// If YES, supports two-factor authentication for EAP-TTLS, PEAP, or EAP-FAST.
5678 /// If NO, allows for zero-factor authentication for EAP-TLS. The default is YES for EAP-TLS,
5679 /// and NO for other EAP types.
5680 #[unsafe(method(isTLSClientCertificateRequired))]
5681 #[unsafe(method_family = none)]
5682 pub unsafe fn isTLSClientCertificateRequired(&self) -> bool;
5683
5684 /// Setter for [`isTLSClientCertificateRequired`][Self::isTLSClientCertificateRequired].
5685 #[unsafe(method(setTlsClientCertificateRequired:))]
5686 #[unsafe(method_family = none)]
5687 pub unsafe fn setTlsClientCertificateRequired(&self, tls_client_certificate_required: bool);
5688
5689 /// TLS version to use during the TLS handshake.
5690 /// Default value is NEHotspotConfigurationEAPTLSVersion_1_2.
5691 #[unsafe(method(preferredTLSVersion))]
5692 #[unsafe(method_family = none)]
5693 pub unsafe fn preferredTLSVersion(&self) -> NEHotspotConfigurationEAPTLSVersion;
5694
5695 /// Setter for [`preferredTLSVersion`][Self::preferredTLSVersion].
5696 #[unsafe(method(setPreferredTLSVersion:))]
5697 #[unsafe(method_family = none)]
5698 pub unsafe fn setPreferredTLSVersion(
5699 &self,
5700 preferred_tls_version: NEHotspotConfigurationEAPTLSVersion,
5701 );
5702
5703 #[cfg(feature = "objc2-security")]
5704 /// Setter to configure the EAP peer identity. The application needs to store
5705 /// this identity in keychain access group "$(TeamIdentifierPrefix)com.apple.networkextensionsharing".
5706 /// The API uses SecItemCopyMatching to obtain persistent reference for this identity from application's
5707 /// keychain and uses that at the time of EAP authentication.
5708 /// This property is mandatory when EAP-TLS is desired or tlsClientCertificateRequired is set to YES.
5709 ///
5710 ///
5711 /// Parameter `identity`: The identity of the EAP Peer. This is a SecIdentityRef object that contains
5712 /// a SecKeyRef object and an associated SecCertificateRef object.
5713 ///
5714 /// Returns: returns NO if the parameter is not an object of SecIdentityRef type or if the persistent reference
5715 /// is not found in the application's keychain else returns YES.
5716 #[unsafe(method(setIdentity:))]
5717 #[unsafe(method_family = none)]
5718 pub unsafe fn setIdentity(&self, identity: &SecIdentity) -> bool;
5719
5720 /// Setter to configure an array of trusted server certificates used for trust evaluation of
5721 /// the server certificate.
5722 ///
5723 ///
5724 /// Parameter `certificates`: Each value in the array is a SecCertificateRef object. Application needs to store
5725 /// the certificates in keychain access group "$(TeamIdentifierPrefix)com.apple.networkextensionsharing".
5726 /// The API uses SecItemCopyMatching to obtain persistent reference for each certificate from application's
5727 /// keychain and uses that at the time os EAP authentication.
5728 /// Number of elements in the array cannot be more than 10.
5729 ///
5730 ///
5731 /// Returns: returns NO if any element in the array is not an object of type SecCertificateRef or if API
5732 /// fails to find persistent reference for each element from the application's keychain else return YES.
5733 ///
5734 /// # Safety
5735 ///
5736 /// `certificates` generic should be of the correct type.
5737 #[unsafe(method(setTrustedServerCertificates:))]
5738 #[unsafe(method_family = none)]
5739 pub unsafe fn setTrustedServerCertificates(&self, certificates: &NSArray) -> bool;
5740 );
5741}
5742
5743/// Methods declared on superclass `NSObject`.
5744impl NEHotspotEAPSettings {
5745 extern_methods!(
5746 #[unsafe(method(init))]
5747 #[unsafe(method_family = init)]
5748 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
5749
5750 #[unsafe(method(new))]
5751 #[unsafe(method_family = new)]
5752 pub unsafe fn new() -> Retained<Self>;
5753 );
5754}
5755
5756extern_class!(
5757 /// The NEHotspotConfiguration class represents set of properties that are required
5758 /// to configure a Wi-Fi Network.
5759 ///
5760 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspotconfiguration?language=objc)
5761 #[unsafe(super(NSObject))]
5762 #[derive(Debug, PartialEq, Eq, Hash)]
5763 pub struct NEHotspotConfiguration;
5764);
5765
5766extern_conformance!(
5767 unsafe impl NSCoding for NEHotspotConfiguration {}
5768);
5769
5770extern_conformance!(
5771 unsafe impl NSCopying for NEHotspotConfiguration {}
5772);
5773
5774unsafe impl CopyingHelper for NEHotspotConfiguration {
5775 type Result = Self;
5776}
5777
5778extern_conformance!(
5779 unsafe impl NSObjectProtocol for NEHotspotConfiguration {}
5780);
5781
5782extern_conformance!(
5783 unsafe impl NSSecureCoding for NEHotspotConfiguration {}
5784);
5785
5786impl NEHotspotConfiguration {
5787 extern_methods!(
5788 /// SSID of the Wi-Fi Network.
5789 #[unsafe(method(SSID))]
5790 #[unsafe(method_family = none)]
5791 pub unsafe fn SSID(&self) -> Retained<NSString>;
5792
5793 /// Prefix string of SSID of the Wi-Fi Network.
5794 #[unsafe(method(SSIDPrefix))]
5795 #[unsafe(method_family = none)]
5796 pub unsafe fn SSIDPrefix(&self) -> Retained<NSString>;
5797
5798 /// if set to YES the configuration will not be persisted. Default is NO.
5799 #[unsafe(method(joinOnce))]
5800 #[unsafe(method_family = none)]
5801 pub unsafe fn joinOnce(&self) -> bool;
5802
5803 /// Setter for [`joinOnce`][Self::joinOnce].
5804 #[unsafe(method(setJoinOnce:))]
5805 #[unsafe(method_family = none)]
5806 pub unsafe fn setJoinOnce(&self, join_once: bool);
5807
5808 /// The lifetime of the configuration in days. The configuration is stored for the
5809 /// number of days specified by this property. The minimum value is 1 day and maximum value is 365 days.
5810 /// A configuration does not get deleted automatically if this property is not set or set to an invalid value.
5811 /// This property does not apply to Enterprise and HS2.0 networks.
5812 #[unsafe(method(lifeTimeInDays))]
5813 #[unsafe(method_family = none)]
5814 pub unsafe fn lifeTimeInDays(&self) -> Retained<NSNumber>;
5815
5816 /// Setter for [`lifeTimeInDays`][Self::lifeTimeInDays].
5817 ///
5818 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
5819 #[unsafe(method(setLifeTimeInDays:))]
5820 #[unsafe(method_family = none)]
5821 pub unsafe fn setLifeTimeInDays(&self, life_time_in_days: &NSNumber);
5822
5823 /// if set to YES the system will perform active scan of the SSID. Default is NO.
5824 #[unsafe(method(hidden))]
5825 #[unsafe(method_family = none)]
5826 pub unsafe fn hidden(&self) -> bool;
5827
5828 /// Setter for [`hidden`][Self::hidden].
5829 #[unsafe(method(setHidden:))]
5830 #[unsafe(method_family = none)]
5831 pub unsafe fn setHidden(&self, hidden: bool);
5832
5833 /// A designated initializer to instantiate a new NEHotspotConfiguration object.
5834 /// This initializer is used to configure open Wi-Fi Networks.
5835 ///
5836 ///
5837 /// Parameter `SSID`: The SSID of the open Wi-Fi Network.
5838 /// Length of SSID must be between 1 and 32 characters.
5839 #[unsafe(method(initWithSSID:))]
5840 #[unsafe(method_family = init)]
5841 pub unsafe fn initWithSSID(this: Allocated<Self>, ssid: &NSString) -> Retained<Self>;
5842
5843 /// A designated initializer to instantiate a new NEHotspotConfiguration object.
5844 /// This initializer is used configure either WEP or WPA/WPA2 Personal Wi-Fi Networks.
5845 ///
5846 ///
5847 /// Parameter `SSID`: The SSID of the WEP or WPA/WPA2 Personal Wi-Fi Network
5848 ///
5849 /// Parameter `passphrase`: The passphrase credential.
5850 /// For WPA/WPA2 Personal networks: between 8 and 63 characters.
5851 /// For Static WEP(64bit) : 10 Hex Digits
5852 /// For Static WEP(128bit) : 26 Hex Digits
5853 ///
5854 /// Parameter `isWEP`: YES specifies WEP Wi-Fi Network else WPA/WPA2 Personal Wi-Fi Network
5855 #[unsafe(method(initWithSSID:passphrase:isWEP:))]
5856 #[unsafe(method_family = init)]
5857 pub unsafe fn initWithSSID_passphrase_isWEP(
5858 this: Allocated<Self>,
5859 ssid: &NSString,
5860 passphrase: &NSString,
5861 is_wep: bool,
5862 ) -> Retained<Self>;
5863
5864 /// A designated initializer to instantiate a new NEHotspotConfiguration object.
5865 /// This initializer is used configure WPA/WPA2 Enterprise Wi-Fi Networks.
5866 ///
5867 ///
5868 /// Parameter `SSID`: The SSID of WPA/WPA2 Enterprise Wi-Fi Network
5869 ///
5870 /// Parameter `eapSettings`: EAP configuration
5871 #[unsafe(method(initWithSSID:eapSettings:))]
5872 #[unsafe(method_family = init)]
5873 pub unsafe fn initWithSSID_eapSettings(
5874 this: Allocated<Self>,
5875 ssid: &NSString,
5876 eap_settings: &NEHotspotEAPSettings,
5877 ) -> Retained<Self>;
5878
5879 /// A designated initializer to instantiate a new NEHotspotConfiguration object.
5880 /// This initializer is used configure HS2.0 Wi-Fi Networks.
5881 ///
5882 ///
5883 /// Parameter `hs20Settings`: Hotspot 2.0 configuration
5884 ///
5885 /// Parameter `eapSettings`: EAP configuration
5886 #[unsafe(method(initWithHS20Settings:eapSettings:))]
5887 #[unsafe(method_family = init)]
5888 pub unsafe fn initWithHS20Settings_eapSettings(
5889 this: Allocated<Self>,
5890 hs20_settings: &NEHotspotHS20Settings,
5891 eap_settings: &NEHotspotEAPSettings,
5892 ) -> Retained<Self>;
5893
5894 /// A designated initializer to instantiate a new NEHotspotConfiguration object.
5895 /// This initializer is used to configure open Wi-Fi Networks.
5896 ///
5897 ///
5898 /// Parameter `SSIDPrefix`: The prefix string of SSID of the open Wi-Fi Network.
5899 /// Length of SSIDPrefix must be between 3 and 32 characters.
5900 #[unsafe(method(initWithSSIDPrefix:))]
5901 #[unsafe(method_family = init)]
5902 pub unsafe fn initWithSSIDPrefix(
5903 this: Allocated<Self>,
5904 ssid_prefix: &NSString,
5905 ) -> Retained<Self>;
5906
5907 /// A designated initializer to instantiate a new NEHotspotConfiguration object.
5908 /// This initializer is used configure either WEP or WPA/WPA2 Personal Wi-Fi Networks.
5909 ///
5910 ///
5911 /// Parameter `SSIDPrefix`: The prefix string of SSID of the WEP or WPA/WPA2 Personal Wi-Fi Network.
5912 /// Length of SSIDPrefix must be between 3 and 32 characters.
5913 ///
5914 /// Parameter `passphrase`: The passphrase credential.
5915 /// For WPA/WPA2 Personal networks: between 8 and 63 characters.
5916 /// For Static WEP(64bit) : 10 Hex Digits
5917 /// For Static WEP(128bit) : 26 Hex Digits
5918 ///
5919 /// Parameter `isWEP`: YES specifies WEP Wi-Fi Network else WPA/WPA2 Personal Wi-Fi Network
5920 #[unsafe(method(initWithSSIDPrefix:passphrase:isWEP:))]
5921 #[unsafe(method_family = init)]
5922 pub unsafe fn initWithSSIDPrefix_passphrase_isWEP(
5923 this: Allocated<Self>,
5924 ssid_prefix: &NSString,
5925 passphrase: &NSString,
5926 is_wep: bool,
5927 ) -> Retained<Self>;
5928 );
5929}
5930
5931/// Methods declared on superclass `NSObject`.
5932impl NEHotspotConfiguration {
5933 extern_methods!(
5934 #[unsafe(method(init))]
5935 #[unsafe(method_family = init)]
5936 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
5937
5938 #[unsafe(method(new))]
5939 #[unsafe(method_family = new)]
5940 pub unsafe fn new() -> Retained<Self>;
5941 );
5942}
5943
5944extern "C" {
5945 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspotconfigurationerrordomain?language=objc)
5946 pub static NEHotspotConfigurationErrorDomain: &'static NSString;
5947}
5948
5949/// Hotspot Configuration error codes
5950///
5951/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspotconfigurationerror?language=objc)
5952// NS_ENUM
5953#[repr(transparent)]
5954#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
5955pub struct NEHotspotConfigurationError(pub NSInteger);
5956impl NEHotspotConfigurationError {
5957 #[doc(alias = "NEHotspotConfigurationErrorInvalid")]
5958 pub const Invalid: Self = Self(0);
5959 #[doc(alias = "NEHotspotConfigurationErrorInvalidSSID")]
5960 pub const InvalidSSID: Self = Self(1);
5961 #[doc(alias = "NEHotspotConfigurationErrorInvalidWPAPassphrase")]
5962 pub const InvalidWPAPassphrase: Self = Self(2);
5963 #[doc(alias = "NEHotspotConfigurationErrorInvalidWEPPassphrase")]
5964 pub const InvalidWEPPassphrase: Self = Self(3);
5965 #[doc(alias = "NEHotspotConfigurationErrorInvalidEAPSettings")]
5966 pub const InvalidEAPSettings: Self = Self(4);
5967 #[doc(alias = "NEHotspotConfigurationErrorInvalidHS20Settings")]
5968 pub const InvalidHS20Settings: Self = Self(5);
5969 #[doc(alias = "NEHotspotConfigurationErrorInvalidHS20DomainName")]
5970 pub const InvalidHS20DomainName: Self = Self(6);
5971 #[doc(alias = "NEHotspotConfigurationErrorUserDenied")]
5972 pub const UserDenied: Self = Self(7);
5973 #[doc(alias = "NEHotspotConfigurationErrorInternal")]
5974 pub const Internal: Self = Self(8);
5975 #[doc(alias = "NEHotspotConfigurationErrorPending")]
5976 pub const Pending: Self = Self(9);
5977 #[doc(alias = "NEHotspotConfigurationErrorSystemConfiguration")]
5978 pub const SystemConfiguration: Self = Self(10);
5979 #[doc(alias = "NEHotspotConfigurationErrorUnknown")]
5980 pub const Unknown: Self = Self(11);
5981 #[doc(alias = "NEHotspotConfigurationErrorJoinOnceNotSupported")]
5982 pub const JoinOnceNotSupported: Self = Self(12);
5983 #[doc(alias = "NEHotspotConfigurationErrorAlreadyAssociated")]
5984 pub const AlreadyAssociated: Self = Self(13);
5985 #[doc(alias = "NEHotspotConfigurationErrorApplicationIsNotInForeground")]
5986 pub const ApplicationIsNotInForeground: Self = Self(14);
5987 #[doc(alias = "NEHotspotConfigurationErrorInvalidSSIDPrefix")]
5988 pub const InvalidSSIDPrefix: Self = Self(15);
5989 #[doc(alias = "NEHotspotConfigurationErrorUserUnauthorized")]
5990 pub const UserUnauthorized: Self = Self(16);
5991 #[doc(alias = "NEHotspotConfigurationErrorSystemDenied")]
5992 pub const SystemDenied: Self = Self(17);
5993}
5994
5995unsafe impl Encode for NEHotspotConfigurationError {
5996 const ENCODING: Encoding = NSInteger::ENCODING;
5997}
5998
5999unsafe impl RefEncode for NEHotspotConfigurationError {
6000 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
6001}
6002
6003extern_class!(
6004 /// The NEHotspotConfigurationManager class allows an application to
6005 /// Add/Update/Remove Wi-Fi Network Configuraton.
6006 ///
6007 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nehotspotconfigurationmanager?language=objc)
6008 #[unsafe(super(NSObject))]
6009 #[derive(Debug, PartialEq, Eq, Hash)]
6010 pub struct NEHotspotConfigurationManager;
6011);
6012
6013extern_conformance!(
6014 unsafe impl NSObjectProtocol for NEHotspotConfigurationManager {}
6015);
6016
6017impl NEHotspotConfigurationManager {
6018 extern_methods!(
6019 #[unsafe(method(sharedManager))]
6020 #[unsafe(method_family = none)]
6021 pub unsafe fn sharedManager() -> Retained<NEHotspotConfigurationManager>;
6022
6023 #[cfg(feature = "block2")]
6024 /// This function adds or updates a Wi-Fi network configuration.
6025 ///
6026 /// Parameter `configuration`: NEHotspotConfiguration object containing the Wi-Fi network configuration.
6027 ///
6028 /// Parameter `completionHandler`: A block that will be called when add/update operation is completed.
6029 /// Pass nil if application does not intend to receive the result.
6030 /// The NSError passed to this block will be nil if the configuration is successfully stored, non-nil otherwise.
6031 /// If the configuration is found invalid or API encounters some other error then completionHandler is called
6032 /// with instance of NSError containing appropriate error code. This API attempts to join the Wi-Fi network
6033 /// if the configuration is successfully added or updated and the network is found nearby.
6034 #[unsafe(method(applyConfiguration:completionHandler:))]
6035 #[unsafe(method_family = none)]
6036 pub unsafe fn applyConfiguration_completionHandler(
6037 &self,
6038 configuration: &NEHotspotConfiguration,
6039 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
6040 );
6041
6042 /// This function removes Wi-Fi configuration.
6043 /// If the joinOnce property was set to YES, invoking this method will disassociate from the Wi-Fi network
6044 /// after the configuration is removed.
6045 ///
6046 /// Parameter `SSID`: Wi-Fi SSID for which the configuration is to be deleted.
6047 #[unsafe(method(removeConfigurationForSSID:))]
6048 #[unsafe(method_family = none)]
6049 pub unsafe fn removeConfigurationForSSID(&self, ssid: &NSString);
6050
6051 /// This function removes Wi-Fi configuration.
6052 ///
6053 /// Parameter `domainName`: HS2.0 domainName for which the configuration is to be deleted.
6054 #[unsafe(method(removeConfigurationForHS20DomainName:))]
6055 #[unsafe(method_family = none)]
6056 pub unsafe fn removeConfigurationForHS20DomainName(&self, domain_name: &NSString);
6057
6058 #[cfg(feature = "block2")]
6059 /// This function returns array of SSIDs and HS2.0 Domain Names that the calling application has configured.
6060 /// It returns nil if there are no networks configurred by the calling application.
6061 #[unsafe(method(getConfiguredSSIDsWithCompletionHandler:))]
6062 #[unsafe(method_family = none)]
6063 pub unsafe fn getConfiguredSSIDsWithCompletionHandler(
6064 &self,
6065 completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<NSString>>)>,
6066 );
6067
6068 #[cfg(all(feature = "block2", feature = "objc2-accessory-setup-kit"))]
6069 #[cfg(target_os = "ios")]
6070 /// This function performs a one-time join of a Wi-Fi network configuration defined by an ASAccessory.
6071 /// This function implicitly sets joinOnce to YES. The network must support WPA/WPA2/WPA3 Personal security type.
6072 ///
6073 /// Parameter `accessory`: Object of type ASAccessory class.
6074 /// This parameter is required to specify the Accessory Wi-Fi network.
6075 ///
6076 /// Parameter `passphrase`: The required passphrase credential.
6077 /// The passphrase with a length between 8 and 63 characters to join WPA/WPA2/WPA3 Personal networks.
6078 ///
6079 /// Parameter `completionHandler`: A block that will be called when join operation is completed.
6080 /// Pass nil if application does not intend to receive the result.
6081 /// The NSError passed to this block will be nil if the hotspot is successfully joined, non-nil otherwise.
6082 /// If the configuration is found to be invalid or some other error is encountered then the completionHandler
6083 /// block is executed with with an instance of NSError containing an appropriate error code.
6084 #[unsafe(method(joinAccessoryHotspot:passphrase:completionHandler:))]
6085 #[unsafe(method_family = none)]
6086 pub unsafe fn joinAccessoryHotspot_passphrase_completionHandler(
6087 &self,
6088 accessory: &ASAccessory,
6089 passphrase: &NSString,
6090 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
6091 );
6092
6093 #[cfg(all(feature = "block2", feature = "objc2-accessory-setup-kit"))]
6094 #[cfg(target_os = "ios")]
6095 /// This function performs a one-time join of an open Wi-Fi network configuration defined by an ASAccessory.
6096 /// This function implicitly sets joinOnce to YES.
6097 ///
6098 /// Parameter `accessory`: Object of type ASAccessory class.
6099 /// This parameter is required to specify the Accessory Wi-Fi network.
6100 ///
6101 /// Parameter `completionHandler`: A block that will be called when join operation is completed.
6102 /// Pass nil if application does not intend to receive the result.
6103 /// The NSError passed to this block will be nil if the hotspot is successfully joined, non-nil otherwise.
6104 /// If the configuration is found to be invalid or some other error is encountered then the completionHandler
6105 /// block is executed with with an instance of NSError containing an appropriate error code.
6106 #[unsafe(method(joinAccessoryHotspotWithoutSecurity:completionHandler:))]
6107 #[unsafe(method_family = none)]
6108 pub unsafe fn joinAccessoryHotspotWithoutSecurity_completionHandler(
6109 &self,
6110 accessory: &ASAccessory,
6111 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
6112 );
6113 );
6114}
6115
6116/// Methods declared on superclass `NSObject`.
6117impl NEHotspotConfigurationManager {
6118 extern_methods!(
6119 #[unsafe(method(init))]
6120 #[unsafe(method_family = init)]
6121 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
6122
6123 #[unsafe(method(new))]
6124 #[unsafe(method_family = new)]
6125 pub unsafe fn new() -> Retained<Self>;
6126 );
6127}
6128
6129extern_class!(
6130 /// The NEIPv4Settings class declares the programmatic interface for an object that contains IPv4 settings.
6131 ///
6132 /// Instances of this class are thread safe.
6133 ///
6134 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neipv4settings?language=objc)
6135 #[unsafe(super(NSObject))]
6136 #[derive(Debug, PartialEq, Eq, Hash)]
6137 pub struct NEIPv4Settings;
6138);
6139
6140extern_conformance!(
6141 unsafe impl NSCoding for NEIPv4Settings {}
6142);
6143
6144extern_conformance!(
6145 unsafe impl NSCopying for NEIPv4Settings {}
6146);
6147
6148unsafe impl CopyingHelper for NEIPv4Settings {
6149 type Result = Self;
6150}
6151
6152extern_conformance!(
6153 unsafe impl NSObjectProtocol for NEIPv4Settings {}
6154);
6155
6156extern_conformance!(
6157 unsafe impl NSSecureCoding for NEIPv4Settings {}
6158);
6159
6160impl NEIPv4Settings {
6161 extern_methods!(
6162 /// Initialize a newly-allocated NEIPv4Settings object.
6163 ///
6164 /// Parameter `addresses`: An array of IPv4 addresses represented as dotted decimal strings.
6165 ///
6166 /// Parameter `subnetMasks`: An array of IPv4 subnet masks represented as dotted decimal strings.
6167 ///
6168 /// Returns: The initialized object.
6169 #[unsafe(method(initWithAddresses:subnetMasks:))]
6170 #[unsafe(method_family = init)]
6171 pub unsafe fn initWithAddresses_subnetMasks(
6172 this: Allocated<Self>,
6173 addresses: &NSArray<NSString>,
6174 subnet_masks: &NSArray<NSString>,
6175 ) -> Retained<Self>;
6176
6177 /// Create a NEIPv4Settings object that will obtain IP addresses and netmasks using DHCP.
6178 ///
6179 /// Returns: The initialized object.
6180 #[unsafe(method(settingsWithAutomaticAddressing))]
6181 #[unsafe(method_family = none)]
6182 pub unsafe fn settingsWithAutomaticAddressing() -> Retained<Self>;
6183
6184 /// An array of IPv4 addresses represented as dotted decimal strings. These addresses will be set on the virtual interface used by the VPN tunnel.
6185 #[unsafe(method(addresses))]
6186 #[unsafe(method_family = none)]
6187 pub unsafe fn addresses(&self) -> Retained<NSArray<NSString>>;
6188
6189 /// An array of IPv4 subnet masks represented as dotted decimal strings. These subnet masks will be set along with their corresponding addresses from the addresses array on the virtual interface used by the VPN tunnel.
6190 #[unsafe(method(subnetMasks))]
6191 #[unsafe(method_family = none)]
6192 pub unsafe fn subnetMasks(&self) -> Retained<NSArray<NSString>>;
6193
6194 /// The address of the next-hop gateway router represented as a dotted decimal string. This property is ignored for TUN interfaces.
6195 #[unsafe(method(router))]
6196 #[unsafe(method_family = none)]
6197 pub unsafe fn router(&self) -> Option<Retained<NSString>>;
6198
6199 /// Setter for [`router`][Self::router].
6200 ///
6201 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
6202 #[unsafe(method(setRouter:))]
6203 #[unsafe(method_family = none)]
6204 pub unsafe fn setRouter(&self, router: Option<&NSString>);
6205
6206 /// An array of NEIPv4Route objects. Traffic matching these routes will be routed through the virtual interface used by the VPN tunnel.
6207 #[unsafe(method(includedRoutes))]
6208 #[unsafe(method_family = none)]
6209 pub unsafe fn includedRoutes(&self) -> Option<Retained<NSArray<NEIPv4Route>>>;
6210
6211 /// Setter for [`includedRoutes`][Self::includedRoutes].
6212 ///
6213 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
6214 #[unsafe(method(setIncludedRoutes:))]
6215 #[unsafe(method_family = none)]
6216 pub unsafe fn setIncludedRoutes(&self, included_routes: Option<&NSArray<NEIPv4Route>>);
6217
6218 /// An array of NEIPv4Route objects. Traffic matching these routes will be routed through the current primary physical interface of the device.
6219 #[unsafe(method(excludedRoutes))]
6220 #[unsafe(method_family = none)]
6221 pub unsafe fn excludedRoutes(&self) -> Option<Retained<NSArray<NEIPv4Route>>>;
6222
6223 /// Setter for [`excludedRoutes`][Self::excludedRoutes].
6224 ///
6225 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
6226 #[unsafe(method(setExcludedRoutes:))]
6227 #[unsafe(method_family = none)]
6228 pub unsafe fn setExcludedRoutes(&self, excluded_routes: Option<&NSArray<NEIPv4Route>>);
6229 );
6230}
6231
6232/// Methods declared on superclass `NSObject`.
6233impl NEIPv4Settings {
6234 extern_methods!(
6235 #[unsafe(method(init))]
6236 #[unsafe(method_family = init)]
6237 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
6238
6239 #[unsafe(method(new))]
6240 #[unsafe(method_family = new)]
6241 pub unsafe fn new() -> Retained<Self>;
6242 );
6243}
6244
6245extern_class!(
6246 /// The NEIPv4Route class declares the programmatic interface for an object that contains settings for an IPv4 route.
6247 ///
6248 /// Instances of this class are thread safe.
6249 ///
6250 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neipv4route?language=objc)
6251 #[unsafe(super(NSObject))]
6252 #[derive(Debug, PartialEq, Eq, Hash)]
6253 pub struct NEIPv4Route;
6254);
6255
6256extern_conformance!(
6257 unsafe impl NSCoding for NEIPv4Route {}
6258);
6259
6260extern_conformance!(
6261 unsafe impl NSCopying for NEIPv4Route {}
6262);
6263
6264unsafe impl CopyingHelper for NEIPv4Route {
6265 type Result = Self;
6266}
6267
6268extern_conformance!(
6269 unsafe impl NSObjectProtocol for NEIPv4Route {}
6270);
6271
6272extern_conformance!(
6273 unsafe impl NSSecureCoding for NEIPv4Route {}
6274);
6275
6276impl NEIPv4Route {
6277 extern_methods!(
6278 /// Initialize a newly-allocated NEIPv4Route.
6279 ///
6280 /// Parameter `address`: The IPv4 address of the destination network.
6281 ///
6282 /// Parameter `subnetMask`: The subnet mask of the destination network.
6283 ///
6284 /// Returns: The initialized NEIPv4Route.
6285 #[unsafe(method(initWithDestinationAddress:subnetMask:))]
6286 #[unsafe(method_family = init)]
6287 pub unsafe fn initWithDestinationAddress_subnetMask(
6288 this: Allocated<Self>,
6289 address: &NSString,
6290 subnet_mask: &NSString,
6291 ) -> Retained<Self>;
6292
6293 /// An IPv4 address represented as a dotted decimal string.
6294 #[unsafe(method(destinationAddress))]
6295 #[unsafe(method_family = none)]
6296 pub unsafe fn destinationAddress(&self) -> Retained<NSString>;
6297
6298 /// An IPv4 subnet mask represented as a dotted decimal string. This mask in combination with the destinationAddress property is used to determine the destination network of the route.
6299 #[unsafe(method(destinationSubnetMask))]
6300 #[unsafe(method_family = none)]
6301 pub unsafe fn destinationSubnetMask(&self) -> Retained<NSString>;
6302
6303 /// The IPv4 address of the route's gateway. If this property is nil then the route's gateway will be set to the tunnel's virtual interface.
6304 #[unsafe(method(gatewayAddress))]
6305 #[unsafe(method_family = none)]
6306 pub unsafe fn gatewayAddress(&self) -> Option<Retained<NSString>>;
6307
6308 /// Setter for [`gatewayAddress`][Self::gatewayAddress].
6309 ///
6310 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
6311 #[unsafe(method(setGatewayAddress:))]
6312 #[unsafe(method_family = none)]
6313 pub unsafe fn setGatewayAddress(&self, gateway_address: Option<&NSString>);
6314
6315 /// Returns: A route object that represents the IPv4 default route.
6316 #[unsafe(method(defaultRoute))]
6317 #[unsafe(method_family = none)]
6318 pub unsafe fn defaultRoute() -> Retained<NEIPv4Route>;
6319 );
6320}
6321
6322/// Methods declared on superclass `NSObject`.
6323impl NEIPv4Route {
6324 extern_methods!(
6325 #[unsafe(method(init))]
6326 #[unsafe(method_family = init)]
6327 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
6328
6329 #[unsafe(method(new))]
6330 #[unsafe(method_family = new)]
6331 pub unsafe fn new() -> Retained<Self>;
6332 );
6333}
6334
6335extern_class!(
6336 /// The NEIPv6Settings class declares the programmatic interface for an object that contains IPv6 settings.
6337 ///
6338 /// Instances of this class are thread safe.
6339 ///
6340 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neipv6settings?language=objc)
6341 #[unsafe(super(NSObject))]
6342 #[derive(Debug, PartialEq, Eq, Hash)]
6343 pub struct NEIPv6Settings;
6344);
6345
6346extern_conformance!(
6347 unsafe impl NSCoding for NEIPv6Settings {}
6348);
6349
6350extern_conformance!(
6351 unsafe impl NSCopying for NEIPv6Settings {}
6352);
6353
6354unsafe impl CopyingHelper for NEIPv6Settings {
6355 type Result = Self;
6356}
6357
6358extern_conformance!(
6359 unsafe impl NSObjectProtocol for NEIPv6Settings {}
6360);
6361
6362extern_conformance!(
6363 unsafe impl NSSecureCoding for NEIPv6Settings {}
6364);
6365
6366impl NEIPv6Settings {
6367 extern_methods!(
6368 /// Initialize a newly-allocated NEIPv6Settings object.
6369 ///
6370 /// Parameter `addresses`: An array of IPv6 addresses represented as dotted decimal strings.
6371 ///
6372 /// Parameter `networkPrefixLengths`: An array of NSNumber objects each containing the length in bits of the network prefix of the corresponding address in the addresses parameter.
6373 ///
6374 /// Returns: The initialized object.
6375 #[unsafe(method(initWithAddresses:networkPrefixLengths:))]
6376 #[unsafe(method_family = init)]
6377 pub unsafe fn initWithAddresses_networkPrefixLengths(
6378 this: Allocated<Self>,
6379 addresses: &NSArray<NSString>,
6380 network_prefix_lengths: &NSArray<NSNumber>,
6381 ) -> Retained<Self>;
6382
6383 /// Create a NEIPv6Settings object that will obtain IP addresses and netmasks automatically.
6384 #[unsafe(method(settingsWithAutomaticAddressing))]
6385 #[unsafe(method_family = none)]
6386 pub unsafe fn settingsWithAutomaticAddressing() -> Retained<Self>;
6387
6388 /// Create a NEIPv6Settings object that will only use link-local IPv6 addresses.
6389 #[unsafe(method(settingsWithLinkLocalAddressing))]
6390 #[unsafe(method_family = none)]
6391 pub unsafe fn settingsWithLinkLocalAddressing() -> Retained<Self>;
6392
6393 /// An array of IPv6 addresses represented strings. These addresses will be set on the virtual interface used by the VPN tunnel.
6394 #[unsafe(method(addresses))]
6395 #[unsafe(method_family = none)]
6396 pub unsafe fn addresses(&self) -> Retained<NSArray<NSString>>;
6397
6398 /// An array of NSNumber objects each representing the length in bits of the network prefix of the corresponding address in the addresses property.
6399 #[unsafe(method(networkPrefixLengths))]
6400 #[unsafe(method_family = none)]
6401 pub unsafe fn networkPrefixLengths(&self) -> Retained<NSArray<NSNumber>>;
6402
6403 /// An array of NEIPv6Route objects. Traffic matching these routes will be routed through the virtual interface used by the VPN tunnel.
6404 #[unsafe(method(includedRoutes))]
6405 #[unsafe(method_family = none)]
6406 pub unsafe fn includedRoutes(&self) -> Option<Retained<NSArray<NEIPv6Route>>>;
6407
6408 /// Setter for [`includedRoutes`][Self::includedRoutes].
6409 ///
6410 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
6411 #[unsafe(method(setIncludedRoutes:))]
6412 #[unsafe(method_family = none)]
6413 pub unsafe fn setIncludedRoutes(&self, included_routes: Option<&NSArray<NEIPv6Route>>);
6414
6415 /// An array of NEIPv6Route objects. Traffic matching these routes will be routed through the current primary physical interface of the device.
6416 #[unsafe(method(excludedRoutes))]
6417 #[unsafe(method_family = none)]
6418 pub unsafe fn excludedRoutes(&self) -> Option<Retained<NSArray<NEIPv6Route>>>;
6419
6420 /// Setter for [`excludedRoutes`][Self::excludedRoutes].
6421 ///
6422 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
6423 #[unsafe(method(setExcludedRoutes:))]
6424 #[unsafe(method_family = none)]
6425 pub unsafe fn setExcludedRoutes(&self, excluded_routes: Option<&NSArray<NEIPv6Route>>);
6426 );
6427}
6428
6429/// Methods declared on superclass `NSObject`.
6430impl NEIPv6Settings {
6431 extern_methods!(
6432 #[unsafe(method(init))]
6433 #[unsafe(method_family = init)]
6434 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
6435
6436 #[unsafe(method(new))]
6437 #[unsafe(method_family = new)]
6438 pub unsafe fn new() -> Retained<Self>;
6439 );
6440}
6441
6442extern_class!(
6443 /// The NEIPv6Route class declares the programmatic interface for an object that contains settings for an IPv6 route.
6444 ///
6445 /// Instances of this class are thread safe.
6446 ///
6447 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neipv6route?language=objc)
6448 #[unsafe(super(NSObject))]
6449 #[derive(Debug, PartialEq, Eq, Hash)]
6450 pub struct NEIPv6Route;
6451);
6452
6453extern_conformance!(
6454 unsafe impl NSCoding for NEIPv6Route {}
6455);
6456
6457extern_conformance!(
6458 unsafe impl NSCopying for NEIPv6Route {}
6459);
6460
6461unsafe impl CopyingHelper for NEIPv6Route {
6462 type Result = Self;
6463}
6464
6465extern_conformance!(
6466 unsafe impl NSObjectProtocol for NEIPv6Route {}
6467);
6468
6469extern_conformance!(
6470 unsafe impl NSSecureCoding for NEIPv6Route {}
6471);
6472
6473impl NEIPv6Route {
6474 extern_methods!(
6475 /// Initialize a newly-allocated NEIPv6Route.
6476 ///
6477 /// Parameter `address`: The IPv6 address of the destination network.
6478 ///
6479 /// Parameter `networkPrefixLength`: A number containing the length in bits of the network prefix of the destination network.
6480 ///
6481 /// Returns: The initialized NEIPv6Route.
6482 #[unsafe(method(initWithDestinationAddress:networkPrefixLength:))]
6483 #[unsafe(method_family = init)]
6484 pub unsafe fn initWithDestinationAddress_networkPrefixLength(
6485 this: Allocated<Self>,
6486 address: &NSString,
6487 network_prefix_length: &NSNumber,
6488 ) -> Retained<Self>;
6489
6490 /// An IPv6 address represented as a string.
6491 #[unsafe(method(destinationAddress))]
6492 #[unsafe(method_family = none)]
6493 pub unsafe fn destinationAddress(&self) -> Retained<NSString>;
6494
6495 /// A number containing the length in bits of the network prefix of the destination network. This prefix in combination with the destinationAddress property is used to determine the destination network of the route.
6496 #[unsafe(method(destinationNetworkPrefixLength))]
6497 #[unsafe(method_family = none)]
6498 pub unsafe fn destinationNetworkPrefixLength(&self) -> Retained<NSNumber>;
6499
6500 /// The IPv6 address of the route's gateway. If this property is nil then the route's gateway will be set to the tunnel's virtual interface.
6501 #[unsafe(method(gatewayAddress))]
6502 #[unsafe(method_family = none)]
6503 pub unsafe fn gatewayAddress(&self) -> Option<Retained<NSString>>;
6504
6505 /// Setter for [`gatewayAddress`][Self::gatewayAddress].
6506 ///
6507 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
6508 #[unsafe(method(setGatewayAddress:))]
6509 #[unsafe(method_family = none)]
6510 pub unsafe fn setGatewayAddress(&self, gateway_address: Option<&NSString>);
6511
6512 /// Returns: A route object that represents the IPv6 default route.
6513 #[unsafe(method(defaultRoute))]
6514 #[unsafe(method_family = none)]
6515 pub unsafe fn defaultRoute() -> Retained<NEIPv6Route>;
6516 );
6517}
6518
6519/// Methods declared on superclass `NSObject`.
6520impl NEIPv6Route {
6521 extern_methods!(
6522 #[unsafe(method(init))]
6523 #[unsafe(method_family = init)]
6524 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
6525
6526 #[unsafe(method(new))]
6527 #[unsafe(method_family = new)]
6528 pub unsafe fn new() -> Retained<Self>;
6529 );
6530}
6531
6532extern_class!(
6533 /// The NETunnelNetworkSettings class declares the programmatic interface for an object that contains network settings.
6534 ///
6535 /// NETunnelNetworkSettings is used by NETunnelProviders to communicate the desired network settings for the tunnel to the framework. The framework takes care of applying the contained settings to the system.
6536 ///
6537 /// Instances of this class are thread safe.
6538 ///
6539 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/netunnelnetworksettings?language=objc)
6540 #[unsafe(super(NSObject))]
6541 #[derive(Debug, PartialEq, Eq, Hash)]
6542 pub struct NETunnelNetworkSettings;
6543);
6544
6545extern_conformance!(
6546 unsafe impl NSCoding for NETunnelNetworkSettings {}
6547);
6548
6549extern_conformance!(
6550 unsafe impl NSCopying for NETunnelNetworkSettings {}
6551);
6552
6553unsafe impl CopyingHelper for NETunnelNetworkSettings {
6554 type Result = Self;
6555}
6556
6557extern_conformance!(
6558 unsafe impl NSObjectProtocol for NETunnelNetworkSettings {}
6559);
6560
6561extern_conformance!(
6562 unsafe impl NSSecureCoding for NETunnelNetworkSettings {}
6563);
6564
6565impl NETunnelNetworkSettings {
6566 extern_methods!(
6567 /// This function initializes a newly-allocated NETunnelNetworkSettings object with a given tunnel remote address.
6568 ///
6569 /// Parameter `address`: The address of the remote endpoint that is providing the tunnel service.
6570 #[unsafe(method(initWithTunnelRemoteAddress:))]
6571 #[unsafe(method_family = init)]
6572 pub unsafe fn initWithTunnelRemoteAddress(
6573 this: Allocated<Self>,
6574 address: &NSString,
6575 ) -> Retained<Self>;
6576
6577 /// A string containing the IP address of the remote endpoint that is providing the tunnel service.
6578 #[unsafe(method(tunnelRemoteAddress))]
6579 #[unsafe(method_family = none)]
6580 pub unsafe fn tunnelRemoteAddress(&self) -> Retained<NSString>;
6581
6582 /// An NEDNSSettings object that contains the desired tunnel DNS settings.
6583 #[unsafe(method(DNSSettings))]
6584 #[unsafe(method_family = none)]
6585 pub unsafe fn DNSSettings(&self) -> Option<Retained<NEDNSSettings>>;
6586
6587 /// Setter for [`DNSSettings`][Self::DNSSettings].
6588 ///
6589 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
6590 #[unsafe(method(setDNSSettings:))]
6591 #[unsafe(method_family = none)]
6592 pub unsafe fn setDNSSettings(&self, dns_settings: Option<&NEDNSSettings>);
6593
6594 /// An NEProxySettings object that contains the desired tunnel proxy settings.
6595 #[unsafe(method(proxySettings))]
6596 #[unsafe(method_family = none)]
6597 pub unsafe fn proxySettings(&self) -> Option<Retained<NEProxySettings>>;
6598
6599 /// Setter for [`proxySettings`][Self::proxySettings].
6600 ///
6601 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
6602 #[unsafe(method(setProxySettings:))]
6603 #[unsafe(method_family = none)]
6604 pub unsafe fn setProxySettings(&self, proxy_settings: Option<&NEProxySettings>);
6605 );
6606}
6607
6608/// Methods declared on superclass `NSObject`.
6609impl NETunnelNetworkSettings {
6610 extern_methods!(
6611 #[unsafe(method(init))]
6612 #[unsafe(method_family = init)]
6613 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
6614
6615 #[unsafe(method(new))]
6616 #[unsafe(method_family = new)]
6617 pub unsafe fn new() -> Retained<Self>;
6618 );
6619}
6620
6621extern_class!(
6622 /// The NEPacketTunnelNetworkSettings class declares the programmatic interface for an object that contains IP network settings.
6623 ///
6624 /// NEPacketTunnelNetworkSettings is used by NEPacketTunnelProviders to communicate the desired IP network settings for the packet tunnel to the framework. The framework takes care of applying the contained settings to the system.
6625 ///
6626 /// Instances of this class are thread safe.
6627 ///
6628 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nepackettunnelnetworksettings?language=objc)
6629 #[unsafe(super(NETunnelNetworkSettings, NSObject))]
6630 #[derive(Debug, PartialEq, Eq, Hash)]
6631 pub struct NEPacketTunnelNetworkSettings;
6632);
6633
6634extern_conformance!(
6635 unsafe impl NSCoding for NEPacketTunnelNetworkSettings {}
6636);
6637
6638extern_conformance!(
6639 unsafe impl NSCopying for NEPacketTunnelNetworkSettings {}
6640);
6641
6642unsafe impl CopyingHelper for NEPacketTunnelNetworkSettings {
6643 type Result = Self;
6644}
6645
6646extern_conformance!(
6647 unsafe impl NSObjectProtocol for NEPacketTunnelNetworkSettings {}
6648);
6649
6650extern_conformance!(
6651 unsafe impl NSSecureCoding for NEPacketTunnelNetworkSettings {}
6652);
6653
6654impl NEPacketTunnelNetworkSettings {
6655 extern_methods!(
6656 /// An NEIPv4Settings object that contains the desired tunnel IPv4 settings.
6657 #[unsafe(method(IPv4Settings))]
6658 #[unsafe(method_family = none)]
6659 pub unsafe fn IPv4Settings(&self) -> Option<Retained<NEIPv4Settings>>;
6660
6661 /// Setter for [`IPv4Settings`][Self::IPv4Settings].
6662 ///
6663 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
6664 #[unsafe(method(setIPv4Settings:))]
6665 #[unsafe(method_family = none)]
6666 pub unsafe fn setIPv4Settings(&self, i_pv4_settings: Option<&NEIPv4Settings>);
6667
6668 /// An NEIPv6Settings object that contains the desired tunnel IPv6 settings.
6669 #[unsafe(method(IPv6Settings))]
6670 #[unsafe(method_family = none)]
6671 pub unsafe fn IPv6Settings(&self) -> Option<Retained<NEIPv6Settings>>;
6672
6673 /// Setter for [`IPv6Settings`][Self::IPv6Settings].
6674 ///
6675 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
6676 #[unsafe(method(setIPv6Settings:))]
6677 #[unsafe(method_family = none)]
6678 pub unsafe fn setIPv6Settings(&self, i_pv6_settings: Option<&NEIPv6Settings>);
6679
6680 /// An NSNumber object containing the number of bytes of overhead appended to each outbound packet through the tunnel. The MTU for the TUN interface is computed by subtracting this value from the MTU of the primary physical interface.
6681 #[unsafe(method(tunnelOverheadBytes))]
6682 #[unsafe(method_family = none)]
6683 pub unsafe fn tunnelOverheadBytes(&self) -> Option<Retained<NSNumber>>;
6684
6685 /// Setter for [`tunnelOverheadBytes`][Self::tunnelOverheadBytes].
6686 ///
6687 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
6688 #[unsafe(method(setTunnelOverheadBytes:))]
6689 #[unsafe(method_family = none)]
6690 pub unsafe fn setTunnelOverheadBytes(&self, tunnel_overhead_bytes: Option<&NSNumber>);
6691
6692 /// An NSNumber object containing the Maximum Transmission Unit (MTU) size in bytes to assign to the TUN interface. If this property is set, the tunnelOverheadBytes property is ignored.
6693 #[unsafe(method(MTU))]
6694 #[unsafe(method_family = none)]
6695 pub unsafe fn MTU(&self) -> Option<Retained<NSNumber>>;
6696
6697 /// Setter for [`MTU`][Self::MTU].
6698 ///
6699 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
6700 #[unsafe(method(setMTU:))]
6701 #[unsafe(method_family = none)]
6702 pub unsafe fn setMTU(&self, mtu: Option<&NSNumber>);
6703 );
6704}
6705
6706/// Methods declared on superclass `NETunnelNetworkSettings`.
6707impl NEPacketTunnelNetworkSettings {
6708 extern_methods!(
6709 /// This function initializes a newly-allocated NETunnelNetworkSettings object with a given tunnel remote address.
6710 ///
6711 /// Parameter `address`: The address of the remote endpoint that is providing the tunnel service.
6712 #[unsafe(method(initWithTunnelRemoteAddress:))]
6713 #[unsafe(method_family = init)]
6714 pub unsafe fn initWithTunnelRemoteAddress(
6715 this: Allocated<Self>,
6716 address: &NSString,
6717 ) -> Retained<Self>;
6718 );
6719}
6720
6721/// Methods declared on superclass `NSObject`.
6722impl NEPacketTunnelNetworkSettings {
6723 extern_methods!(
6724 #[unsafe(method(init))]
6725 #[unsafe(method_family = init)]
6726 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
6727
6728 #[unsafe(method(new))]
6729 #[unsafe(method_family = new)]
6730 pub unsafe fn new() -> Retained<Self>;
6731 );
6732}
6733
6734extern_class!(
6735 /// The NEEthernetTunnelNetworkSettings class declares the programmatic interface for an object that contains network settings.
6736 ///
6737 /// NEEthernetTunnelNetworkSettings is used by NEEthernetTunnelProviders to communicate the desired network settings for the packet tunnel to the framework. The framework takes care of applying the contained settings to the system.
6738 ///
6739 /// Instances of this class are thread safe.
6740 ///
6741 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neethernettunnelnetworksettings?language=objc)
6742 #[unsafe(super(NEPacketTunnelNetworkSettings, NETunnelNetworkSettings, NSObject))]
6743 #[derive(Debug, PartialEq, Eq, Hash)]
6744 pub struct NEEthernetTunnelNetworkSettings;
6745);
6746
6747extern_conformance!(
6748 unsafe impl NSCoding for NEEthernetTunnelNetworkSettings {}
6749);
6750
6751extern_conformance!(
6752 unsafe impl NSCopying for NEEthernetTunnelNetworkSettings {}
6753);
6754
6755unsafe impl CopyingHelper for NEEthernetTunnelNetworkSettings {
6756 type Result = Self;
6757}
6758
6759extern_conformance!(
6760 unsafe impl NSObjectProtocol for NEEthernetTunnelNetworkSettings {}
6761);
6762
6763extern_conformance!(
6764 unsafe impl NSSecureCoding for NEEthernetTunnelNetworkSettings {}
6765);
6766
6767impl NEEthernetTunnelNetworkSettings {
6768 extern_methods!(
6769 /// This function initializes a newly-allocated NEEthernetTunnelNetworkSettings object with a given tunnel remote address and MAC address.
6770 ///
6771 /// Parameter `address`: The address of the remote endpoint that is providing the tunnel service.
6772 ///
6773 /// Parameter `ethernetAddress`: The ethernet address to be assigned to the tunnel interface. This string should be in the format "xx:xx:xx:xx:xx:xx", where each xx is a hexidecimal number between 0 and ff.
6774 ///
6775 /// Parameter `mtu`: The MTU (Maxium Transmission Unit) in bytes to be assigned to the tunnel interface.
6776 #[unsafe(method(initWithTunnelRemoteAddress:ethernetAddress:mtu:))]
6777 #[unsafe(method_family = init)]
6778 pub unsafe fn initWithTunnelRemoteAddress_ethernetAddress_mtu(
6779 this: Allocated<Self>,
6780 address: &NSString,
6781 ethernet_address: &NSString,
6782 mtu: NSInteger,
6783 ) -> Retained<Self>;
6784
6785 /// An NSString object containing the ethernet address of the tunnel interface.
6786 #[unsafe(method(ethernetAddress))]
6787 #[unsafe(method_family = none)]
6788 pub unsafe fn ethernetAddress(&self) -> Retained<NSString>;
6789 );
6790}
6791
6792/// Methods declared on superclass `NETunnelNetworkSettings`.
6793impl NEEthernetTunnelNetworkSettings {
6794 extern_methods!(
6795 /// This function initializes a newly-allocated NETunnelNetworkSettings object with a given tunnel remote address.
6796 ///
6797 /// Parameter `address`: The address of the remote endpoint that is providing the tunnel service.
6798 #[unsafe(method(initWithTunnelRemoteAddress:))]
6799 #[unsafe(method_family = init)]
6800 pub unsafe fn initWithTunnelRemoteAddress(
6801 this: Allocated<Self>,
6802 address: &NSString,
6803 ) -> Retained<Self>;
6804 );
6805}
6806
6807/// Methods declared on superclass `NSObject`.
6808impl NEEthernetTunnelNetworkSettings {
6809 extern_methods!(
6810 #[unsafe(method(init))]
6811 #[unsafe(method_family = init)]
6812 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
6813
6814 #[unsafe(method(new))]
6815 #[unsafe(method_family = new)]
6816 pub unsafe fn new() -> Retained<Self>;
6817 );
6818}
6819
6820extern_class!(
6821 /// The NEPacketTunnelProvider class declares the programmatic interface of an object that implements the client side of a custom IP packet tunneling protocol.
6822 ///
6823 /// NEPacketTunnelProvider is part of NetworkExtension.framework.
6824 ///
6825 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nepackettunnelprovider?language=objc)
6826 #[unsafe(super(NETunnelProvider, NEProvider, NSObject))]
6827 #[derive(Debug, PartialEq, Eq, Hash)]
6828 pub struct NEPacketTunnelProvider;
6829);
6830
6831extern_conformance!(
6832 unsafe impl NSObjectProtocol for NEPacketTunnelProvider {}
6833);
6834
6835impl NEPacketTunnelProvider {
6836 extern_methods!(
6837 #[cfg(feature = "block2")]
6838 /// This function is called by the framework when a new tunnel is being created. Subclasses must override this method to perform whatever steps are necessary to establish the tunnel.
6839 ///
6840 /// Parameter `options`: A dictionary containing keys and values passed by the provider's containing app. If the containing app did not start the tunnel then this parameter will be nil.
6841 ///
6842 /// Parameter `completionHandler`: A block that must be called when the process of starting the tunnel is complete. If the tunnel cannot be established then the subclass' implementation of this method must pass a non-nil NSError object to this block. A value of nil passed to the completion handler indicates that the tunnel was successfully established.
6843 ///
6844 /// # Safety
6845 ///
6846 /// `options` generic should be of the correct type.
6847 #[unsafe(method(startTunnelWithOptions:completionHandler:))]
6848 #[unsafe(method_family = none)]
6849 pub unsafe fn startTunnelWithOptions_completionHandler(
6850 &self,
6851 options: Option<&NSDictionary<NSString, NSObject>>,
6852 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
6853 );
6854
6855 #[cfg(feature = "block2")]
6856 /// This function is called by the framework when the tunnel is being destroyed. Subclasses must override this method to perform whatever steps are necessary to tear down the tunnel.
6857 ///
6858 /// Parameter `reason`: An NEProviderStopReason indicating why the tunnel is being stopped.
6859 ///
6860 /// Parameter `completionHandler`: A block that must be called when the tunnel is completely torn down.
6861 #[unsafe(method(stopTunnelWithReason:completionHandler:))]
6862 #[unsafe(method_family = none)]
6863 pub unsafe fn stopTunnelWithReason_completionHandler(
6864 &self,
6865 reason: NEProviderStopReason,
6866 completion_handler: &block2::DynBlock<dyn Fn()>,
6867 );
6868
6869 /// This function is called by tunnel provider implementations to initiate tunnel destruction when a network error is encountered that renders the tunnel no longer viable. Subclasses should not override this method.
6870 ///
6871 /// Parameter `error`: An NSError object containing details about the error that the tunnel provider implementation encountered.
6872 #[unsafe(method(cancelTunnelWithError:))]
6873 #[unsafe(method_family = none)]
6874 pub unsafe fn cancelTunnelWithError(&self, error: Option<&NSError>);
6875
6876 /// An NEPacketFlow object that the tunnel provider implementation should use to receive packets from the network stack and inject packets into the network stack. Every time the tunnel is started the packet flow object is in an initialized state and must be explicitly opened before any packets can be received or injected.
6877 #[unsafe(method(packetFlow))]
6878 #[unsafe(method_family = none)]
6879 pub unsafe fn packetFlow(&self) -> Retained<NEPacketTunnelFlow>;
6880
6881 /// This function can be called by subclass implementations to create a TCP connection to a given network endpoint, through the tunnel established by the provider. This function should not be overridden by subclasses.
6882 ///
6883 /// Parameter `remoteEndpoint`: An NWEndpoint object that specifies the remote network endpoint to connect to.
6884 ///
6885 /// Parameter `enableTLS`: A flag indicating if a TLS session should be negotiated on the connection.
6886 ///
6887 /// Parameter `TLSParameters`: A set of optional TLS parameters. Only valid if enableTLS is YES. If TLSParameters is nil, the default system parameters will be used for TLS negotiation.
6888 ///
6889 /// Parameter `delegate`: An object to use as the connection delegate. This object should conform to the NWTCPConnectionAuthenticationDelegate protocol.
6890 ///
6891 /// Returns: An NWTCPConnection object.
6892 ///
6893 /// # Safety
6894 ///
6895 /// `delegate` should be of the correct type.
6896 #[deprecated = "Use the `virtualInterface` property with `nw_parameters_require_interface`"]
6897 #[unsafe(method(createTCPConnectionThroughTunnelToEndpoint:enableTLS:TLSParameters:delegate:))]
6898 #[unsafe(method_family = none)]
6899 pub unsafe fn createTCPConnectionThroughTunnelToEndpoint_enableTLS_TLSParameters_delegate(
6900 &self,
6901 remote_endpoint: &NWEndpoint,
6902 enable_tls: bool,
6903 tls_parameters: Option<&NWTLSParameters>,
6904 delegate: Option<&AnyObject>,
6905 ) -> Retained<NWTCPConnection>;
6906
6907 /// This function can be called by subclass implementations to create a UDP session between a local network endpoint and a remote network endpoint, through the tunnel established by the provider. This function should not be overridden by subclasses.
6908 ///
6909 /// Parameter `remoteEndpoint`: An NWEndpoint object that specifies the remote endpoint to which UDP datagrams will be sent by the UDP session.
6910 ///
6911 /// Parameter `localEndpoint`: An NWHostEndpoint object that specifies the local IP address endpoint to use as the source endpoint of the UDP session.
6912 ///
6913 /// Returns: An NWUDPSession object.
6914 #[deprecated = "Use the `virtualInterface` property with `nw_parameters_require_interface`"]
6915 #[unsafe(method(createUDPSessionThroughTunnelToEndpoint:fromEndpoint:))]
6916 #[unsafe(method_family = none)]
6917 pub unsafe fn createUDPSessionThroughTunnelToEndpoint_fromEndpoint(
6918 &self,
6919 remote_endpoint: &NWEndpoint,
6920 local_endpoint: Option<&NWHostEndpoint>,
6921 ) -> Retained<NWUDPSession>;
6922 );
6923}
6924
6925/// Methods declared on superclass `NSObject`.
6926impl NEPacketTunnelProvider {
6927 extern_methods!(
6928 #[unsafe(method(init))]
6929 #[unsafe(method_family = init)]
6930 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
6931
6932 #[unsafe(method(new))]
6933 #[unsafe(method_family = new)]
6934 pub unsafe fn new() -> Retained<Self>;
6935 );
6936}
6937
6938extern_class!(
6939 /// The NEEthernetTunnelProvider class declares the programmatic interface of an object that implements the client side of a custom link-layer packet tunneling protocol.
6940 ///
6941 /// NEEthernetTunnelProvider is part of NetworkExtension.framework.
6942 ///
6943 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neethernettunnelprovider?language=objc)
6944 #[unsafe(super(NEPacketTunnelProvider, NETunnelProvider, NEProvider, NSObject))]
6945 #[derive(Debug, PartialEq, Eq, Hash)]
6946 pub struct NEEthernetTunnelProvider;
6947);
6948
6949extern_conformance!(
6950 unsafe impl NSObjectProtocol for NEEthernetTunnelProvider {}
6951);
6952
6953impl NEEthernetTunnelProvider {
6954 extern_methods!();
6955}
6956
6957/// Methods declared on superclass `NSObject`.
6958impl NEEthernetTunnelProvider {
6959 extern_methods!(
6960 #[unsafe(method(init))]
6961 #[unsafe(method_family = init)]
6962 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
6963
6964 #[unsafe(method(new))]
6965 #[unsafe(method_family = new)]
6966 pub unsafe fn new() -> Retained<Self>;
6967 );
6968}
6969
6970/// On Demand rule actions
6971///
6972/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neondemandruleaction?language=objc)
6973// NS_ENUM
6974#[repr(transparent)]
6975#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
6976pub struct NEOnDemandRuleAction(pub NSInteger);
6977impl NEOnDemandRuleAction {
6978 #[doc(alias = "NEOnDemandRuleActionConnect")]
6979 pub const Connect: Self = Self(1);
6980 #[doc(alias = "NEOnDemandRuleActionDisconnect")]
6981 pub const Disconnect: Self = Self(2);
6982 #[doc(alias = "NEOnDemandRuleActionEvaluateConnection")]
6983 pub const EvaluateConnection: Self = Self(3);
6984 #[doc(alias = "NEOnDemandRuleActionIgnore")]
6985 pub const Ignore: Self = Self(4);
6986}
6987
6988unsafe impl Encode for NEOnDemandRuleAction {
6989 const ENCODING: Encoding = NSInteger::ENCODING;
6990}
6991
6992unsafe impl RefEncode for NEOnDemandRuleAction {
6993 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
6994}
6995
6996/// On Demand rule network interface types
6997///
6998/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neondemandruleinterfacetype?language=objc)
6999// NS_ENUM
7000#[repr(transparent)]
7001#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
7002pub struct NEOnDemandRuleInterfaceType(pub NSInteger);
7003impl NEOnDemandRuleInterfaceType {
7004 #[doc(alias = "NEOnDemandRuleInterfaceTypeAny")]
7005 pub const Any: Self = Self(0);
7006 #[doc(alias = "NEOnDemandRuleInterfaceTypeEthernet")]
7007 pub const Ethernet: Self = Self(1);
7008 #[doc(alias = "NEOnDemandRuleInterfaceTypeWiFi")]
7009 pub const WiFi: Self = Self(2);
7010 #[doc(alias = "NEOnDemandRuleInterfaceTypeCellular")]
7011 pub const Cellular: Self = Self(3);
7012}
7013
7014unsafe impl Encode for NEOnDemandRuleInterfaceType {
7015 const ENCODING: Encoding = NSInteger::ENCODING;
7016}
7017
7018unsafe impl RefEncode for NEOnDemandRuleInterfaceType {
7019 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
7020}
7021
7022extern_class!(
7023 /// The NEOnDemandRule class declares the programmatic interface for an object that defines an On Demand rule.
7024 ///
7025 /// NEOnDemandRule is an abstract base class from which other action-specific rule classes are derived.
7026 ///
7027 /// Instances of this class are thread safe.
7028 ///
7029 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neondemandrule?language=objc)
7030 #[unsafe(super(NSObject))]
7031 #[derive(Debug, PartialEq, Eq, Hash)]
7032 pub struct NEOnDemandRule;
7033);
7034
7035extern_conformance!(
7036 unsafe impl NSCoding for NEOnDemandRule {}
7037);
7038
7039extern_conformance!(
7040 unsafe impl NSCopying for NEOnDemandRule {}
7041);
7042
7043unsafe impl CopyingHelper for NEOnDemandRule {
7044 type Result = Self;
7045}
7046
7047extern_conformance!(
7048 unsafe impl NSObjectProtocol for NEOnDemandRule {}
7049);
7050
7051extern_conformance!(
7052 unsafe impl NSSecureCoding for NEOnDemandRule {}
7053);
7054
7055impl NEOnDemandRule {
7056 extern_methods!(
7057 /// The rule's action
7058 #[unsafe(method(action))]
7059 #[unsafe(method_family = none)]
7060 pub unsafe fn action(&self) -> NEOnDemandRuleAction;
7061
7062 /// An array of NSString objects. If the current default search domain is equal to one of the strings in this array and all of the other conditions in the rule match, then the rule matches. If this property is nil (the default), then the current default search domain does not factor into the rule match.
7063 #[unsafe(method(DNSSearchDomainMatch))]
7064 #[unsafe(method_family = none)]
7065 pub unsafe fn DNSSearchDomainMatch(&self) -> Option<Retained<NSArray<NSString>>>;
7066
7067 /// Setter for [`DNSSearchDomainMatch`][Self::DNSSearchDomainMatch].
7068 ///
7069 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7070 #[unsafe(method(setDNSSearchDomainMatch:))]
7071 #[unsafe(method_family = none)]
7072 pub unsafe fn setDNSSearchDomainMatch(
7073 &self,
7074 dns_search_domain_match: Option<&NSArray<NSString>>,
7075 );
7076
7077 /// An array of DNS server IP addresses represented as NSString objects. If each of the current default DNS servers is equal to one of the strings in this array and all of the other conditions in the rule match, then the rule matches. If this property is nil (the default), then the default DNS servers do not factor into the rule match.
7078 #[unsafe(method(DNSServerAddressMatch))]
7079 #[unsafe(method_family = none)]
7080 pub unsafe fn DNSServerAddressMatch(&self) -> Option<Retained<NSArray<NSString>>>;
7081
7082 /// Setter for [`DNSServerAddressMatch`][Self::DNSServerAddressMatch].
7083 ///
7084 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7085 #[unsafe(method(setDNSServerAddressMatch:))]
7086 #[unsafe(method_family = none)]
7087 pub unsafe fn setDNSServerAddressMatch(
7088 &self,
7089 dns_server_address_match: Option<&NSArray<NSString>>,
7090 );
7091
7092 /// The type of interface that this rule matches. If the current primary network interface is of this type and all of the other conditions in the rule match, then the rule matches. If this property is 0 (the default), then the current primary interface type does not factor into the rule match.
7093 #[unsafe(method(interfaceTypeMatch))]
7094 #[unsafe(method_family = none)]
7095 pub unsafe fn interfaceTypeMatch(&self) -> NEOnDemandRuleInterfaceType;
7096
7097 /// Setter for [`interfaceTypeMatch`][Self::interfaceTypeMatch].
7098 #[unsafe(method(setInterfaceTypeMatch:))]
7099 #[unsafe(method_family = none)]
7100 pub unsafe fn setInterfaceTypeMatch(
7101 &self,
7102 interface_type_match: NEOnDemandRuleInterfaceType,
7103 );
7104
7105 /// An array of NSString objects. If the Service Set Identifier (SSID) of the current primary connected network matches one of the strings in this array and all of the other conditions in the rule match, then the rule matches. If this property is nil (the default), then the current primary connected network SSID does not factor into the rule match.
7106 #[unsafe(method(SSIDMatch))]
7107 #[unsafe(method_family = none)]
7108 pub unsafe fn SSIDMatch(&self) -> Option<Retained<NSArray<NSString>>>;
7109
7110 /// Setter for [`SSIDMatch`][Self::SSIDMatch].
7111 ///
7112 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7113 #[unsafe(method(setSSIDMatch:))]
7114 #[unsafe(method_family = none)]
7115 pub unsafe fn setSSIDMatch(&self, ssid_match: Option<&NSArray<NSString>>);
7116
7117 /// An HTTP or HTTPS URL. If a request sent to this URL results in a HTTP 200 OK response and all of the other conditions in the rule match, then then rule matches. If this property is nil (the default), then an HTTP request does not factor into the rule match.
7118 #[unsafe(method(probeURL))]
7119 #[unsafe(method_family = none)]
7120 pub unsafe fn probeURL(&self) -> Option<Retained<NSURL>>;
7121
7122 /// Setter for [`probeURL`][Self::probeURL].
7123 ///
7124 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7125 #[unsafe(method(setProbeURL:))]
7126 #[unsafe(method_family = none)]
7127 pub unsafe fn setProbeURL(&self, probe_url: Option<&NSURL>);
7128 );
7129}
7130
7131/// Methods declared on superclass `NSObject`.
7132impl NEOnDemandRule {
7133 extern_methods!(
7134 #[unsafe(method(init))]
7135 #[unsafe(method_family = init)]
7136 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
7137
7138 #[unsafe(method(new))]
7139 #[unsafe(method_family = new)]
7140 pub unsafe fn new() -> Retained<Self>;
7141 );
7142}
7143
7144extern_class!(
7145 /// The NEOnDemandRuleConnect class declares the programmatic interface for an object that defines an On Demand rule with the "Connect" action.
7146 ///
7147 /// When rules of this class match, the VPN connection is started whenever an application running on the system opens a network connection.
7148 ///
7149 /// Instances of this class are thread safe.
7150 ///
7151 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neondemandruleconnect?language=objc)
7152 #[unsafe(super(NEOnDemandRule, NSObject))]
7153 #[derive(Debug, PartialEq, Eq, Hash)]
7154 pub struct NEOnDemandRuleConnect;
7155);
7156
7157extern_conformance!(
7158 unsafe impl NSCoding for NEOnDemandRuleConnect {}
7159);
7160
7161extern_conformance!(
7162 unsafe impl NSCopying for NEOnDemandRuleConnect {}
7163);
7164
7165unsafe impl CopyingHelper for NEOnDemandRuleConnect {
7166 type Result = Self;
7167}
7168
7169extern_conformance!(
7170 unsafe impl NSObjectProtocol for NEOnDemandRuleConnect {}
7171);
7172
7173extern_conformance!(
7174 unsafe impl NSSecureCoding for NEOnDemandRuleConnect {}
7175);
7176
7177impl NEOnDemandRuleConnect {
7178 extern_methods!();
7179}
7180
7181/// Methods declared on superclass `NSObject`.
7182impl NEOnDemandRuleConnect {
7183 extern_methods!(
7184 #[unsafe(method(init))]
7185 #[unsafe(method_family = init)]
7186 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
7187
7188 #[unsafe(method(new))]
7189 #[unsafe(method_family = new)]
7190 pub unsafe fn new() -> Retained<Self>;
7191 );
7192}
7193
7194extern_class!(
7195 /// The NEOnDemandRuleDisconnect class declares the programmatic interface for an object that defines an On Demand rule with the "Disconnect" action.
7196 ///
7197 /// When rules of this class match, the VPN connection is not started, and the VPN connection is disconnected if it is not currently disconnected.
7198 ///
7199 /// Instances of this class are thread safe.
7200 ///
7201 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neondemandruledisconnect?language=objc)
7202 #[unsafe(super(NEOnDemandRule, NSObject))]
7203 #[derive(Debug, PartialEq, Eq, Hash)]
7204 pub struct NEOnDemandRuleDisconnect;
7205);
7206
7207extern_conformance!(
7208 unsafe impl NSCoding for NEOnDemandRuleDisconnect {}
7209);
7210
7211extern_conformance!(
7212 unsafe impl NSCopying for NEOnDemandRuleDisconnect {}
7213);
7214
7215unsafe impl CopyingHelper for NEOnDemandRuleDisconnect {
7216 type Result = Self;
7217}
7218
7219extern_conformance!(
7220 unsafe impl NSObjectProtocol for NEOnDemandRuleDisconnect {}
7221);
7222
7223extern_conformance!(
7224 unsafe impl NSSecureCoding for NEOnDemandRuleDisconnect {}
7225);
7226
7227impl NEOnDemandRuleDisconnect {
7228 extern_methods!();
7229}
7230
7231/// Methods declared on superclass `NSObject`.
7232impl NEOnDemandRuleDisconnect {
7233 extern_methods!(
7234 #[unsafe(method(init))]
7235 #[unsafe(method_family = init)]
7236 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
7237
7238 #[unsafe(method(new))]
7239 #[unsafe(method_family = new)]
7240 pub unsafe fn new() -> Retained<Self>;
7241 );
7242}
7243
7244extern_class!(
7245 /// The NEOnDemandRuleIgnore class declares the programmatic interface for an object that defines an On Demand rule with the "Ignore" action.
7246 ///
7247 /// When rules of this class match, the VPN connection is not started, and the current status of the VPN connection is left unchanged.
7248 ///
7249 /// Instances of this class are thread safe.
7250 ///
7251 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neondemandruleignore?language=objc)
7252 #[unsafe(super(NEOnDemandRule, NSObject))]
7253 #[derive(Debug, PartialEq, Eq, Hash)]
7254 pub struct NEOnDemandRuleIgnore;
7255);
7256
7257extern_conformance!(
7258 unsafe impl NSCoding for NEOnDemandRuleIgnore {}
7259);
7260
7261extern_conformance!(
7262 unsafe impl NSCopying for NEOnDemandRuleIgnore {}
7263);
7264
7265unsafe impl CopyingHelper for NEOnDemandRuleIgnore {
7266 type Result = Self;
7267}
7268
7269extern_conformance!(
7270 unsafe impl NSObjectProtocol for NEOnDemandRuleIgnore {}
7271);
7272
7273extern_conformance!(
7274 unsafe impl NSSecureCoding for NEOnDemandRuleIgnore {}
7275);
7276
7277impl NEOnDemandRuleIgnore {
7278 extern_methods!();
7279}
7280
7281/// Methods declared on superclass `NSObject`.
7282impl NEOnDemandRuleIgnore {
7283 extern_methods!(
7284 #[unsafe(method(init))]
7285 #[unsafe(method_family = init)]
7286 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
7287
7288 #[unsafe(method(new))]
7289 #[unsafe(method_family = new)]
7290 pub unsafe fn new() -> Retained<Self>;
7291 );
7292}
7293
7294extern_class!(
7295 /// The NEOnDemandRuleEvaluateConnection class declares the programmatic interface for an object that defines an On Demand rule with the "Evaluate Connection" action.
7296 ///
7297 /// When rules of this class match, the properties of the network connection being established are matched against a set of connection rules. The action of the matched rule (if any) is used to determine whether or not the VPN will be started.
7298 ///
7299 /// Instances of this class are thread safe.
7300 ///
7301 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neondemandruleevaluateconnection?language=objc)
7302 #[unsafe(super(NEOnDemandRule, NSObject))]
7303 #[derive(Debug, PartialEq, Eq, Hash)]
7304 pub struct NEOnDemandRuleEvaluateConnection;
7305);
7306
7307extern_conformance!(
7308 unsafe impl NSCoding for NEOnDemandRuleEvaluateConnection {}
7309);
7310
7311extern_conformance!(
7312 unsafe impl NSCopying for NEOnDemandRuleEvaluateConnection {}
7313);
7314
7315unsafe impl CopyingHelper for NEOnDemandRuleEvaluateConnection {
7316 type Result = Self;
7317}
7318
7319extern_conformance!(
7320 unsafe impl NSObjectProtocol for NEOnDemandRuleEvaluateConnection {}
7321);
7322
7323extern_conformance!(
7324 unsafe impl NSSecureCoding for NEOnDemandRuleEvaluateConnection {}
7325);
7326
7327impl NEOnDemandRuleEvaluateConnection {
7328 extern_methods!(
7329 /// An array of NEEvaluateConnectionRule objects. Each NEEvaluateConnectionRule object is evaluated in order against the properties of the network connection being established.
7330 #[unsafe(method(connectionRules))]
7331 #[unsafe(method_family = none)]
7332 pub unsafe fn connectionRules(&self)
7333 -> Option<Retained<NSArray<NEEvaluateConnectionRule>>>;
7334
7335 /// Setter for [`connectionRules`][Self::connectionRules].
7336 ///
7337 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7338 #[unsafe(method(setConnectionRules:))]
7339 #[unsafe(method_family = none)]
7340 pub unsafe fn setConnectionRules(
7341 &self,
7342 connection_rules: Option<&NSArray<NEEvaluateConnectionRule>>,
7343 );
7344 );
7345}
7346
7347/// Methods declared on superclass `NSObject`.
7348impl NEOnDemandRuleEvaluateConnection {
7349 extern_methods!(
7350 #[unsafe(method(init))]
7351 #[unsafe(method_family = init)]
7352 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
7353
7354 #[unsafe(method(new))]
7355 #[unsafe(method_family = new)]
7356 pub unsafe fn new() -> Retained<Self>;
7357 );
7358}
7359
7360/// Evaluate Connection rule actions
7361///
7362/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neevaluateconnectionruleaction?language=objc)
7363// NS_ENUM
7364#[repr(transparent)]
7365#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
7366pub struct NEEvaluateConnectionRuleAction(pub NSInteger);
7367impl NEEvaluateConnectionRuleAction {
7368 #[doc(alias = "NEEvaluateConnectionRuleActionConnectIfNeeded")]
7369 pub const ConnectIfNeeded: Self = Self(1);
7370 #[doc(alias = "NEEvaluateConnectionRuleActionNeverConnect")]
7371 pub const NeverConnect: Self = Self(2);
7372}
7373
7374unsafe impl Encode for NEEvaluateConnectionRuleAction {
7375 const ENCODING: Encoding = NSInteger::ENCODING;
7376}
7377
7378unsafe impl RefEncode for NEEvaluateConnectionRuleAction {
7379 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
7380}
7381
7382extern_class!(
7383 /// The NEEvaluateConnectionRule class declares the programmatic interface for an object that associates properties of network connections with an action.
7384 ///
7385 /// Instances of this class are thread safe.
7386 ///
7387 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neevaluateconnectionrule?language=objc)
7388 #[unsafe(super(NSObject))]
7389 #[derive(Debug, PartialEq, Eq, Hash)]
7390 pub struct NEEvaluateConnectionRule;
7391);
7392
7393extern_conformance!(
7394 unsafe impl NSCoding for NEEvaluateConnectionRule {}
7395);
7396
7397extern_conformance!(
7398 unsafe impl NSCopying for NEEvaluateConnectionRule {}
7399);
7400
7401unsafe impl CopyingHelper for NEEvaluateConnectionRule {
7402 type Result = Self;
7403}
7404
7405extern_conformance!(
7406 unsafe impl NSObjectProtocol for NEEvaluateConnectionRule {}
7407);
7408
7409extern_conformance!(
7410 unsafe impl NSSecureCoding for NEEvaluateConnectionRule {}
7411);
7412
7413impl NEEvaluateConnectionRule {
7414 extern_methods!(
7415 /// Initialize an NEEvaluateConnectionRule instance with a list of destination host domains and an action
7416 #[unsafe(method(initWithMatchDomains:andAction:))]
7417 #[unsafe(method_family = init)]
7418 pub unsafe fn initWithMatchDomains_andAction(
7419 this: Allocated<Self>,
7420 domains: &NSArray<NSString>,
7421 action: NEEvaluateConnectionRuleAction,
7422 ) -> Retained<Self>;
7423
7424 /// The action to take if the properties of the network connection being established match the rule.
7425 #[unsafe(method(action))]
7426 #[unsafe(method_family = none)]
7427 pub unsafe fn action(&self) -> NEEvaluateConnectionRuleAction;
7428
7429 /// An array of NSString objects. If the host name of the destination of the network connection being established shares a suffix with one of the strings in this array, then the rule matches.
7430 #[unsafe(method(matchDomains))]
7431 #[unsafe(method_family = none)]
7432 pub unsafe fn matchDomains(&self) -> Retained<NSArray<NSString>>;
7433
7434 /// An array of NSString objects. If the rule matches the connection being established and the action is NEEvaluateConnectionRuleActionConnectIfNeeded, the DNS servers specified in this array are used to resolve the host name of the destination while evaluating connectivity to the destination. If the resolution fails for any reason, the VPN is started.
7435 #[unsafe(method(useDNSServers))]
7436 #[unsafe(method_family = none)]
7437 pub unsafe fn useDNSServers(&self) -> Option<Retained<NSArray<NSString>>>;
7438
7439 /// Setter for [`useDNSServers`][Self::useDNSServers].
7440 ///
7441 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7442 #[unsafe(method(setUseDNSServers:))]
7443 #[unsafe(method_family = none)]
7444 pub unsafe fn setUseDNSServers(&self, use_dns_servers: Option<&NSArray<NSString>>);
7445
7446 /// An HTTP or HTTPS URL. If the rule matches the connection being established and the action is NEEvaluateConnectionRuleActionConnectIfNeeded and a request sent to this URL results in a response with an HTTP response code other than 200, then the VPN is started.
7447 #[unsafe(method(probeURL))]
7448 #[unsafe(method_family = none)]
7449 pub unsafe fn probeURL(&self) -> Option<Retained<NSURL>>;
7450
7451 /// Setter for [`probeURL`][Self::probeURL].
7452 ///
7453 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7454 #[unsafe(method(setProbeURL:))]
7455 #[unsafe(method_family = none)]
7456 pub unsafe fn setProbeURL(&self, probe_url: Option<&NSURL>);
7457 );
7458}
7459
7460/// Methods declared on superclass `NSObject`.
7461impl NEEvaluateConnectionRule {
7462 extern_methods!(
7463 #[unsafe(method(init))]
7464 #[unsafe(method_family = init)]
7465 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
7466
7467 #[unsafe(method(new))]
7468 #[unsafe(method_family = new)]
7469 pub unsafe fn new() -> Retained<Self>;
7470 );
7471}
7472
7473extern_class!(
7474 /// An NEPacket object represents the data, protocol family, and metadata associated with an IP packet.
7475 /// These packets are used to read and write on an NEPacketTunnelFlow.
7476 ///
7477 /// NEPacket is part of NetworkExtension.framework
7478 ///
7479 /// Instances of this class are thread safe.
7480 ///
7481 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nepacket?language=objc)
7482 #[unsafe(super(NSObject))]
7483 #[derive(Debug, PartialEq, Eq, Hash)]
7484 pub struct NEPacket;
7485);
7486
7487extern_conformance!(
7488 unsafe impl NSCoding for NEPacket {}
7489);
7490
7491extern_conformance!(
7492 unsafe impl NSCopying for NEPacket {}
7493);
7494
7495unsafe impl CopyingHelper for NEPacket {
7496 type Result = Self;
7497}
7498
7499extern_conformance!(
7500 unsafe impl NSObjectProtocol for NEPacket {}
7501);
7502
7503extern_conformance!(
7504 unsafe impl NSSecureCoding for NEPacket {}
7505);
7506
7507impl NEPacket {
7508 extern_methods!(
7509 #[cfg(feature = "libc")]
7510 /// Initializes a new NEPacket object with data and protocol family.
7511 ///
7512 /// Parameter `data`: The content of the packet.
7513 ///
7514 /// Parameter `protocolFamily`: The protocol family of the packet (such as AF_INET or AF_INET6).
7515 #[unsafe(method(initWithData:protocolFamily:))]
7516 #[unsafe(method_family = init)]
7517 pub unsafe fn initWithData_protocolFamily(
7518 this: Allocated<Self>,
7519 data: &NSData,
7520 protocol_family: libc::sa_family_t,
7521 ) -> Retained<Self>;
7522
7523 /// The data content of the packet.
7524 #[unsafe(method(data))]
7525 #[unsafe(method_family = none)]
7526 pub unsafe fn data(&self) -> Retained<NSData>;
7527
7528 #[cfg(feature = "libc")]
7529 /// The protocol family of the packet (such as AF_INET or AF_INET6).
7530 #[unsafe(method(protocolFamily))]
7531 #[unsafe(method_family = none)]
7532 pub unsafe fn protocolFamily(&self) -> libc::sa_family_t;
7533
7534 /// The direction of the packet.
7535 #[unsafe(method(direction))]
7536 #[unsafe(method_family = none)]
7537 pub unsafe fn direction(&self) -> NETrafficDirection;
7538
7539 /// Metadata about the source application and flow for this packet.
7540 /// This property will only be non-nil when the routing method for the NEPacketTunnelProvider
7541 /// is NETunnelProviderRoutingMethodSourceApplication.
7542 #[unsafe(method(metadata))]
7543 #[unsafe(method_family = none)]
7544 pub unsafe fn metadata(&self) -> Option<Retained<NEFlowMetaData>>;
7545 );
7546}
7547
7548/// Methods declared on superclass `NSObject`.
7549impl NEPacket {
7550 extern_methods!(
7551 #[unsafe(method(init))]
7552 #[unsafe(method_family = init)]
7553 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
7554
7555 #[unsafe(method(new))]
7556 #[unsafe(method_family = new)]
7557 pub unsafe fn new() -> Retained<Self>;
7558 );
7559}
7560
7561extern_class!(
7562 /// The NEPacketTunnelFlow class declares the programmatic interface of an object that is used by NEPacketTunnelProvider implementations to tunnel IP packets.
7563 ///
7564 /// NEPacketTunnelFlow is part of NetworkExtension.framework
7565 ///
7566 /// Instances of this class are thread safe.
7567 ///
7568 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nepackettunnelflow?language=objc)
7569 #[unsafe(super(NSObject))]
7570 #[derive(Debug, PartialEq, Eq, Hash)]
7571 pub struct NEPacketTunnelFlow;
7572);
7573
7574extern_conformance!(
7575 unsafe impl NSObjectProtocol for NEPacketTunnelFlow {}
7576);
7577
7578impl NEPacketTunnelFlow {
7579 extern_methods!(
7580 #[cfg(feature = "block2")]
7581 /// Read available IP packets from the flow.
7582 ///
7583 /// Parameter `completionHandler`: A block that will be executed to handle the packets. This block takes an array of NSData objects and an array of NSNumber objects. The NSData and NSNumber in corresponding indicies in the array represent one packet. If after handling the packets the caller wants to read more packets then the caller must call this method again.
7584 #[unsafe(method(readPacketsWithCompletionHandler:))]
7585 #[unsafe(method_family = none)]
7586 pub unsafe fn readPacketsWithCompletionHandler(
7587 &self,
7588 completion_handler: &block2::DynBlock<
7589 dyn Fn(NonNull<NSArray<NSData>>, NonNull<NSArray<NSNumber>>),
7590 >,
7591 );
7592
7593 /// Write multiple IP packets to the flow.
7594 ///
7595 /// Parameter `packets`: An array of NSData objects, each containing packet data to be written.
7596 ///
7597 /// Parameter `protocols`: An array of NSNumber objects. Each number contains the protocol of the packet in the corresponding index in the packets array.
7598 #[unsafe(method(writePackets:withProtocols:))]
7599 #[unsafe(method_family = none)]
7600 pub unsafe fn writePackets_withProtocols(
7601 &self,
7602 packets: &NSArray<NSData>,
7603 protocols: &NSArray<NSNumber>,
7604 ) -> bool;
7605
7606 #[cfg(feature = "block2")]
7607 /// Read available IP packets from the flow.
7608 ///
7609 /// Parameter `completionHandler`: A block that will be executed to handle the packets. This block takes an array of NEPacket objects. If after handling the packets the caller wants to read more packets then the caller must call this method again.
7610 #[unsafe(method(readPacketObjectsWithCompletionHandler:))]
7611 #[unsafe(method_family = none)]
7612 pub unsafe fn readPacketObjectsWithCompletionHandler(
7613 &self,
7614 completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<NEPacket>>)>,
7615 );
7616
7617 /// Write multiple IP packets to the flow.
7618 ///
7619 /// Parameter `packets`: An array of NEPacket objects, each containing packet data and protocol family to be written.
7620 #[unsafe(method(writePacketObjects:))]
7621 #[unsafe(method_family = none)]
7622 pub unsafe fn writePacketObjects(&self, packets: &NSArray<NEPacket>) -> bool;
7623 );
7624}
7625
7626/// Methods declared on superclass `NSObject`.
7627impl NEPacketTunnelFlow {
7628 extern_methods!(
7629 #[unsafe(method(init))]
7630 #[unsafe(method_family = init)]
7631 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
7632
7633 #[unsafe(method(new))]
7634 #[unsafe(method_family = new)]
7635 pub unsafe fn new() -> Retained<Self>;
7636 );
7637}
7638
7639extern_class!(
7640 /// The NERelay class declares the programmatic interface of an object that
7641 /// manages the details of a relay's configuration, such as authentication and URL details.
7642 ///
7643 /// Instances of this class are thread safe.
7644 ///
7645 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nerelay?language=objc)
7646 #[unsafe(super(NSObject))]
7647 #[derive(Debug, PartialEq, Eq, Hash)]
7648 pub struct NERelay;
7649);
7650
7651extern_conformance!(
7652 unsafe impl NSCoding for NERelay {}
7653);
7654
7655extern_conformance!(
7656 unsafe impl NSCopying for NERelay {}
7657);
7658
7659unsafe impl CopyingHelper for NERelay {
7660 type Result = Self;
7661}
7662
7663extern_conformance!(
7664 unsafe impl NSObjectProtocol for NERelay {}
7665);
7666
7667extern_conformance!(
7668 unsafe impl NSSecureCoding for NERelay {}
7669);
7670
7671impl NERelay {
7672 extern_methods!(
7673 /// The URL of the relay accessible over HTTP/3.
7674 #[unsafe(method(HTTP3RelayURL))]
7675 #[unsafe(method_family = none)]
7676 pub unsafe fn HTTP3RelayURL(&self) -> Option<Retained<NSURL>>;
7677
7678 /// Setter for [`HTTP3RelayURL`][Self::HTTP3RelayURL].
7679 ///
7680 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7681 #[unsafe(method(setHTTP3RelayURL:))]
7682 #[unsafe(method_family = none)]
7683 pub unsafe fn setHTTP3RelayURL(&self, http3_relay_url: Option<&NSURL>);
7684
7685 /// The URL of the relay accessible over HTTP/2.
7686 #[unsafe(method(HTTP2RelayURL))]
7687 #[unsafe(method_family = none)]
7688 pub unsafe fn HTTP2RelayURL(&self) -> Option<Retained<NSURL>>;
7689
7690 /// Setter for [`HTTP2RelayURL`][Self::HTTP2RelayURL].
7691 ///
7692 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7693 #[unsafe(method(setHTTP2RelayURL:))]
7694 #[unsafe(method_family = none)]
7695 pub unsafe fn setHTTP2RelayURL(&self, http2_relay_url: Option<&NSURL>);
7696
7697 /// The URL of a DNS-over-HTTPS (DoH) resolver accessible via the relay.
7698 #[unsafe(method(dnsOverHTTPSURL))]
7699 #[unsafe(method_family = none)]
7700 pub unsafe fn dnsOverHTTPSURL(&self) -> Option<Retained<NSURL>>;
7701
7702 /// Setter for [`dnsOverHTTPSURL`][Self::dnsOverHTTPSURL].
7703 ///
7704 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7705 #[unsafe(method(setDnsOverHTTPSURL:))]
7706 #[unsafe(method_family = none)]
7707 pub unsafe fn setDnsOverHTTPSURL(&self, dns_over_httpsurl: Option<&NSURL>);
7708
7709 /// An IPv4 address prefix (such as "192.0.2.0/24") that will be used to synthesize
7710 /// DNS answers for apps that use `getaddrinfo()` to resolve domains included in `matchDomains`
7711 #[unsafe(method(syntheticDNSAnswerIPv4Prefix))]
7712 #[unsafe(method_family = none)]
7713 pub unsafe fn syntheticDNSAnswerIPv4Prefix(&self) -> Option<Retained<NSString>>;
7714
7715 /// Setter for [`syntheticDNSAnswerIPv4Prefix`][Self::syntheticDNSAnswerIPv4Prefix].
7716 ///
7717 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7718 #[unsafe(method(setSyntheticDNSAnswerIPv4Prefix:))]
7719 #[unsafe(method_family = none)]
7720 pub unsafe fn setSyntheticDNSAnswerIPv4Prefix(
7721 &self,
7722 synthetic_dns_answer_i_pv4_prefix: Option<&NSString>,
7723 );
7724
7725 /// An IPv6 address prefix (such as "2001:DB8::/32") that will be used to synthesize
7726 /// DNS answers for apps that use `getaddrinfo()` to resolve domains included in `matchDomains`
7727 #[unsafe(method(syntheticDNSAnswerIPv6Prefix))]
7728 #[unsafe(method_family = none)]
7729 pub unsafe fn syntheticDNSAnswerIPv6Prefix(&self) -> Option<Retained<NSString>>;
7730
7731 /// Setter for [`syntheticDNSAnswerIPv6Prefix`][Self::syntheticDNSAnswerIPv6Prefix].
7732 ///
7733 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7734 #[unsafe(method(setSyntheticDNSAnswerIPv6Prefix:))]
7735 #[unsafe(method_family = none)]
7736 pub unsafe fn setSyntheticDNSAnswerIPv6Prefix(
7737 &self,
7738 synthetic_dns_answer_i_pv6_prefix: Option<&NSString>,
7739 );
7740
7741 /// Additional HTTP header field names and values to be added to all relay requests.
7742 #[unsafe(method(additionalHTTPHeaderFields))]
7743 #[unsafe(method_family = none)]
7744 pub unsafe fn additionalHTTPHeaderFields(
7745 &self,
7746 ) -> Retained<NSDictionary<NSString, NSString>>;
7747
7748 /// Setter for [`additionalHTTPHeaderFields`][Self::additionalHTTPHeaderFields].
7749 ///
7750 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7751 #[unsafe(method(setAdditionalHTTPHeaderFields:))]
7752 #[unsafe(method_family = none)]
7753 pub unsafe fn setAdditionalHTTPHeaderFields(
7754 &self,
7755 additional_http_header_fields: &NSDictionary<NSString, NSString>,
7756 );
7757
7758 /// TLS 1.3 raw public keys to use to authenticate the relay servers.
7759 #[unsafe(method(rawPublicKeys))]
7760 #[unsafe(method_family = none)]
7761 pub unsafe fn rawPublicKeys(&self) -> Option<Retained<NSArray<NSData>>>;
7762
7763 /// Setter for [`rawPublicKeys`][Self::rawPublicKeys].
7764 ///
7765 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7766 #[unsafe(method(setRawPublicKeys:))]
7767 #[unsafe(method_family = none)]
7768 pub unsafe fn setRawPublicKeys(&self, raw_public_keys: Option<&NSArray<NSData>>);
7769
7770 /// The PKCS12 data for the relay client authentication. The value is a NSData in PKCS12 format.
7771 #[unsafe(method(identityData))]
7772 #[unsafe(method_family = none)]
7773 pub unsafe fn identityData(&self) -> Option<Retained<NSData>>;
7774
7775 /// Setter for [`identityData`][Self::identityData].
7776 ///
7777 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7778 #[unsafe(method(setIdentityData:))]
7779 #[unsafe(method_family = none)]
7780 pub unsafe fn setIdentityData(&self, identity_data: Option<&NSData>);
7781
7782 /// The password to be used to decrypt the PKCS12 identity data.
7783 #[unsafe(method(identityDataPassword))]
7784 #[unsafe(method_family = none)]
7785 pub unsafe fn identityDataPassword(&self) -> Option<Retained<NSString>>;
7786
7787 /// Setter for [`identityDataPassword`][Self::identityDataPassword].
7788 ///
7789 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7790 #[unsafe(method(setIdentityDataPassword:))]
7791 #[unsafe(method_family = none)]
7792 pub unsafe fn setIdentityDataPassword(&self, identity_data_password: Option<&NSString>);
7793 );
7794}
7795
7796/// Methods declared on superclass `NSObject`.
7797impl NERelay {
7798 extern_methods!(
7799 #[unsafe(method(init))]
7800 #[unsafe(method_family = init)]
7801 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
7802
7803 #[unsafe(method(new))]
7804 #[unsafe(method_family = new)]
7805 pub unsafe fn new() -> Retained<Self>;
7806 );
7807}
7808
7809/// NERelay Manager error codes
7810///
7811/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nerelaymanagererror?language=objc)
7812// NS_ENUM
7813#[repr(transparent)]
7814#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
7815pub struct NERelayManagerError(pub NSInteger);
7816impl NERelayManagerError {
7817 #[doc(alias = "NERelayManagerErrorConfigurationInvalid")]
7818 pub const ConfigurationInvalid: Self = Self(1);
7819 #[doc(alias = "NERelayManagerErrorConfigurationDisabled")]
7820 pub const ConfigurationDisabled: Self = Self(2);
7821 #[doc(alias = "NERelayManagerErrorConfigurationStale")]
7822 pub const ConfigurationStale: Self = Self(3);
7823 #[doc(alias = "NERelayManagerErrorConfigurationCannotBeRemoved")]
7824 pub const ConfigurationCannotBeRemoved: Self = Self(4);
7825}
7826
7827unsafe impl Encode for NERelayManagerError {
7828 const ENCODING: Encoding = NSInteger::ENCODING;
7829}
7830
7831unsafe impl RefEncode for NERelayManagerError {
7832 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
7833}
7834
7835extern "C" {
7836 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nerelayerrordomain?language=objc)
7837 pub static NERelayErrorDomain: &'static NSString;
7838}
7839
7840/// NERelay Manager error codes detected by the client while trying to use this relay
7841///
7842/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nerelaymanagerclienterror?language=objc)
7843// NS_ENUM
7844#[repr(transparent)]
7845#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
7846pub struct NERelayManagerClientError(pub NSInteger);
7847impl NERelayManagerClientError {
7848 #[doc(alias = "NERelayManagerClientErrorNone")]
7849 pub const None: Self = Self(1);
7850 #[doc(alias = "NERelayManagerClientErrorDNSFailed")]
7851 pub const DNSFailed: Self = Self(2);
7852 #[doc(alias = "NERelayManagerClientErrorServerUnreachable")]
7853 pub const ServerUnreachable: Self = Self(3);
7854 #[doc(alias = "NERelayManagerClientErrorServerDisconnected")]
7855 pub const ServerDisconnected: Self = Self(4);
7856 #[doc(alias = "NERelayManagerClientErrorCertificateMissing")]
7857 pub const CertificateMissing: Self = Self(5);
7858 #[doc(alias = "NERelayManagerClientErrorCertificateInvalid")]
7859 pub const CertificateInvalid: Self = Self(6);
7860 #[doc(alias = "NERelayManagerClientErrorCertificateExpired")]
7861 pub const CertificateExpired: Self = Self(7);
7862 #[doc(alias = "NERelayManagerClientErrorServerCertificateInvalid")]
7863 pub const ServerCertificateInvalid: Self = Self(8);
7864 #[doc(alias = "NERelayManagerClientErrorServerCertificateExpired")]
7865 pub const ServerCertificateExpired: Self = Self(9);
7866 #[doc(alias = "NERelayManagerClientErrorOther")]
7867 pub const Other: Self = Self(10);
7868}
7869
7870unsafe impl Encode for NERelayManagerClientError {
7871 const ENCODING: Encoding = NSInteger::ENCODING;
7872}
7873
7874unsafe impl RefEncode for NERelayManagerClientError {
7875 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
7876}
7877
7878extern "C" {
7879 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nerelayclienterrordomain?language=objc)
7880 pub static NERelayClientErrorDomain: &'static NSString;
7881}
7882
7883extern "C" {
7884 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nerelayconfigurationdidchangenotification?language=objc)
7885 pub static NERelayConfigurationDidChangeNotification: &'static NSString;
7886}
7887
7888extern_class!(
7889 /// The NERelayManager class declares the programmatic interface for an object that manages relay configurations.
7890 ///
7891 /// NERelayManager declares methods and properties for configuring and controlling relay settings on the system.
7892 ///
7893 /// Instances of this class are thread safe.
7894 ///
7895 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nerelaymanager?language=objc)
7896 #[unsafe(super(NSObject))]
7897 #[derive(Debug, PartialEq, Eq, Hash)]
7898 pub struct NERelayManager;
7899);
7900
7901extern_conformance!(
7902 unsafe impl NSObjectProtocol for NERelayManager {}
7903);
7904
7905impl NERelayManager {
7906 extern_methods!(
7907 /// Returns: The singleton NERelayManager object for the calling process.
7908 #[unsafe(method(sharedManager))]
7909 #[unsafe(method_family = none)]
7910 pub unsafe fn sharedManager() -> Retained<NERelayManager>;
7911
7912 #[cfg(feature = "block2")]
7913 /// This function loads the current relay configuration from the caller's relay preferences.
7914 ///
7915 /// Parameter `completionHandler`: A block that will be called when the load operation is completed. The NSError passed to this block will be nil if the load operation succeeded, non-nil otherwise.
7916 #[unsafe(method(loadFromPreferencesWithCompletionHandler:))]
7917 #[unsafe(method_family = none)]
7918 pub unsafe fn loadFromPreferencesWithCompletionHandler(
7919 &self,
7920 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
7921 );
7922
7923 #[cfg(feature = "block2")]
7924 /// This function removes the relay configuration from the caller's relay preferences. If the relay is enabled, the relay becomes disabled.
7925 ///
7926 /// Parameter `completionHandler`: A block that will be called when the remove operation is completed. The NSError passed to this block will be nil if the remove operation succeeded, non-nil otherwise.
7927 #[unsafe(method(removeFromPreferencesWithCompletionHandler:))]
7928 #[unsafe(method_family = none)]
7929 pub unsafe fn removeFromPreferencesWithCompletionHandler(
7930 &self,
7931 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
7932 );
7933
7934 #[cfg(feature = "block2")]
7935 /// This function saves the relay configuration in the caller's relay preferences. If the relay are enabled, they will become active.
7936 ///
7937 /// Parameter `completionHandler`: A block that will be called when the save operation is completed. The NSError passed to this block will be nil if the save operation succeeded, non-nil otherwise.
7938 #[unsafe(method(saveToPreferencesWithCompletionHandler:))]
7939 #[unsafe(method_family = none)]
7940 pub unsafe fn saveToPreferencesWithCompletionHandler(
7941 &self,
7942 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
7943 );
7944
7945 #[cfg(feature = "block2")]
7946 /// This function will get errors that the client detected while using this relay configuration within the specified time period. Errors will be from the NERelayClientErrorDomain and the NERelayManagerClientErrorNone value will be set for successful connections.
7947 ///
7948 /// Parameter `seconds`: A NSTimeInterval that specifies how many seconds to report errors for. The maximum supported value is 24 hours and any larger values will be automatically reduced to 24 hours.
7949 ///
7950 /// Parameter `completionHandler`: A block that will be called when once the errors have been collected. The NSArray will contain a list of NERelayManagerClientError values detected within the last number of seconds as specified by the "seconds" parameter. The values will be ordered from the error most recently detected to the oldest. The error value of NERelayManagerClientErrorNone indicates the last successful use of the relay without error. The NSArray will be empty if there are no values detected within the specified time period or nil if there was a problem in retrieving the errors.
7951 #[unsafe(method(getLastClientErrors:completionHandler:))]
7952 #[unsafe(method_family = none)]
7953 pub unsafe fn getLastClientErrors_completionHandler(
7954 &self,
7955 seconds: NSTimeInterval,
7956 completion_handler: &block2::DynBlock<dyn Fn(*mut NSArray<NSError>)>,
7957 );
7958
7959 /// A string containing a description of the relay.
7960 #[unsafe(method(localizedDescription))]
7961 #[unsafe(method_family = none)]
7962 pub unsafe fn localizedDescription(&self) -> Option<Retained<NSString>>;
7963
7964 /// Setter for [`localizedDescription`][Self::localizedDescription].
7965 ///
7966 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
7967 #[unsafe(method(setLocalizedDescription:))]
7968 #[unsafe(method_family = none)]
7969 pub unsafe fn setLocalizedDescription(&self, localized_description: Option<&NSString>);
7970
7971 /// Toggles the enabled status of the relay.
7972 #[unsafe(method(isEnabled))]
7973 #[unsafe(method_family = none)]
7974 pub unsafe fn isEnabled(&self) -> bool;
7975
7976 /// Setter for [`isEnabled`][Self::isEnabled].
7977 #[unsafe(method(setEnabled:))]
7978 #[unsafe(method_family = none)]
7979 pub unsafe fn setEnabled(&self, enabled: bool);
7980
7981 /// Determines if the user will have the ability to enable and disable the relay
7982 #[unsafe(method(isUIToggleEnabled))]
7983 #[unsafe(method_family = none)]
7984 pub unsafe fn isUIToggleEnabled(&self) -> bool;
7985
7986 /// Setter for [`isUIToggleEnabled`][Self::isUIToggleEnabled].
7987 #[unsafe(method(setUIToggleEnabled:))]
7988 #[unsafe(method_family = none)]
7989 pub unsafe fn setUIToggleEnabled(&self, ui_toggle_enabled: bool);
7990
7991 /// Determines if DNS queries that fail over relay can fallback to default DNS
7992 #[unsafe(method(isDNSFailoverAllowed))]
7993 #[unsafe(method_family = none)]
7994 pub unsafe fn isDNSFailoverAllowed(&self) -> bool;
7995
7996 /// Setter for [`isDNSFailoverAllowed`][Self::isDNSFailoverAllowed].
7997 #[unsafe(method(setAllowDNSFailover:))]
7998 #[unsafe(method_family = none)]
7999 pub unsafe fn setAllowDNSFailover(&self, allow_dns_failover: bool);
8000
8001 /// An array of relay configurations describing one or more relay hops.
8002 #[unsafe(method(relays))]
8003 #[unsafe(method_family = none)]
8004 pub unsafe fn relays(&self) -> Option<Retained<NSArray<NERelay>>>;
8005
8006 /// Setter for [`relays`][Self::relays].
8007 #[unsafe(method(setRelays:))]
8008 #[unsafe(method_family = none)]
8009 pub unsafe fn setRelays(&self, relays: Option<&NSArray<NERelay>>);
8010
8011 /// An array of strings containing domain names. If this property is non-nil, the relay will be used to access hosts within the specified domains. If this and the match FQDNs property is nil, the relay will be used for all domains.
8012 #[unsafe(method(matchDomains))]
8013 #[unsafe(method_family = none)]
8014 pub unsafe fn matchDomains(&self) -> Option<Retained<NSArray<NSString>>>;
8015
8016 /// Setter for [`matchDomains`][Self::matchDomains].
8017 ///
8018 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
8019 #[unsafe(method(setMatchDomains:))]
8020 #[unsafe(method_family = none)]
8021 pub unsafe fn setMatchDomains(&self, match_domains: Option<&NSArray<NSString>>);
8022
8023 /// An array of strings containing Fully Qualified Domain Names (FQDNs). If this property is non-nil, the relay will be used to access the specified hosts. If this and the matchDomains property is nil, the relay will be used for all domains.
8024 #[unsafe(method(matchFQDNs))]
8025 #[unsafe(method_family = none)]
8026 pub unsafe fn matchFQDNs(&self) -> Option<Retained<NSArray<NSString>>>;
8027
8028 /// Setter for [`matchFQDNs`][Self::matchFQDNs].
8029 ///
8030 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
8031 #[unsafe(method(setMatchFQDNs:))]
8032 #[unsafe(method_family = none)]
8033 pub unsafe fn setMatchFQDNs(&self, match_fqd_ns: Option<&NSArray<NSString>>);
8034
8035 /// An array of strings containing domain names. If the destination host name of a connection shares a suffix with one of these strings then the relay will not be used.
8036 #[unsafe(method(excludedDomains))]
8037 #[unsafe(method_family = none)]
8038 pub unsafe fn excludedDomains(&self) -> Option<Retained<NSArray<NSString>>>;
8039
8040 /// Setter for [`excludedDomains`][Self::excludedDomains].
8041 ///
8042 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
8043 #[unsafe(method(setExcludedDomains:))]
8044 #[unsafe(method_family = none)]
8045 pub unsafe fn setExcludedDomains(&self, excluded_domains: Option<&NSArray<NSString>>);
8046
8047 /// An array of strings containing Fully Qualified Domain Names (FQDNs). If the destination host matches one of these strings then the relay will not be used. An excluded FQDN takes priority over the matchDomain property. This means the relay will not be used if the hostname matches an FQDN in this array even if the matchDomains contains a domain that would have been considered a match.
8048 #[unsafe(method(excludedFQDNs))]
8049 #[unsafe(method_family = none)]
8050 pub unsafe fn excludedFQDNs(&self) -> Option<Retained<NSArray<NSString>>>;
8051
8052 /// Setter for [`excludedFQDNs`][Self::excludedFQDNs].
8053 ///
8054 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
8055 #[unsafe(method(setExcludedFQDNs:))]
8056 #[unsafe(method_family = none)]
8057 pub unsafe fn setExcludedFQDNs(&self, excluded_fqd_ns: Option<&NSArray<NSString>>);
8058
8059 /// An array of NEOnDemandRule objects. If nil, the associated relay will always apply. If non-nil, the array describes the networks on which the relay should be used or not.
8060 #[unsafe(method(onDemandRules))]
8061 #[unsafe(method_family = none)]
8062 pub unsafe fn onDemandRules(&self) -> Option<Retained<NSArray<NEOnDemandRule>>>;
8063
8064 /// Setter for [`onDemandRules`][Self::onDemandRules].
8065 ///
8066 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
8067 #[unsafe(method(setOnDemandRules:))]
8068 #[unsafe(method_family = none)]
8069 pub unsafe fn setOnDemandRules(&self, on_demand_rules: Option<&NSArray<NEOnDemandRule>>);
8070
8071 #[cfg(feature = "block2")]
8072 /// This function asynchronously reads all of the NERelay configurations created by the calling app that have previously been saved to disk and returns them as NERelayManager objects.
8073 ///
8074 /// Parameter `completionHandler`: A block that takes an array NERelayManager objects. The array passed to the block may be empty if no NERelay configurations were successfully read from the disk. The NSError passed to this block will be nil if the load operation succeeded, non-nil otherwise.
8075 #[unsafe(method(loadAllManagersFromPreferencesWithCompletionHandler:))]
8076 #[unsafe(method_family = none)]
8077 pub unsafe fn loadAllManagersFromPreferencesWithCompletionHandler(
8078 completion_handler: &block2::DynBlock<
8079 dyn Fn(NonNull<NSArray<NERelayManager>>, *mut NSError),
8080 >,
8081 );
8082 );
8083}
8084
8085/// Methods declared on superclass `NSObject`.
8086impl NERelayManager {
8087 extern_methods!(
8088 #[unsafe(method(init))]
8089 #[unsafe(method_family = init)]
8090 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
8091
8092 #[unsafe(method(new))]
8093 #[unsafe(method_family = new)]
8094 pub unsafe fn new() -> Retained<Self>;
8095 );
8096}
8097
8098extern_class!(
8099 /// The NETransparentProxyManager class declares the programmatic interface for an object that is used to configure and control transparent proxies provided by NEAppProxyProviders.
8100 ///
8101 /// Instances of this class are thread safe.
8102 ///
8103 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/netransparentproxymanager?language=objc)
8104 #[unsafe(super(NEVPNManager, NSObject))]
8105 #[derive(Debug, PartialEq, Eq, Hash)]
8106 pub struct NETransparentProxyManager;
8107);
8108
8109extern_conformance!(
8110 unsafe impl NSObjectProtocol for NETransparentProxyManager {}
8111);
8112
8113impl NETransparentProxyManager {
8114 extern_methods!(
8115 #[cfg(feature = "block2")]
8116 /// This function asynchronously reads all of the transparent proxy configurations associated with the calling app that have previously been saved to disk and returns them as NETransparentProxyManager objects.
8117 ///
8118 /// Parameter `completionHandler`: A block that takes an array NETransparentProxyManager objects. The array passed to the block may be empty if no transparent proxy configurations were successfully read from the disk. The NSError passed to this block will be nil if the load operation succeeded, non-nil otherwise.
8119 #[unsafe(method(loadAllFromPreferencesWithCompletionHandler:))]
8120 #[unsafe(method_family = none)]
8121 pub unsafe fn loadAllFromPreferencesWithCompletionHandler(
8122 completion_handler: &block2::DynBlock<
8123 dyn Fn(*mut NSArray<NETransparentProxyManager>, *mut NSError),
8124 >,
8125 );
8126 );
8127}
8128
8129/// Methods declared on superclass `NSObject`.
8130impl NETransparentProxyManager {
8131 extern_methods!(
8132 #[unsafe(method(init))]
8133 #[unsafe(method_family = init)]
8134 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
8135
8136 #[unsafe(method(new))]
8137 #[unsafe(method_family = new)]
8138 pub unsafe fn new() -> Retained<Self>;
8139 );
8140}
8141
8142extern_class!(
8143 /// The NETransparentProxyNetworkSettings class declares the programmatic interface for an object that contains network settings.
8144 ///
8145 /// NETransparentProxyNetworkSettings is used by NEAppProxyProviders to communicate the desired network settings for the proxy to the framework. The framework takes care of applying the contained settings to the system.
8146 ///
8147 /// Instances of this class are thread safe.
8148 ///
8149 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/netransparentproxynetworksettings?language=objc)
8150 #[unsafe(super(NETunnelNetworkSettings, NSObject))]
8151 #[derive(Debug, PartialEq, Eq, Hash)]
8152 pub struct NETransparentProxyNetworkSettings;
8153);
8154
8155extern_conformance!(
8156 unsafe impl NSCoding for NETransparentProxyNetworkSettings {}
8157);
8158
8159extern_conformance!(
8160 unsafe impl NSCopying for NETransparentProxyNetworkSettings {}
8161);
8162
8163unsafe impl CopyingHelper for NETransparentProxyNetworkSettings {
8164 type Result = Self;
8165}
8166
8167extern_conformance!(
8168 unsafe impl NSObjectProtocol for NETransparentProxyNetworkSettings {}
8169);
8170
8171extern_conformance!(
8172 unsafe impl NSSecureCoding for NETransparentProxyNetworkSettings {}
8173);
8174
8175impl NETransparentProxyNetworkSettings {
8176 extern_methods!(
8177 /// An array of NENetworkRule objects that collectively specify the traffic that will be routed through the transparent proxy. The following restrictions
8178 /// apply to each NENetworkRule in this list:
8179 /// Restrictions for rules with an address endpoint:
8180 /// If the port string of the endpoint is "0" or is the empty string, then the address of the endpoint must be a non-wildcard address (i.e. "0.0.0.0" or "::").
8181 /// If the address is a wildcard address (i.e. "0.0.0.0" or "::"), then the port string of the endpoint must be non-empty and must not be "0".
8182 /// A port string of "53" is not allowed. Destination Domain-based rules must be used to match DNS traffic.
8183 /// The matchLocalNetwork property must be nil.
8184 /// The matchDirection property must be NETrafficDirectionOutbound.
8185 #[unsafe(method(includedNetworkRules))]
8186 #[unsafe(method_family = none)]
8187 pub unsafe fn includedNetworkRules(&self) -> Option<Retained<NSArray<NENetworkRule>>>;
8188
8189 /// Setter for [`includedNetworkRules`][Self::includedNetworkRules].
8190 ///
8191 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
8192 #[unsafe(method(setIncludedNetworkRules:))]
8193 #[unsafe(method_family = none)]
8194 pub unsafe fn setIncludedNetworkRules(
8195 &self,
8196 included_network_rules: Option<&NSArray<NENetworkRule>>,
8197 );
8198
8199 /// An array of NENetworkRule objects that collectively specify the traffic that will not be routed through the transparent proxy. The following restrictions
8200 /// apply to each NENetworkRule in this list:
8201 /// Restrictions for rules with an address endpoint:
8202 /// If the port string of the endpoint is "0" or is the empty string, then the address of the endpoint must be a non-wildcard address (i.e. "0.0.0.0" or "::").
8203 /// If the address is a wildcard address (i.e. "0.0.0.0" or "::"), then the port string of the endpoint must be non-empty and must not be "0".
8204 /// A port string of "53" is not allowed. Destination Domain-based rules must be used to match DNS traffic.
8205 /// The matchLocalNetwork property must be nil.
8206 /// The matchDirection property must be NETrafficDirectionOutbound.
8207 #[unsafe(method(excludedNetworkRules))]
8208 #[unsafe(method_family = none)]
8209 pub unsafe fn excludedNetworkRules(&self) -> Option<Retained<NSArray<NENetworkRule>>>;
8210
8211 /// Setter for [`excludedNetworkRules`][Self::excludedNetworkRules].
8212 ///
8213 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
8214 #[unsafe(method(setExcludedNetworkRules:))]
8215 #[unsafe(method_family = none)]
8216 pub unsafe fn setExcludedNetworkRules(
8217 &self,
8218 excluded_network_rules: Option<&NSArray<NENetworkRule>>,
8219 );
8220 );
8221}
8222
8223/// Methods declared on superclass `NETunnelNetworkSettings`.
8224impl NETransparentProxyNetworkSettings {
8225 extern_methods!(
8226 /// This function initializes a newly-allocated NETunnelNetworkSettings object with a given tunnel remote address.
8227 ///
8228 /// Parameter `address`: The address of the remote endpoint that is providing the tunnel service.
8229 #[unsafe(method(initWithTunnelRemoteAddress:))]
8230 #[unsafe(method_family = init)]
8231 pub unsafe fn initWithTunnelRemoteAddress(
8232 this: Allocated<Self>,
8233 address: &NSString,
8234 ) -> Retained<Self>;
8235 );
8236}
8237
8238/// Methods declared on superclass `NSObject`.
8239impl NETransparentProxyNetworkSettings {
8240 extern_methods!(
8241 #[unsafe(method(init))]
8242 #[unsafe(method_family = init)]
8243 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
8244
8245 #[unsafe(method(new))]
8246 #[unsafe(method_family = new)]
8247 pub unsafe fn new() -> Retained<Self>;
8248 );
8249}
8250
8251extern_class!(
8252 /// The NETransparentProxyProvider class declares the programmatic interface for an object that implements the client side of a custom transparent network proxy solution.
8253 /// The NETransparentProxyProvider class has the following behavior differences from its super class NEAppProxyProvider:
8254 /// - Returning NO from handleNewFlow: and handleNewUDPFlow:initialRemoteEndpoint: causes the flow to proceed to communicate directly with the flow's ultimate destination, instead of closing the flow with a "Connection Refused" error.
8255 /// - NEDNSSettings and NEProxySettings specified within NETransparentProxyNetworkSettings are ignored. Flows that match the includedNetworkRules within NETransparentProxyNetworkSettings will use the same DNS and proxy settings that other flows on the system are currently using.
8256 /// - Flows that are created using a "connect by name" API (such as Network.framework or NSURLSession) that match the includedNetworkRules will not bypass DNS resolution.
8257 ///
8258 /// NETransparentProxyProvider is part of NetworkExtension.framework
8259 ///
8260 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/netransparentproxyprovider?language=objc)
8261 #[unsafe(super(NEAppProxyProvider, NETunnelProvider, NEProvider, NSObject))]
8262 #[derive(Debug, PartialEq, Eq, Hash)]
8263 pub struct NETransparentProxyProvider;
8264);
8265
8266extern_conformance!(
8267 unsafe impl NSObjectProtocol for NETransparentProxyProvider {}
8268);
8269
8270impl NETransparentProxyProvider {
8271 extern_methods!();
8272}
8273
8274/// Methods declared on superclass `NSObject`.
8275impl NETransparentProxyProvider {
8276 extern_methods!(
8277 #[unsafe(method(init))]
8278 #[unsafe(method_family = init)]
8279 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
8280
8281 #[unsafe(method(new))]
8282 #[unsafe(method_family = new)]
8283 pub unsafe fn new() -> Retained<Self>;
8284 );
8285}
8286
8287/// VPN status codes
8288///
8289/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnstatus?language=objc)
8290// NS_ENUM
8291#[repr(transparent)]
8292#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
8293pub struct NEVPNStatus(pub NSInteger);
8294impl NEVPNStatus {
8295 #[doc(alias = "NEVPNStatusInvalid")]
8296 pub const Invalid: Self = Self(0);
8297 #[doc(alias = "NEVPNStatusDisconnected")]
8298 pub const Disconnected: Self = Self(1);
8299 #[doc(alias = "NEVPNStatusConnecting")]
8300 pub const Connecting: Self = Self(2);
8301 #[doc(alias = "NEVPNStatusConnected")]
8302 pub const Connected: Self = Self(3);
8303 #[doc(alias = "NEVPNStatusReasserting")]
8304 pub const Reasserting: Self = Self(4);
8305 #[doc(alias = "NEVPNStatusDisconnecting")]
8306 pub const Disconnecting: Self = Self(5);
8307}
8308
8309unsafe impl Encode for NEVPNStatus {
8310 const ENCODING: Encoding = NSInteger::ENCODING;
8311}
8312
8313unsafe impl RefEncode for NEVPNStatus {
8314 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
8315}
8316
8317extern "C" {
8318 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnstatusdidchangenotification?language=objc)
8319 pub static NEVPNStatusDidChangeNotification: &'static NSString;
8320}
8321
8322extern "C" {
8323 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnconnectionstartoptionusername?language=objc)
8324 pub static NEVPNConnectionStartOptionUsername: &'static NSString;
8325}
8326
8327extern "C" {
8328 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnconnectionstartoptionpassword?language=objc)
8329 pub static NEVPNConnectionStartOptionPassword: &'static NSString;
8330}
8331
8332/// VPN error codes
8333///
8334/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnconnectionerror?language=objc)
8335// NS_ENUM
8336#[repr(transparent)]
8337#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
8338pub struct NEVPNConnectionError(pub NSInteger);
8339impl NEVPNConnectionError {
8340 #[doc(alias = "NEVPNConnectionErrorOverslept")]
8341 pub const Overslept: Self = Self(1);
8342 #[doc(alias = "NEVPNConnectionErrorNoNetworkAvailable")]
8343 pub const NoNetworkAvailable: Self = Self(2);
8344 /// way that the VPN connection could not be maintained.
8345 #[doc(alias = "NEVPNConnectionErrorUnrecoverableNetworkChange")]
8346 pub const UnrecoverableNetworkChange: Self = Self(3);
8347 #[doc(alias = "NEVPNConnectionErrorConfigurationFailed")]
8348 pub const ConfigurationFailed: Self = Self(4);
8349 #[doc(alias = "NEVPNConnectionErrorServerAddressResolutionFailed")]
8350 pub const ServerAddressResolutionFailed: Self = Self(5);
8351 #[doc(alias = "NEVPNConnectionErrorServerNotResponding")]
8352 pub const ServerNotResponding: Self = Self(6);
8353 #[doc(alias = "NEVPNConnectionErrorServerDead")]
8354 pub const ServerDead: Self = Self(7);
8355 #[doc(alias = "NEVPNConnectionErrorAuthenticationFailed")]
8356 pub const AuthenticationFailed: Self = Self(8);
8357 #[doc(alias = "NEVPNConnectionErrorClientCertificateInvalid")]
8358 pub const ClientCertificateInvalid: Self = Self(9);
8359 #[doc(alias = "NEVPNConnectionErrorClientCertificateNotYetValid")]
8360 pub const ClientCertificateNotYetValid: Self = Self(10);
8361 #[doc(alias = "NEVPNConnectionErrorClientCertificateExpired")]
8362 pub const ClientCertificateExpired: Self = Self(11);
8363 #[doc(alias = "NEVPNConnectionErrorPluginFailed")]
8364 pub const PluginFailed: Self = Self(12);
8365 #[doc(alias = "NEVPNConnectionErrorConfigurationNotFound")]
8366 pub const ConfigurationNotFound: Self = Self(13);
8367 #[doc(alias = "NEVPNConnectionErrorPluginDisabled")]
8368 pub const PluginDisabled: Self = Self(14);
8369 #[doc(alias = "NEVPNConnectionErrorNegotiationFailed")]
8370 pub const NegotiationFailed: Self = Self(15);
8371 #[doc(alias = "NEVPNConnectionErrorServerDisconnected")]
8372 pub const ServerDisconnected: Self = Self(16);
8373 #[doc(alias = "NEVPNConnectionErrorServerCertificateInvalid")]
8374 pub const ServerCertificateInvalid: Self = Self(17);
8375 #[doc(alias = "NEVPNConnectionErrorServerCertificateNotYetValid")]
8376 pub const ServerCertificateNotYetValid: Self = Self(18);
8377 #[doc(alias = "NEVPNConnectionErrorServerCertificateExpired")]
8378 pub const ServerCertificateExpired: Self = Self(19);
8379}
8380
8381unsafe impl Encode for NEVPNConnectionError {
8382 const ENCODING: Encoding = NSInteger::ENCODING;
8383}
8384
8385unsafe impl RefEncode for NEVPNConnectionError {
8386 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
8387}
8388
8389extern "C" {
8390 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnconnectionerrordomain?language=objc)
8391 pub static NEVPNConnectionErrorDomain: &'static NSString;
8392}
8393
8394extern_class!(
8395 /// The NEVPNConnection class declares the programmatic interface for an object that manages VPN connections.
8396 ///
8397 /// Instances of this class are thread safe.
8398 ///
8399 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnconnection?language=objc)
8400 #[unsafe(super(NSObject))]
8401 #[derive(Debug, PartialEq, Eq, Hash)]
8402 pub struct NEVPNConnection;
8403);
8404
8405extern_conformance!(
8406 unsafe impl NSObjectProtocol for NEVPNConnection {}
8407);
8408
8409impl NEVPNConnection {
8410 extern_methods!(
8411 /// This function is used to start the VPN tunnel using the current VPN configuration. The VPN tunnel connection process is started and this function returns immediately.
8412 ///
8413 /// Parameter `error`: If the VPN tunnel was started successfully, this parameter is set to nil. Otherwise this parameter is set to the error that occurred. Possible errors include:
8414 /// 1. NEVPNErrorConfigurationInvalid
8415 /// 2. NEVPNErrorConfigurationDisabled
8416 ///
8417 /// Returns: YES if the VPN tunnel was started successfully, NO if an error occurred.
8418 #[unsafe(method(startVPNTunnelAndReturnError:_))]
8419 #[unsafe(method_family = none)]
8420 pub unsafe fn startVPNTunnelAndReturnError(&self) -> Result<(), Retained<NSError>>;
8421
8422 /// This function is used to start the VPN tunnel using the current VPN configuration. The VPN tunnel connection process is started and this function returns immediately.
8423 ///
8424 /// Parameter `options`: A dictionary that will be passed to the tunnel provider during the process of starting the tunnel.
8425 /// If not nil, 'options' is an NSDictionary may contain the following keys
8426 /// NEVPNConnectionStartOptionUsername
8427 /// NEVPNConnectionStartOptionPassword
8428 ///
8429 /// Parameter `error`: If the VPN tunnel was started successfully, this parameter is set to nil. Otherwise this parameter is set to the error that occurred. Possible errors include:
8430 /// 1. NEVPNErrorConfigurationInvalid
8431 /// 2. NEVPNErrorConfigurationDisabled
8432 ///
8433 /// Returns: YES if the VPN tunnel was started successfully, NO if an error occurred.
8434 ///
8435 /// # Safety
8436 ///
8437 /// `options` generic should be of the correct type.
8438 #[unsafe(method(startVPNTunnelWithOptions:andReturnError:_))]
8439 #[unsafe(method_family = none)]
8440 pub unsafe fn startVPNTunnelWithOptions_andReturnError(
8441 &self,
8442 options: Option<&NSDictionary<NSString, NSObject>>,
8443 ) -> Result<(), Retained<NSError>>;
8444
8445 /// This function is used to stop the VPN tunnel. The VPN tunnel disconnect process is started and this function returns immediately.
8446 #[unsafe(method(stopVPNTunnel))]
8447 #[unsafe(method_family = none)]
8448 pub unsafe fn stopVPNTunnel(&self);
8449
8450 #[cfg(feature = "block2")]
8451 /// Retrive the most recent error that caused the VPN to disconnect. If the error was generated by the VPN system (including the IPsec client) then the error will be in the NEVPNConnectionErrorDomain error domain. If the error was generated by a tunnel provider app extension then the error will be the NSError that the provider passed when disconnecting the tunnel.
8452 ///
8453 /// Parameter `handler`: A block which takes an optional NSError that will be called when the error is obtained.
8454 #[unsafe(method(fetchLastDisconnectErrorWithCompletionHandler:))]
8455 #[unsafe(method_family = none)]
8456 pub unsafe fn fetchLastDisconnectErrorWithCompletionHandler(
8457 &self,
8458 handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
8459 );
8460
8461 /// The current status of the VPN.
8462 #[unsafe(method(status))]
8463 #[unsafe(method_family = none)]
8464 pub unsafe fn status(&self) -> NEVPNStatus;
8465
8466 /// The date and time when the connection status changed to NEVPNStatusConnected. This property is nil if the connection is not fully established.
8467 #[unsafe(method(connectedDate))]
8468 #[unsafe(method_family = none)]
8469 pub unsafe fn connectedDate(&self) -> Option<Retained<NSDate>>;
8470
8471 /// The NEVPNManager associated with this NEVPNConnection.
8472 #[unsafe(method(manager))]
8473 #[unsafe(method_family = none)]
8474 pub unsafe fn manager(&self) -> Retained<NEVPNManager>;
8475 );
8476}
8477
8478/// Methods declared on superclass `NSObject`.
8479impl NEVPNConnection {
8480 extern_methods!(
8481 #[unsafe(method(init))]
8482 #[unsafe(method_family = init)]
8483 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
8484
8485 #[unsafe(method(new))]
8486 #[unsafe(method_family = new)]
8487 pub unsafe fn new() -> Retained<Self>;
8488 );
8489}
8490
8491extern_class!(
8492 /// This file declares the NETunnelProviderSession API. The NETunnelProviderSession API is used to control network tunnel services provided by NETunnelProvider implementations.
8493 ///
8494 /// This API is part of NetworkExtension.framework.
8495 ///
8496 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/netunnelprovidersession?language=objc)
8497 #[unsafe(super(NEVPNConnection, NSObject))]
8498 #[derive(Debug, PartialEq, Eq, Hash)]
8499 pub struct NETunnelProviderSession;
8500);
8501
8502extern_conformance!(
8503 unsafe impl NSObjectProtocol for NETunnelProviderSession {}
8504);
8505
8506impl NETunnelProviderSession {
8507 extern_methods!(
8508 /// This function is used to start the tunnel using the configuration associated with this connection object. The tunnel connection process is started and this function returns immediately.
8509 ///
8510 /// Parameter `options`: A dictionary that will be passed as-is to the tunnel provider during the process of starting the tunnel.
8511 ///
8512 /// Parameter `error`: If the tunnel was started successfully, this parameter is set to nil. Otherwise this parameter is set to the error that occurred. Possible errors include:
8513 /// 1. NEVPNErrorConfigurationInvalid
8514 /// 2. NEVPNErrorConfigurationDisabled
8515 ///
8516 /// Returns: YES if the tunnel was started successfully, NO if an error occurred.
8517 ///
8518 /// # Safety
8519 ///
8520 /// `options` generic should be of the correct type.
8521 #[unsafe(method(startTunnelWithOptions:andReturnError:_))]
8522 #[unsafe(method_family = none)]
8523 pub unsafe fn startTunnelWithOptions_andReturnError(
8524 &self,
8525 options: Option<&NSDictionary<NSString, AnyObject>>,
8526 ) -> Result<(), Retained<NSError>>;
8527
8528 /// This function is used to stop the tunnel. The tunnel disconnect process is started and this function returns immediately.
8529 #[unsafe(method(stopTunnel))]
8530 #[unsafe(method_family = none)]
8531 pub unsafe fn stopTunnel(&self);
8532
8533 #[cfg(feature = "block2")]
8534 /// This function sends a message to the NETunnelProvider and provides a way to receive a response.
8535 ///
8536 /// Parameter `messageData`: An NSData object containing the message to be sent.
8537 ///
8538 /// Parameter `error`: If the message was sent successfully, this parameter is set to nil. Otherwise this parameter is set to the error that occurred. Possible errors include:
8539 /// 1. NEVPNErrorConfigurationInvalid
8540 /// 2. NEVPNErrorConfigurationDisabled
8541 ///
8542 /// Parameter `responseHandler`: A block that handles the response. Can be set to nil if no response is expected.
8543 ///
8544 /// Returns: YES if the message was sent successfully, NO if an error occurred.
8545 #[unsafe(method(sendProviderMessage:returnError:responseHandler:))]
8546 #[unsafe(method_family = none)]
8547 pub unsafe fn sendProviderMessage_returnError_responseHandler(
8548 &self,
8549 message_data: &NSData,
8550 error: Option<&mut Option<Retained<NSError>>>,
8551 response_handler: Option<&block2::DynBlock<dyn Fn(*mut NSData)>>,
8552 ) -> bool;
8553 );
8554}
8555
8556/// Methods declared on superclass `NSObject`.
8557impl NETunnelProviderSession {
8558 extern_methods!(
8559 #[unsafe(method(init))]
8560 #[unsafe(method_family = init)]
8561 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
8562
8563 #[unsafe(method(new))]
8564 #[unsafe(method_family = new)]
8565 pub unsafe fn new() -> Retained<Self>;
8566 );
8567}
8568
8569extern_class!(
8570 /// The NETunnelProviderProtocol class declares the programmatic interface for an object that contains NETunnelProvider-specific configuration settings.
8571 ///
8572 /// Instances of this class are thread safe.
8573 ///
8574 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/netunnelproviderprotocol?language=objc)
8575 #[unsafe(super(NEVPNProtocol, NSObject))]
8576 #[derive(Debug, PartialEq, Eq, Hash)]
8577 pub struct NETunnelProviderProtocol;
8578);
8579
8580extern_conformance!(
8581 unsafe impl NSCoding for NETunnelProviderProtocol {}
8582);
8583
8584extern_conformance!(
8585 unsafe impl NSCopying for NETunnelProviderProtocol {}
8586);
8587
8588unsafe impl CopyingHelper for NETunnelProviderProtocol {
8589 type Result = Self;
8590}
8591
8592extern_conformance!(
8593 unsafe impl NSObjectProtocol for NETunnelProviderProtocol {}
8594);
8595
8596extern_conformance!(
8597 unsafe impl NSSecureCoding for NETunnelProviderProtocol {}
8598);
8599
8600impl NETunnelProviderProtocol {
8601 extern_methods!(
8602 /// A dictionary containing NETunnelProvider vendor-specific configuration parameters. This dictionary is passed as-is to NETunnelProviders when a tunnel is started.
8603 #[unsafe(method(providerConfiguration))]
8604 #[unsafe(method_family = none)]
8605 pub unsafe fn providerConfiguration(
8606 &self,
8607 ) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
8608
8609 /// Setter for [`providerConfiguration`][Self::providerConfiguration].
8610 ///
8611 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
8612 ///
8613 /// # Safety
8614 ///
8615 /// `provider_configuration` generic should be of the correct type.
8616 #[unsafe(method(setProviderConfiguration:))]
8617 #[unsafe(method_family = none)]
8618 pub unsafe fn setProviderConfiguration(
8619 &self,
8620 provider_configuration: Option<&NSDictionary<NSString, AnyObject>>,
8621 );
8622
8623 /// A string containing the bundle identifier of the NETunnelProvider to be used by this configuration.
8624 #[unsafe(method(providerBundleIdentifier))]
8625 #[unsafe(method_family = none)]
8626 pub unsafe fn providerBundleIdentifier(&self) -> Option<Retained<NSString>>;
8627
8628 /// Setter for [`providerBundleIdentifier`][Self::providerBundleIdentifier].
8629 ///
8630 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
8631 #[unsafe(method(setProviderBundleIdentifier:))]
8632 #[unsafe(method_family = none)]
8633 pub unsafe fn setProviderBundleIdentifier(
8634 &self,
8635 provider_bundle_identifier: Option<&NSString>,
8636 );
8637 );
8638}
8639
8640/// Methods declared on superclass `NSObject`.
8641impl NETunnelProviderProtocol {
8642 extern_methods!(
8643 #[unsafe(method(init))]
8644 #[unsafe(method_family = init)]
8645 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
8646
8647 #[unsafe(method(new))]
8648 #[unsafe(method_family = new)]
8649 pub unsafe fn new() -> Retained<Self>;
8650 );
8651}
8652
8653/// Internet Key Exchange (IKE) authentication methods used to authenticate with the IPSec server.
8654///
8655/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnikeauthenticationmethod?language=objc)
8656// NS_ENUM
8657#[repr(transparent)]
8658#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
8659pub struct NEVPNIKEAuthenticationMethod(pub NSInteger);
8660impl NEVPNIKEAuthenticationMethod {
8661 #[doc(alias = "NEVPNIKEAuthenticationMethodNone")]
8662 pub const None: Self = Self(0);
8663 #[doc(alias = "NEVPNIKEAuthenticationMethodCertificate")]
8664 pub const Certificate: Self = Self(1);
8665 #[doc(alias = "NEVPNIKEAuthenticationMethodSharedSecret")]
8666 pub const SharedSecret: Self = Self(2);
8667}
8668
8669unsafe impl Encode for NEVPNIKEAuthenticationMethod {
8670 const ENCODING: Encoding = NSInteger::ENCODING;
8671}
8672
8673unsafe impl RefEncode for NEVPNIKEAuthenticationMethod {
8674 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
8675}
8676
8677extern_class!(
8678 /// The NEVPNProtocolIPSec class declares the programmatic interface of an object that manages the IPSec-specific portion of a VPN configuration.
8679 ///
8680 /// Instances of this class use IKE version 1 for key negotiation.
8681 ///
8682 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnprotocolipsec?language=objc)
8683 #[unsafe(super(NEVPNProtocol, NSObject))]
8684 #[derive(Debug, PartialEq, Eq, Hash)]
8685 pub struct NEVPNProtocolIPSec;
8686);
8687
8688extern_conformance!(
8689 unsafe impl NSCoding for NEVPNProtocolIPSec {}
8690);
8691
8692extern_conformance!(
8693 unsafe impl NSCopying for NEVPNProtocolIPSec {}
8694);
8695
8696unsafe impl CopyingHelper for NEVPNProtocolIPSec {
8697 type Result = Self;
8698}
8699
8700extern_conformance!(
8701 unsafe impl NSObjectProtocol for NEVPNProtocolIPSec {}
8702);
8703
8704extern_conformance!(
8705 unsafe impl NSSecureCoding for NEVPNProtocolIPSec {}
8706);
8707
8708impl NEVPNProtocolIPSec {
8709 extern_methods!(
8710 /// The method used to authenticate with the IPSec server. Note that if this property is set to NEVPNIKEAuthenticationMethodNone, extended authentication will still be negotiated if useExtendedAuthentication is set to YES.
8711 #[unsafe(method(authenticationMethod))]
8712 #[unsafe(method_family = none)]
8713 pub unsafe fn authenticationMethod(&self) -> NEVPNIKEAuthenticationMethod;
8714
8715 /// Setter for [`authenticationMethod`][Self::authenticationMethod].
8716 #[unsafe(method(setAuthenticationMethod:))]
8717 #[unsafe(method_family = none)]
8718 pub unsafe fn setAuthenticationMethod(
8719 &self,
8720 authentication_method: NEVPNIKEAuthenticationMethod,
8721 );
8722
8723 /// A flag indicating if extended authentication will be negotiated. This authentication is in addition to the IKE authentication used to authenticate the endpoints of the IKE session.
8724 /// For IKE version 1, when this flag is set X-Auth authentication will be negotiated as part of the IKE session, using the username and password properties as the credential.
8725 /// For IKE version 2, when this flag is set EAP authentication will be negotiated as part of the IKE session, using the username, password, and/or identity properties as the credential depending on which EAP method the server requires.
8726 #[unsafe(method(useExtendedAuthentication))]
8727 #[unsafe(method_family = none)]
8728 pub unsafe fn useExtendedAuthentication(&self) -> bool;
8729
8730 /// Setter for [`useExtendedAuthentication`][Self::useExtendedAuthentication].
8731 #[unsafe(method(setUseExtendedAuthentication:))]
8732 #[unsafe(method_family = none)]
8733 pub unsafe fn setUseExtendedAuthentication(&self, use_extended_authentication: bool);
8734
8735 /// A persistent reference to a keychain item of class kSecClassGenericPassword containing the IKE shared secret.
8736 #[unsafe(method(sharedSecretReference))]
8737 #[unsafe(method_family = none)]
8738 pub unsafe fn sharedSecretReference(&self) -> Option<Retained<NSData>>;
8739
8740 /// Setter for [`sharedSecretReference`][Self::sharedSecretReference].
8741 ///
8742 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
8743 #[unsafe(method(setSharedSecretReference:))]
8744 #[unsafe(method_family = none)]
8745 pub unsafe fn setSharedSecretReference(&self, shared_secret_reference: Option<&NSData>);
8746
8747 /// A string identifying the local IPSec endpoint for authentication purposes.
8748 #[unsafe(method(localIdentifier))]
8749 #[unsafe(method_family = none)]
8750 pub unsafe fn localIdentifier(&self) -> Option<Retained<NSString>>;
8751
8752 /// Setter for [`localIdentifier`][Self::localIdentifier].
8753 ///
8754 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
8755 #[unsafe(method(setLocalIdentifier:))]
8756 #[unsafe(method_family = none)]
8757 pub unsafe fn setLocalIdentifier(&self, local_identifier: Option<&NSString>);
8758
8759 /// A string identifying the remote IPSec endpoint for authentication purposes.
8760 #[unsafe(method(remoteIdentifier))]
8761 #[unsafe(method_family = none)]
8762 pub unsafe fn remoteIdentifier(&self) -> Option<Retained<NSString>>;
8763
8764 /// Setter for [`remoteIdentifier`][Self::remoteIdentifier].
8765 ///
8766 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
8767 #[unsafe(method(setRemoteIdentifier:))]
8768 #[unsafe(method_family = none)]
8769 pub unsafe fn setRemoteIdentifier(&self, remote_identifier: Option<&NSString>);
8770 );
8771}
8772
8773/// Methods declared on superclass `NSObject`.
8774impl NEVPNProtocolIPSec {
8775 extern_methods!(
8776 #[unsafe(method(init))]
8777 #[unsafe(method_family = init)]
8778 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
8779
8780 #[unsafe(method(new))]
8781 #[unsafe(method_family = new)]
8782 pub unsafe fn new() -> Retained<Self>;
8783 );
8784}
8785
8786/// IKEv2 Encryption Algorithms
8787///
8788/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnikev2encryptionalgorithm?language=objc)
8789// NS_ENUM
8790#[repr(transparent)]
8791#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
8792pub struct NEVPNIKEv2EncryptionAlgorithm(pub NSInteger);
8793impl NEVPNIKEv2EncryptionAlgorithm {
8794 #[doc(alias = "NEVPNIKEv2EncryptionAlgorithmDES")]
8795 #[deprecated = "DES is not supported"]
8796 pub const AlgorithmDES: Self = Self(1);
8797 #[doc(alias = "NEVPNIKEv2EncryptionAlgorithm3DES")]
8798 #[deprecated = "3DES is not supported"]
8799 pub const Algorithm3DES: Self = Self(2);
8800 #[doc(alias = "NEVPNIKEv2EncryptionAlgorithmAES128")]
8801 #[deprecated = "Use an encryption algorithm with 256-bit keys instead"]
8802 pub const AlgorithmAES128: Self = Self(3);
8803 #[doc(alias = "NEVPNIKEv2EncryptionAlgorithmAES256")]
8804 pub const AlgorithmAES256: Self = Self(4);
8805 #[doc(alias = "NEVPNIKEv2EncryptionAlgorithmAES128GCM")]
8806 #[deprecated = "Use an encryption algorithm with 256-bit keys instead"]
8807 pub const AlgorithmAES128GCM: Self = Self(5);
8808 #[doc(alias = "NEVPNIKEv2EncryptionAlgorithmAES256GCM")]
8809 pub const AlgorithmAES256GCM: Self = Self(6);
8810 #[doc(alias = "NEVPNIKEv2EncryptionAlgorithmChaCha20Poly1305")]
8811 pub const AlgorithmChaCha20Poly1305: Self = Self(7);
8812}
8813
8814unsafe impl Encode for NEVPNIKEv2EncryptionAlgorithm {
8815 const ENCODING: Encoding = NSInteger::ENCODING;
8816}
8817
8818unsafe impl RefEncode for NEVPNIKEv2EncryptionAlgorithm {
8819 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
8820}
8821
8822/// IKEv2 Integrity Algorithms
8823///
8824/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnikev2integrityalgorithm?language=objc)
8825// NS_ENUM
8826#[repr(transparent)]
8827#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
8828pub struct NEVPNIKEv2IntegrityAlgorithm(pub NSInteger);
8829impl NEVPNIKEv2IntegrityAlgorithm {
8830 #[doc(alias = "NEVPNIKEv2IntegrityAlgorithmSHA96")]
8831 #[deprecated = "SHA-1 is not supported"]
8832 pub const SHA96: Self = Self(1);
8833 #[doc(alias = "NEVPNIKEv2IntegrityAlgorithmSHA160")]
8834 #[deprecated = "SHA-1 is not supported"]
8835 pub const SHA160: Self = Self(2);
8836 #[doc(alias = "NEVPNIKEv2IntegrityAlgorithmSHA256")]
8837 pub const SHA256: Self = Self(3);
8838 #[doc(alias = "NEVPNIKEv2IntegrityAlgorithmSHA384")]
8839 pub const SHA384: Self = Self(4);
8840 #[doc(alias = "NEVPNIKEv2IntegrityAlgorithmSHA512")]
8841 pub const SHA512: Self = Self(5);
8842}
8843
8844unsafe impl Encode for NEVPNIKEv2IntegrityAlgorithm {
8845 const ENCODING: Encoding = NSInteger::ENCODING;
8846}
8847
8848unsafe impl RefEncode for NEVPNIKEv2IntegrityAlgorithm {
8849 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
8850}
8851
8852/// IKEv2 Dead Peer Detection Rates
8853///
8854/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnikev2deadpeerdetectionrate?language=objc)
8855// NS_ENUM
8856#[repr(transparent)]
8857#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
8858pub struct NEVPNIKEv2DeadPeerDetectionRate(pub NSInteger);
8859impl NEVPNIKEv2DeadPeerDetectionRate {
8860 #[doc(alias = "NEVPNIKEv2DeadPeerDetectionRateNone")]
8861 pub const None: Self = Self(0);
8862 #[doc(alias = "NEVPNIKEv2DeadPeerDetectionRateLow")]
8863 pub const Low: Self = Self(1);
8864 #[doc(alias = "NEVPNIKEv2DeadPeerDetectionRateMedium")]
8865 pub const Medium: Self = Self(2);
8866 #[doc(alias = "NEVPNIKEv2DeadPeerDetectionRateHigh")]
8867 pub const High: Self = Self(3);
8868}
8869
8870unsafe impl Encode for NEVPNIKEv2DeadPeerDetectionRate {
8871 const ENCODING: Encoding = NSInteger::ENCODING;
8872}
8873
8874unsafe impl RefEncode for NEVPNIKEv2DeadPeerDetectionRate {
8875 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
8876}
8877
8878/// IKEv2 Diffie Hellman groups
8879///
8880/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnikev2diffiehellmangroup?language=objc)
8881// NS_ENUM
8882#[repr(transparent)]
8883#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
8884pub struct NEVPNIKEv2DiffieHellmanGroup(pub NSInteger);
8885impl NEVPNIKEv2DiffieHellmanGroup {
8886 #[doc(alias = "NEVPNIKEv2DiffieHellmanGroupInvalid")]
8887 pub const GroupInvalid: Self = Self(0);
8888 #[doc(alias = "NEVPNIKEv2DiffieHellmanGroup1")]
8889 #[deprecated = "Diffie Hellman groups less than 14 are not supported"]
8890 pub const Group1: Self = Self(1);
8891 #[doc(alias = "NEVPNIKEv2DiffieHellmanGroup2")]
8892 #[deprecated = "Diffie Hellman groups less than 14 are not supported"]
8893 pub const Group2: Self = Self(2);
8894 #[doc(alias = "NEVPNIKEv2DiffieHellmanGroup5")]
8895 #[deprecated = "Diffie Hellman groups less than 14 are not supported"]
8896 pub const Group5: Self = Self(5);
8897 #[doc(alias = "NEVPNIKEv2DiffieHellmanGroup14")]
8898 pub const Group14: Self = Self(14);
8899 #[doc(alias = "NEVPNIKEv2DiffieHellmanGroup15")]
8900 pub const Group15: Self = Self(15);
8901 #[doc(alias = "NEVPNIKEv2DiffieHellmanGroup16")]
8902 pub const Group16: Self = Self(16);
8903 #[doc(alias = "NEVPNIKEv2DiffieHellmanGroup17")]
8904 pub const Group17: Self = Self(17);
8905 #[doc(alias = "NEVPNIKEv2DiffieHellmanGroup18")]
8906 pub const Group18: Self = Self(18);
8907 #[doc(alias = "NEVPNIKEv2DiffieHellmanGroup19")]
8908 pub const Group19: Self = Self(19);
8909 #[doc(alias = "NEVPNIKEv2DiffieHellmanGroup20")]
8910 pub const Group20: Self = Self(20);
8911 #[doc(alias = "NEVPNIKEv2DiffieHellmanGroup21")]
8912 pub const Group21: Self = Self(21);
8913 #[doc(alias = "NEVPNIKEv2DiffieHellmanGroup31")]
8914 pub const Group31: Self = Self(31);
8915 #[doc(alias = "NEVPNIKEv2DiffieHellmanGroup32")]
8916 pub const Group32: Self = Self(32);
8917}
8918
8919unsafe impl Encode for NEVPNIKEv2DiffieHellmanGroup {
8920 const ENCODING: Encoding = NSInteger::ENCODING;
8921}
8922
8923unsafe impl RefEncode for NEVPNIKEv2DiffieHellmanGroup {
8924 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
8925}
8926
8927/// IKEv2 post-quantum key exchange methods
8928///
8929/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnikev2postquantumkeyexchangemethod?language=objc)
8930// NS_ENUM
8931#[repr(transparent)]
8932#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
8933pub struct NEVPNIKEv2PostQuantumKeyExchangeMethod(pub NSInteger);
8934impl NEVPNIKEv2PostQuantumKeyExchangeMethod {
8935 #[doc(alias = "NEVPNIKEv2PostQuantumKeyExchangeMethodNone")]
8936 pub const MethodNone: Self = Self(0);
8937 #[doc(alias = "NEVPNIKEv2PostQuantumKeyExchangeMethod36")]
8938 pub const Method36: Self = Self(36);
8939 #[doc(alias = "NEVPNIKEv2PostQuantumKeyExchangeMethod37")]
8940 pub const Method37: Self = Self(37);
8941}
8942
8943unsafe impl Encode for NEVPNIKEv2PostQuantumKeyExchangeMethod {
8944 const ENCODING: Encoding = NSInteger::ENCODING;
8945}
8946
8947unsafe impl RefEncode for NEVPNIKEv2PostQuantumKeyExchangeMethod {
8948 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
8949}
8950
8951/// IKEv2 Certificate types
8952///
8953/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnikev2certificatetype?language=objc)
8954// NS_ENUM
8955#[repr(transparent)]
8956#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
8957pub struct NEVPNIKEv2CertificateType(pub NSInteger);
8958impl NEVPNIKEv2CertificateType {
8959 #[doc(alias = "NEVPNIKEv2CertificateTypeRSA")]
8960 pub const RSA: Self = Self(1);
8961 #[doc(alias = "NEVPNIKEv2CertificateTypeECDSA256")]
8962 pub const ECDSA256: Self = Self(2);
8963 #[doc(alias = "NEVPNIKEv2CertificateTypeECDSA384")]
8964 pub const ECDSA384: Self = Self(3);
8965 #[doc(alias = "NEVPNIKEv2CertificateTypeECDSA521")]
8966 pub const ECDSA521: Self = Self(4);
8967 #[doc(alias = "NEVPNIKEv2CertificateTypeEd25519")]
8968 pub const Ed25519: Self = Self(5);
8969 #[doc(alias = "NEVPNIKEv2CertificateTypeRSAPSS")]
8970 pub const RSAPSS: Self = Self(6);
8971}
8972
8973unsafe impl Encode for NEVPNIKEv2CertificateType {
8974 const ENCODING: Encoding = NSInteger::ENCODING;
8975}
8976
8977unsafe impl RefEncode for NEVPNIKEv2CertificateType {
8978 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
8979}
8980
8981/// TLS Versions for use in EAP-TLS
8982///
8983/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnikev2tlsversion?language=objc)
8984// NS_ENUM
8985#[repr(transparent)]
8986#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
8987pub struct NEVPNIKEv2TLSVersion(pub NSInteger);
8988impl NEVPNIKEv2TLSVersion {
8989 #[doc(alias = "NEVPNIKEv2TLSVersionDefault")]
8990 pub const VersionDefault: Self = Self(0);
8991 #[doc(alias = "NEVPNIKEv2TLSVersion1_0")]
8992 pub const Version1_0: Self = Self(1);
8993 #[doc(alias = "NEVPNIKEv2TLSVersion1_1")]
8994 pub const Version1_1: Self = Self(2);
8995 #[doc(alias = "NEVPNIKEv2TLSVersion1_2")]
8996 pub const Version1_2: Self = Self(3);
8997}
8998
8999unsafe impl Encode for NEVPNIKEv2TLSVersion {
9000 const ENCODING: Encoding = NSInteger::ENCODING;
9001}
9002
9003unsafe impl RefEncode for NEVPNIKEv2TLSVersion {
9004 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
9005}
9006
9007extern_class!(
9008 /// The NEVPNIKEv2SecurityAssociationParameters class declares the programmatic interface of an object that manages parameters for an IPSec Security Association
9009 ///
9010 /// Instances of this class are thread safe.
9011 ///
9012 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnikev2securityassociationparameters?language=objc)
9013 #[unsafe(super(NSObject))]
9014 #[derive(Debug, PartialEq, Eq, Hash)]
9015 pub struct NEVPNIKEv2SecurityAssociationParameters;
9016);
9017
9018extern_conformance!(
9019 unsafe impl NSCoding for NEVPNIKEv2SecurityAssociationParameters {}
9020);
9021
9022extern_conformance!(
9023 unsafe impl NSCopying for NEVPNIKEv2SecurityAssociationParameters {}
9024);
9025
9026unsafe impl CopyingHelper for NEVPNIKEv2SecurityAssociationParameters {
9027 type Result = Self;
9028}
9029
9030extern_conformance!(
9031 unsafe impl NSObjectProtocol for NEVPNIKEv2SecurityAssociationParameters {}
9032);
9033
9034extern_conformance!(
9035 unsafe impl NSSecureCoding for NEVPNIKEv2SecurityAssociationParameters {}
9036);
9037
9038impl NEVPNIKEv2SecurityAssociationParameters {
9039 extern_methods!(
9040 /// The algorithm used by the Security Association to encrypt and decrypt data. On macOS and iOS, the default is NEVPNIKEv2EncryptionAlgorithmAES256 starting in macOS 11 and iOS 14.
9041 /// Prior to that the default was NEVPNIKEv2EncryptionAlgorithm3DES. On tvOS, the default is NEVPNIKEv2EncryptionAlgorithmAES256GCM.
9042 #[unsafe(method(encryptionAlgorithm))]
9043 #[unsafe(method_family = none)]
9044 pub unsafe fn encryptionAlgorithm(&self) -> NEVPNIKEv2EncryptionAlgorithm;
9045
9046 /// Setter for [`encryptionAlgorithm`][Self::encryptionAlgorithm].
9047 #[unsafe(method(setEncryptionAlgorithm:))]
9048 #[unsafe(method_family = none)]
9049 pub unsafe fn setEncryptionAlgorithm(
9050 &self,
9051 encryption_algorithm: NEVPNIKEv2EncryptionAlgorithm,
9052 );
9053
9054 /// The algorithm used by the Security Association to verify the integrity of data. The IKE psedo-random function algorithm will be inferred based on the integrity algorithm.
9055 /// Default is NEVPNIKEv2IntegrityAlgorithmSHA256 starting in macOS 11, iOS 14, and tvOS 17. Prior to that the default was NEVPNIKEv2IntegrityAlgorithmSHA96.
9056 #[unsafe(method(integrityAlgorithm))]
9057 #[unsafe(method_family = none)]
9058 pub unsafe fn integrityAlgorithm(&self) -> NEVPNIKEv2IntegrityAlgorithm;
9059
9060 /// Setter for [`integrityAlgorithm`][Self::integrityAlgorithm].
9061 #[unsafe(method(setIntegrityAlgorithm:))]
9062 #[unsafe(method_family = none)]
9063 pub unsafe fn setIntegrityAlgorithm(
9064 &self,
9065 integrity_algorithm: NEVPNIKEv2IntegrityAlgorithm,
9066 );
9067
9068 /// The Diffie Hellman group used by the Security Association. Default is NEVPNIKEv2DiffieHellmanGroup14 starting in macOS 11, iOS 14, and tvOS 17. Prior to that the default was NEVPNIKEv2DiffieHellmanGroup2.
9069 #[unsafe(method(diffieHellmanGroup))]
9070 #[unsafe(method_family = none)]
9071 pub unsafe fn diffieHellmanGroup(&self) -> NEVPNIKEv2DiffieHellmanGroup;
9072
9073 /// Setter for [`diffieHellmanGroup`][Self::diffieHellmanGroup].
9074 #[unsafe(method(setDiffieHellmanGroup:))]
9075 #[unsafe(method_family = none)]
9076 pub unsafe fn setDiffieHellmanGroup(
9077 &self,
9078 diffie_hellman_group: NEVPNIKEv2DiffieHellmanGroup,
9079 );
9080
9081 /// The post-quantum key exchange method(s) used by the Security Association, if any. Values are taken from NEVPNIKEv2PostQuantumKeyExchangeMethod. Up to 7 methods may be specified, mapping to ADDKE1 - ADDKE7 from RFC 9370.
9082 #[unsafe(method(postQuantumKeyExchangeMethods))]
9083 #[unsafe(method_family = none)]
9084 pub unsafe fn postQuantumKeyExchangeMethods(&self) -> Retained<NSArray<NSNumber>>;
9085
9086 /// Setter for [`postQuantumKeyExchangeMethods`][Self::postQuantumKeyExchangeMethods].
9087 ///
9088 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
9089 #[unsafe(method(setPostQuantumKeyExchangeMethods:))]
9090 #[unsafe(method_family = none)]
9091 pub unsafe fn setPostQuantumKeyExchangeMethods(
9092 &self,
9093 post_quantum_key_exchange_methods: &NSArray<NSNumber>,
9094 );
9095
9096 /// The life time of the Security Association, in minutes. Default is 60 for IKE Security Associations, and 30 for Child Security Associations. Before the lifetime is reached, IKEv2 will attempt to rekey the Security Association to maintain the connection.
9097 #[unsafe(method(lifetimeMinutes))]
9098 #[unsafe(method_family = none)]
9099 pub unsafe fn lifetimeMinutes(&self) -> i32;
9100
9101 /// Setter for [`lifetimeMinutes`][Self::lifetimeMinutes].
9102 #[unsafe(method(setLifetimeMinutes:))]
9103 #[unsafe(method_family = none)]
9104 pub unsafe fn setLifetimeMinutes(&self, lifetime_minutes: i32);
9105 );
9106}
9107
9108/// Methods declared on superclass `NSObject`.
9109impl NEVPNIKEv2SecurityAssociationParameters {
9110 extern_methods!(
9111 #[unsafe(method(init))]
9112 #[unsafe(method_family = init)]
9113 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
9114
9115 #[unsafe(method(new))]
9116 #[unsafe(method_family = new)]
9117 pub unsafe fn new() -> Retained<Self>;
9118 );
9119}
9120
9121extern_class!(
9122 /// The NEVPNIKEv2PPKConfiguration class declares the programmatic interface of an object that manages parameters for a Post-quantum Pre-shared Key (PPK)
9123 ///
9124 /// Instances of this class conform to RFC 8784.
9125 /// Instances of this class are thread safe.
9126 ///
9127 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnikev2ppkconfiguration?language=objc)
9128 #[unsafe(super(NSObject))]
9129 #[derive(Debug, PartialEq, Eq, Hash)]
9130 pub struct NEVPNIKEv2PPKConfiguration;
9131);
9132
9133extern_conformance!(
9134 unsafe impl NSCopying for NEVPNIKEv2PPKConfiguration {}
9135);
9136
9137unsafe impl CopyingHelper for NEVPNIKEv2PPKConfiguration {
9138 type Result = Self;
9139}
9140
9141extern_conformance!(
9142 unsafe impl NSObjectProtocol for NEVPNIKEv2PPKConfiguration {}
9143);
9144
9145impl NEVPNIKEv2PPKConfiguration {
9146 extern_methods!(
9147 /// Initialize a newly-allocated NEVPNIKEv2PPKConfiguration object.
9148 ///
9149 /// Parameter `identifier`: The identifier for the PPK.
9150 ///
9151 /// Parameter `keychainReference`: A persistent reference to a keychain item of class kSecClassGenericPassword containing the PPK.
9152 #[unsafe(method(initWithIdentifier:keychainReference:))]
9153 #[unsafe(method_family = init)]
9154 pub unsafe fn initWithIdentifier_keychainReference(
9155 this: Allocated<Self>,
9156 identifier: &NSString,
9157 keychain_reference: &NSData,
9158 ) -> Retained<Self>;
9159
9160 /// The identifer for the PPK.
9161 #[unsafe(method(identifier))]
9162 #[unsafe(method_family = none)]
9163 pub unsafe fn identifier(&self) -> Retained<NSString>;
9164
9165 /// A persistent reference to a keychain item of class kSecClassGenericPassword containing the PPK.
9166 #[unsafe(method(keychainReference))]
9167 #[unsafe(method_family = none)]
9168 pub unsafe fn keychainReference(&self) -> Retained<NSData>;
9169
9170 /// Boolean indicating whether use of the PPK is mandatory or not. Default is YES.
9171 #[unsafe(method(isMandatory))]
9172 #[unsafe(method_family = none)]
9173 pub unsafe fn isMandatory(&self) -> bool;
9174
9175 /// Setter for [`isMandatory`][Self::isMandatory].
9176 #[unsafe(method(setIsMandatory:))]
9177 #[unsafe(method_family = none)]
9178 pub unsafe fn setIsMandatory(&self, is_mandatory: bool);
9179 );
9180}
9181
9182/// Methods declared on superclass `NSObject`.
9183impl NEVPNIKEv2PPKConfiguration {
9184 extern_methods!(
9185 #[unsafe(method(init))]
9186 #[unsafe(method_family = init)]
9187 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
9188
9189 #[unsafe(method(new))]
9190 #[unsafe(method_family = new)]
9191 pub unsafe fn new() -> Retained<Self>;
9192 );
9193}
9194
9195extern_class!(
9196 /// The NEVPNProtocolIKEv2 class declares the programmatic interface of an object that manages the IKEv2-specific portion of a VPN configuration.
9197 ///
9198 /// Instances of this class use IKE version 2 for key negotiation.
9199 /// Instances of this class are thread safe.
9200 ///
9201 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nevpnprotocolikev2?language=objc)
9202 #[unsafe(super(NEVPNProtocolIPSec, NEVPNProtocol, NSObject))]
9203 #[derive(Debug, PartialEq, Eq, Hash)]
9204 pub struct NEVPNProtocolIKEv2;
9205);
9206
9207extern_conformance!(
9208 unsafe impl NSCoding for NEVPNProtocolIKEv2 {}
9209);
9210
9211extern_conformance!(
9212 unsafe impl NSCopying for NEVPNProtocolIKEv2 {}
9213);
9214
9215unsafe impl CopyingHelper for NEVPNProtocolIKEv2 {
9216 type Result = Self;
9217}
9218
9219extern_conformance!(
9220 unsafe impl NSObjectProtocol for NEVPNProtocolIKEv2 {}
9221);
9222
9223extern_conformance!(
9224 unsafe impl NSSecureCoding for NEVPNProtocolIKEv2 {}
9225);
9226
9227impl NEVPNProtocolIKEv2 {
9228 extern_methods!(
9229 /// How frequently the IKEv2 client will run the dead peer detection algorithm. Default is NEVPNIKEv2DeadPeerDetectionRateMedium.
9230 #[unsafe(method(deadPeerDetectionRate))]
9231 #[unsafe(method_family = none)]
9232 pub unsafe fn deadPeerDetectionRate(&self) -> NEVPNIKEv2DeadPeerDetectionRate;
9233
9234 /// Setter for [`deadPeerDetectionRate`][Self::deadPeerDetectionRate].
9235 #[unsafe(method(setDeadPeerDetectionRate:))]
9236 #[unsafe(method_family = none)]
9237 pub unsafe fn setDeadPeerDetectionRate(
9238 &self,
9239 dead_peer_detection_rate: NEVPNIKEv2DeadPeerDetectionRate,
9240 );
9241
9242 /// A string containing the Subject Common Name field of the Certificate Authority certificate that issued the IKEv2 server's certificate.
9243 #[unsafe(method(serverCertificateIssuerCommonName))]
9244 #[unsafe(method_family = none)]
9245 pub unsafe fn serverCertificateIssuerCommonName(&self) -> Option<Retained<NSString>>;
9246
9247 /// Setter for [`serverCertificateIssuerCommonName`][Self::serverCertificateIssuerCommonName].
9248 ///
9249 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
9250 #[unsafe(method(setServerCertificateIssuerCommonName:))]
9251 #[unsafe(method_family = none)]
9252 pub unsafe fn setServerCertificateIssuerCommonName(
9253 &self,
9254 server_certificate_issuer_common_name: Option<&NSString>,
9255 );
9256
9257 /// A string containing the value to verify in the IKEv2 server certificate's Subject Common Name field.
9258 #[unsafe(method(serverCertificateCommonName))]
9259 #[unsafe(method_family = none)]
9260 pub unsafe fn serverCertificateCommonName(&self) -> Option<Retained<NSString>>;
9261
9262 /// Setter for [`serverCertificateCommonName`][Self::serverCertificateCommonName].
9263 ///
9264 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
9265 #[unsafe(method(setServerCertificateCommonName:))]
9266 #[unsafe(method_family = none)]
9267 pub unsafe fn setServerCertificateCommonName(
9268 &self,
9269 server_certificate_common_name: Option<&NSString>,
9270 );
9271
9272 /// contains the type of certificate if an certificate is configured. Default is RSA.
9273 #[unsafe(method(certificateType))]
9274 #[unsafe(method_family = none)]
9275 pub unsafe fn certificateType(&self) -> NEVPNIKEv2CertificateType;
9276
9277 /// Setter for [`certificateType`][Self::certificateType].
9278 #[unsafe(method(setCertificateType:))]
9279 #[unsafe(method_family = none)]
9280 pub unsafe fn setCertificateType(&self, certificate_type: NEVPNIKEv2CertificateType);
9281
9282 /// Boolean indicating if client should use INTERNAL_IP4_SUBNET / INTERNAL_IP6_SUBNET attributes. Default is False.
9283 #[unsafe(method(useConfigurationAttributeInternalIPSubnet))]
9284 #[unsafe(method_family = none)]
9285 pub unsafe fn useConfigurationAttributeInternalIPSubnet(&self) -> bool;
9286
9287 /// Setter for [`useConfigurationAttributeInternalIPSubnet`][Self::useConfigurationAttributeInternalIPSubnet].
9288 #[unsafe(method(setUseConfigurationAttributeInternalIPSubnet:))]
9289 #[unsafe(method_family = none)]
9290 pub unsafe fn setUseConfigurationAttributeInternalIPSubnet(
9291 &self,
9292 use_configuration_attribute_internal_ip_subnet: bool,
9293 );
9294
9295 /// Parameters for the IKE SA
9296 #[unsafe(method(IKESecurityAssociationParameters))]
9297 #[unsafe(method_family = none)]
9298 pub unsafe fn IKESecurityAssociationParameters(
9299 &self,
9300 ) -> Retained<NEVPNIKEv2SecurityAssociationParameters>;
9301
9302 /// Parameters for the child SA
9303 #[unsafe(method(childSecurityAssociationParameters))]
9304 #[unsafe(method_family = none)]
9305 pub unsafe fn childSecurityAssociationParameters(
9306 &self,
9307 ) -> Retained<NEVPNIKEv2SecurityAssociationParameters>;
9308
9309 /// Disable MOBIKE negotiation. Default is NO.
9310 #[unsafe(method(disableMOBIKE))]
9311 #[unsafe(method_family = none)]
9312 pub unsafe fn disableMOBIKE(&self) -> bool;
9313
9314 /// Setter for [`disableMOBIKE`][Self::disableMOBIKE].
9315 #[unsafe(method(setDisableMOBIKE:))]
9316 #[unsafe(method_family = none)]
9317 pub unsafe fn setDisableMOBIKE(&self, disable_mobike: bool);
9318
9319 /// Disable Server Redirect. Default is NO.
9320 #[unsafe(method(disableRedirect))]
9321 #[unsafe(method_family = none)]
9322 pub unsafe fn disableRedirect(&self) -> bool;
9323
9324 /// Setter for [`disableRedirect`][Self::disableRedirect].
9325 #[unsafe(method(setDisableRedirect:))]
9326 #[unsafe(method_family = none)]
9327 pub unsafe fn setDisableRedirect(&self, disable_redirect: bool);
9328
9329 /// Enable Perfect Forward Secrecy. Default is NO.
9330 #[unsafe(method(enablePFS))]
9331 #[unsafe(method_family = none)]
9332 pub unsafe fn enablePFS(&self) -> bool;
9333
9334 /// Setter for [`enablePFS`][Self::enablePFS].
9335 #[unsafe(method(setEnablePFS:))]
9336 #[unsafe(method_family = none)]
9337 pub unsafe fn setEnablePFS(&self, enable_pfs: bool);
9338
9339 /// Allow servers that do not support post-quantum key exchanges to skip them. This property has no effect if no post-quantum key exchange methods
9340 /// are configured for the IKE SA or Child SA (see NEVPNIKEv2SecurityAssociationParameters.postQuantumKeyExchangeMethods). Default is NO.
9341 #[unsafe(method(allowPostQuantumKeyExchangeFallback))]
9342 #[unsafe(method_family = none)]
9343 pub unsafe fn allowPostQuantumKeyExchangeFallback(&self) -> bool;
9344
9345 /// Setter for [`allowPostQuantumKeyExchangeFallback`][Self::allowPostQuantumKeyExchangeFallback].
9346 #[unsafe(method(setAllowPostQuantumKeyExchangeFallback:))]
9347 #[unsafe(method_family = none)]
9348 pub unsafe fn setAllowPostQuantumKeyExchangeFallback(
9349 &self,
9350 allow_post_quantum_key_exchange_fallback: bool,
9351 );
9352
9353 /// Enable certificate revocation check. Default is NO.
9354 #[unsafe(method(enableRevocationCheck))]
9355 #[unsafe(method_family = none)]
9356 pub unsafe fn enableRevocationCheck(&self) -> bool;
9357
9358 /// Setter for [`enableRevocationCheck`][Self::enableRevocationCheck].
9359 #[unsafe(method(setEnableRevocationCheck:))]
9360 #[unsafe(method_family = none)]
9361 pub unsafe fn setEnableRevocationCheck(&self, enable_revocation_check: bool);
9362
9363 /// Require positive certificate revocation check response for peer certificate validation to pass. Default is NO.
9364 #[unsafe(method(strictRevocationCheck))]
9365 #[unsafe(method_family = none)]
9366 pub unsafe fn strictRevocationCheck(&self) -> bool;
9367
9368 /// Setter for [`strictRevocationCheck`][Self::strictRevocationCheck].
9369 #[unsafe(method(setStrictRevocationCheck:))]
9370 #[unsafe(method_family = none)]
9371 pub unsafe fn setStrictRevocationCheck(&self, strict_revocation_check: bool);
9372
9373 /// Sets a minimum TLS version to allow for EAP-TLS authentication. Default is NEVPNIKEv2TLSVersionDefault.
9374 #[unsafe(method(minimumTLSVersion))]
9375 #[unsafe(method_family = none)]
9376 pub unsafe fn minimumTLSVersion(&self) -> NEVPNIKEv2TLSVersion;
9377
9378 /// Setter for [`minimumTLSVersion`][Self::minimumTLSVersion].
9379 #[unsafe(method(setMinimumTLSVersion:))]
9380 #[unsafe(method_family = none)]
9381 pub unsafe fn setMinimumTLSVersion(&self, minimum_tls_version: NEVPNIKEv2TLSVersion);
9382
9383 /// Sets a maximum TLS version to allow for EAP-TLS authentication. Default is NEVPNIKEv2TLSVersionDefault.
9384 #[unsafe(method(maximumTLSVersion))]
9385 #[unsafe(method_family = none)]
9386 pub unsafe fn maximumTLSVersion(&self) -> NEVPNIKEv2TLSVersion;
9387
9388 /// Setter for [`maximumTLSVersion`][Self::maximumTLSVersion].
9389 #[unsafe(method(setMaximumTLSVersion:))]
9390 #[unsafe(method_family = none)]
9391 pub unsafe fn setMaximumTLSVersion(&self, maximum_tls_version: NEVPNIKEv2TLSVersion);
9392
9393 /// Enable Fallback is used to support Wi-Fi Assist. Wi-Fi Assist allows connections for foreground apps to switch over
9394 /// to Cellular Data when WiFi connectivity is poor. By setting the EnableFallback key, the device will bring up a tunnel over
9395 /// Cellular Data to carry traffic that is eligible for Wi-Fi Assist and also requires VPN. Enabling fallback requires that the
9396 /// server support multiple tunnels for a single user. Default is NO.
9397 #[unsafe(method(enableFallback))]
9398 #[unsafe(method_family = none)]
9399 pub unsafe fn enableFallback(&self) -> bool;
9400
9401 /// Setter for [`enableFallback`][Self::enableFallback].
9402 #[unsafe(method(setEnableFallback:))]
9403 #[unsafe(method_family = none)]
9404 pub unsafe fn setEnableFallback(&self, enable_fallback: bool);
9405
9406 /// Maximum Transmission Unit (MTU) size in bytes to assign to the tunnel interface.
9407 #[unsafe(method(mtu))]
9408 #[unsafe(method_family = none)]
9409 pub unsafe fn mtu(&self) -> NSUInteger;
9410
9411 /// Setter for [`mtu`][Self::mtu].
9412 #[unsafe(method(setMtu:))]
9413 #[unsafe(method_family = none)]
9414 pub unsafe fn setMtu(&self, mtu: NSUInteger);
9415
9416 /// Configuration for the use of a Post-quantum Pre-shared Key (PPK).
9417 #[unsafe(method(ppkConfiguration))]
9418 #[unsafe(method_family = none)]
9419 pub unsafe fn ppkConfiguration(&self) -> Option<Retained<NEVPNIKEv2PPKConfiguration>>;
9420
9421 /// Setter for [`ppkConfiguration`][Self::ppkConfiguration].
9422 ///
9423 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
9424 #[unsafe(method(setPpkConfiguration:))]
9425 #[unsafe(method_family = none)]
9426 pub unsafe fn setPpkConfiguration(
9427 &self,
9428 ppk_configuration: Option<&NEVPNIKEv2PPKConfiguration>,
9429 );
9430 );
9431}
9432
9433/// Methods declared on superclass `NSObject`.
9434impl NEVPNProtocolIKEv2 {
9435 extern_methods!(
9436 #[unsafe(method(init))]
9437 #[unsafe(method_family = init)]
9438 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
9439
9440 #[unsafe(method(new))]
9441 #[unsafe(method_family = new)]
9442 pub unsafe fn new() -> Retained<Self>;
9443 );
9444}
9445
9446extern "C" {
9447 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/neapppusherrordomain?language=objc)
9448 pub static NEAppPushErrorDomain: &'static NSErrorDomain;
9449}
9450
9451/// App Push Manager error codes
9452///
9453/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neapppushmanagererror?language=objc)
9454#[repr(transparent)]
9455#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
9456pub struct NEAppPushManagerError(pub NSInteger);
9457impl NEAppPushManagerError {
9458 #[doc(alias = "NEAppPushManagerErrorConfigurationInvalid")]
9459 pub const ConfigurationInvalid: Self = Self(1);
9460 #[doc(alias = "NEAppPushManagerErrorConfigurationNotLoaded")]
9461 pub const ConfigurationNotLoaded: Self = Self(2);
9462 #[doc(alias = "NEAppPushManagerErrorInternalError")]
9463 pub const InternalError: Self = Self(3);
9464 #[doc(alias = "NEAppPushManagerErrorInactiveSession")]
9465 pub const InactiveSession: Self = Self(4);
9466}
9467
9468unsafe impl Encode for NEAppPushManagerError {
9469 const ENCODING: Encoding = NSInteger::ENCODING;
9470}
9471
9472unsafe impl RefEncode for NEAppPushManagerError {
9473 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
9474}
9475
9476extern_class!(
9477 /// The NEPrivateLTENetwork class declares an object that contains the parameters of a private LTE network.
9478 ///
9479 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neprivateltenetwork?language=objc)
9480 #[unsafe(super(NSObject))]
9481 #[derive(Debug, PartialEq, Eq, Hash)]
9482 pub struct NEPrivateLTENetwork;
9483);
9484
9485extern_conformance!(
9486 unsafe impl NSCoding for NEPrivateLTENetwork {}
9487);
9488
9489extern_conformance!(
9490 unsafe impl NSCopying for NEPrivateLTENetwork {}
9491);
9492
9493unsafe impl CopyingHelper for NEPrivateLTENetwork {
9494 type Result = Self;
9495}
9496
9497extern_conformance!(
9498 unsafe impl NSObjectProtocol for NEPrivateLTENetwork {}
9499);
9500
9501extern_conformance!(
9502 unsafe impl NSSecureCoding for NEPrivateLTENetwork {}
9503);
9504
9505impl NEPrivateLTENetwork {
9506 extern_methods!(
9507 /// Mobile Country Code of the private LTE network.
9508 #[unsafe(method(mobileCountryCode))]
9509 #[unsafe(method_family = none)]
9510 pub unsafe fn mobileCountryCode(&self) -> Retained<NSString>;
9511
9512 /// Setter for [`mobileCountryCode`][Self::mobileCountryCode].
9513 ///
9514 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
9515 #[unsafe(method(setMobileCountryCode:))]
9516 #[unsafe(method_family = none)]
9517 pub unsafe fn setMobileCountryCode(&self, mobile_country_code: &NSString);
9518
9519 /// Mobile Network Code of the private LTE network.
9520 #[unsafe(method(mobileNetworkCode))]
9521 #[unsafe(method_family = none)]
9522 pub unsafe fn mobileNetworkCode(&self) -> Retained<NSString>;
9523
9524 /// Setter for [`mobileNetworkCode`][Self::mobileNetworkCode].
9525 ///
9526 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
9527 #[unsafe(method(setMobileNetworkCode:))]
9528 #[unsafe(method_family = none)]
9529 pub unsafe fn setMobileNetworkCode(&self, mobile_network_code: &NSString);
9530
9531 /// Tracking Area Code of the private LTE network. This property is only applicable for band 48 private LTE networks.
9532 #[unsafe(method(trackingAreaCode))]
9533 #[unsafe(method_family = none)]
9534 pub unsafe fn trackingAreaCode(&self) -> Option<Retained<NSString>>;
9535
9536 /// Setter for [`trackingAreaCode`][Self::trackingAreaCode].
9537 ///
9538 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
9539 #[unsafe(method(setTrackingAreaCode:))]
9540 #[unsafe(method_family = none)]
9541 pub unsafe fn setTrackingAreaCode(&self, tracking_area_code: Option<&NSString>);
9542 );
9543}
9544
9545/// Methods declared on superclass `NSObject`.
9546impl NEPrivateLTENetwork {
9547 extern_methods!(
9548 #[unsafe(method(init))]
9549 #[unsafe(method_family = init)]
9550 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
9551
9552 #[unsafe(method(new))]
9553 #[unsafe(method_family = new)]
9554 pub unsafe fn new() -> Retained<Self>;
9555 );
9556}
9557
9558extern_class!(
9559 /// The NEAppPushManager class declares a programmatic interface to configure NEAppPushProvider.
9560 ///
9561 /// NEAppPushManager declares methods and properties for configuring and managing life cycle of app push provider.
9562 ///
9563 /// Instances of this class are thread safe.
9564 ///
9565 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neapppushmanager?language=objc)
9566 #[unsafe(super(NSObject))]
9567 #[derive(Debug, PartialEq, Eq, Hash)]
9568 pub struct NEAppPushManager;
9569);
9570
9571extern_conformance!(
9572 unsafe impl NSObjectProtocol for NEAppPushManager {}
9573);
9574
9575impl NEAppPushManager {
9576 extern_methods!(
9577 /// An array of Wi-Fi SSID strings. If the SSID string of current Wi-Fi network matches with one of these strings and the Wi-Fi network is the primary route
9578 /// on the device then the NEAppPushProvider is started. The upper limit of number of SSIDs is 10.
9579 #[unsafe(method(matchSSIDs))]
9580 #[unsafe(method_family = none)]
9581 pub unsafe fn matchSSIDs(&self) -> Retained<NSArray<NSString>>;
9582
9583 /// Setter for [`matchSSIDs`][Self::matchSSIDs].
9584 ///
9585 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
9586 #[unsafe(method(setMatchSSIDs:))]
9587 #[unsafe(method_family = none)]
9588 pub unsafe fn setMatchSSIDs(&self, match_ssi_ds: &NSArray<NSString>);
9589
9590 /// An array of NEPrivateLTENetwork objects. If the properties of current private LTE network match with properties of one of these NEPrivateLTENetwork
9591 /// objects and the private LTE network is the primary route on the device then the NEAppPushProvider is started. The upper limit of number of private LTE networks is 10.
9592 /// For private LTE networks that are not band 48, the device must be supervised in order to perform the match
9593 #[unsafe(method(matchPrivateLTENetworks))]
9594 #[unsafe(method_family = none)]
9595 pub unsafe fn matchPrivateLTENetworks(&self) -> Retained<NSArray<NEPrivateLTENetwork>>;
9596
9597 /// Setter for [`matchPrivateLTENetworks`][Self::matchPrivateLTENetworks].
9598 ///
9599 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
9600 #[unsafe(method(setMatchPrivateLTENetworks:))]
9601 #[unsafe(method_family = none)]
9602 pub unsafe fn setMatchPrivateLTENetworks(
9603 &self,
9604 match_private_lte_networks: &NSArray<NEPrivateLTENetwork>,
9605 );
9606
9607 /// If set to YES NEAppPushProvider is started when iOS device is connected to an Ethernet network and the ethernet network is the primary route
9608 /// on the device. NEAppPushProvider must determine viability of its functionality on the network. If the network does not support its operation it must call
9609 /// [NEAppPushProvider unmatchEthernet:] method to stop itself.
9610 #[unsafe(method(matchEthernet))]
9611 #[unsafe(method_family = none)]
9612 pub unsafe fn matchEthernet(&self) -> bool;
9613
9614 /// Setter for [`matchEthernet`][Self::matchEthernet].
9615 #[unsafe(method(setMatchEthernet:))]
9616 #[unsafe(method_family = none)]
9617 pub unsafe fn setMatchEthernet(&self, match_ethernet: bool);
9618
9619 /// A dictionary containing vendor-specific key-value pairs, where the data type of values must be one of the data types supported by property list. Values of user defined data
9620 /// type are not supported. This dictionary is passed as-is to NEAppPushProvider when is it is started or notified for other specified reasons.
9621 #[unsafe(method(providerConfiguration))]
9622 #[unsafe(method_family = none)]
9623 pub unsafe fn providerConfiguration(&self) -> Retained<NSDictionary<NSString, AnyObject>>;
9624
9625 /// Setter for [`providerConfiguration`][Self::providerConfiguration].
9626 ///
9627 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
9628 ///
9629 /// # Safety
9630 ///
9631 /// `provider_configuration` generic should be of the correct type.
9632 #[unsafe(method(setProviderConfiguration:))]
9633 #[unsafe(method_family = none)]
9634 pub unsafe fn setProviderConfiguration(
9635 &self,
9636 provider_configuration: &NSDictionary<NSString, AnyObject>,
9637 );
9638
9639 /// A string containing the bundle identifier of the NEAppPushProvider.
9640 #[unsafe(method(providerBundleIdentifier))]
9641 #[unsafe(method_family = none)]
9642 pub unsafe fn providerBundleIdentifier(&self) -> Option<Retained<NSString>>;
9643
9644 /// Setter for [`providerBundleIdentifier`][Self::providerBundleIdentifier].
9645 ///
9646 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
9647 #[unsafe(method(setProviderBundleIdentifier:))]
9648 #[unsafe(method_family = none)]
9649 pub unsafe fn setProviderBundleIdentifier(
9650 &self,
9651 provider_bundle_identifier: Option<&NSString>,
9652 );
9653
9654 /// An instance of type NEAppPushDelegate that is required to receive incoming call informarion from the provider.
9655 #[unsafe(method(delegate))]
9656 #[unsafe(method_family = none)]
9657 pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NEAppPushDelegate>>>;
9658
9659 /// Setter for [`delegate`][Self::delegate].
9660 ///
9661 /// This is a [weak property][objc2::topics::weak_property].
9662 #[unsafe(method(setDelegate:))]
9663 #[unsafe(method_family = none)]
9664 pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NEAppPushDelegate>>);
9665
9666 #[cfg(feature = "block2")]
9667 /// This class method asynchronously reads all of the saved configurations and returns them as an array of NEAppPushManager objects.
9668 ///
9669 /// Parameter `completionHandler`: A block that takes an array of NEAppPushManager objects. The array passed to the block may be empty if no configurations
9670 /// were successfully read from the disk. The NSError object passed to this block will be nil if the load operation succeeded, non-nil otherwise.
9671 #[unsafe(method(loadAllFromPreferencesWithCompletionHandler:))]
9672 #[unsafe(method_family = none)]
9673 pub unsafe fn loadAllFromPreferencesWithCompletionHandler(
9674 completion_handler: &block2::DynBlock<
9675 dyn Fn(*mut NSArray<NEAppPushManager>, *mut NSError),
9676 >,
9677 );
9678
9679 #[cfg(feature = "block2")]
9680 /// This method loads the saved configuration from the persistent store.
9681 ///
9682 /// Parameter `completionHandler`: A block that will be called when the load operation is completed. The NSError object passed to this block will be nil if the load operation succeeded, non-nil otherwise.
9683 #[unsafe(method(loadFromPreferencesWithCompletionHandler:))]
9684 #[unsafe(method_family = none)]
9685 pub unsafe fn loadFromPreferencesWithCompletionHandler(
9686 &self,
9687 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
9688 );
9689
9690 #[cfg(feature = "block2")]
9691 /// This method removes the configuration from the persistent store.
9692 ///
9693 /// Parameter `completionHandler`: A block that will be called when the remove operation is completed. The NSError object passed to this block will be nil if the remove operation succeeded, non-nil otherwise.
9694 #[unsafe(method(removeFromPreferencesWithCompletionHandler:))]
9695 #[unsafe(method_family = none)]
9696 pub unsafe fn removeFromPreferencesWithCompletionHandler(
9697 &self,
9698 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
9699 );
9700
9701 #[cfg(feature = "block2")]
9702 /// This method saves the configuration in the persistent store.
9703 ///
9704 /// Parameter `completionHandler`: A block that will be called when the save operation is completed. The NSError object passed to this block will be nil if the save operation succeeded, non-nil otherwise.
9705 #[unsafe(method(saveToPreferencesWithCompletionHandler:))]
9706 #[unsafe(method_family = none)]
9707 pub unsafe fn saveToPreferencesWithCompletionHandler(
9708 &self,
9709 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
9710 );
9711
9712 /// A string containing a description of the app push manager.
9713 #[unsafe(method(localizedDescription))]
9714 #[unsafe(method_family = none)]
9715 pub unsafe fn localizedDescription(&self) -> Option<Retained<NSString>>;
9716
9717 /// Setter for [`localizedDescription`][Self::localizedDescription].
9718 ///
9719 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
9720 #[unsafe(method(setLocalizedDescription:))]
9721 #[unsafe(method_family = none)]
9722 pub unsafe fn setLocalizedDescription(&self, localized_description: Option<&NSString>);
9723
9724 /// Toggles the enabled status of the configuration. This property will be set to NO when the same app saves another configuration that overlaps with this configuration.
9725 #[unsafe(method(isEnabled))]
9726 #[unsafe(method_family = none)]
9727 pub unsafe fn isEnabled(&self) -> bool;
9728
9729 /// Setter for [`isEnabled`][Self::isEnabled].
9730 #[unsafe(method(setEnabled:))]
9731 #[unsafe(method_family = none)]
9732 pub unsafe fn setEnabled(&self, enabled: bool);
9733
9734 /// If set to YES, it indicates the associated configuration is in use. Use KVO to watch for changes.
9735 #[unsafe(method(isActive))]
9736 #[unsafe(method_family = none)]
9737 pub unsafe fn isActive(&self) -> bool;
9738 );
9739}
9740
9741/// Methods declared on superclass `NSObject`.
9742impl NEAppPushManager {
9743 extern_methods!(
9744 #[unsafe(method(init))]
9745 #[unsafe(method_family = init)]
9746 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
9747
9748 #[unsafe(method(new))]
9749 #[unsafe(method_family = new)]
9750 pub unsafe fn new() -> Retained<Self>;
9751 );
9752}
9753
9754extern_protocol!(
9755 /// Delegate for NEAppPushManager.
9756 ///
9757 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neapppushdelegate?language=objc)
9758 pub unsafe trait NEAppPushDelegate: NSObjectProtocol {
9759 /// This delegate method is called when the provider reports incoming call using reportIncomingCommunicationWithUserInfo method.
9760 ///
9761 /// Parameter `userInfo`: A dictionary of custom information that the provider passes to reportIncomingCommunicationWithUserInfo method.
9762 ///
9763 /// # Safety
9764 ///
9765 /// `user_info` generic should be of the correct type.
9766 #[unsafe(method(appPushManager:didReceiveIncomingCallWithUserInfo:))]
9767 #[unsafe(method_family = none)]
9768 unsafe fn appPushManager_didReceiveIncomingCallWithUserInfo(
9769 &self,
9770 manager: &NEAppPushManager,
9771 user_info: &NSDictionary,
9772 );
9773 }
9774);
9775
9776extern_class!(
9777 /// The NEAppPushProvider class declares a programmatic interface to manage a life cycle of app push provider. It also allows the provider to handle outgoing
9778 /// communication message from the containing app, and pass incoming call message to the containing app.
9779 /// NEAppPushProvider is part of NetworkExtension.framework
9780 ///
9781 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neapppushprovider?language=objc)
9782 #[unsafe(super(NEProvider, NSObject))]
9783 #[derive(Debug, PartialEq, Eq, Hash)]
9784 pub struct NEAppPushProvider;
9785);
9786
9787extern_conformance!(
9788 unsafe impl NSObjectProtocol for NEAppPushProvider {}
9789);
9790
9791impl NEAppPushProvider {
9792 extern_methods!(
9793 /// A dictionary containing current vendor-specific configuration parameters. This dictionary is provided by NEAppPushManager. Use KVO to watch for changes.
9794 #[unsafe(method(providerConfiguration))]
9795 #[unsafe(method_family = none)]
9796 pub unsafe fn providerConfiguration(
9797 &self,
9798 ) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
9799
9800 #[cfg(feature = "block2")]
9801 /// This method is called by the framework when the provider is started. Subclasses must override this method to create a connection with its server.
9802 ///
9803 /// Parameter `completionHandler`: A block that must be called when the provider establishes a connection with the server. If the providers fails to create a connection,
9804 /// the subclass' implementation of this method must pass a non-nil NSError object to this block. A value of nil passed to the completion handler indicates that the connection
9805 /// was successfully created.
9806 #[deprecated]
9807 #[unsafe(method(startWithCompletionHandler:))]
9808 #[unsafe(method_family = none)]
9809 pub unsafe fn startWithCompletionHandler(
9810 &self,
9811 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
9812 );
9813
9814 /// This method is called by the framework when the provider is started. Subclasses must override this method to create a connection with its server.
9815 #[unsafe(method(start))]
9816 #[unsafe(method_family = none)]
9817 pub unsafe fn start(&self);
9818
9819 #[cfg(feature = "block2")]
9820 /// This method is called by the framework when the app push provider needs to be stopped. Subclasses must override this method to perform necessary tasks.
9821 ///
9822 /// Parameter `reason`: An NEProviderStopReason indicating why the provider was stopped.
9823 ///
9824 /// Parameter `completionHandler`: A block that must be called when the provider is completely stopped.
9825 #[unsafe(method(stopWithReason:completionHandler:))]
9826 #[unsafe(method_family = none)]
9827 pub unsafe fn stopWithReason_completionHandler(
9828 &self,
9829 reason: NEProviderStopReason,
9830 completion_handler: &block2::DynBlock<dyn Fn()>,
9831 );
9832
9833 /// This function is called by the provider when it determines incoming call on the conection.
9834 ///
9835 /// Parameter `userInfo`: A dictionary of custom information associated with the incoming call. This dictionary is passed to containg app as-is.
9836 ///
9837 /// # Safety
9838 ///
9839 /// `user_info` generic should be of the correct type.
9840 #[unsafe(method(reportIncomingCallWithUserInfo:))]
9841 #[unsafe(method_family = none)]
9842 pub unsafe fn reportIncomingCallWithUserInfo(&self, user_info: &NSDictionary);
9843
9844 /// This function is called by the provider when it receives a Push to Talk message on the connection.
9845 ///
9846 /// Parameter `userInfo`: A dictionary of custom information associated with the Push to Talk message, such as the active remote participant. This dictionary is passed to the PTChannelManagerDelegate of the containing app if the user is joined to a Push to Talk channel.
9847 ///
9848 /// # Safety
9849 ///
9850 /// `user_info` generic should be of the correct type.
9851 #[unsafe(method(reportPushToTalkMessageWithUserInfo:))]
9852 #[unsafe(method_family = none)]
9853 pub unsafe fn reportPushToTalkMessageWithUserInfo(&self, user_info: &NSDictionary);
9854
9855 /// This method is called by the framework periodically after every 60 seconds. Subclasses must override this method to perform necessary tasks.
9856 #[unsafe(method(handleTimerEvent))]
9857 #[unsafe(method_family = none)]
9858 pub unsafe fn handleTimerEvent(&self);
9859
9860 /// This method is called by the provider when it does not require runtime while the device is connected to the current Ethernet network.
9861 /// This method is applicable only when NEAppPushManager has set matchEthernet property to YES and the provider is running because the device is connected to an
9862 /// Ethernet network.
9863 #[unsafe(method(unmatchEthernet))]
9864 #[unsafe(method_family = none)]
9865 pub unsafe fn unmatchEthernet(&self);
9866 );
9867}
9868
9869/// Methods declared on superclass `NSObject`.
9870impl NEAppPushProvider {
9871 extern_methods!(
9872 #[unsafe(method(init))]
9873 #[unsafe(method_family = init)]
9874 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
9875
9876 #[unsafe(method(new))]
9877 #[unsafe(method_family = new)]
9878 pub unsafe fn new() -> Retained<Self>;
9879 );
9880}
9881
9882extern_class!(
9883 /// NWEndpoint is a generic class to represent network endpoints, such as a port on a remote server.
9884 ///
9885 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nwendpoint?language=objc)
9886 #[unsafe(super(NSObject))]
9887 #[derive(Debug, PartialEq, Eq, Hash)]
9888 #[deprecated = "Use nw_endpoint_t in Network framework instead, see deprecation notice in <NetworkExtension/NWEndpoint.h>"]
9889 pub struct NWEndpoint;
9890);
9891
9892extern_conformance!(
9893 unsafe impl NSCoding for NWEndpoint {}
9894);
9895
9896extern_conformance!(
9897 unsafe impl NSCopying for NWEndpoint {}
9898);
9899
9900unsafe impl CopyingHelper for NWEndpoint {
9901 type Result = Self;
9902}
9903
9904extern_conformance!(
9905 unsafe impl NSObjectProtocol for NWEndpoint {}
9906);
9907
9908extern_conformance!(
9909 unsafe impl NSSecureCoding for NWEndpoint {}
9910);
9911
9912impl NWEndpoint {
9913 extern_methods!();
9914}
9915
9916/// Methods declared on superclass `NSObject`.
9917impl NWEndpoint {
9918 extern_methods!(
9919 #[unsafe(method(init))]
9920 #[unsafe(method_family = init)]
9921 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
9922
9923 #[unsafe(method(new))]
9924 #[unsafe(method_family = new)]
9925 pub unsafe fn new() -> Retained<Self>;
9926 );
9927}
9928
9929extern_class!(
9930 /// NWHostEndpoint is a subclass of NWEndpoint. It represents an endpoint backed by a
9931 /// hostname and port. Note that a hostname string may be an IP or IPv6 address.
9932 ///
9933 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nwhostendpoint?language=objc)
9934 #[unsafe(super(NWEndpoint, NSObject))]
9935 #[derive(Debug, PartialEq, Eq, Hash)]
9936 #[deprecated = "Use `nw_endpoint_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWHostEndpoint.h>"]
9937 pub struct NWHostEndpoint;
9938);
9939
9940extern_conformance!(
9941 unsafe impl NSCoding for NWHostEndpoint {}
9942);
9943
9944extern_conformance!(
9945 unsafe impl NSCopying for NWHostEndpoint {}
9946);
9947
9948unsafe impl CopyingHelper for NWHostEndpoint {
9949 type Result = Self;
9950}
9951
9952extern_conformance!(
9953 unsafe impl NSObjectProtocol for NWHostEndpoint {}
9954);
9955
9956extern_conformance!(
9957 unsafe impl NSSecureCoding for NWHostEndpoint {}
9958);
9959
9960impl NWHostEndpoint {
9961 extern_methods!(
9962 /// Parameter `hostname`: A string representation of the hostname or address, such as www.apple.com or 10.0.0.1.
9963 ///
9964 /// Parameter `port`: A string containing the port on the host, such as 80.
9965 ///
9966 /// Returns: An initialized NWHostEndpoint object.
9967 #[deprecated = "Use `nw_endpoint_create_host` in Network framework instead, see deprecation notice in <NetworkExtension/NWHostEndpoint.h>"]
9968 #[unsafe(method(endpointWithHostname:port:))]
9969 #[unsafe(method_family = none)]
9970 pub unsafe fn endpointWithHostname_port(
9971 hostname: &NSString,
9972 port: &NSString,
9973 ) -> Retained<Self>;
9974
9975 /// The endpoint's hostname.
9976 #[deprecated = "Use `nw_endpoint_get_hostname` in Network framework instead, see deprecation notice in <NetworkExtension/NWHostEndpoint.h>"]
9977 #[unsafe(method(hostname))]
9978 #[unsafe(method_family = none)]
9979 pub unsafe fn hostname(&self) -> Retained<NSString>;
9980
9981 /// The endpoint's port.
9982 #[deprecated = "Use `nw_endpoint_get_port` in Network framework instead, see deprecation notice in <NetworkExtension/NWHostEndpoint.h>"]
9983 #[unsafe(method(port))]
9984 #[unsafe(method_family = none)]
9985 pub unsafe fn port(&self) -> Retained<NSString>;
9986 );
9987}
9988
9989/// Methods declared on superclass `NSObject`.
9990impl NWHostEndpoint {
9991 extern_methods!(
9992 #[unsafe(method(init))]
9993 #[unsafe(method_family = init)]
9994 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
9995
9996 #[unsafe(method(new))]
9997 #[unsafe(method_family = new)]
9998 pub unsafe fn new() -> Retained<Self>;
9999 );
10000}
10001
10002extern_class!(
10003 /// NWBonjourServiceEndpoint is a subclass of NWEndpoint. It represents an endpoint
10004 /// backed by a Bonjour service, specified with a name, type, and domain. For example, the
10005 /// Bonjour service MyMusicStudio._music._tcp.local. has the name "MyMusicStudio",
10006 /// the type "_music._tcp", and the domain "local".
10007 ///
10008 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nwbonjourserviceendpoint?language=objc)
10009 #[unsafe(super(NWEndpoint, NSObject))]
10010 #[derive(Debug, PartialEq, Eq, Hash)]
10011 #[deprecated = "Use `nw_endpoint_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWBonjourServiceEndpoint.h>"]
10012 pub struct NWBonjourServiceEndpoint;
10013);
10014
10015extern_conformance!(
10016 unsafe impl NSCoding for NWBonjourServiceEndpoint {}
10017);
10018
10019extern_conformance!(
10020 unsafe impl NSCopying for NWBonjourServiceEndpoint {}
10021);
10022
10023unsafe impl CopyingHelper for NWBonjourServiceEndpoint {
10024 type Result = Self;
10025}
10026
10027extern_conformance!(
10028 unsafe impl NSObjectProtocol for NWBonjourServiceEndpoint {}
10029);
10030
10031extern_conformance!(
10032 unsafe impl NSSecureCoding for NWBonjourServiceEndpoint {}
10033);
10034
10035impl NWBonjourServiceEndpoint {
10036 extern_methods!(
10037 /// Parameter `name`: The Bonjour service name.
10038 ///
10039 /// Parameter `type`: The Bonjour service type.
10040 ///
10041 /// Parameter `domain`: The Bonjour service domain.
10042 ///
10043 /// Returns: An initialized NWBonjourServiceEndpoint object.
10044 #[deprecated = "Use `nw_endpoint_create_bonjour_service` in Network framework instead, see deprecation notice in <NetworkExtension/NWBonjourServiceEndpoint.h>"]
10045 #[unsafe(method(endpointWithName:type:domain:))]
10046 #[unsafe(method_family = none)]
10047 pub unsafe fn endpointWithName_type_domain(
10048 name: &NSString,
10049 r#type: &NSString,
10050 domain: &NSString,
10051 ) -> Retained<Self>;
10052
10053 /// The endpoint's Bonjour service name.
10054 #[deprecated = "Use `nw_endpoint_get_bonjour_service_name` in Network framework instead, see deprecation notice in <NetworkExtension/NWBonjourServiceEndpoint.h>"]
10055 #[unsafe(method(name))]
10056 #[unsafe(method_family = none)]
10057 pub unsafe fn name(&self) -> Retained<NSString>;
10058
10059 /// The endpoint's Bonjour service type.
10060 #[deprecated = "Use `nw_endpoint_get_bonjour_service_type` in Network framework instead, see deprecation notice in <NetworkExtension/NWBonjourServiceEndpoint.h>"]
10061 #[unsafe(method(type))]
10062 #[unsafe(method_family = none)]
10063 pub unsafe fn r#type(&self) -> Retained<NSString>;
10064
10065 /// The endpoint's Bonjour service domain.
10066 #[deprecated = "Use `nw_endpoint_get_bonjour_service_domain` in Network framework instead, see deprecation notice in <NetworkExtension/NWBonjourServiceEndpoint.h>"]
10067 #[unsafe(method(domain))]
10068 #[unsafe(method_family = none)]
10069 pub unsafe fn domain(&self) -> Retained<NSString>;
10070 );
10071}
10072
10073/// Methods declared on superclass `NSObject`.
10074impl NWBonjourServiceEndpoint {
10075 extern_methods!(
10076 #[unsafe(method(init))]
10077 #[unsafe(method_family = init)]
10078 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
10079
10080 #[unsafe(method(new))]
10081 #[unsafe(method_family = new)]
10082 pub unsafe fn new() -> Retained<Self>;
10083 );
10084}
10085
10086/// Path status values
10087///
10088/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nwpathstatus?language=objc)
10089// NS_ENUM
10090#[deprecated = "Use `nw_path_status_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWPath.h>"]
10091#[repr(transparent)]
10092#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
10093pub struct NWPathStatus(pub NSInteger);
10094impl NWPathStatus {
10095 #[doc(alias = "NWPathStatusInvalid")]
10096 #[deprecated = "Use `nw_path_status_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWPath.h>"]
10097 pub const Invalid: Self = Self(0);
10098 #[doc(alias = "NWPathStatusSatisfied")]
10099 #[deprecated = "Use `nw_path_status_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWPath.h>"]
10100 pub const Satisfied: Self = Self(1);
10101 #[doc(alias = "NWPathStatusUnsatisfied")]
10102 #[deprecated = "Use `nw_path_status_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWPath.h>"]
10103 pub const Unsatisfied: Self = Self(2);
10104 /// a connection attempt.
10105 #[doc(alias = "NWPathStatusSatisfiable")]
10106 #[deprecated = "Use `nw_path_status_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWPath.h>"]
10107 pub const Satisfiable: Self = Self(3);
10108}
10109
10110unsafe impl Encode for NWPathStatus {
10111 const ENCODING: Encoding = NSInteger::ENCODING;
10112}
10113
10114unsafe impl RefEncode for NWPathStatus {
10115 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
10116}
10117
10118extern_class!(
10119 /// A network path, represented with NWPath, expresses the viability status and
10120 /// properties of the path that a networking connection will take on the device. For example,
10121 /// if the path status is NWPathStatusSatisfied, then a connection could use that path.
10122 ///
10123 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nwpath?language=objc)
10124 #[unsafe(super(NSObject))]
10125 #[derive(Debug, PartialEq, Eq, Hash)]
10126 #[deprecated = "Use `nw_path_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWPath.h>"]
10127 pub struct NWPath;
10128);
10129
10130extern_conformance!(
10131 unsafe impl NSObjectProtocol for NWPath {}
10132);
10133
10134impl NWPath {
10135 extern_methods!(
10136 /// The evaluated NWPathStatus of the NWPath.
10137 #[deprecated = "Use `nw_path_get_status` in Network framework instead, see deprecation notice in <NetworkExtension/NWPath.h>"]
10138 #[unsafe(method(status))]
10139 #[unsafe(method_family = none)]
10140 pub unsafe fn status(&self) -> NWPathStatus;
10141
10142 /// Returns YES if the path is considered expensive, as when using a cellular data plan.
10143 #[deprecated = "Use `nw_path_is_expensive` in Network framework instead, see deprecation notice in <NetworkExtension/NWPath.h>"]
10144 #[unsafe(method(isExpensive))]
10145 #[unsafe(method_family = none)]
10146 pub unsafe fn isExpensive(&self) -> bool;
10147
10148 /// Returns YES if the path is considered constrained, as when it is in save data mode.
10149 #[deprecated = "Use `nw_path_is_constrained` in Network framework instead, see deprecation notice in <NetworkExtension/NWPath.h>"]
10150 #[unsafe(method(isConstrained))]
10151 #[unsafe(method_family = none)]
10152 pub unsafe fn isConstrained(&self) -> bool;
10153
10154 /// Parameter `path`: An NWPath object to compare.
10155 ///
10156 /// Returns: YES if the two path objects have the same content, NO otherwise.
10157 #[deprecated = "Use `nw_path_is_equal` in Network framework instead, see deprecation notice in <NetworkExtension/NWPath.h>"]
10158 #[unsafe(method(isEqualToPath:))]
10159 #[unsafe(method_family = none)]
10160 pub unsafe fn isEqualToPath(&self, path: &NWPath) -> bool;
10161 );
10162}
10163
10164/// Methods declared on superclass `NSObject`.
10165impl NWPath {
10166 extern_methods!(
10167 #[unsafe(method(init))]
10168 #[unsafe(method_family = init)]
10169 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
10170
10171 #[unsafe(method(new))]
10172 #[unsafe(method_family = new)]
10173 pub unsafe fn new() -> Retained<Self>;
10174 );
10175}
10176
10177/// Defined connection states. New types may be defined in the future.
10178///
10179/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nwtcpconnectionstate?language=objc)
10180// NS_ENUM
10181#[deprecated = "Use `nw_connection_state_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10182#[repr(transparent)]
10183#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
10184pub struct NWTCPConnectionState(pub NSInteger);
10185impl NWTCPConnectionState {
10186 #[doc(alias = "NWTCPConnectionStateInvalid")]
10187 #[deprecated = "Use `nw_connection_state_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10188 pub const Invalid: Self = Self(0);
10189 #[doc(alias = "NWTCPConnectionStateConnecting")]
10190 #[deprecated = "Use `nw_connection_state_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10191 pub const Connecting: Self = Self(1);
10192 /// waiting for better condition(s) before trying again.
10193 #[doc(alias = "NWTCPConnectionStateWaiting")]
10194 #[deprecated = "Use `nw_connection_state_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10195 pub const Waiting: Self = Self(2);
10196 /// to transfer data. If TLS is in use, the TLS handshake would have finished when the connection
10197 /// is in this state.
10198 #[doc(alias = "NWTCPConnectionStateConnected")]
10199 #[deprecated = "Use `nw_connection_state_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10200 pub const Connected: Self = Self(3);
10201 /// possible to transfer data. The application should call cancellation method to clean up resources
10202 /// when the connection is in this state.
10203 #[doc(alias = "NWTCPConnectionStateDisconnected")]
10204 #[deprecated = "Use `nw_connection_state_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10205 pub const Disconnected: Self = Self(4);
10206 /// the cancellation method.
10207 #[doc(alias = "NWTCPConnectionStateCancelled")]
10208 #[deprecated = "Use `nw_connection_state_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10209 pub const Cancelled: Self = Self(5);
10210}
10211
10212unsafe impl Encode for NWTCPConnectionState {
10213 const ENCODING: Encoding = NSInteger::ENCODING;
10214}
10215
10216unsafe impl RefEncode for NWTCPConnectionState {
10217 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
10218}
10219
10220extern_class!(
10221 /// Establish TCP connections to an endpoint, and send and receive data on the TCP connection.
10222 ///
10223 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nwtcpconnection?language=objc)
10224 #[unsafe(super(NSObject))]
10225 #[derive(Debug, PartialEq, Eq, Hash)]
10226 #[deprecated = "Use `nw_connection_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10227 pub struct NWTCPConnection;
10228);
10229
10230extern_conformance!(
10231 unsafe impl NSObjectProtocol for NWTCPConnection {}
10232);
10233
10234impl NWTCPConnection {
10235 extern_methods!(
10236 /// This convenience initializer can be used to create a new connection that would only
10237 /// be connected if there exists a better path (as determined by the system) to the destination
10238 /// endpoint of the original connection. It will be initialized using the same destination endpoint
10239 /// and set of parameters from the original connection.
10240 ///
10241 /// If the original connection becomes disconnected or cancelled, the new "upgrade" connection
10242 /// would automatically be considered better.
10243 ///
10244 /// The caller should create an NWTCPConnection and watch for the hasBetterPath property.
10245 /// When this property is YES, the caller should attempt to create a new upgrade
10246 /// connection, with the goal to start transferring data on the new better path as soon as
10247 /// possible to reduce power and potentially monetary cost. When the new upgrade connection
10248 /// becomes connected and when the caller wraps up the previous caller session on
10249 /// the original connection, the caller can start using the new upgrade connection and
10250 /// tear down the original one.
10251 ///
10252 ///
10253 /// Parameter `connection`: The original connection from which the caller will upgrade
10254 ///
10255 /// Returns: An initialized NWTCPConnection
10256 #[deprecated = "Use `nw_connection_create` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10257 #[unsafe(method(initWithUpgradeForConnection:))]
10258 #[unsafe(method_family = init)]
10259 pub unsafe fn initWithUpgradeForConnection(
10260 this: Allocated<Self>,
10261 connection: &NWTCPConnection,
10262 ) -> Retained<Self>;
10263
10264 /// The status of the connection. Use KVO to watch this property to get updates.
10265 #[deprecated = "Use `nw_connection_set_state_changed_handler` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10266 #[unsafe(method(state))]
10267 #[unsafe(method_family = none)]
10268 pub unsafe fn state(&self) -> NWTCPConnectionState;
10269
10270 /// YES if the connection can read and write data, NO otherwise. Use KVO to watch this property.
10271 #[deprecated = "Use `nw_connection_set_viability_changed_handler` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10272 #[unsafe(method(isViable))]
10273 #[unsafe(method_family = none)]
10274 pub unsafe fn isViable(&self) -> bool;
10275
10276 /// YES if the system determines there is a better path the destination can be reached if
10277 /// the caller creates a new connection using the same endpoint and parameters. This can
10278 /// be done using the convenience upgrade initializer method.
10279 /// Use KVO to watch this property to get updates.
10280 #[deprecated = "Use `nw_connection_set_better_path_available_handler` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10281 #[unsafe(method(hasBetterPath))]
10282 #[unsafe(method_family = none)]
10283 pub unsafe fn hasBetterPath(&self) -> bool;
10284
10285 /// The destination endpoint with which this connection was created.
10286 #[deprecated = "Use `nw_connection_copy_endpoint` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10287 #[unsafe(method(endpoint))]
10288 #[unsafe(method_family = none)]
10289 pub unsafe fn endpoint(&self) -> Retained<NWEndpoint>;
10290
10291 /// The network path over which the connection was established. The caller can query
10292 /// additional properties from the NWPath object for more information.
10293 ///
10294 /// Note that this contains a snapshot of information at the time of connection establishment
10295 /// for this connection only. As a result, some underlying properties might change in time and
10296 /// might not reflect the path for other connections that might be established at different times.
10297 #[deprecated = "Use `nw_connection_copy_current_path` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10298 #[unsafe(method(connectedPath))]
10299 #[unsafe(method_family = none)]
10300 pub unsafe fn connectedPath(&self) -> Option<Retained<NWPath>>;
10301
10302 /// The IP address endpoint from which the connection was connected.
10303 #[deprecated = "Use `nw_path_copy_effective_local_endpoint` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10304 #[unsafe(method(localAddress))]
10305 #[unsafe(method_family = none)]
10306 pub unsafe fn localAddress(&self) -> Option<Retained<NWEndpoint>>;
10307
10308 /// The IP address endpoint to which the connection was connected.
10309 #[deprecated = "Use `nw_path_copy_effective_remote_endpoint` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10310 #[unsafe(method(remoteAddress))]
10311 #[unsafe(method_family = none)]
10312 pub unsafe fn remoteAddress(&self) -> Option<Retained<NWEndpoint>>;
10313
10314 /// When the connection is connected to a Bonjour service endpoint, the TXT record associated
10315 /// with the Bonjour service is available via this property. Beware that the value comes from
10316 /// the network. Care must be taken when parsing this potentially malicious value.
10317 #[deprecated = "Use `nw_endpoint_copy_txt_record` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10318 #[unsafe(method(txtRecord))]
10319 #[unsafe(method_family = none)]
10320 pub unsafe fn txtRecord(&self) -> Option<Retained<NSData>>;
10321
10322 /// The connection-wide error property indicates any fatal error that occurred while
10323 /// processing the connection or performing data reading or writing.
10324 #[deprecated = "Use `nw_connection_set_state_changed_handler` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10325 #[unsafe(method(error))]
10326 #[unsafe(method_family = none)]
10327 pub unsafe fn error(&self) -> Option<Retained<NSError>>;
10328
10329 /// Cancel the connection. This will clean up the resources associated with this object
10330 /// and transition this object to NWTCPConnectionStateCancelled state.
10331 #[deprecated = "Use `nw_connection_cancel` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10332 #[unsafe(method(cancel))]
10333 #[unsafe(method_family = none)]
10334 pub unsafe fn cancel(&self);
10335
10336 #[cfg(feature = "block2")]
10337 /// Read "length" number of bytes. See readMinimumLength:maximumLength:completionHandler:
10338 /// for a complete discussion of the callback behavior.
10339 ///
10340 /// Parameter `length`: The exact number of bytes the application wants to read
10341 ///
10342 /// Parameter `completion`: The completion handler to be invoked when there is data to read or an error occurred
10343 #[deprecated = "Use `nw_connection_receive` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10344 #[unsafe(method(readLength:completionHandler:))]
10345 #[unsafe(method_family = none)]
10346 pub unsafe fn readLength_completionHandler(
10347 &self,
10348 length: NSUInteger,
10349 completion: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
10350 );
10351
10352 #[cfg(feature = "block2")]
10353 /// Read the requested range of bytes. The completion handler will be invoked when:
10354 /// - Exactly "length" number of bytes have been read. 'data' will be non-nil.
10355 ///
10356 /// - Fewer than "length" number of bytes, including 0 bytes, have been read, and the connection's
10357 /// read side has been closed. 'data' might be nil, depending on whether there was any data to be
10358 /// read when the connection's read side was closed.
10359 ///
10360 /// - Some fatal error has occurred, and 'data' will be nil.
10361 ///
10362 /// To know when to schedule a read again, check for the condition whether an error has occurred.
10363 ///
10364 /// For better performance, the caller should pick the effective minimum and maximum lengths.
10365 /// For example, if the caller absolutely needs a specific number of bytes before it can
10366 /// make any progress, use that value as the minimum. The maximum bytes can be the upperbound
10367 /// that the caller wants to read. Typically, the minimum length can be the caller
10368 /// protocol fixed-size header and the maximum length can be the maximum size of the payload or
10369 /// the size of the current read buffer.
10370 ///
10371 ///
10372 /// Parameter `minimum`: The minimum number of bytes the caller wants to read
10373 ///
10374 /// Parameter `maximum`: The maximum number of bytes the caller wants to read
10375 ///
10376 /// Parameter `completion`: The completion handler to be invoked when there is data to read or an error occurred
10377 #[deprecated = "Use `nw_connection_receive` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10378 #[unsafe(method(readMinimumLength:maximumLength:completionHandler:))]
10379 #[unsafe(method_family = none)]
10380 pub unsafe fn readMinimumLength_maximumLength_completionHandler(
10381 &self,
10382 minimum: NSUInteger,
10383 maximum: NSUInteger,
10384 completion: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
10385 );
10386
10387 #[cfg(feature = "block2")]
10388 /// Write the given data object content. Callers should wait until the completionHandler is executed
10389 /// before issuing another write.
10390 ///
10391 /// Parameter `data`: The data object whose content will be written
10392 ///
10393 /// Parameter `completion`: The completion handler to be invoked when the data content has been written or an error has occurred.
10394 /// If the error is nil, the write succeeded and the caller can write more data.
10395 #[deprecated = "Use `nw_connection_send` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10396 #[unsafe(method(write:completionHandler:))]
10397 #[unsafe(method_family = none)]
10398 pub unsafe fn write_completionHandler(
10399 &self,
10400 data: &NSData,
10401 completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
10402 );
10403
10404 /// Close this connection's write side such that further write requests won't succeed.
10405 /// Note that this has the effect of closing the read side of the peer connection.
10406 /// When the connection's read side and write side are closed, the connection is considered
10407 /// disconnected and will transition to the appropriate state.
10408 #[deprecated = "Use `nw_connection_send` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10409 #[unsafe(method(writeClose))]
10410 #[unsafe(method_family = none)]
10411 pub unsafe fn writeClose(&self);
10412 );
10413}
10414
10415/// Methods declared on superclass `NSObject`.
10416impl NWTCPConnection {
10417 extern_methods!(
10418 #[unsafe(method(init))]
10419 #[unsafe(method_family = init)]
10420 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
10421
10422 #[unsafe(method(new))]
10423 #[unsafe(method_family = new)]
10424 pub unsafe fn new() -> Retained<Self>;
10425 );
10426}
10427
10428extern_protocol!(
10429 /// Allows the caller to take custom actions on some connection events.
10430 ///
10431 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nwtcpconnectionauthenticationdelegate?language=objc)
10432 #[deprecated = "Use `sec_protocol_options_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10433 pub unsafe trait NWTCPConnectionAuthenticationDelegate: NSObjectProtocol {
10434 /// The caller can implement this optional protocol method to decide whether it
10435 /// wants to provide the identity for this connection for authentication. If this delegate
10436 /// method is not implemented, the return value will default to YES if
10437 /// provideIdentityForConnection:completionHandler: is implemented.
10438 ///
10439 /// Parameter `connection`: The connection sending this message
10440 ///
10441 /// Returns: YES to provide the identity for this connection, in which case, the delegate method
10442 /// provideIdentityForConnection:completionHandler: will be called.
10443 #[deprecated = "Use `sec_protocol_options_set_challenge_block` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10444 #[optional]
10445 #[unsafe(method(shouldProvideIdentityForConnection:))]
10446 #[unsafe(method_family = none)]
10447 unsafe fn shouldProvideIdentityForConnection(&self, connection: &NWTCPConnection) -> bool;
10448
10449 #[cfg(all(feature = "block2", feature = "objc2-security"))]
10450 /// The caller can implement this optional protocol method to provide the identity
10451 /// and an optional certificate chain to be used for authentication.
10452 ///
10453 /// Parameter `connection`: The connection sending this message
10454 ///
10455 /// Parameter `completion`: The completion handler for passing identity and certificate chain to the connection.
10456 /// The "identity" argument is required and must not be nil. The "certificateChain" argument is optional,
10457 /// and is an array of one or more SecCertificateRef objects. The certificate chain must contain objects
10458 /// of type SecCertificateRef only. If the certificate chain is set, it will be used. Otherwise, the leaf
10459 /// certificate will be extracted from the SecIdentityRef object and will be used for authentication.
10460 ///
10461 /// The caller is responsible for keeping the argument object(s) alive for the duration of the
10462 /// completion handler invocation.
10463 #[deprecated = "Use `sec_protocol_options_set_challenge_block` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10464 #[optional]
10465 #[unsafe(method(provideIdentityForConnection:completionHandler:))]
10466 #[unsafe(method_family = none)]
10467 unsafe fn provideIdentityForConnection_completionHandler(
10468 &self,
10469 connection: &NWTCPConnection,
10470 completion: &block2::DynBlock<
10471 dyn Fn(NonNull<SecIdentity>, NonNull<NSArray<AnyObject>>),
10472 >,
10473 );
10474
10475 /// The caller can implement this optional protocol method to decide whether it
10476 /// wants to take over the default trust evaluation for this connection. If this delegate method
10477 /// is not implemented, the return value will default to YES if
10478 /// provideIdentityForConnection:completionHandler: is implemented.
10479 ///
10480 /// Parameter `connection`: The connection sending this message
10481 ///
10482 /// Returns: YES to take over the default trust evaluation, in which case, the delegate method
10483 /// evaluateTrustForConnection:peerCertificateChain:completionHandler: will be called.
10484 #[deprecated = "Use `sec_protocol_options_set_verify_block` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10485 #[optional]
10486 #[unsafe(method(shouldEvaluateTrustForConnection:))]
10487 #[unsafe(method_family = none)]
10488 unsafe fn shouldEvaluateTrustForConnection(&self, connection: &NWTCPConnection) -> bool;
10489
10490 #[cfg(all(feature = "block2", feature = "objc2-security"))]
10491 /// The caller can implement this optional protocol method to set up custom policies
10492 /// for peer certificate trust evaluation. If the delegate method is implemented, the caller
10493 /// is responsible for creating and setting up the SecTrustRef object and passing it to the
10494 /// completion handler. Otherwise, the default trust evaluation policy is used for the connection.
10495 ///
10496 /// Parameter `connection`: The connection sending this message
10497 ///
10498 /// Parameter `peerCertificateChain`: The peer certificate chain
10499 ///
10500 /// Parameter `completion`: The completion handler for passing the SecTrustRef object to the connection.
10501 /// The SecTrustRef object "trust" is required and must not be nil. It will be evaluated using
10502 /// SecTrustEvaluate() if necessary. The caller is responsible for keeping the argument object
10503 /// alive for the duration of the completion handler invocation.
10504 ///
10505 /// # Safety
10506 ///
10507 /// `peer_certificate_chain` generic should be of the correct type.
10508 #[deprecated = "Use `sec_protocol_options_set_verify_block` in Network framework instead, see deprecation notice in <NetworkExtension/NWTCPConnection.h>"]
10509 #[optional]
10510 #[unsafe(method(evaluateTrustForConnection:peerCertificateChain:completionHandler:))]
10511 #[unsafe(method_family = none)]
10512 unsafe fn evaluateTrustForConnection_peerCertificateChain_completionHandler(
10513 &self,
10514 connection: &NWTCPConnection,
10515 peer_certificate_chain: &NSArray<AnyObject>,
10516 completion: &block2::DynBlock<dyn Fn(NonNull<SecTrust>)>,
10517 );
10518 }
10519);
10520
10521/// UDP session state values
10522///
10523/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nwudpsessionstate?language=objc)
10524// NS_ENUM
10525#[deprecated = "Use `nw_connection_state_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10526#[repr(transparent)]
10527#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
10528pub struct NWUDPSessionState(pub NSInteger);
10529impl NWUDPSessionState {
10530 #[doc(alias = "NWUDPSessionStateInvalid")]
10531 #[deprecated = "Use `nw_connection_state_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10532 pub const Invalid: Self = Self(0);
10533 /// attempting to make the session ready.
10534 #[doc(alias = "NWUDPSessionStateWaiting")]
10535 #[deprecated = "Use `nw_connection_state_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10536 pub const Waiting: Self = Self(1);
10537 #[doc(alias = "NWUDPSessionStatePreparing")]
10538 #[deprecated = "Use `nw_connection_state_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10539 pub const Preparing: Self = Self(2);
10540 #[doc(alias = "NWUDPSessionStateReady")]
10541 #[deprecated = "Use `nw_connection_state_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10542 pub const Ready: Self = Self(3);
10543 /// at this time, either due to problems with the path or the client rejecting the
10544 /// endpoints.
10545 #[doc(alias = "NWUDPSessionStateFailed")]
10546 #[deprecated = "Use `nw_connection_state_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10547 pub const Failed: Self = Self(4);
10548 #[doc(alias = "NWUDPSessionStateCancelled")]
10549 #[deprecated = "Use `nw_connection_state_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10550 pub const Cancelled: Self = Self(5);
10551}
10552
10553unsafe impl Encode for NWUDPSessionState {
10554 const ENCODING: Encoding = NSInteger::ENCODING;
10555}
10556
10557unsafe impl RefEncode for NWUDPSessionState {
10558 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
10559}
10560
10561extern_class!(
10562 /// Open UDP datagram sessions to an endpoint, and send and receive datagrams.
10563 ///
10564 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nwudpsession?language=objc)
10565 #[unsafe(super(NSObject))]
10566 #[derive(Debug, PartialEq, Eq, Hash)]
10567 #[deprecated = "Use `nw_connection_t` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10568 pub struct NWUDPSession;
10569);
10570
10571extern_conformance!(
10572 unsafe impl NSObjectProtocol for NWUDPSession {}
10573);
10574
10575impl NWUDPSession {
10576 extern_methods!(
10577 /// This convenience initializer can be used to create a new session based on the
10578 /// original session's endpoint and parameters.
10579 ///
10580 /// The application should create an NWUDPSession and watch the "hasBetterPath" property.
10581 /// When this property is YES, it should call initWithUpgradeForSession: to create a new
10582 /// session, with the goal to start transferring data on the new better path as soon as
10583 /// possible to reduce power and potentially monetary cost. When the new "upgrade" session
10584 /// becomes ready and when the application wraps up the previous application session on
10585 /// the original session, the application can start using the new "upgrade" session and
10586 /// tear down the original one.
10587 ///
10588 ///
10589 /// Parameter `session`: The original session from which the application will upgrade
10590 ///
10591 /// Returns: An initialized NWUDPSession object.
10592 #[deprecated = "Use `nw_connection_create` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10593 #[unsafe(method(initWithUpgradeForSession:))]
10594 #[unsafe(method_family = init)]
10595 pub unsafe fn initWithUpgradeForSession(
10596 this: Allocated<Self>,
10597 session: &NWUDPSession,
10598 ) -> Retained<Self>;
10599
10600 /// The current state of the UDP session. If the state is NWUDPSessionStateReady,
10601 /// then the connection is eligible for reading and writing. The state will be
10602 /// NWUDPSessionStateFailed if the endpoint could not be resolved, or all endpoints have been
10603 /// rejected. Use KVO to watch for changes.
10604 #[deprecated = "Use `nw_connection_set_state_changed_handler` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10605 #[unsafe(method(state))]
10606 #[unsafe(method_family = none)]
10607 pub unsafe fn state(&self) -> NWUDPSessionState;
10608
10609 /// The provided endpoint.
10610 #[deprecated = "Use `nw_connection_copy_endpoint` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10611 #[unsafe(method(endpoint))]
10612 #[unsafe(method_family = none)]
10613 pub unsafe fn endpoint(&self) -> Retained<NWEndpoint>;
10614
10615 /// The currently targeted remote endpoint. Use KVO to watch for changes.
10616 #[deprecated = "Use `nw_connection_copy_current_path` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10617 #[unsafe(method(resolvedEndpoint))]
10618 #[unsafe(method_family = none)]
10619 pub unsafe fn resolvedEndpoint(&self) -> Option<Retained<NWEndpoint>>;
10620
10621 /// YES if the connection can read and write data, NO otherwise.
10622 /// Use KVO to watch this property.
10623 #[deprecated = "Use `nw_connection_set_viability_changed_handler` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10624 #[unsafe(method(isViable))]
10625 #[unsafe(method_family = none)]
10626 pub unsafe fn isViable(&self) -> bool;
10627
10628 /// YES if there is another path available that is preferred over the currentPath.
10629 /// To take advantage of this path, create a new UDPSession. Use KVO to watch for changes.
10630 #[deprecated = "Use `nw_connection_set_better_path_available_handler` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10631 #[unsafe(method(hasBetterPath))]
10632 #[unsafe(method_family = none)]
10633 pub unsafe fn hasBetterPath(&self) -> bool;
10634
10635 /// The current evaluated path for the resolvedEndpoint. Use KVO to watch for changes.
10636 #[deprecated = "Use `nw_connection_copy_current_path` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10637 #[unsafe(method(currentPath))]
10638 #[unsafe(method_family = none)]
10639 pub unsafe fn currentPath(&self) -> Option<Retained<NWPath>>;
10640
10641 /// Mark the current value of resolvedEndpoint as unusable, and try to switch to the
10642 /// next available endpoint. This should be used when the caller has attempted to communicate
10643 /// with the current resolvedEndpoint, and the caller has determined that it is unusable. If
10644 /// there are no other resolved endpoints, the session will move to the failed state.
10645 #[deprecated = "Use `nw_connection_cancel_current_endpoint` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10646 #[unsafe(method(tryNextResolvedEndpoint))]
10647 #[unsafe(method_family = none)]
10648 pub unsafe fn tryNextResolvedEndpoint(&self);
10649
10650 /// The maximum size of a datagram to be written currently. If a datagram is written
10651 /// with a longer length, the datagram may be fragmented or encounter an error. Note that this
10652 /// value is not guaranteed to be the maximum datagram length for end-to-end communication
10653 /// across the network. Use KVO to watch for changes.
10654 #[deprecated = "Use `nw_connection_get_maximum_datagram_size` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10655 #[unsafe(method(maximumDatagramLength))]
10656 #[unsafe(method_family = none)]
10657 pub unsafe fn maximumDatagramLength(&self) -> NSUInteger;
10658
10659 #[cfg(feature = "block2")]
10660 /// Set a read handler for datagrams. Reads will be scheduled by the system, so this
10661 /// method only needs to be called once for a session.
10662 ///
10663 /// Parameter `handler`: A handler called when datagrams have been read, or when an error has occurred.
10664 ///
10665 /// Parameter `maxDatagrams`: The maximum number of datagrams to send to the handler.
10666 #[deprecated = "Use `nw_connection_receive` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10667 #[unsafe(method(setReadHandler:maxDatagrams:))]
10668 #[unsafe(method_family = none)]
10669 pub unsafe fn setReadHandler_maxDatagrams(
10670 &self,
10671 handler: &block2::DynBlock<dyn Fn(*mut NSArray<NSData>, *mut NSError)>,
10672 max_datagrams: NSUInteger,
10673 );
10674
10675 #[cfg(feature = "block2")]
10676 /// Write multiple datagrams. Callers should wait until the completionHandler is executed
10677 /// before issuing another write.
10678 ///
10679 /// Parameter `datagramArray`: An NSArray of NSData objects, containing the ordered list datagrams to write.
10680 ///
10681 /// Parameter `completionHandler`: A handler called when the write request has either succeeded or failed.
10682 #[deprecated = "Use `nw_connection_send` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10683 #[unsafe(method(writeMultipleDatagrams:completionHandler:))]
10684 #[unsafe(method_family = none)]
10685 pub unsafe fn writeMultipleDatagrams_completionHandler(
10686 &self,
10687 datagram_array: &NSArray<NSData>,
10688 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
10689 );
10690
10691 #[cfg(feature = "block2")]
10692 /// Write a single datagram. Callers should wait until the completionHandler is executed
10693 /// before issuing another write.
10694 ///
10695 /// Parameter `datagram`: An NSData containing the datagram to write.
10696 ///
10697 /// Parameter `completionHandler`: A handler called when the write request has either succeeded or failed.
10698 #[deprecated = "Use `nw_connection_send` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10699 #[unsafe(method(writeDatagram:completionHandler:))]
10700 #[unsafe(method_family = none)]
10701 pub unsafe fn writeDatagram_completionHandler(
10702 &self,
10703 datagram: &NSData,
10704 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
10705 );
10706
10707 /// Move into the NWUDPSessionStateCancelled state. The connection will be terminated,
10708 /// and all handlers will be cancelled.
10709 #[deprecated = "Use `nw_connection_cancel` in Network framework instead, see deprecation notice in <NetworkExtension/NWUDPSession.h>"]
10710 #[unsafe(method(cancel))]
10711 #[unsafe(method_family = none)]
10712 pub unsafe fn cancel(&self);
10713 );
10714}
10715
10716/// Methods declared on superclass `NSObject`.
10717impl NWUDPSession {
10718 extern_methods!(
10719 #[unsafe(method(init))]
10720 #[unsafe(method_family = init)]
10721 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
10722
10723 #[unsafe(method(new))]
10724 #[unsafe(method_family = new)]
10725 pub unsafe fn new() -> Retained<Self>;
10726 );
10727}
10728
10729extern_class!(
10730 /// DEPRECATION NOTICE
10731 ///
10732 /// NW object wrappers are hidden in Swift 6. To continue accessing them, you
10733 /// can prepend double underscores to the symbol name.
10734 ///
10735 /// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/nwtlsparameters?language=objc)
10736 #[unsafe(super(NSObject))]
10737 #[derive(Debug, PartialEq, Eq, Hash)]
10738 #[deprecated = "Use `sec_protocol_options_t` in Security framework instead, see deprecation notice in <NetworkExtension/NWTLSParameters.h>"]
10739 pub struct NWTLSParameters;
10740);
10741
10742extern_conformance!(
10743 unsafe impl NSObjectProtocol for NWTLSParameters {}
10744);
10745
10746impl NWTLSParameters {
10747 extern_methods!(
10748 /// The session ID for the associated connection, used for TLS session resumption.
10749 /// This property is optional when using TLS.
10750 #[deprecated = "Use `sec_protocol_options_set_tls_resumption_enabled` in Security framework instead, see deprecation notice in <NetworkExtension/NWTLSParameters.h>"]
10751 #[unsafe(method(TLSSessionID))]
10752 #[unsafe(method_family = none)]
10753 pub unsafe fn TLSSessionID(&self) -> Option<Retained<NSData>>;
10754
10755 /// Setter for [`TLSSessionID`][Self::TLSSessionID].
10756 ///
10757 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
10758 #[deprecated = "Use `sec_protocol_options_set_tls_resumption_enabled` in Security framework instead, see deprecation notice in <NetworkExtension/NWTLSParameters.h>"]
10759 #[unsafe(method(setTLSSessionID:))]
10760 #[unsafe(method_family = none)]
10761 pub unsafe fn setTLSSessionID(&self, tls_session_id: Option<&NSData>);
10762
10763 /// The set of allowed cipher suites, as defined in
10764 /// <Security
10765 /// /CipherSuite.h>.
10766 /// If set to nil, the default cipher suites will be used.
10767 #[deprecated = "Use `sec_protocol_options_append_tls_ciphersuite` in Security framework instead, see deprecation notice in <NetworkExtension/NWTLSParameters.h>"]
10768 #[unsafe(method(SSLCipherSuites))]
10769 #[unsafe(method_family = none)]
10770 pub unsafe fn SSLCipherSuites(&self) -> Option<Retained<NSSet<NSNumber>>>;
10771
10772 /// Setter for [`SSLCipherSuites`][Self::SSLCipherSuites].
10773 ///
10774 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
10775 #[deprecated = "Use `sec_protocol_options_append_tls_ciphersuite` in Security framework instead, see deprecation notice in <NetworkExtension/NWTLSParameters.h>"]
10776 #[unsafe(method(setSSLCipherSuites:))]
10777 #[unsafe(method_family = none)]
10778 pub unsafe fn setSSLCipherSuites(&self, ssl_cipher_suites: Option<&NSSet<NSNumber>>);
10779
10780 /// The minimum allowed SSLProtocol value. as defined in
10781 /// <Security
10782 /// /SecureTransport.h>.
10783 /// If set, the SSL handshake will not accept any protocol version older than the minimum.
10784 #[deprecated = "Use `sec_protocol_options_set_min_tls_protocol_version` in Security framework instead, see deprecation notice in <NetworkExtension/NWTLSParameters.h>"]
10785 #[unsafe(method(minimumSSLProtocolVersion))]
10786 #[unsafe(method_family = none)]
10787 pub unsafe fn minimumSSLProtocolVersion(&self) -> NSUInteger;
10788
10789 /// Setter for [`minimumSSLProtocolVersion`][Self::minimumSSLProtocolVersion].
10790 #[deprecated = "Use `sec_protocol_options_set_min_tls_protocol_version` in Security framework instead, see deprecation notice in <NetworkExtension/NWTLSParameters.h>"]
10791 #[unsafe(method(setMinimumSSLProtocolVersion:))]
10792 #[unsafe(method_family = none)]
10793 pub unsafe fn setMinimumSSLProtocolVersion(&self, minimum_ssl_protocol_version: NSUInteger);
10794
10795 /// The maximum allowed SSLProtocol value. as defined in
10796 /// <Security
10797 /// /SecureTransport.h>.
10798 /// If set, the SSL handshake will not accept any protocol version newer than the maximum.
10799 /// This property should be used with caution, since it may limit the use of preferred
10800 /// SSL protocols.
10801 #[deprecated = "Use `sec_protocol_options_set_max_tls_protocol_version` in Security framework instead, see deprecation notice in <NetworkExtension/NWTLSParameters.h>"]
10802 #[unsafe(method(maximumSSLProtocolVersion))]
10803 #[unsafe(method_family = none)]
10804 pub unsafe fn maximumSSLProtocolVersion(&self) -> NSUInteger;
10805
10806 /// Setter for [`maximumSSLProtocolVersion`][Self::maximumSSLProtocolVersion].
10807 #[deprecated = "Use `sec_protocol_options_set_max_tls_protocol_version` in Security framework instead, see deprecation notice in <NetworkExtension/NWTLSParameters.h>"]
10808 #[unsafe(method(setMaximumSSLProtocolVersion:))]
10809 #[unsafe(method_family = none)]
10810 pub unsafe fn setMaximumSSLProtocolVersion(&self, maximum_ssl_protocol_version: NSUInteger);
10811 );
10812}
10813
10814/// Methods declared on superclass `NSObject`.
10815impl NWTLSParameters {
10816 extern_methods!(
10817 #[unsafe(method(init))]
10818 #[unsafe(method_family = init)]
10819 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
10820
10821 #[unsafe(method(new))]
10822 #[unsafe(method_family = new)]
10823 pub unsafe fn new() -> Retained<Self>;
10824 );
10825}
10826
10827/// URL Filter Verdicts
10828///
10829/// See also [Apple's documentation](https://developer.apple.com/documentation/networkextension/neurlfilterverdict?language=objc)
10830// NS_ENUM
10831#[repr(transparent)]
10832#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
10833pub struct NEURLFilterVerdict(pub NSInteger);
10834impl NEURLFilterVerdict {
10835 #[doc(alias = "NEURLFilterVerdictUnknown")]
10836 pub const Unknown: Self = Self(1);
10837 #[doc(alias = "NEURLFilterVerdictAllow")]
10838 pub const Allow: Self = Self(2);
10839 #[doc(alias = "NEURLFilterVerdictDeny")]
10840 pub const Deny: Self = Self(3);
10841}
10842
10843unsafe impl Encode for NEURLFilterVerdict {
10844 const ENCODING: Encoding = NSInteger::ENCODING;
10845}
10846
10847unsafe impl RefEncode for NEURLFilterVerdict {
10848 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
10849}
10850
10851extern_class!(
10852 /// [Apple's documentation](https://developer.apple.com/documentation/networkextension/neurlfilter?language=objc)
10853 #[unsafe(super(NSObject))]
10854 #[derive(Debug, PartialEq, Eq, Hash)]
10855 pub struct NEURLFilter;
10856);
10857
10858extern_conformance!(
10859 unsafe impl NSObjectProtocol for NEURLFilter {}
10860);
10861
10862impl NEURLFilter {
10863 extern_methods!(
10864 #[cfg(feature = "block2")]
10865 /// This method determines if the specified URL should be allowed or denied. The returned Allow or Deny verdict should be honored to prevent
10866 /// communication with restricted or malicious Internet sites.
10867 /// - Parameters:
10868 /// - url: url to be validated
10869 /// - completionHandler: A block that will be called when validation is completed. A NEURLFilterVerdict verdict will be returned to indicate
10870 /// whether the specified URL should be allowed or denied. If verdict is Deny, caller should fail the URL request.
10871 #[unsafe(method(verdictForURL:completionHandler:))]
10872 #[unsafe(method_family = none)]
10873 pub unsafe fn verdictForURL_completionHandler(
10874 url: &NSURL,
10875 completion_handler: &block2::DynBlock<dyn Fn(NEURLFilterVerdict)>,
10876 );
10877
10878 #[unsafe(method(init))]
10879 #[unsafe(method_family = init)]
10880 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
10881 );
10882}
10883
10884/// Methods declared on superclass `NSObject`.
10885impl NEURLFilter {
10886 extern_methods!(
10887 #[unsafe(method(new))]
10888 #[unsafe(method_family = new)]
10889 pub unsafe fn new() -> Retained<Self>;
10890 );
10891}