-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
luozijun
committed
Feb 20, 2018
1 parent
290fc79
commit d7f7154
Showing
7 changed files
with
552 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use core_foundation_sys::base::Boolean; | ||
use core_foundation_sys::string::CFStringRef; | ||
use core_foundation_sys::dictionary::CFDictionaryRef; | ||
use core_foundation_sys::array::CFArrayRef; | ||
|
||
use SCPreferencesRef; | ||
|
||
use std::os::raw::{c_void, c_int}; | ||
|
||
|
||
pub type __SCNetworkInterface = c_void; | ||
pub type SCNetworkInterfaceRef = *const __SCNetworkInterface; | ||
pub type SCBondInterfaceRef = SCNetworkInterfaceRef; | ||
pub type SCVLANInterfaceRef = SCNetworkInterfaceRef; | ||
|
||
pub type __SCBondStatus = c_void; | ||
pub type SCBondStatusRef = *const __SCBondStatus; | ||
|
||
pub type __SCNetworkProtocol = c_void; | ||
pub type SCNetworkProtocolRef = *const __SCNetworkProtocol; | ||
|
||
pub type __SCNetworkService = c_void; | ||
pub type SCNetworkServiceRef = *const __SCNetworkService; | ||
|
||
pub type __SCNetworkSet = c_void; | ||
pub type SCNetworkSetRef = *const __SCNetworkSet; | ||
|
||
|
||
#[link(name = "SystemConfiguration", kind = "framework")] | ||
extern "C" { | ||
pub fn SCNetworkServiceCopyAll(prefs: SCPreferencesRef) -> CFArrayRef; | ||
pub fn SCNetworkServiceCopy(prefs: SCPreferencesRef, | ||
serviceID: CFStringRef) -> SCNetworkServiceRef; | ||
pub fn SCNetworkServiceGetEnabled(service: SCNetworkServiceRef) -> Boolean; | ||
pub fn SCNetworkServiceGetInterface(service: SCNetworkServiceRef) -> SCNetworkInterfaceRef; | ||
pub fn SCNetworkServiceGetName(service: SCNetworkServiceRef) -> CFStringRef; | ||
pub fn SCNetworkServiceGetServiceID(service: SCNetworkServiceRef) -> CFStringRef; | ||
pub fn SCNetworkSetGetServiceOrder(set: SCNetworkSetRef) -> CFArrayRef; | ||
pub fn SCNetworkSetCopyServices(set: SCNetworkSetRef) -> CFArrayRef; | ||
pub fn SCNetworkSetCopyCurrent(prefs:SCPreferencesRef) -> SCNetworkSetRef; | ||
|
||
pub fn SCNetworkInterfaceCopyAll() -> CFArrayRef; | ||
pub fn SCNetworkInterfaceCopyMTU(interface: SCNetworkInterfaceRef, | ||
mtu_cur: *mut c_int, | ||
mtu_min: *mut c_int, | ||
mtu_max: *mut c_int) -> Boolean; | ||
pub fn SCNetworkInterfaceCopyMediaOptions(interface: SCNetworkInterfaceRef, | ||
urrent: *mut CFDictionaryRef, | ||
active: *mut CFDictionaryRef, | ||
available: *mut CFArrayRef, | ||
filter: Boolean) -> Boolean; | ||
pub fn SCNetworkInterfaceGetBSDName(interface: SCNetworkInterfaceRef) -> CFStringRef; | ||
pub fn SCNetworkInterfaceGetInterfaceType(interface: SCNetworkInterfaceRef) -> CFStringRef; | ||
pub fn SCNetworkInterfaceGetHardwareAddressString(interface: SCNetworkInterfaceRef) -> CFStringRef; | ||
|
||
pub fn SCNetworkInterfaceGetConfiguration(interface: SCNetworkInterfaceRef) -> CFDictionaryRef; | ||
pub fn SCNetworkInterfaceGetExtendedConfiguration(interface: SCNetworkInterfaceRef, | ||
extendedType: CFStringRef) -> CFDictionaryRef; | ||
|
||
pub fn SCNetworkInterfaceSetConfiguration(interface: SCNetworkInterfaceRef, | ||
config: CFDictionaryRef) -> Boolean; | ||
pub fn SCNetworkInterfaceSetExtendedConfiguration(interface: SCNetworkInterfaceRef, | ||
extendedType: CFStringRef, | ||
config: CFDictionaryRef) -> Boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use core_foundation_sys::base::CFAllocatorRef; | ||
use core_foundation_sys::string::CFStringRef; | ||
|
||
use std::os::raw::c_void; | ||
|
||
|
||
pub type __SCPreferences = c_void; | ||
pub type SCPreferencesRef = *const __SCPreferences; | ||
|
||
|
||
#[link(name = "SystemConfiguration", kind = "framework")] | ||
extern "C" { | ||
pub fn SCPreferencesCreate(allocator: CFAllocatorRef, | ||
name: CFStringRef, | ||
prefsID: CFStringRef) -> SCPreferencesRef; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
extern crate system_configuration; | ||
|
||
use system_configuration::network_configuration::{ | ||
// SCNetworkInterfaceMTU, SCNetworkServiceDNS, | ||
SCNetworkGlobal, SCNetworkService, SCNetworkInterface | ||
}; | ||
|
||
|
||
fn main (){ | ||
println!("{:?}", SCNetworkGlobal.service()); | ||
|
||
println!("{:?}", SCNetworkGlobal.interface()); | ||
|
||
println!("{:?}", SCNetworkGlobal.router()); | ||
|
||
for service in SCNetworkService::list_order() { | ||
println!("{:?}\n\n", service); | ||
} | ||
|
||
println!("{:?}", SCNetworkService::list()); | ||
|
||
println!("{:?}", SCNetworkInterface::list()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.