-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-Authored-By: Goshin <[email protected]> Co-Authored-By: zxystd <[email protected]> Co-Authored-By: DogAndPot <[email protected]>
- Loading branch information
Showing
63 changed files
with
4,290 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
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,31 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: "[Bug]" | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. | ||
2. | ||
3. | ||
4. | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Environment (please complete the following information):** | ||
- OS Version: | ||
- Software Version: | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
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,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: "[Feature Request]" | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
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,49 @@ | ||
# Xcode | ||
# | ||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore | ||
|
||
## macOS | ||
.DS_Store | ||
._* | ||
|
||
## User settings | ||
xcuserdata/ | ||
|
||
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) | ||
*.xcscmblueprint | ||
*.xccheckout | ||
|
||
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) | ||
build/ | ||
Build/ | ||
DerivedData/ | ||
*.moved-aside | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
|
||
## Obj-C/Swift specific | ||
*.hmap | ||
|
||
## App packaging | ||
*.dSYM.zip | ||
*.dSYM | ||
|
||
## Playgrounds | ||
timeline.xctimeline | ||
playground.xcworkspace | ||
|
||
.build/ | ||
|
||
# CocoaPods | ||
# | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
# | ||
# Pods/ |
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,63 @@ | ||
// | ||
// Api.c | ||
// ClientKit | ||
// | ||
// Created by 钟先耀 on 2020/4/7. | ||
// Copyright © 2020 lhy. All rights reserved. | ||
// | ||
|
||
/* | ||
* This program and the accompanying materials are licensed and made available | ||
* under the terms and conditions of the The 3-Clause BSD License | ||
* which accompanies this distribution. The full text of the license may be found at | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
#include "Api.h" | ||
|
||
static io_service_t service; | ||
static io_connect_t driver_connection; | ||
|
||
bool connect_driver(void) { | ||
printf("connecting driver\n"); | ||
|
||
service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("ItlNetworkUserClient")); | ||
if (service == IO_OBJECT_NULL) { | ||
printf("could not find any service matching\n"); | ||
return false; | ||
} | ||
|
||
if (IOServiceOpen(service, mach_task_self(), 0, &driver_connection) != KERN_SUCCESS) { | ||
printf("could not open service\n"); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool get_platform_info(platform_info_t *info) { | ||
memset(info, 0, sizeof(platform_info_t)); | ||
// test | ||
strcpy(info->device_info_str, "intel"); | ||
strcpy(info->driver_info_str, "itwlm v1.0"); | ||
return true; | ||
} | ||
|
||
bool get_network_list(network_info_list_t *list) { | ||
memset(list, 0, sizeof(network_info_list_t)); | ||
// test | ||
list->count = 2; | ||
strcpy(list->networks[0].SSID, "test0"); | ||
list->networks[0].is_connected = true; | ||
list->networks[0].is_encrypted = true; | ||
|
||
strcpy(list->networks[1].SSID, "test2"); | ||
list->networks[1].is_connected = false; | ||
list->networks[1].is_encrypted = true; | ||
return true; | ||
} | ||
|
||
void disconnect_driver(void) { | ||
IOServiceClose(driver_connection); | ||
IOObjectRelease(service); | ||
} |
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,53 @@ | ||
// | ||
// Api.h | ||
// ClientKit | ||
// | ||
// Created by 钟先耀 on 2020/4/7. | ||
// Copyright © 2020 lhy. All rights reserved. | ||
// | ||
|
||
/* | ||
* This program and the accompanying materials are licensed and made available | ||
* under the terms and conditions of the The 3-Clause BSD License | ||
* which accompanies this distribution. The full text of the license may be found at | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
#ifndef Api_h | ||
#define Api_h | ||
|
||
#include <IOKit/IOKitLib.h> | ||
#include "Common.h" | ||
#include <inttypes.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#define MAX_NETWORK_LIST_LENGTH 50 | ||
|
||
typedef struct { | ||
char device_info_str[32]; | ||
char driver_info_str[32]; | ||
} platform_info_t; | ||
|
||
typedef struct { | ||
char SSID[32]; | ||
bool is_connected; | ||
bool is_encrypted; | ||
int RSSI; | ||
char password[63]; | ||
} network_info_t; | ||
|
||
typedef struct { | ||
int count; | ||
network_info_t networks[MAX_NETWORK_LIST_LENGTH]; | ||
} network_info_list_t; | ||
|
||
bool connect_driver(void); | ||
|
||
void disconnect_driver(void); | ||
|
||
bool get_platform_info(platform_info_t *result); | ||
|
||
bool get_network_list(network_info_list_t *list); | ||
|
||
#endif /* Api_h */ |
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,86 @@ | ||
// | ||
// main.cpp | ||
// ClientKit | ||
// | ||
// Created by 钟先耀 on 2020/4/7. | ||
// Copyright © 2020 lhy. All rights reserved. | ||
// | ||
|
||
/* | ||
* This program and the accompanying materials are licensed and made available | ||
* under the terms and conditions of the The 3-Clause BSD License | ||
* which accompanies this distribution. The full text of the license may be found at | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
#include <iostream> | ||
#include <sys/types.h> | ||
#include <sys/socket.h> | ||
#include <sys/file.h> | ||
#include <sys/sys_domain.h> | ||
#include <sys/ioctl.h> | ||
#include <sys/kern_event.h> | ||
#include <sys/kern_control.h> | ||
|
||
#include "Api.h" | ||
|
||
IONotificationPortRef gAsyncNotificationPort = NULL; | ||
|
||
IONotificationPortRef MyDriverGetAsyncCompletionPort() | ||
{ | ||
if (gAsyncNotificationPort != NULL) | ||
return gAsyncNotificationPort; | ||
|
||
gAsyncNotificationPort = IONotificationPortCreate(kIOMasterPortDefault); | ||
return gAsyncNotificationPort; | ||
} | ||
|
||
int main(int argc, const char * argv[]) { | ||
CFDictionaryRef matchingDict = NULL; | ||
io_iterator_t iter = 0; | ||
io_service_t service = 0; | ||
kern_return_t kr; | ||
|
||
matchingDict = IOServiceMatching("ItlNetworkUserClient"); | ||
kr = IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, &iter); | ||
if (kr != KERN_SUCCESS) | ||
return -1; | ||
while ((service = IOIteratorNext(iter)) != 0) | ||
{ | ||
task_port_t owningTask = mach_task_self(); | ||
uint32_t type = 0; | ||
io_connect_t driverConnection; | ||
|
||
kr = IOServiceOpen( | ||
service, | ||
owningTask, | ||
type, | ||
&driverConnection); | ||
if (kr == KERN_SUCCESS) | ||
{ | ||
IONotificationPortRef notificationPort; | ||
notificationPort = MyDriverGetAsyncCompletionPort(); | ||
if (notificationPort) | ||
{ | ||
CFRunLoopSourceRef runLoopSource; | ||
runLoopSource = IONotificationPortGetRunLoopSource(notificationPort); | ||
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopDefaultMode); | ||
} | ||
|
||
kr = IOConnectCallAsyncScalarMethod(driverConnection, IOCTL_80211_TEST, IONotificationPortGetMachPort(gAsyncNotificationPort), NULL, kIOAsyncCalloutCount, NULL, 1, NULL, NULL); | ||
printf("IOCTL_80211_TEST - %08x\n", kr); | ||
|
||
CFRunLoopRun(); | ||
|
||
IONotificationPortDestroy(gAsyncNotificationPort); | ||
gAsyncNotificationPort = NULL; | ||
IOServiceClose(driverConnection); | ||
} | ||
|
||
IOObjectRelease(service); | ||
} | ||
IOObjectRelease(iter); | ||
|
||
std::cout << "Hello, World!\n"; | ||
return 0; | ||
} |
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,22 @@ | ||
// | ||
// Common.h | ||
// ClientKit | ||
// | ||
// Created by 钟先耀 on 2020/4/7. | ||
// Copyright © 2020 lhy. All rights reserved. | ||
// | ||
|
||
/* | ||
* This program and the accompanying materials are licensed and made available | ||
* under the terms and conditions of the The 3-Clause BSD License | ||
* which accompanies this distribution. The full text of the license may be found at | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
#ifndef Common_h | ||
#define Common_h | ||
|
||
#include "IoctlId.h" | ||
|
||
|
||
#endif /* Common_h */ |
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,61 @@ | ||
// | ||
// IoctlId.h | ||
// HeliPort | ||
// | ||
// Created by 钟先耀 on 2020/4/8. | ||
// Copyright © 2020 lhy. All rights reserved. | ||
// | ||
|
||
/* | ||
* This program and the accompanying materials are licensed and made available | ||
* under the terms and conditions of the The 3-Clause BSD License | ||
* which accompanies this distribution. The full text of the license may be found at | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
#ifndef IoctlId_h | ||
#define IoctlId_h | ||
|
||
enum IOCTL_IDS { | ||
IOCTL_80211_TEST, | ||
IOCTL_80211_BSSID, | ||
IOCTL_80211_SSID, | ||
IOCTL_80211_NETWORK_TYPES_SUPPORTED, | ||
IOCTL_80211_NETWORK_TYPE_IN_USE, | ||
IOCTL_80211_TX_POWER_LEVEL, | ||
IOCTL_80211_RSSI, | ||
IOCTL_80211_RSSI_TRIGGER, | ||
IOCTL_80211_INFRASTRUCTURE_MODE, | ||
IOCTL_80211_FRAGMENTATION_THRESHOLD, | ||
IOCTL_80211_RTS_THRESHOLD, | ||
IOCTL_80211_NUMBER_OF_ANTENNAS, | ||
IOCTL_80211_RX_ANTENNA_SELECTED, | ||
IOCTL_80211_TX_ANTENNA_SELECTED, | ||
IOCTL_80211_SUPPORTED_RATES, | ||
IOCTL_80211_DESIRED_RATES, | ||
IOCTL_80211_CONFIGURATION, | ||
IOCTL_80211_STATISTICS, | ||
IOCTL_80211_ADD_WEP, | ||
IOCTL_80211_REMOVE_WEP, | ||
IOCTL_80211_DISASSOCIATE, | ||
IOCTL_80211_POWER_MODE, | ||
IOCTL_80211_BSSID_LIST, | ||
IOCTL_80211_BSSID_LIST_NEXT, | ||
IOCTL_80211_AUTHENTICATION_MODE, | ||
IOCTL_80211_PRIVACY_FILTER, | ||
IOCTL_80211_BSSID_LIST_SCAN, | ||
IOCTL_80211_WEP_STATUS, | ||
IOCTL_80211_RELOAD_DEFAULTS, | ||
IOCTL_80211_ADD_KEY, | ||
IOCTL_80211_REMOVE_KEY, | ||
IOCTL_80211_ASSOCIATION_INFORMATION, | ||
IOCTL_80211_TEST_SLEEP, | ||
IOCTL_80211_DEVICE_READY_AFTER_SLEEP, | ||
IOCTL_80211_IS_PORT_SECURED, | ||
|
||
IOCTL_ID_MAX | ||
}; | ||
|
||
#define SIOCSTEST 0x10086 | ||
|
||
#endif /* IoctlId_h */ |
Oops, something went wrong.