objc2_core_wlan/generated/
CWInterface.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7#[cfg(feature = "objc2-security")]
8use objc2_security::*;
9
10use crate::*;
11
12extern_class!(
13    /// Control and query a Wi-Fi interface on OS X.
14    ///
15    ///
16    /// All actions performed by a CWInterface object are executed on the Wi-Fi device with the corresponding interface name.
17    ///
18    /// See also [Apple's documentation](https://developer.apple.com/documentation/corewlan/cwinterface?language=objc)
19    #[unsafe(super(NSObject))]
20    #[derive(Debug, PartialEq, Eq, Hash)]
21    pub struct CWInterface;
22);
23
24extern_conformance!(
25    unsafe impl NSObjectProtocol for CWInterface {}
26);
27
28impl CWInterface {
29    extern_methods!(
30        /// Returns the BSD name of the Wi-Fi interface (e.g. "en0").
31        #[unsafe(method(interfaceName))]
32        #[unsafe(method_family = none)]
33        pub unsafe fn interfaceName(&self) -> Option<Retained<NSString>>;
34
35        /// Returns: YES if the Wi-Fi interface is on, NO otherwise.
36        ///
37        ///
38        /// Indicates the Wi-Fi interface power state.
39        ///
40        ///
41        /// Returns NO if an error occurs.
42        #[unsafe(method(powerOn))]
43        #[unsafe(method_family = none)]
44        pub unsafe fn powerOn(&self) -> bool;
45
46        #[cfg(feature = "CWChannel")]
47        /// Returns: An NSSet of CWChannel objects.
48        ///
49        ///
50        /// Returns the set of channels supported by the Wi-Fi interface for the currently adopted country code.
51        ///
52        ///
53        /// Returns nil if an error occurs.
54        #[unsafe(method(supportedWLANChannels))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn supportedWLANChannels(&self) -> Option<Retained<NSSet<CWChannel>>>;
57
58        #[cfg(feature = "CWChannel")]
59        /// Returns the current channel of the Wi-Fi interface.
60        ///
61        ///
62        /// Returns nil if an error occurs.
63        #[unsafe(method(wlanChannel))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn wlanChannel(&self) -> Option<Retained<CWChannel>>;
66
67        #[cfg(feature = "CoreWLANTypes")]
68        /// Returns the currently active physical layer (PHY) mode of the Wi-Fi interface.
69        ///
70        ///
71        /// Returns kCWPHYModeNone if an error occurs.
72        #[unsafe(method(activePHYMode))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn activePHYMode(&self) -> CWPHYMode;
75
76        /// Returns the current service set identifier (SSID) of the Wi-Fi interface, encoded as a string.
77        ///
78        ///
79        /// Returns nil if an error occurs, or if the interface is not participating in a Wi-Fi network,
80        /// or if the SSID can not be encoded as a valid UTF-8 or WinLatin1 string.
81        ///
82        ///
83        /// Note: SSID information is not available unless Location Services is enabled and the user has authorized the calling app to use location services.
84        ///
85        ///
86        /// See also: CLLocationManager
87        #[unsafe(method(ssid))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn ssid(&self) -> Option<Retained<NSString>>;
90
91        /// Returns the current service set identifier (SSID) for the interface, encapsulated in an NSData object.
92        ///
93        ///
94        /// Returns nil if an error occurs, or if the interface is not participating in a Wi-Fi network.
95        ///
96        ///
97        /// Note: SSID information is not available unless Location Services is enabled and the user has authorized the calling app to use location services.
98        ///
99        ///
100        /// See also: CLLocationManager
101        #[unsafe(method(ssidData))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn ssidData(&self) -> Option<Retained<NSData>>;
104
105        /// Returns the current basic service set identifier (BSSID) of the Wi-Fi interface, returned as an UTF-8 string.
106        ///
107        ///
108        /// Returns a UTF-8 string using hexadecimal characters formatted as XX:XX:XX:XX:XX:XX.
109        /// Returns nil if an error occurred, or if the interface is not participating in a Wi-Fi network.
110        ///
111        ///
112        /// Note: BSSID information is not available unless Location Services is enabled and the user has authorized the calling app to use location services.
113        ///
114        ///
115        /// See also: CLLocationManager
116        #[unsafe(method(bssid))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn bssid(&self) -> Option<Retained<NSString>>;
119
120        /// Returns the current received signal strength indication (RSSI) measurement (dBm) for the Wi-Fi interface.
121        ///
122        ///
123        /// Returns 0 if an error occurs, or if the interface is not participating in a Wi-Fi network.
124        #[unsafe(method(rssiValue))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn rssiValue(&self) -> NSInteger;
127
128        /// Returns the current noise measurement (dBm) for the Wi-Fi interface.
129        ///
130        ///
131        /// Returns 0 if an error occurs, or if the interface is not participating in a Wi-Fi network.
132        #[unsafe(method(noiseMeasurement))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn noiseMeasurement(&self) -> NSInteger;
135
136        #[cfg(feature = "CoreWLANTypes")]
137        /// Returns the current security type of the Wi-Fi interface.
138        ///
139        ///
140        /// Returns kCWSecurityUnknown if an error occurs, or if the interface is not participating in a Wi-Fi network.
141        #[unsafe(method(security))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn security(&self) -> CWSecurity;
144
145        /// Returns the current transmit rate (Mbps) for the Wi-Fi interface.
146        ///
147        ///
148        /// Returns 0 if an error occurs, or if the interface is not participating in a Wi-Fi network.
149        #[unsafe(method(transmitRate))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn transmitRate(&self) -> c_double;
152
153        /// Returns the currently adopted country code (ISO/IEC 3166-1:1997) for the Wi-Fi interface.
154        ///
155        ///
156        /// Returns nil if an error occurs, or if the Wi-Fi interface is off.
157        ///
158        ///
159        /// Note: Country code information is not available unless Location Services is enabled and the user has authorized the calling app to use location services.
160        ///
161        ///
162        /// See also: CLLocationManager
163        #[unsafe(method(countryCode))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn countryCode(&self) -> Option<Retained<NSString>>;
166
167        #[cfg(feature = "CoreWLANTypes")]
168        /// Returns the current operating mode for the Wi-Fi interface.
169        ///
170        ///
171        /// Returns kCWInterfaceModeNone if an error occurs, or if the interface is not participating in a Wi-Fi network.
172        #[unsafe(method(interfaceMode))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn interfaceMode(&self) -> CWInterfaceMode;
175
176        /// Returns the current transmit power (mW) for the Wi-Fi interface.
177        ///
178        ///
179        /// Returns 0 if an error occurs.
180        #[unsafe(method(transmitPower))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn transmitPower(&self) -> NSInteger;
183
184        /// Returns the hardware media access control (MAC) address for the Wi-Fi interface, returned as an UTF-8 string.
185        ///
186        ///
187        /// The standard format for printing a MAC-48 address XX:XX:XX:XX:XX:XX is used to represent
188        /// the MAC address as a string.
189        /// Returns nil if an error occurs.
190        #[unsafe(method(hardwareAddress))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn hardwareAddress(&self) -> Option<Retained<NSString>>;
193
194        /// Returns: YES if the corresponding network service is active, NO otherwise.
195        ///
196        ///
197        /// Indicates the network service state of the Wi-Fi interface.
198        ///
199        ///
200        /// Returns NO if an error occurs.
201        #[unsafe(method(serviceActive))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn serviceActive(&self) -> bool;
204
205        #[cfg(feature = "CWNetwork")]
206        /// Returns: An NSSet of CWNetwork objects.
207        ///
208        ///
209        /// Returns the scan results currently in the scan cache for the Wi-Fi interface.
210        ///
211        ///
212        /// Returns nil if an error occurs.
213        #[unsafe(method(cachedScanResults))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn cachedScanResults(&self) -> Option<Retained<NSSet<CWNetwork>>>;
216
217        #[cfg(feature = "CWConfiguration")]
218        /// Returns the current configuration for the Wi-Fi interface.
219        ///
220        ///
221        /// Returns nil if an error occurs.
222        #[unsafe(method(configuration))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn configuration(&self) -> Option<Retained<CWConfiguration>>;
225
226        /// Returns: An NSSet of NSString objects.
227        ///
228        ///
229        /// Returns the list of available Wi-Fi interface names (e.g. "en0").
230        ///
231        ///
232        /// Returns an empty NSArray object if no Wi-Fi interfaces exist.
233        /// Returns nil if an error occurs.
234        #[deprecated = "Use -[CWWiFiClient interfaceNames] instead"]
235        #[unsafe(method(interfaceNames))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn interfaceNames() -> Option<Retained<NSSet<NSString>>>;
238
239        /// Convenience method for getting a CWInterface object for the default Wi-Fi interface.
240        #[deprecated = "Use -[CWWiFiClient interface] instead"]
241        #[unsafe(method(interface))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn interface() -> Retained<Self>;
244
245        /// Parameter `name`: The name of an available Wi-Fi interface.
246        ///
247        ///
248        /// Convenience method for getting a CWInterface object bound to the Wi-Fi interface with a specific interface name.
249        ///
250        ///
251        /// Use +[CWInterface interfaceNames] to get a list of available Wi-Fi interface names.
252        /// Returns a CWInterface object for the default Wi-Fi interface if no interface name is specified.
253        #[deprecated = "Use -[CWWiFiClient interfaceWithName:] instead"]
254        #[unsafe(method(interfaceWithName:))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn interfaceWithName(name: Option<&NSString>) -> Retained<Self>;
257
258        /// Parameter `name`: The name of an available Wi-Fi interface.
259        ///
260        ///
261        /// Initializes a CWInterface object, binding to the Wi-Fi interface with a specific interface name.
262        ///
263        ///
264        /// Use +[CWInterface interfaceNames] to get a list of available Wi-Fi interface names.
265        /// Returns a CWInterface object for the default Wi-Fi interface if no interface name is specified.
266        #[deprecated = "Use -[CWWiFiClient interfaceWithName:] instead"]
267        #[unsafe(method(initWithInterfaceName:))]
268        #[unsafe(method_family = init)]
269        pub unsafe fn initWithInterfaceName(
270            this: Allocated<Self>,
271            name: Option<&NSString>,
272        ) -> Retained<Self>;
273
274        /// Parameter `power`: A BOOL value indicating Wi-Fi power state. Specify YES to turn on the Wi-Fi interface.
275        ///
276        ///
277        /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
278        /// This parameter is optional.
279        ///
280        ///
281        /// Returns: Returns YES upon success, or NO if an error occurred.
282        ///
283        ///
284        /// Sets the Wi-Fi interface power state.
285        #[unsafe(method(setPower:error:_))]
286        #[unsafe(method_family = none)]
287        pub unsafe fn setPower_error(&self, power: bool) -> Result<(), Retained<NSError>>;
288
289        #[cfg(feature = "CWChannel")]
290        /// Parameter `channel`: A CWChannel object.
291        ///
292        ///
293        /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
294        /// This parameter is optional.
295        ///
296        ///
297        /// Returns: Returns YES upon success, or NO if an error occurred.
298        ///
299        ///
300        /// Sets the Wi-Fi interface channel.
301        ///
302        ///
303        /// Setting the channel while the interface is associated to a Wi-Fi network is not permitted.
304        #[unsafe(method(setWLANChannel:error:_))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn setWLANChannel_error(
307            &self,
308            channel: &CWChannel,
309        ) -> Result<(), Retained<NSError>>;
310
311        /// Parameter `key`: An NSData object containing the pairwise master key (PMK).
312        /// Passing nil clear the PMK for the Wi-Fi interface.
313        ///
314        ///
315        /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
316        /// This parameter is optional.
317        ///
318        ///
319        /// Returns: Returns YES upon success, or NO if an error occurred.
320        ///
321        ///
322        /// Sets the Wi-Fi interface pairwise master key (PMK).
323        ///
324        ///
325        /// The specified key must be exactly 32 octets.
326        #[unsafe(method(setPairwiseMasterKey:error:_))]
327        #[unsafe(method_family = none)]
328        pub unsafe fn setPairwiseMasterKey_error(
329            &self,
330            key: Option<&NSData>,
331        ) -> Result<(), Retained<NSError>>;
332
333        #[cfg(feature = "CoreWLANTypes")]
334        /// Parameter `key`: An NSData object containing the WEP key.
335        /// Passing nil clears the WEP key for the Wi-Fi interface.
336        ///
337        ///
338        /// Parameter `flags`: A bitmask indicating which CWCipherKeyFlags to use for the specified WEP key.
339        ///
340        ///
341        /// Parameter `index`: An NSInteger indicating which default key index (1-4) to use for the specified key.
342        ///
343        ///
344        /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
345        /// This parameter is optional.
346        ///
347        ///
348        /// Returns: Returns YES upon success, or NO if an error occurred.
349        ///
350        ///
351        /// Sets the Wi-Fi interface WEP key.
352        #[unsafe(method(setWEPKey:flags:index:error:_))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn setWEPKey_flags_index_error(
355            &self,
356            key: Option<&NSData>,
357            flags: CWCipherKeyFlags,
358            index: NSInteger,
359        ) -> Result<(), Retained<NSError>>;
360
361        #[cfg(feature = "CWNetwork")]
362        /// Parameter `ssid`: Probe request SSID.
363        /// Pass an SSID to perform a directed scan for hidden Wi-Fi networks.
364        /// This parameter is optional.
365        ///
366        ///
367        /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
368        /// This parameter is optional.
369        ///
370        ///
371        /// Returns: An NSSet of CWNetwork objects, or nil if an error occurs.
372        ///
373        ///
374        /// Performs a scan for Wi-Fi networks and returns scan results to the caller.
375        ///
376        ///
377        /// This method will block for the duration of the scan.
378        ///
379        ///
380        /// Note: Returned networks will not contain BSSID information unless Location Services is enabled and the user has authorized the calling app to use location services.
381        ///
382        ///
383        /// See also: CLLocationManager
384        #[unsafe(method(scanForNetworksWithSSID:error:_))]
385        #[unsafe(method_family = none)]
386        pub unsafe fn scanForNetworksWithSSID_error(
387            &self,
388            ssid: Option<&NSData>,
389        ) -> Result<Retained<NSSet<CWNetwork>>, Retained<NSError>>;
390
391        #[cfg(feature = "CWNetwork")]
392        /// Parameter `ssid`: Probe request SSID.
393        /// Pass an SSID to perform a directed scan for hidden Wi-Fi networks.
394        /// This parameter is optional.
395        ///
396        ///
397        /// Parameter `includeHidden`: Indicate whether or not hidden networks should not be filtered from the returned scan results.
398        ///
399        ///
400        /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
401        /// This parameter is optional.
402        ///
403        ///
404        /// Returns: An NSSet of CWNetwork objects, or nil if an error occurs.
405        ///
406        ///
407        /// Performs a scan for Wi-Fi networks and returns scan results to the caller.
408        ///
409        ///
410        /// This method will block for the duration of the scan.
411        ///
412        ///
413        /// Note: Returned networks will not contain BSSID information unless Location Services is enabled and the user has authorized the calling app to use location services.
414        ///
415        ///
416        /// See also: CLLocationManager
417        #[unsafe(method(scanForNetworksWithSSID:includeHidden:error:_))]
418        #[unsafe(method_family = none)]
419        pub unsafe fn scanForNetworksWithSSID_includeHidden_error(
420            &self,
421            ssid: Option<&NSData>,
422            include_hidden: bool,
423        ) -> Result<Retained<NSSet<CWNetwork>>, Retained<NSError>>;
424
425        #[cfg(feature = "CWNetwork")]
426        /// Parameter `networkName`: Probe request SSID, encoded as an UTF-8 string.
427        /// Pass a networkName to perform a directed scan for hidden Wi-Fi networks.
428        /// This parameter is optional.
429        ///
430        ///
431        /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
432        /// This parameter is optional.
433        ///
434        ///
435        /// Returns: An NSSet of CWNetwork objects, or nil if an error occurs.
436        ///
437        ///
438        /// Performs a scan for Wi-Fi networks and returns scan results to the caller.
439        ///
440        ///
441        /// This method will block for the duration of the scan.
442        ///
443        ///
444        /// Note: Returned networks will not contain BSSID information unless Location Services is enabled and the user has authorized the calling app to use location services.
445        ///
446        ///
447        /// See also: CLLocationManager
448        #[unsafe(method(scanForNetworksWithName:error:_))]
449        #[unsafe(method_family = none)]
450        pub unsafe fn scanForNetworksWithName_error(
451            &self,
452            network_name: Option<&NSString>,
453        ) -> Result<Retained<NSSet<CWNetwork>>, Retained<NSError>>;
454
455        #[cfg(feature = "CWNetwork")]
456        /// Parameter `networkName`: Probe request SSID, encoded as an UTF-8 string.
457        /// Pass a networkName to perform a directed scan for hidden Wi-Fi networks.
458        /// This parameter is optional.
459        ///
460        ///
461        /// Parameter `includeHidden`: Indicate whether or not hidden networks should not be filtered from the returned scan results.
462        ///
463        ///
464        /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
465        /// This parameter is optional.
466        ///
467        ///
468        /// Returns: An NSSet of CWNetwork objects, or nil if an error occurs.
469        ///
470        ///
471        /// Performs a scan for Wi-Fi networks and returns scan results to the caller.
472        ///
473        ///
474        /// This method will block for the duration of the scan.
475        ///
476        ///
477        /// Note: Returned networks will not contain BSSID information unless Location Services is enabled and the user has authorized the calling app to use location services.
478        ///
479        ///
480        /// See also: CLLocationManager
481        #[unsafe(method(scanForNetworksWithName:includeHidden:error:_))]
482        #[unsafe(method_family = none)]
483        pub unsafe fn scanForNetworksWithName_includeHidden_error(
484            &self,
485            network_name: Option<&NSString>,
486            include_hidden: bool,
487        ) -> Result<Retained<NSSet<CWNetwork>>, Retained<NSError>>;
488
489        #[cfg(feature = "CWNetwork")]
490        /// Parameter `network`: The network to which the Wi-Fi interface will associate.
491        ///
492        ///
493        /// Parameter `password`: The network passphrase or key. Required for association to WEP, WPA Personal, and WPA2 Personal networks.
494        ///
495        ///
496        /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
497        /// This parameter is optional.
498        ///
499        ///
500        /// Returns: Returns YES upon success, or NO if an error occurred.
501        ///
502        ///
503        /// Associates to a W-Fi network using the specified passphrase.
504        ///
505        ///
506        /// This method will block for the duration of the association.
507        #[unsafe(method(associateToNetwork:password:error:_))]
508        #[unsafe(method_family = none)]
509        pub unsafe fn associateToNetwork_password_error(
510            &self,
511            network: &CWNetwork,
512            password: Option<&NSString>,
513        ) -> Result<(), Retained<NSError>>;
514
515        /// Disassociates from the current Wi-Fi network.
516        #[unsafe(method(disassociate))]
517        #[unsafe(method_family = none)]
518        pub unsafe fn disassociate(&self);
519
520        #[cfg(all(feature = "CWNetwork", feature = "objc2-security"))]
521        /// Parameter `network`: The network to which the Wi-Fi interface will associate.
522        ///
523        ///
524        /// Parameter `username`: The username to use for 802.1X authentication.
525        ///
526        ///
527        /// Parameter `password`: The password to use for 802.1X authentication.
528        ///
529        ///
530        /// Parameter `identity`: The identity to use for IEEE 802.1X authentication. Holds the corresponding client certificate.
531        ///
532        ///
533        /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
534        /// This parameter is optional.
535        ///
536        ///
537        /// Returns: Returns YES upon success, or NO if an error occurred.
538        ///
539        ///
540        /// Associates to an enterprise W-Fi network using the specified 802.1X credentials.
541        ///
542        ///
543        /// This method will block for the duration of the association.
544        #[unsafe(method(associateToEnterpriseNetwork:identity:username:password:error:_))]
545        #[unsafe(method_family = none)]
546        pub unsafe fn associateToEnterpriseNetwork_identity_username_password_error(
547            &self,
548            network: &CWNetwork,
549            identity: Option<&SecIdentity>,
550            username: Option<&NSString>,
551            password: Option<&NSString>,
552        ) -> Result<(), Retained<NSError>>;
553
554        #[cfg(feature = "CoreWLANTypes")]
555        /// Parameter `ssidData`: The SSID to use for the IBSS network.
556        /// Pass nil to use the machine name as the IBSS network name.
557        ///
558        ///
559        /// Parameter `security`: The CWIBSSModeSecurity type.
560        ///
561        ///
562        /// Parameter `channel`: The channel on which the IBSS network will be created.
563        ///
564        ///
565        /// Parameter `password`: The password to be used. This paramter is required for kCWIBSSModeSecurityWEP40 or kCWIBSSModeSecurityWEP104 security types.
566        ///
567        ///
568        /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
569        /// This parameter is optional.
570        ///
571        ///
572        /// Returns: Returns YES upon success, or NO if an error occurred.
573        ///
574        ///
575        /// Creates a computer-to-computer (IBSS) network.
576        #[deprecated]
577        #[unsafe(method(startIBSSModeWithSSID:security:channel:password:error:_))]
578        #[unsafe(method_family = none)]
579        pub unsafe fn startIBSSModeWithSSID_security_channel_password_error(
580            &self,
581            ssid_data: &NSData,
582            security: CWIBSSModeSecurity,
583            channel: NSUInteger,
584            password: Option<&NSString>,
585        ) -> Result<(), Retained<NSError>>;
586    );
587}
588
589/// Methods declared on superclass `NSObject`.
590impl CWInterface {
591    extern_methods!(
592        #[unsafe(method(init))]
593        #[unsafe(method_family = init)]
594        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
595
596        #[unsafe(method(new))]
597        #[unsafe(method_family = new)]
598        pub unsafe fn new() -> Retained<Self>;
599    );
600}