Struct SCNetworkInterface

Source
#[repr(C)]
pub struct SCNetworkInterface { /* private fields */ }
Available on crate feature SCNetworkConfiguration only.
Expand description

This is the type of a reference to an object that represents a network interface.

See also Apple’s documentation

Implementations§

Source§

impl SCNetworkInterface

Source

pub fn all() -> CFRetained<CFArray>

Returns all network capable interfaces on the system.

Returns: The list of interfaces on the system. You must release the returned value.

Source

pub fn supported_interface_types( self: &SCNetworkInterface, ) -> Option<CFRetained<CFArray>>

Identify all of the network interface types (e.g. PPP) that can be layered on top of this interface.

Parameter interface: The network interface.

Returns: The list of SCNetworkInterface types supported by the interface; NULL if no interface types are supported.

Source

pub fn supported_protocol_types( self: &SCNetworkInterface, ) -> Option<CFRetained<CFArray>>

Identify all of the network protocol types (e.g. IPv4, IPv6) that can be layered on top of this interface.

Parameter interface: The network interface.

Returns: The list of SCNetworkProtocol types supported by the interface; NULL if no protocol types are supported.

Source

pub fn with_interface( self: &SCNetworkInterface, interface_type: &CFString, ) -> Option<CFRetained<SCNetworkInterface>>

Create a new network interface layered on top of another. For example, this function would be used to create a “PPP” interface on top of a “modem”.

Parameter interface: The network interface.

Parameter interfaceType: The type of SCNetworkInterface to be layered on top of the provided interface.

Returns: A reference to the new SCNetworkInterface. You must release the returned value.

Source

pub fn bsd_name(self: &SCNetworkInterface) -> Option<CFRetained<CFString>>

Returns the BSD interface (en0) or device name (modem) for the interface.

Parameter interface: The network interface.

Returns: The BSD name associated with the interface (e.g. “en0”); NULL if no BSD name is available.

Source

pub fn configuration( self: &SCNetworkInterface, ) -> Option<CFRetained<CFDictionary>>

Returns the configuration settings associated with a interface.

Parameter interface: The network interface.

Returns: The configuration settings associated with the interface; NULL if no configuration settings are associated with the interface or an error was encountered.

Source

pub fn extended_configuration( self: &SCNetworkInterface, extended_type: &CFString, ) -> Option<CFRetained<CFDictionary>>

Returns the configuration settings associated with a interface.

Parameter interface: The network interface.

Parameter extendedType: A string representing the type of extended information (e.g. EAPOL).

Returns: The configuration settings associated with the interface; NULL if no configuration settings are associated with the interface or an error was encountered.

Source

pub fn hardware_address_string( self: &SCNetworkInterface, ) -> Option<CFRetained<CFString>>

Returns a displayable link layer address for the interface.

Parameter interface: The network interface.

Returns: A string representing the hardware (MAC) address for the interface.

Source

pub fn interface( self: &SCNetworkInterface, ) -> Option<CFRetained<SCNetworkInterface>>

For layered network interfaces, return the underlying interface.

Parameter interface: The network interface.

Returns: The underlying network interface; NULL if this is a leaf interface.

Source

pub fn interface_type(self: &SCNetworkInterface) -> Option<CFRetained<CFString>>

Returns the associated network interface type.

Parameter interface: The network interface.

Returns: The interface type.

Source

pub fn localized_display_name( self: &SCNetworkInterface, ) -> Option<CFRetained<CFString>>

Returns the localized name (e.g. “Ethernet”, “FireWire”) for the interface.

Parameter interface: The network interface.

Returns: A localized, display name for the interface; NULL if no name is available.

Source

pub unsafe fn set_configuration( self: &SCNetworkInterface, config: Option<&CFDictionary>, ) -> bool

Stores the configuration settings for the interface.

Parameter interface: The network interface.

Parameter config: The configuration settings to associate with this interface.

Returns: TRUE if the configuration was stored; FALSE if an error was encountered.

Source

pub unsafe fn set_extended_configuration( self: &SCNetworkInterface, extended_type: &CFString, config: Option<&CFDictionary>, ) -> bool

Stores the configuration settings for the interface.

Parameter interface: The network interface.

Parameter config: The configuration settings to associate with this interface.

Returns: TRUE if the configuration was stored; FALSE if an error was encountered.

Source

pub unsafe fn media_options( self: &SCNetworkInterface, current: *mut *const CFDictionary, active: *mut *const CFDictionary, available: *mut *const CFArray, filter: bool, ) -> bool

For the specified network interface, returns information about the currently requested media options, the active media options, and the media options which are available.

Parameter interface: The desired network interface.

Parameter current: A pointer to memory that will be filled with a CFDictionaryRef representing the currently requested media options (subtype, options). If NULL, the current options will not be returned.

Parameter active: A pointer to memory that will be filled with a CFDictionaryRef representing the active media options (subtype, options). If NULL, the active options will not be returned.

Parameter available: A pointer to memory that will be filled with a CFArrayRef representing the possible media options (subtype, options). If NULL, the available options will not be returned.

Parameter filter: A boolean indicating whether the available options should be filtered to exclude those options which would not normally be requested by a user/admin (e.g. hw-loopback).

