Skip to content

Commit

Permalink
Add new Client APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
zxystd committed Sep 12, 2021
1 parent b6a041f commit b40b49a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
30 changes: 30 additions & 0 deletions ClientKit/Api.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,36 @@ bool get_80211_state(uint32_t *state) {
return false;
}

bool get_network_ssid(char *ssid)
{
struct ioctl_nw_id nwid;
if (ioctl_get(IOCTL_80211_NW_ID, &nwid, sizeof(struct ioctl_nw_id)) != KERN_SUCCESS) {
goto error;
}

memcpy(ssid, nwid.nwid, nwid.len);

return true;

error:
return false;
}

bool get_network_bssid(char *bssid)
{
struct ioctl_nw_bssid nwbssid;
if (ioctl_get(IOCTL_80211_NW_BSSID, &nwbssid, sizeof(struct ioctl_nw_bssid)) != KERN_SUCCESS) {
goto error;
}

memcpy(bssid, nwbssid.bssid, ETHER_ADDR_LEN);

return true;

error:
return false;
}

bool get_network_list(network_info_list_t *list) {
memset(list, 0, sizeof(network_info_list_t));

Expand Down
4 changes: 4 additions & 0 deletions ClientKit/Api.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ bool get_power_state(bool *enabled);

bool get_80211_state(uint32_t *state);

bool get_network_ssid(char *ssid);

bool get_network_bssid(char *bssid);

bool get_network_list(network_info_list_t *list);

bool connect_network(const char *ssid, const char *pwd);
Expand Down
5 changes: 5 additions & 0 deletions ClientKit/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ struct ioctl_nw_id {
char nwid[NWID_LEN];
};

struct ioctl_nw_bssid {
unsigned int version;
char bssid[ETHER_ADDR_LEN];
};

struct ioctl_wpa_key {
unsigned int version;
unsigned int len;
Expand Down
1 change: 1 addition & 0 deletions ClientKit/IoctlId.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum IOCTL_IDS {
IOCTL_80211_SCAN,
IOCTL_80211_SCAN_RESULT,
IOCTL_80211_TX_POWER_LEVEL,
IOCTL_80211_NW_BSSID,

IOCTL_ID_MAX
};
Expand Down

0 comments on commit b40b49a

Please # to comment.