1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
/* automatically generated by rust-bindgen 0.66.1 */

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

use core::ffi::c_void;
use core_foundation_sys::array::CFArrayRef;
use core_foundation_sys::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID};
use core_foundation_sys::dictionary::CFDictionaryRef;
use core_foundation_sys::runloop::CFRunLoopRef;
use core_foundation_sys::string::CFStringRef;

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

pub type __SCNetworkConnection = c_void;
pub type __SCNetworkInterface = c_void;
pub type __SCBondStatus = c_void;
pub type __SCNetworkProtocol = c_void;
pub type __SCNetworkService = c_void;
pub type __SCNetworkSet = c_void;

pub type SCNetworkConnectionFlags = u32;
extern "C" {
    pub fn SCNetworkCheckReachabilityByAddress(
        address: *const sockaddr,
        addrlen: socklen_t,
        flags: *mut SCNetworkConnectionFlags,
    ) -> Boolean;

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

    pub fn SCNetworkInterfaceRefreshConfiguration(ifName: CFStringRef) -> Boolean;
}
pub type SCNetworkConnectionRef = *const __SCNetworkConnection;
#[repr(C)]
pub struct SCNetworkConnectionContext {
    pub version: CFIndex,
    pub info: *mut ::core::ffi::c_void,
    pub retain: Option<
        unsafe extern "C" fn(info: *const ::core::ffi::c_void) -> *const ::core::ffi::c_void,
    >,
    pub release: Option<unsafe extern "C" fn(info: *const ::core::ffi::c_void)>,
    pub copyDescription:
        Option<unsafe extern "C" fn(info: *const ::core::ffi::c_void) -> CFStringRef>,
}
pub type SCNetworkConnectionStatus = i32;
pub type SCNetworkConnectionCallBack = Option<
    unsafe extern "C" fn(
        connection: SCNetworkConnectionRef,
        status: SCNetworkConnectionStatus,
        info: *mut ::core::ffi::c_void,
    ),
