Skip to content

Commit 3f2dcab

Browse files
Andrej Mihajlovdlon
authored andcommitted
Update bindings and move private Bridge and deprecated IrDA interface types into separate string constants
1 parent 3367a6f commit 3f2dcab

File tree

8 files changed

+94
-91
lines changed

8 files changed

+94
-91
lines changed

generate_bindings.sh

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ BINDGEN_COMMON_ARGUMENTS=(
8686
echo "Generating bindings for $PREFERENCES_HEADER_PATH"
8787
bindgen \
8888
"${BINDGEN_COMMON_ARGUMENTS[@]}" \
89-
--whitelist-function "SCPreferences.*" \
90-
--blacklist-type "(__)?CF.*" \
91-
--blacklist-type "Boolean" \
92-
--blacklist-type "dispatch_queue_[ts]" \
93-
--blacklist-type "(AuthorizationOpaqueRef|__SCPreferences)" \
89+
--allowlist-function "SCPreferences.*" \
90+
--blocklist-type "(__)?CF.*" \
91+
--blocklist-type "Boolean" \
92+
--blocklist-type "dispatch_queue_[ts]" \
93+
--blocklist-type "(AuthorizationOpaqueRef|__SCPreferences)" \
9494
--raw-line "use core::ffi::c_void;" \
9595
--raw-line "use core_foundation_sys::array::CFArrayRef;" \
9696
--raw-line "use core_foundation_sys::base::{Boolean, CFIndex, CFAllocatorRef, CFTypeID};" \
@@ -116,11 +116,11 @@ echo "Generating bindings for $DYNAMIC_STORE_HEADER_PATH"
116116

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

144144
bindgen \
145145
"${BINDGEN_COMMON_ARGUMENTS[@]}" \
146-
--whitelist-function "SCDynamicStoreCopy(ComputerName|ConsoleUser|LocalHostName|Location|Proxies)" \
147-
--blacklist-type "(__)?CF.*" \
148-
--blacklist-type "Boolean" \
149-
--blacklist-type "dispatch_queue_[ts]" \
150-
--blacklist-type "(__)?SCDynamicStore.*" \
146+
--allowlist-function "SCDynamicStoreCopy(ComputerName|ConsoleUser|LocalHostName|Location|Proxies)" \
147+
--blocklist-type "(__)?CF.*" \
148+
--blocklist-type "Boolean" \
149+
--blocklist-type "dispatch_queue_[ts]" \
150+
--blocklist-type "(__)?SCDynamicStore.*" \
151151
--raw-line "use core_foundation_sys::string::{CFStringEncoding, CFStringRef};" \
152152
--raw-line "use core_foundation_sys::dictionary::CFDictionaryRef;" \
153153
--raw-line "use crate::dynamic_store::SCDynamicStoreRef;" \
154-
--raw-line "" \
155-
--raw-line "use libc::c_uint;" \
156154
-o $DYNAMIC_STORE_COPY_SPECIFIC_BINDING_PATH \
157155
$DYNAMIC_STORE_COPY_SPECIFIC_HEADER_PATH -- \
158156
-I$SDK_PATH/usr/include \
@@ -166,17 +164,17 @@ echo "Generating bindings for $NETWORK_CONFIGURATION_HEADER_PATH"
166164

167165
bindgen \
168166
"${BINDGEN_COMMON_ARGUMENTS[@]}" \
169-
--whitelist-function "SCNetwork.*" \
170-
--whitelist-function "SCBondInterface.*" \
171-
--whitelist-var "kSC(NetworkInterface|BondStatus).*" \
172-
--blacklist-type "SCNetworkReachability.*" \
173-
--blacklist-function "SCNetworkReachability.*" \
174-
--blacklist-type "dispatch_queue_[ts]" \
175-
--blacklist-type "(__)?CF.*" \
176-
--blacklist-type "__SC.*" \
177-
--blacklist-type "Boolean" \
178-
--blacklist-type "(sockaddr|socklen_t|sa_family_t|__darwin_socklen_t|__uint.*_t)" \
179-
--blacklist-type "(__)?SCPreferences.*" \
167+
--allowlist-function "SCNetwork.*" \
168+
--allowlist-function "SCBondInterface.*" \
169+
--allowlist-var "kSC(NetworkInterface|BondStatus).*" \
170+
--blocklist-type "SCNetworkReachability.*" \
171+
--blocklist-function "SCNetworkReachability.*" \
172+
--blocklist-type "dispatch_queue_[ts]" \
173+
--blocklist-type "(__)?CF.*" \
174+
--blocklist-type "__SC.*" \
175+
--blocklist-type "Boolean" \
176+
--blocklist-type "(sockaddr|socklen_t|sa_family_t|__darwin_socklen_t|__uint.*_t)" \
177+
--blocklist-type "(__)?SCPreferences.*" \
180178
--raw-line "use core::ffi::c_void;" \
181179
--raw-line "use core_foundation_sys::array::CFArrayRef;" \
182180
--raw-line "use core_foundation_sys::base::{Boolean, CFIndex, CFAllocatorRef, CFTypeID};" \
@@ -185,7 +183,7 @@ bindgen \
185183
--raw-line "use core_foundation_sys::runloop::CFRunLoopRef;" \
186184
--raw-line "" \
187185
--raw-line "use crate::dispatch_queue_t;" \
188-
--raw-line "use libc::{c_char, c_int, sockaddr, socklen_t};" \
186+
--raw-line "use libc::{sockaddr, socklen_t};" \
189187
--raw-line "use crate::preferences::SCPreferencesRef;" \
190188
--raw-line "" \
191189
--raw-line "pub type __SCNetworkConnection = c_void;" \
@@ -207,23 +205,23 @@ echo "Generating bindings for $NETWORK_REACHABILITY_HEADER_PATH"
207205

208206
bindgen \
209207
"${BINDGEN_COMMON_ARGUMENTS[@]}" \
210-
--whitelist-function "SCNetworkReachability.*" \
211-
--whitelist-type "SCNetworkReachability.*" \
212-
--whitelist-var "kSCNetworkReachability.*" \
213-
--blacklist-type "sockaddr" \
214-
--blacklist-type "dispatch_queue_[ts]" \
215-
--blacklist-type "(__)?CF.*" \
216-
--blacklist-type "__SC.*" \
217-
--blacklist-type "Boolean" \
218-
--blacklist-type "dispatch_.*" \
219-
--blacklist-type "(sockaddr|socklen_t|sa_family_t|__darwin_socklen_t|__uint.*_t)" \
208+
--allowlist-function "SCNetworkReachability.*" \
209+
--allowlist-type "SCNetworkReachability.*" \
210+
--allowlist-var "kSCNetworkReachability.*" \
211+
--blocklist-type "sockaddr" \
212+
--blocklist-type "dispatch_queue_[ts]" \
213+
--blocklist-type "(__)?CF.*" \
214+
--blocklist-type "__SC.*" \
215+
--blocklist-type "Boolean" \
216+
--blocklist-type "dispatch_.*" \
217+
--blocklist-type "(sockaddr|socklen_t|sa_family_t|__darwin_socklen_t|__uint.*_t)" \
220218
--raw-line '#![cfg_attr(feature = "cargo-clippy", allow(clippy::unreadable_literal))]' \
221219
--raw-line "use core_foundation_sys::base::{Boolean, CFAllocatorRef, CFTypeID, CFIndex};" \
222220
--raw-line "use core_foundation_sys::string::CFStringRef;" \
223221
--raw-line "use core_foundation_sys::runloop::CFRunLoopRef;" \
224-
--raw-line "use libc::{c_char, sockaddr, c_void};" \
222+
--raw-line "use libc::sockaddr;" \
225223
--raw-line "use crate::dispatch_queue_t;" \
226-
--raw-line "pub type __SCNetworkReachability = c_void;" \
224+
--raw-line "pub type __SCNetworkReachability = ::core::ffi::c_void;" \
227225
-o $NETWORK_REACHABILITY_BINDING_PATH \
228226
$NETWORK_REACHABILITY_HEADER_PATH -- \
229227
-I$SDK_PATH/usr/include \
@@ -238,9 +236,9 @@ echo "Generating bindings for $SCHEMA_DEFINITIONS_HEADER_PATH"
238236

239237
bindgen \
240238
"${BINDGEN_COMMON_ARGUMENTS[@]}" \
241-
--whitelist-var "kSC.*" \
242-
--blacklist-type "(__)?CF.*" \
243-
--blacklist-type "dispatch_queue_[ts]" \
239+
--allowlist-var "kSC.*" \
240+
--blocklist-type "(__)?CF.*" \
241+
--blocklist-type "dispatch_queue_[ts]" \
244242
--raw-line "use core_foundation_sys::string::CFStringRef;" \
245243
--raw-line "" \
246244
-o $SCHEMA_DEFINITIONS_BINDING_PATH \

system-configuration-sys/src/dynamic_store.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// automatically generated by rust-bindgen
1+
/* automatically generated by rust-bindgen 0.66.1 */
22

33
// Generated using:
4-
// bindgen 0.54.0
5-
// macOS SDK 10.15.4.
4+
// bindgen 0.66.1
5+
// macOS SDK 13.3.
66

77
use core::ffi::c_void;
88
use core_foundation_sys::array::CFArrayRef;

system-configuration-sys/src/dynamic_store_copy_specific.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
// automatically generated by rust-bindgen
1+
/* automatically generated by rust-bindgen 0.66.1 */
22

33
// Generated using:
4-
// bindgen 0.54.0
5-
// macOS SDK 10.15.4.
4+
// bindgen 0.66.1
5+
// macOS SDK 13.3.
66

77
use crate::dynamic_store::SCDynamicStoreRef;
88
use core_foundation_sys::dictionary::CFDictionaryRef;
99
use core_foundation_sys::string::{CFStringEncoding, CFStringRef};
1010

11-
use libc::c_uint;
12-
13-
pub type __uint32_t = c_uint;
11+
pub type __uint32_t = ::core::ffi::c_uint;
1412
pub type __darwin_gid_t = __uint32_t;
1513
pub type __darwin_uid_t = __uint32_t;
1614
pub type gid_t = __darwin_gid_t;
1715
pub type uid_t = __darwin_uid_t;
18-
pub type UInt32 = c_uint;
16+
pub type UInt32 = ::core::ffi::c_uint;
1917
extern "C" {
2018
pub fn SCDynamicStoreCopyComputerName(
2119
store: SCDynamicStoreRef,

system-configuration-sys/src/network_configuration.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// automatically generated by rust-bindgen
1+
/* automatically generated by rust-bindgen 0.66.1 */
22

33
// Generated using:
4-
// bindgen 0.54.0
5-
// macOS SDK 10.15.4.
4+
// bindgen 0.66.1
5+
// macOS SDK 13.3.
66

77
use core::ffi::c_void;
88
use core_foundation_sys::array::CFArrayRef;
@@ -13,7 +13,7 @@ use core_foundation_sys::string::CFStringRef;
1313

1414
use crate::dispatch_queue_t;
1515
use crate::preferences::SCPreferencesRef;
16-
use libc::{c_char, c_int, sockaddr, socklen_t};
16+
use libc::{sockaddr, socklen_t};
1717

1818
pub type __SCNetworkConnection = c_void;
1919
pub type __SCNetworkInterface = c_void;
@@ -31,7 +31,7 @@ extern "C" {
3131
) -> Boolean;
3232

3333
pub fn SCNetworkCheckReachabilityByName(
34-
nodename: *const c_char,
34+
nodename: *const ::core::ffi::c_char,
3535
flags: *mut SCNetworkConnectionFlags,
3636
) -> Boolean;
3737

@@ -126,8 +126,6 @@ extern "C" {
126126

127127
pub static kSCNetworkInterfaceTypeBond: CFStringRef;
128128

129-
pub static kSCNetworkInterfaceTypeBridge: CFStringRef;
130-
131129
pub static kSCNetworkInterfaceTypeEthernet: CFStringRef;
132130

133131
pub static kSCNetworkInterfaceTypeFireWire: CFStringRef;
@@ -163,7 +161,7 @@ pub const kSCBondStatusLinkInvalid: _bindgen_ty_286 = 1;
163161
pub const kSCBondStatusNoPartner: _bindgen_ty_286 = 2;
164162
pub const kSCBondStatusNotInActiveGroup: _bindgen_ty_286 = 3;
165163
pub const kSCBondStatusUnknown: _bindgen_ty_286 = 999;
166-
pub type _bindgen_ty_286 = u32;
164+
pub type _bindgen_ty_286 = ::core::ffi::c_uint;
167165
extern "C" {
168166
pub static kSCBondStatusDeviceAggregationStatus: CFStringRef;
169167

@@ -243,9 +241,9 @@ extern "C" {
243241

244242
pub fn SCNetworkInterfaceCopyMTU(
245243
interface: SCNetworkInterfaceRef,
246-
mtu_cur: *mut c_int,
247-
mtu_min: *mut c_int,
248-
mtu_max: *mut c_int,
244+
mtu_cur: *mut ::core::ffi::c_int,
245+
mtu_min: *mut ::core::ffi::c_int,
246+
mtu_max: *mut ::core::ffi::c_int,
249247
) -> Boolean;
250248

251249
pub fn SCNetworkInterfaceSetMediaOptions(
@@ -254,7 +252,10 @@ extern "C" {
254252
options: CFArrayRef,
255253
) -> Boolean;
256254

257-
pub fn SCNetworkInterfaceSetMTU(interface: SCNetworkInterfaceRef, mtu: c_int) -> Boolean;
255+
pub fn SCNetworkInterfaceSetMTU(
256+
interface: SCNetworkInterfaceRef,
257+
mtu: ::core::ffi::c_int,
258+
) -> Boolean;
258259

259260
pub fn SCNetworkInterfaceForceConfigurationRefresh(interface: SCNetworkInterfaceRef)
260261
-> Boolean;

system-configuration-sys/src/network_reachability.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
// automatically generated by rust-bindgen
1+
/* automatically generated by rust-bindgen 0.66.1 */
22

33
// Generated using:
4-
// bindgen 0.54.0
5-
// macOS SDK 10.15.4.
4+
// bindgen 0.66.1
5+
// macOS SDK 13.3.
66

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

1515
pub type SCNetworkReachabilityRef = *const __SCNetworkReachability;
1616
#[repr(C)]
@@ -25,17 +25,17 @@ pub struct SCNetworkReachabilityContext {
2525
Option<unsafe extern "C" fn(info: *const ::core::ffi::c_void) -> CFStringRef>,
2626
}
2727
pub type SCNetworkReachabilityFlags = u32;
28-
pub const kSCNetworkReachabilityFlagsTransientConnection: _bindgen_ty_64 = 1;
29-
pub const kSCNetworkReachabilityFlagsReachable: _bindgen_ty_64 = 2;
30-
pub const kSCNetworkReachabilityFlagsConnectionRequired: _bindgen_ty_64 = 4;
31-
pub const kSCNetworkReachabilityFlagsConnectionOnTraffic: _bindgen_ty_64 = 8;
32-
pub const kSCNetworkReachabilityFlagsInterventionRequired: _bindgen_ty_64 = 16;
33-
pub const kSCNetworkReachabilityFlagsConnectionOnDemand: _bindgen_ty_64 = 32;
34-
pub const kSCNetworkReachabilityFlagsIsLocalAddress: _bindgen_ty_64 = 65536;
35-
pub const kSCNetworkReachabilityFlagsIsDirect: _bindgen_ty_64 = 131072;
36-
pub const kSCNetworkReachabilityFlagsIsWWAN: _bindgen_ty_64 = 262144;
37-
pub const kSCNetworkReachabilityFlagsConnectionAutomatic: _bindgen_ty_64 = 8;
38-
pub type _bindgen_ty_64 = u32;
28+
pub const kSCNetworkReachabilityFlagsTransientConnection: _bindgen_ty_65 = 1;
29+
pub const kSCNetworkReachabilityFlagsReachable: _bindgen_ty_65 = 2;
30+
pub const kSCNetworkReachabilityFlagsConnectionRequired: _bindgen_ty_65 = 4;
31+
pub const kSCNetworkReachabilityFlagsConnectionOnTraffic: _bindgen_ty_65 = 8;
32+
pub const kSCNetworkReachabilityFlagsInterventionRequired: _bindgen_ty_65 = 16;
33+
pub const kSCNetworkReachabilityFlagsConnectionOnDemand: _bindgen_ty_65 = 32;
34+
pub const kSCNetworkReachabilityFlagsIsLocalAddress: _bindgen_ty_65 = 65536;
35+
pub const kSCNetworkReachabilityFlagsIsDirect: _bindgen_ty_65 = 131072;
36+
pub const kSCNetworkReachabilityFlagsIsWWAN: _bindgen_ty_65 = 262144;
37+
pub const kSCNetworkReachabilityFlagsConnectionAutomatic: _bindgen_ty_65 = 8;
38+
pub type _bindgen_ty_65 = ::core::ffi::c_uint;
3939
pub type SCNetworkReachabilityCallBack = Option<
4040
unsafe extern "C" fn(
4141
target: SCNetworkReachabilityRef,
@@ -57,7 +57,7 @@ extern "C" {
5757

5858
pub fn SCNetworkReachabilityCreateWithName(
5959
allocator: CFAllocatorRef,
60-
nodename: *const c_char,
60+
nodename: *const ::core::ffi::c_char,
6161
) -> SCNetworkReachabilityRef;
6262

6363
pub fn SCNetworkReachabilityGetTypeID() -> CFTypeID;

system-configuration-sys/src/preferences.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// automatically generated by rust-bindgen
1+
/* automatically generated by rust-bindgen 0.66.1 */
22

33
// Generated using:
4-
// bindgen 0.54.0
5-
// macOS SDK 10.15.4.
4+
// bindgen 0.66.1
5+
// macOS SDK 13.3.
66

77
use core::ffi::c_void;
88
use core_foundation_sys::array::CFArrayRef;

system-configuration-sys/src/schema_definitions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// automatically generated by rust-bindgen
1+
/* automatically generated by rust-bindgen 0.66.1 */
22

33
// Generated using:
4-
// bindgen 0.54.0
5-
// macOS SDK 10.15.4.
4+
// bindgen 0.66.1
5+
// macOS SDK 13.3.
66

77
use core_foundation_sys::string::CFStringRef;
88

system-configuration/src/network_configuration.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ pub enum SCNetworkInterfaceType {
137137
IPv4,
138138
}
139139

140+
/// Bridge interface type referred to as `kSCNetworkInterfaceTypeBridge` in private headers.
141+
static BRIDGE_INTERFACE_TYPE_ID: &str = "Bridge";
142+
143+
/// IrDA interface referenced as `kSCNetworkInterfaceTypeIrDA` but deprecated since macOS 12.
144+
static IRDA_INTERFACE_TYPE_ID: &str = "IrDA";
145+
140146
impl SCNetworkInterfaceType {
141147
/// Tries to construct a type by matching it to string constants used to identify a network
142148
/// interface type. If no constants match it, `None` is returned.
@@ -152,7 +158,7 @@ impl SCNetworkInterfaceType {
152158
Some(SCNetworkInterfaceType::SixToFour)
153159
} else if id_is_equal_to(kSCNetworkInterfaceTypeBluetooth) {
154160
Some(SCNetworkInterfaceType::Bluetooth)
155-
} else if id_is_equal_to(kSCNetworkInterfaceTypeBridge) {
161+
} else if type_id == &BRIDGE_INTERFACE_TYPE_ID {
156162
Some(SCNetworkInterfaceType::Bridge)
157163
} else if id_is_equal_to(kSCNetworkInterfaceTypeBond) {
158164
Some(SCNetworkInterfaceType::Bond)
@@ -164,7 +170,7 @@ impl SCNetworkInterfaceType {
164170
Some(SCNetworkInterfaceType::IEEE80211)
165171
} else if id_is_equal_to(kSCNetworkInterfaceTypeIPSec) {
166172
Some(SCNetworkInterfaceType::IPSec)
167-
} else if id_is_equal_to(kSCNetworkInterfaceTypeIrDA) {
173+
} else if type_id == &IRDA_INTERFACE_TYPE_ID {
168174
Some(SCNetworkInterfaceType::IrDA)
169175
} else if id_is_equal_to(kSCNetworkInterfaceTypeL2TP) {
170176
Some(SCNetworkInterfaceType::L2TP)

0 commit comments

Comments
 (0)