这个项目有 Wi-Fi 相关操作:
https://github.com/digital-pers0n/Aerodrome/我提取了断开操作,我自己测试是可以的:
//main.m
#import <Foundation/Foundation.h>
struct Apple80211;
typedef struct Apple80211 *Apple80211Ref;
int Apple80211Disassociate(Apple80211Ref wref);
int Apple80211Open(Apple80211Ref *handle);
int Apple80211Close(Apple80211Ref handle);
int Apple80211BindToInterface(Apple80211Ref handle, CFStringRef interface);
int main() {
int error;
Apple80211Ref ref;
error = Apple80211Open(&ref);
Apple80211BindToInterface(ref, CFSTR("en0"));
if (error == 0) {
Apple80211Disassociate(ref);
} else {
printf("%d\n", error);
}
Apple80211Close(ref);
return 0;
}
// clang main.m -o main -O3 -F /System/Library/PrivateFrameworks -framework Apple80211 -framework Foundation && ./main