>;
extern "C" {
    pub fn SCNetworkConnectionGetTypeID() -> CFTypeID;

    pub fn SCNetworkConnectionCopyUserPreferences(
        selectionOptions: CFDictionaryRef,
        serviceID: *mut CFStringRef,
        userOptions: *mut CFDictionaryRef,
    ) -> Boolean;

    pub fn SCNetworkConnectionCreateWithServiceID(
        allocator: CFAllocatorRef,
        serviceID: CFStringRef,
        callout: SCNetworkConnectionCallBack,
        context: *mut SCNetworkConnectionContext,
    ) -> SCNetworkConnectionRef;

    pub fn SCNetworkConnectionCopyServiceID(connection: SCNetworkConnectionRef) -> CFStringRef;

    pub fn SCNetworkConnectionGetStatus(
        connection: SCNetworkConnectionRef,
    ) -> SCNetworkConnectionStatus;

    pub fn SCNetworkConnectionCopyExtendedStatus(
        connection: SCNetworkConnectionRef,
    ) -> CFDictionaryRef;

    pub fn SCNetworkConnectionCopyStatistics(connection: SCNetworkConnectionRef)
        -> CFDictionaryRef;

    pub fn SCNetworkConnectionStart(
        connection: SCNetworkConnectionRef,
        userOptions: CFDictionaryRef,
        linger: Boolean,
    ) -> Boolean;

    pub fn SCNetworkConnectionStop(
        connection: SCNetworkConnectionRef,
        forceDisconnect: Boolean,
    ) -> Boolean;

    pub fn SCNetworkConnectionCopyUserOptions(
        connection: SCNetworkConnectionRef,
    ) -> CFDictionaryRef;

    pub fn SCNetworkConnectionScheduleWithRunLoop(
        connection: SCNetworkConnectionRef,
        runLoop: CFRunLoopRef,
        runLoopMode: CFStringRef,
    ) -> Boolean;

    pub fn SCNetworkConnectionUnscheduleFromRunLoop(
        connection: SCNetworkConnectionRef,
        runLoop: CFRunLoopRef,
        runLoopMode: CFStringRef,
    ) -> Boolean;

    pub fn SCNetworkConnectionSetDispatchQueue(
        connection: SCNetworkConnectionRef,
        queue: dispatch_queue_t,
    ) -> Boolean;
}
pub type SCNetworkInterfaceRef = *const __SCNetworkInterface;
extern "C" {
    pub static kSCNetworkInterfaceType6to4: CFStringRef;

    pub static kSCNetworkInterfaceTypeBluetooth: CFStringRef;

    pub static kSCNetworkInterfaceTypeBond: CFStringRef;

    pub static kSCNetworkInterfaceTypeEthernet: CFStringRef;

    pub static kSCNetworkInterfaceTypeFireWire: CFStringRef;

    pub static kSCNetworkInterfaceTypeIEEE80211: CFStringRef;

    pub static kSCNetworkInterfaceTypeIPSec: CFStringRef;

    pub static kSCNetworkInterfaceTypeIrDA: CFStringRef;

    pub static kSCNetworkInterfaceTypeL2TP: CFStringRef;

    pub static kSCNetworkInterfaceTypeModem: CFStringRef;

    pub static kSCNetworkInterfaceTypePPP: CFStringRef;

    pub static kSCNetworkInterfaceTypePPTP: CFStringRef;

    pub static kSCNetworkInterfaceTypeSerial: CFStringRef;

    pub static kSCNetworkInterfaceTypeVLAN: CFStringRef;

    pub static kSCNetworkInterfaceTypeWWAN: CFStringRef;

    pub static kSCNetworkInterfaceTypeIPv4: CFStringRef;

    pub static kSCNetworkInterfaceIPv4: SCNetworkInterfaceRef;
}
pub type SCBondInterfaceRef = SCNetworkInterfaceRef;
pub type SCBondStatusRef = *const __SCBondStatus;
pub const kSCBondStatusOK: _bindgen_ty_286 = 0;
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 = ::core::ffi::c_uint;
extern "C" {
    pub static kSCBondStatusDeviceAggregationStatus: CFStringRef;

    pub static kSCBondStatusDeviceCollecting: CFStringRef;

    pub static kSCBondStatusDeviceDistributing: CFStringRef;
}
pub type SCNetworkProtocolRef = *const __SCNetworkProtocol;
pub type SCNetworkServiceRef = *const __SCNetworkService;
pub type SCNetworkSetRef = *const __SCNetworkSet;
extern "C" {
    pub fn SCNetworkInterfaceGetTypeID() -> CFTypeID;

    pub fn SCNetworkInterfaceCopyAll() -> CFArrayRef;

    pub fn SCNetworkInterfaceGetSupportedInterfaceTypes(
        interface: SCNetworkInterfaceRef,
    ) -> CFArrayRef;

    pub fn SCNetworkInterfaceGetSupportedProtocolTypes(
        interface: SCNetworkInterfaceRef,
    ) -> CFArrayRef;

    pub fn SCNetworkInterfaceCreateWithInterface(
        interface: SCNetworkInterfaceRef,
        interfaceType: CFStringRef,
    ) -> SCNetworkInterfaceRef;

    pub fn SCNetworkInterfaceGetBSDName(interface: SCNetworkInterfaceRef) -> CFStringRef;

    pub fn SCNetworkInterfaceGetConfiguration(interface: SCNetworkInterfaceRef) -> CFDictionaryRef;

    pub fn SCNetworkInterfaceGetExtendedConfiguration(
        interface: SCNetworkInterfaceRef,
        extendedType: CFStringRef,
    ) -> CFDictionaryRef;

    pub fn SCNetworkInterfaceGetHardwareAddressString(
        interface: SCNetworkInterfaceRef,
    ) -> CFStringRef;

    pub fn SCNetworkInterfaceGetInterface(
        interface: SCNetworkInterfaceRef,
    ) -> SCNetworkInterfaceRef;

    pub fn SCNetworkInterfaceGetInterfaceType(interface: SCNetworkInterfaceRef) -> CFStringRef;

    pub fn SCNetworkInterfaceGetLocalizedDisplayName(
        interface: SCNetworkInterfaceRef,
    ) -> CFStringRef;

    pub fn SCNetworkInterfaceSetConfiguration(
        interface: SCNetworkInterfaceRef,
        config: CFDictionaryRef,
    ) -> Boolean;

    pub fn SCNetworkInterfaceSetExtendedConfiguration(
        interface: SCNetworkInterfaceRef,
        extendedType: CFStringRef,
        config: CFDictionaryRef,
    ) -> Boolean;

    pub fn SCNetworkInterfaceCopyMediaOptions(
        interface: SCNetworkInterfaceRef,
        current: *mut CFDictionaryRef,
        active: *mut CFDictionaryRef,
        available: *mut CFArrayRef,
        filter: Boolean,
    ) -> Boolean;

    pub fn SCNetworkInterfaceCopyMediaSubTypes(available: CFArrayRef) -> CFArrayRef;

    pub fn SCNetworkInterfaceCopyMediaSubTypeOptions(
        available: CFArrayRef,
        subType: CFStringRef,
    ) -> CFArrayRef;

    pub fn SCNetworkInterfaceCopyMTU(
        interface: SCNetworkInterfaceRef,
        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(
        interface: SCNetworkInterfaceRef,
        subtype: CFStringRef,
        options: CFArrayRef,
    ) -> Boolean;

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

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

    pub fn SCBondInterfaceCopyAll(prefs: SCPreferencesRef) -> CFArrayRef;

    pub fn SCBondInterfaceCopyAvailableMemberInterfaces(prefs: SCPreferencesRef) -> CFArrayRef;

    pub fn SCBondInterfaceCreate(prefs: SCPreferencesRef) -> SCBondInterfaceRef;

    pub fn SCBondInterfaceRemove(bond: SCBondInterfaceRef) -> Boolean;

    pub fn SCBondInterfaceGetMemberInterfaces(bond: SCBondInterfaceRef) -> CFArrayRef;

    pub fn SCBondInterfaceGetOptions(bond: SCBondInterfaceRef) -> CFDictionaryRef;

    pub fn SCBondInterfaceSetMemberInterfaces(
        bond: SCBondInterfaceRef,
        members: CFArrayRef,
    ) -> Boolean;

    pub fn SCBondInterfaceSetLocalizedDisplayName(
        bond: SCBondInterfaceRef,
        newName: CFStringRef,
    ) -> Boolean;

    pub fn SCBondInterfaceSetOptions(
        bond: SCBondInterfaceRef,
        newOptions: CFDictionaryRef,
    ) -> Boolean;

    pub fn SCBondInterfaceCopyStatus(bond: SCBondInterfaceRef) -> SCBondStatusRef;

    pub fn SCNetworkProtocolGetTypeID() -> CFTypeID;

    pub fn SCNetworkProtocolGetConfiguration(protocol: SCNetworkProtocolRef) -> CFDictionaryRef;

    pub fn SCNetworkProtocolGetEnabled(protocol: SCNetworkProtocolRef) -> Boolean;

    pub fn SCNetworkProtocolGetProtocolType(protocol: SCNetworkProtocolRef) -> CFStringRef;

    pub fn SCNetworkProtocolSetConfiguration(
        protocol: SCNetworkProtocolRef,
        config: CFDictionaryRef,
    ) -> Boolean;

    pub fn SCNetworkProtocolSetEnabled(protocol: SCNetworkProtocolRef, enabled: Boolean)
        -> Boolean;

    pub fn SCNetworkServiceGetTypeID() -> CFTypeID;

    pub fn SCNetworkServiceAddProtocolType(
        service: SCNetworkServiceRef,
        protocolType: CFStringRef,
    ) -> Boolean;

    pub fn SCNetworkServiceCopyAll(prefs: SCPreferencesRef) -> CFArrayRef;

    pub fn SCNetworkServiceCopyProtocols(service: SCNetworkServiceRef) -> CFArrayRef;

    pub fn SCNetworkServiceCreate(
        prefs: SCPreferencesRef,
        interface: SCNetworkInterfaceRef,
    ) -> SCNetworkServiceRef;

    pub fn SCNetworkServiceCopy(
        prefs: SCPreferencesRef,
        serviceID: CFStringRef,
    ) -> SCNetworkServiceRef;

    pub fn SCNetworkServiceEstablishDefaultConfiguration(service: SCNetworkServiceRef) -> Boolean;

    pub fn SCNetworkServiceGetEnabled(service: SCNetworkServiceRef) -> Boolean;

    pub fn SCNetworkServiceGetInterface(service: SCNetworkServiceRef) -> SCNetworkInterfaceRef;

    pub fn SCNetworkServiceGetName(service: SCNetworkServiceRef) -> CFStringRef;

    pub fn SCNetworkServiceCopyProtocol(
        service: SCNetworkServiceRef,
        protocolType: CFStringRef,
    ) -> SCNetworkProtocolRef;

    pub fn SCNetworkServiceGetServiceID(service: SCNetworkServiceRef) -> CFStringRef;

    pub fn SCNetworkServiceRemove(service: SCNetworkServiceRef) -> Boolean;

    pub fn SCNetworkServiceRemoveProtocolType(
        service: SCNetworkServiceRef,
        protocolType: CFStringRef,
    ) -> Boolean;

    pub fn SCNetworkServiceSetEnabled(service: SCNetworkServiceRef, enabled: Boolean) -> Boolean;

    pub fn SCNetworkServiceSetName(service: SCNetworkServiceRef, name: CFStringRef) -> Boolean;

    pub fn SCNetworkSetGetTypeID() -> CFTypeID;

    pub fn SCNetworkSetAddService(set: SCNetworkSetRef, service: SCNetworkServiceRef) -> Boolean;

    pub fn SCNetworkSetContainsInterface(
        set: SCNetworkSetRef,
        interface: SCNetworkInterfaceRef,
    ) -> Boolean;

    pub fn SCNetworkSetCopyAll(prefs: SCPreferencesRef) -> CFArrayRef;

    pub fn SCNetworkSetCopyCurrent(prefs: SCPreferencesRef) -> SCNetworkSetRef;

    pub fn SCNetworkSetCopyServices(set: SCNetworkSetRef) -> CFArrayRef;

    pub fn SCNetworkSetCreate(prefs: SCPreferencesRef) -> SCNetworkSetRef;

    pub fn SCNetworkSetCopy(prefs: SCPreferencesRef, setID: CFStringRef) -> SCNetworkSetRef;

    pub fn SCNetworkSetGetName(set: SCNetworkSetRef) -> CFStringRef;

    pub fn SCNetworkSetGetSetID(set: SCNetworkSetRef) -> CFStringRef;

    pub fn SCNetworkSetGetServiceOrder(set: SCNetworkSetRef) -> CFArrayRef;

    pub fn SCNetworkSetRemove(set: SCNetworkSetRef) -> Boolean;

    pub fn SCNetworkSetRemoveService(set: SCNetworkSetRef, service: SCNetworkServiceRef)
        -> Boolean;

    pub fn SCNetworkSetSetCurrent(set: SCNetworkSetRef) -> Boolean;

    pub fn SCNetworkSetSetName(set: SCNetworkSetRef, name: CFStringRef) -> Boolean;

    pub fn SCNetworkSetSetServiceOrder(set: SCNetworkSetRef, newOrder: CFArrayRef) -> Boolean;
}