Returns: TRUE if requested information has been returned.

Source

pub fn media_sub_types(available: &CFArray) -> Option<CFRetained<CFArray>>

For the provided interface configuration options, return a list of available media subtypes.

Parameter available: The available options as returned by the SCNetworkInterfaceCopyMediaOptions function.

Returns: An array of available media subtypes CFString’s (e.g. 10BaseT/UTP, 100baseTX, etc). NULL if no subtypes are available.

Source

pub fn media_sub_type_options( available: &CFArray, sub_type: &CFString, ) -> Option<CFRetained<CFArray>>

For the provided interface configuration options and specific subtype, return a list of available media options.

Parameter available: The available options as returned by the SCNetworkInterfaceCopyMediaOptions function.

Parameter subType: The subtype

Returns: An array of available media options. Each of the available options is returned as an array of CFString’s (e.g. <half -duplex>, <full -duplex,flow-control>). NULL if no options are available.

Source

pub unsafe fn mtu( self: &SCNetworkInterface, mtu_cur: *mut c_int, mtu_min: *mut c_int, mtu_max: *mut c_int, ) -> bool

For the specified network interface, returns information about the currently MTU setting and the range of allowable values.

Parameter interface: The desired network interface.

Parameter mtu_cur: A pointer to memory that will be filled with the current MTU setting for the interface.

Parameter mtu_min: A pointer to memory that will be filled with the minimum MTU setting for the interface. If negative, the minimum setting could not be determined.

Parameter mtu_max: A pointer to memory that will be filled with the maximum MTU setting for the interface. If negative, the maximum setting could not be determined.

Returns: TRUE if requested information has been returned.

Source

pub fn set_media_options( self: &SCNetworkInterface, subtype: Option<&CFString>, options: Option<&CFArray>, ) -> bool

For the specified network interface, sets the requested media subtype and options.

Parameter interface: The desired network interface.

Parameter subtype: The desired media subtype (e.g. “autoselect”, “100baseTX”, …). If NULL, no specific media subtype will be requested.

Parameter options: The desired media options (e.g. “half-duplex”, “full-duplex”, …). If NULL, no specific media options will be requested.

Returns: TRUE if the configuration was updated; FALSE if an error was encountered.

Source

pub fn set_mtu(self: &SCNetworkInterface, mtu: c_int) -> bool

For the specified network interface, sets the requested MTU setting.

Parameter interface: The desired network interface.

Parameter mtu: The desired MTU setting for the interface. If zero, the interface will use the default MTU setting.

Returns: TRUE if the configuration was updated; FALSE if an error was encountered.

Source

pub fn force_configuration_refresh(self: &SCNetworkInterface) -> bool

Sends a notification to interested network configuration agents to immediately retry their configuration. For example, calling this function will cause the DHCP client to contact the DHCP server immediately rather than waiting until its timeout has expired. The utility of this function is to allow the caller to give a hint to the system that the network infrastructure or configuration has changed.

Note: This function requires root (euid==0) privilege or, alternatively, you may pass an SCNetworkInterface which is derived from a sequence of calls to :

SCPreferencesCreateWithAuthorization SCNetworkSetCopy… SCNetworkServiceGetInterface

Parameter interface: The desired network interface.

Returns: Returns TRUE if the notification was sent; FALSE otherwise.

Methods from Deref<Target = CFType>§

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: ConcreteType,

Attempt to downcast the type to that of type T.

This is the reference-variant. Use CFRetained::downcast if you want to convert a retained type. See also ConcreteType for more details on which types support being converted to.

Source

pub fn retain_count(&self) -> usize

Get the reference count of the object.

This function may be useful for debugging. You normally do not use this function otherwise.

Beware that some things (like CFNumbers, small CFStrings etc.) may not have a normal retain count for optimization purposes, and can return usize::MAX in that case.

Trait Implementations§

Source§

impl AsRef<AnyObject> for SCNetworkInterface

Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<CFType> for SCNetworkInterface

Source§

fn as_ref(&self) -> &CFType

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<SCNetworkInterface> for SCNetworkInterface

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<AnyObject> for SCNetworkInterface

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<CFType> for SCNetworkInterface

Source§

fn borrow(&self) -> &CFType

Immutably borrows from an owned value. Read more
Source§

impl ConcreteType for SCNetworkInterface

Source§

fn type_id() -> CFTypeID

Returns the type identifier of all SCNetworkInterface instances.

Source§

impl Debug for SCNetworkInterface

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for SCNetworkInterface

Source§

type Target = CFType

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Hash for SCNetworkInterface

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for SCNetworkInterface

Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl PartialEq for SCNetworkInterface

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for SCNetworkInterface

Source§

const ENCODING_REF: Encoding

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl Type for SCNetworkInterface

Source§

fn retain(&self) -> CFRetained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

fn as_concrete_TypeRef(&self) -> &Self

👎Deprecated: this is redundant
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::retain
Helper for easier transition from the core-foundation crate. Read more
Source§

fn as_CFTypeRef(&self) -> &CFType
where Self: AsRef<CFType>,

👎Deprecated: this is redundant (CF types deref to CFType)
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::from_raw
Helper for easier transition from the core-foundation crate. Read more
Source§

impl Eq for SCNetworkInterface

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,