Skip to content

Commit

Permalink
Update bindings and move private Bridge and deprecated IrDA interface…
Browse files Browse the repository at this point in the history
… types into separate string constants
  • Loading branch information
Andrej Mihajlov authored and dlon committed Dec 27, 2023
1 parent 3367a6f commit 3f2dcab
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 91 deletions.
86 changes: 42 additions & 44 deletions generate_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ BINDGEN_COMMON_ARGUMENTS=(
echo "Generating bindings for $PREFERENCES_HEADER_PATH"
bindgen \
"${BINDGEN_COMMON_ARGUMENTS[@]}" \
--whitelist-function "SCPreferences.*" \
--blacklist-type "(__)?CF.*" \
--blacklist-type "Boolean" \
--blacklist-type "dispatch_queue_[ts]" \
--blacklist-type "(AuthorizationOpaqueRef|__SCPreferences)" \
--allowlist-function "SCPreferences.*" \
--blocklist-type "(__)?CF.*" \
--blocklist-type "Boolean" \
--blocklist-type "dispatch_queue_[ts]" \
--blocklist-type "(AuthorizationOpaqueRef|__SCPreferences)" \
--raw-line "use core::ffi::c_void;" \
--raw-line "use core_foundation_sys::array::CFArrayRef;" \
--raw-line "use core_foundation_sys::base::{Boolean, CFIndex, CFAllocatorRef, CFTypeID};" \
Expand All @@ -116,11 +116,11 @@ echo "Generating bindings for $DYNAMIC_STORE_HEADER_PATH"

bindgen \
"${BINDGEN_COMMON_ARGUMENTS[@]}" \
--whitelist-function "SCDynamicStore.*" \
--whitelist-var "kSCDynamicStore.*" \
--blacklist-type "(__)?CF.*" \
--blacklist-type "Boolean" \
--blacklist-type "dispatch_queue_[ts]" \
--allowlist-function "SCDynamicStore.*" \
--allowlist-var "kSCDynamicStore.*" \
--blocklist-type "(__)?CF.*" \
--blocklist-type "Boolean" \
--blocklist-type "dispatch_queue_[ts]" \
--raw-line "use core::ffi::c_void;" \
--raw-line "use core_foundation_sys::array::CFArrayRef;" \
--raw-line "use core_foundation_sys::base::{Boolean, CFIndex, CFAllocatorRef, CFTypeID};" \
Expand All @@ -143,16 +143,14 @@ echo "Generating bindings for $DYNAMIC_STORE_COPY_SPECIFIC_HEADER_PATH"

bindgen \
"${BINDGEN_COMMON_ARGUMENTS[@]}" \
--whitelist-function "SCDynamicStoreCopy(ComputerName|ConsoleUser|LocalHostName|Location|Proxies)" \
--blacklist-type "(__)?CF.*" \
--blacklist-type "Boolean" \
--blacklist-type "dispatch_queue_[ts]" \
--blacklist-type "(__)?SCDynamicStore.*" \
--allowlist-function "SCDynamicStoreCopy(ComputerName|ConsoleUser|LocalHostName|Location|Proxies)" \
--blocklist-type "(__)?CF.*" \
--blocklist-type "Boolean" \
--blocklist-type "dispatch_queue_[ts]" \
--blocklist-type "(__)?SCDynamicStore.*" \
--raw-line "use core_foundation_sys::string::{CFStringEncoding, CFStringRef};" \
--raw-line "use core_foundation_sys::dictionary::CFDictionaryRef;" \
--raw-line "use crate::dynamic_store::SCDynamicStoreRef;" \
--raw-line "" \
--raw-line "use libc::c_uint;" \
-o $DYNAMIC_STORE_COPY_SPECIFIC_BINDING_PATH \
$DYNAMIC_STORE_COPY_SPECIFIC_HEADER_PATH -- \
-I$SDK_PATH/usr/include \
Expand All @@ -166,17 +164,17 @@ echo "Generating bindings for $NETWORK_CONFIGURATION_HEADER_PATH"

bindgen \
"${BINDGEN_COMMON_ARGUMENTS[@]}" \
--whitelist-function "SCNetwork.*" \
--whitelist-function "SCBondInterface.*" \
--whitelist-var "kSC(NetworkInterface|BondStatus).*" \
--blacklist-type "SCNetworkReachability.*" \
--blacklist-function "SCNetworkReachability.*" \
--blacklist-type "dispatch_queue_[ts]" \
--blacklist-type "(__)?CF.*" \
--blacklist-type "__SC.*" \
--blacklist-type "Boolean" \
--blacklist-type "(sockaddr|socklen_t|sa_family_t|__darwin_socklen_t|__uint.*_t)" \
--blacklist-type "(__)?SCPreferences.*" \
--allowlist-function "SCNetwork.*" \
--allowlist-function "SCBondInterface.*" \
--allowlist-var "kSC(NetworkInterface|BondStatus).*" \
--blocklist-type "SCNetworkReachability.*" \
--blocklist-function "SCNetworkReachability.*" \
--blocklist-type "dispatch_queue_[ts]" \
--blocklist-type "(__)?CF.*" \
--blocklist-type "__SC.*" \
--blocklist-type "Boolean" \
--blocklist-type "(sockaddr|socklen_t|sa_family_t|__darwin_socklen_t|__uint.*_t)" \
--blocklist-type "(__)?SCPreferences.*" \
--raw-line "use core::ffi::c_void;" \
--raw-line "use core_foundation_sys::array::CFArrayRef;" \
--raw-line "use core_foundation_sys::base::{Boolean, CFIndex, CFAllocatorRef, CFTypeID};" \
Expand All @@ -185,7 +183,7 @@ bindgen \
--raw-line "use core_foundation_sys::runloop::CFRunLoopRef;" \
--raw-line "" \
--raw-line "use crate::dispatch_queue_t;" \
--raw-line "use libc::{c_char, c_int, sockaddr, socklen_t};" \
--raw-line "use libc::{sockaddr, socklen_t};" \
--raw-line "use crate::preferences::SCPreferencesRef;" \
--raw-line "" \
--raw-line "pub type __SCNetworkConnection = c_void;" \
Expand All @@ -207,23 +205,23 @@ echo "Generating bindings for $NETWORK_REACHABILITY_HEADER_PATH"

bindgen \
"${BINDGEN_COMMON_ARGUMENTS[@]}" \
--whitelist-function "SCNetworkReachability.*" \
--whitelist-type "SCNetworkReachability.*" \
--whitelist-var "kSCNetworkReachability.*" \
--blacklist-type "sockaddr" \
--blacklist-type "dispatch_queue_[ts]" \
--blacklist-type "(__)?CF.*" \
--blacklist-type "__SC.*" \
--blacklist-type "Boolean" \
--blacklist-type "dispatch_.*" \
--blacklist-type "(sockaddr|socklen_t|sa_family_t|__darwin_socklen_t|__uint.*_t)" \
--allowlist-function "SCNetworkReachability.*" \
--allowlist-type "SCNetworkReachability.*" \
--allowlist-var "kSCNetworkReachability.*" \
--blocklist-type "sockaddr" \
--blocklist-type "dispatch_queue_[ts]" \
--blocklist-type "(__)?CF.*" \
--blocklist-type "__SC.*" \
--blocklist-type "Boolean" \
--blocklist-type "dispatch_.*" \
--blocklist-type "(sockaddr|socklen_t|sa_family_t|__darwin_socklen_t|__uint.*_t)" \
--raw-line '#![cfg_attr(feature = "cargo-clippy", allow(clippy::unreadable_literal))]' \
--raw-line "use core_foundation_sys::base::{Boolean, CFAllocatorRef, CFTypeID, CFIndex};" \
--raw-line "use core_foundation_sys::string::CFStringRef;" \
--raw-line "use core_foundation_sys::runloop::CFRunLoopRef;" \
--raw-line "use libc::{c_char, sockaddr, c_void};" \
--raw-line "use libc::sockaddr;" \
--raw-line "use crate::dispatch_queue_t;" \
--raw-line "pub type __SCNetworkReachability = c_void;" \
--raw-line "pub type __SCNetworkReachability = ::core::ffi::c_void;" \
-o $NETWORK_REACHABILITY_BINDING_PATH \
$NETWORK_REACHABILITY_HEADER_PATH -- \
-I$SDK_PATH/usr/include \
Expand All @@ -238,9 +236,9 @@ echo "Generating bindings for $SCHEMA_DEFINITIONS_HEADER_PATH"

bindgen \
"${BINDGEN_COMMON_ARGUMENTS[@]}" \
--whitelist-var "kSC.*" \
--blacklist-type "(__)?CF.*" \
--blacklist-type "dispatch_queue_[ts]" \
--allowlist-var "kSC.*" \
--blocklist-type "(__)?CF.*" \
--blocklist-type "dispatch_queue_[ts]" \
--raw-line "use core_foundation_sys::string::CFStringRef;" \
--raw-line "" \
-o $SCHEMA_DEFINITIONS_BINDING_PATH \
Expand Down
6 changes: 3 additions & 3 deletions system-configuration-sys/src/dynamic_store.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// automatically generated by rust-bindgen
/* automatically generated by rust-bindgen 0.66.1 */

// Generated using:
// bindgen 0.54.0
// macOS SDK 10.15.4.
// bindgen 0.66.1
// macOS SDK 13.3.

use core::ffi::c_void;
use core_foundation_sys::array::CFArrayRef;
Expand Down
12 changes: 5 additions & 7 deletions system-configuration-sys/src/dynamic_store_copy_specific.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
// automatically generated by rust-bindgen
/* automatically generated by rust-bindgen 0.66.1 */

// Generated using:
// bindgen 0.54.0
// macOS SDK 10.15.4.
// bindgen 0.66.1
// macOS SDK 13.3.

use crate::dynamic_store::SCDynamicStoreRef;
use core_foundation_sys::dictionary::CFDictionaryRef;
use core_foundation_sys::string::{CFStringEncoding, CFStringRef};

use libc::c_uint;

pub type __uint32_t = c_uint;
pub type __uint32_t = ::core::ffi::c_uint;
pub type __darwin_gid_t = __uint32_t;
pub type __darwin_uid_t = __uint32_t;
pub type gid_t = __darwin_gid_t;
pub type uid_t = __darwin_uid_t;
pub type UInt32 = c_uint;
pub type UInt32 = ::core::ffi::c_uint;
extern "C" {
pub fn SCDynamicStoreCopyComputerName(
store: SCDynamicStoreRef,
Expand Down
25 changes: 13 additions & 12 deletions system-configuration-sys/src/network_configuration.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// automatically generated by rust-bindgen
/* automatically generated by rust-bindgen 0.66.1 */

// Generated using:
// bindgen 0.54.0
// macOS SDK 10.15.4.
// bindgen 0.66.1
// macOS SDK 13.3.

use core::ffi::c_void;
use core_foundation_sys::array::CFArrayRef;
Expand All @@ -13,7 +13,7 @@ use core_foundation_sys::string::CFStringRef;

use crate::dispatch_queue_t;
use crate::preferences::SCPreferencesRef;
use libc::{c_char, c_int, sockaddr, socklen_t};
use libc::{sockaddr, socklen_t};

pub type __SCNetworkConnection = c_void;
pub type __SCNetworkInterface = c_void;
Expand All @@ -31,7 +31,7 @@ extern "C" {
) -> Boolean;

pub fn SCNetworkCheckReachabilityByName(
nodename: *const c_char,
nodename: *const ::core::ffi::c_char,
flags: *mut SCNetworkConnectionFlags,
) -> Boolean;

Expand Down Expand Up @@ -126,8 +126,6 @@ extern "C" {

pub static kSCNetworkInterfaceTypeBond: CFStringRef;

pub static kSCNetworkInterfaceTypeBridge: CFStringRef;

pub static kSCNetworkInterfaceTypeEthernet: CFStringRef;

pub static kSCNetworkInterfaceTypeFireWire: CFStringRef;
Expand Down Expand Up @@ -163,7 +161,7 @@ pub const kSCBondStatusLinkInvalid: _bindgen_ty_286 = 1;
pub const kSCBondStatusNoPartner: _bindgen_ty_286 = 2;
pub const kSCBondStatusNotInActiveGroup: _bindgen_ty_286 = 3;
pub const kSCBondStatusUnknown: _bindgen_ty_286 = 999;
pub type _bindgen_ty_286 = u32;
pub type _bindgen_ty_286 = ::core::ffi::c_uint;
extern "C" {
pub static kSCBondStatusDeviceAggregationStatus: CFStringRef;

Expand Down Expand Up @@ -243,9 +241,9 @@ extern "C" {

pub fn SCNetworkInterfaceCopyMTU(
interface: SCNetworkInterfaceRef,
mtu_cur: *mut c_int,
mtu_min: *mut c_int,
mtu_max: *mut c_int,
mtu_cur: *mut ::core::ffi::c_int,
mtu_min: *mut ::core::ffi::c_int,
mtu_max: *mut ::core::ffi::c_int,
) -> Boolean;

pub fn SCNetworkInterfaceSetMediaOptions(
Expand All @@ -254,7 +252,10 @@ extern "C" {
options: CFArrayRef,
) -> Boolean;

pub fn SCNetworkInterfaceSetMTU(interface: SCNetworkInterfaceRef, mtu: c_int) -> Boolean;
pub fn SCNetworkInterfaceSetMTU(
interface: SCNetworkInterfaceRef,
mtu: ::core::ffi::c_int,
) -> Boolean;

pub fn SCNetworkInterfaceForceConfigurationRefresh(interface: SCNetworkInterfaceRef)
-> Boolean;
Expand Down
34 changes: 17 additions & 17 deletions system-configuration-sys/src/network_reachability.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// automatically generated by rust-bindgen
/* automatically generated by rust-bindgen 0.66.1 */

// Generated using:
// bindgen 0.54.0
// macOS SDK 10.15.4.
// bindgen 0.66.1
// macOS SDK 13.3.

#![cfg_attr(feature = "cargo-clippy", allow(clippy::unreadable_literal))]
use crate::dispatch_queue_t;
use core_foundation_sys::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID};
use core_foundation_sys::runloop::CFRunLoopRef;
use core_foundation_sys::string::CFStringRef;
use libc::{c_char, c_void, sockaddr};
pub type __SCNetworkReachability = c_void;
use libc::sockaddr;
pub type __SCNetworkReachability = ::core::ffi::c_void;

pub type SCNetworkReachabilityRef = *const __SCNetworkReachability;
#[repr(C)]
Expand All @@ -25,17 +25,17 @@ pub struct SCNetworkReachabilityContext {
Option<unsafe extern "C" fn(info: *const ::core::ffi::c_void) -> CFStringRef>,
}
pub type SCNetworkReachabilityFlags = u32;
pub const kSCNetworkReachabilityFlagsTransientConnection: _bindgen_ty_64 = 1;
pub const kSCNetworkReachabilityFlagsReachable: _bindgen_ty_64 = 2;
pub const kSCNetworkReachabilityFlagsConnectionRequired: _bindgen_ty_64 = 4;
pub const kSCNetworkReachabilityFlagsConnectionOnTraffic: _bindgen_ty_64 = 8;
pub const kSCNetworkReachabilityFlagsInterventionRequired: _bindgen_ty_64 = 16;
pub const kSCNetworkReachabilityFlagsConnectionOnDemand: _bindgen_ty_64 = 32;
pub const kSCNetworkReachabilityFlagsIsLocalAddress: _bindgen_ty_64 = 65536;
pub const kSCNetworkReachabilityFlagsIsDirect: _bindgen_ty_64 = 131072;
pub const kSCNetworkReachabilityFlagsIsWWAN: _bindgen_ty_64 = 262144;
pub const kSCNetworkReachabilityFlagsConnectionAutomatic: _bindgen_ty_64 = 8;
pub type _bindgen_ty_64 = u32;
pub const kSCNetworkReachabilityFlagsTransientConnection: _bindgen_ty_65 = 1;
pub const kSCNetworkReachabilityFlagsReachable: _bindgen_ty_65 = 2;
pub const kSCNetworkReachabilityFlagsConnectionRequired: _bindgen_ty_65 = 4;
pub const kSCNetworkReachabilityFlagsConnectionOnTraffic: _bindgen_ty_65 = 8;
pub const kSCNetworkReachabilityFlagsInterventionRequired: _bindgen_ty_65 = 16;
pub const kSCNetworkReachabilityFlagsConnectionOnDemand: _bindgen_ty_65 = 32;
pub const kSCNetworkReachabilityFlagsIsLocalAddress: _bindgen_ty_65 = 65536;
pub const kSCNetworkReachabilityFlagsIsDirect: _bindgen_ty_65 = 131072;
pub const kSCNetworkReachabilityFlagsIsWWAN: _bindgen_ty_65 = 262144;
pub const kSCNetworkReachabilityFlagsConnectionAutomatic: _bindgen_ty_65 = 8;
pub type _bindgen_ty_65 = ::core::ffi::c_uint;
pub type SCNetworkReachabilityCallBack = Option<
unsafe extern "C" fn(
target: SCNetworkReachabilityRef,
Expand All @@ -57,7 +57,7 @@ extern "C" {

pub fn SCNetworkReachabilityCreateWithName(
allocator: CFAllocatorRef,
nodename: *const c_char,
nodename: *const ::core::ffi::c_char,
) -> SCNetworkReachabilityRef;

pub fn SCNetworkReachabilityGetTypeID() -> CFTypeID;
Expand Down
6 changes: 3 additions & 3 deletions system-configuration-sys/src/preferences.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// automatically generated by rust-bindgen
/* automatically generated by rust-bindgen 0.66.1 */

// Generated using:
// bindgen 0.54.0
// macOS SDK 10.15.4.
// bindgen 0.66.1
// macOS SDK 13.3.

use core::ffi::c_void;
use core_foundation_sys::array::CFArrayRef;
Expand Down
6 changes: 3 additions & 3 deletions system-configuration-sys/src/schema_definitions.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// automatically generated by rust-bindgen
/* automatically generated by rust-bindgen 0.66.1 */

// Generated using:
// bindgen 0.54.0
// macOS SDK 10.15.4.
// bindgen 0.66.1
// macOS SDK 13.3.

use core_foundation_sys::string::CFStringRef;

Expand Down
10 changes: 8 additions & 2 deletions system-configuration/src/network_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ pub enum SCNetworkInterfaceType {
IPv4,
}

/// Bridge interface type referred to as `kSCNetworkInterfaceTypeBridge` in private headers.
static BRIDGE_INTERFACE_TYPE_ID: &str = "Bridge";

/// IrDA interface referenced as `kSCNetworkInterfaceTypeIrDA` but deprecated since macOS 12.
static IRDA_INTERFACE_TYPE_ID: &str = "IrDA";

impl SCNetworkInterfaceType {
/// Tries to construct a type by matching it to string constants used to identify a network
/// interface type. If no constants match it, `None` is returned.
Expand All @@ -152,7 +158,7 @@ impl SCNetworkInterfaceType {
Some(SCNetworkInterfaceType::SixToFour)
} else if id_is_equal_to(kSCNetworkInterfaceTypeBluetooth) {
Some(SCNetworkInterfaceType::Bluetooth)
} else if id_is_equal_to(kSCNetworkInterfaceTypeBridge) {
} else if type_id == &BRIDGE_INTERFACE_TYPE_ID {
Some(SCNetworkInterfaceType::Bridge)
} else if id_is_equal_to(kSCNetworkInterfaceTypeBond) {
Some(SCNetworkInterfaceType::Bond)
Expand All @@ -164,7 +170,7 @@ impl SCNetworkInterfaceType {
Some(SCNetworkInterfaceType::IEEE80211)
} else if id_is_equal_to(kSCNetworkInterfaceTypeIPSec) {
Some(SCNetworkInterfaceType::IPSec)
} else if id_is_equal_to(kSCNetworkInterfaceTypeIrDA) {
} else if type_id == &IRDA_INTERFACE_TYPE_ID {
Some(SCNetworkInterfaceType::IrDA)
} else if id_is_equal_to(kSCNetworkInterfaceTypeL2TP) {
Some(SCNetworkInterfaceType::L2TP)
Expand Down

0 comments on commit 3f2dcab

Please sign in to comment.