diff options
author | JaeMan Park <jaeman@google.com> | 2022-03-22 01:08:52 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-03-22 01:08:52 +0000 |
commit | 45a7f09284770d8ef60850329e5e084e7f02ec56 (patch) | |
tree | b460a8d29b6378ec8912f3aa827bfb4ac71c2fd8 | |
parent | 174aa96c0c98b88df3afc23f7f0ec47c4d879dbb (diff) | |
parent | 5ddafbfabc6f4663ff43505b524539504b2805f6 (diff) | |
download | wmediumd-android-13.0.0_r34.tar.gz |
Add API for listing stations at wmediumd am: ab76216841 am: 0c959925e1 am: 5ddafbfabct_frc_odp_330442040t_frc_odp_330442000t_frc_ase_330444010android-t-qpr3-beta-3-gplandroid-t-qpr3-beta-1-gplandroid-t-qpr2-beta-3-gplandroid-t-qpr2-beta-2-gplandroid-13.0.0_r83android-13.0.0_r82android-13.0.0_r81android-13.0.0_r80android-13.0.0_r79android-13.0.0_r78android-13.0.0_r77android-13.0.0_r76android-13.0.0_r75android-13.0.0_r74android-13.0.0_r73android-13.0.0_r72android-13.0.0_r71android-13.0.0_r70android-13.0.0_r69android-13.0.0_r68android-13.0.0_r67android-13.0.0_r66android-13.0.0_r65android-13.0.0_r64android-13.0.0_r63android-13.0.0_r62android-13.0.0_r61android-13.0.0_r60android-13.0.0_r59android-13.0.0_r58android-13.0.0_r57android-13.0.0_r56android-13.0.0_r54android-13.0.0_r53android-13.0.0_r52android-13.0.0_r51android-13.0.0_r50android-13.0.0_r49android-13.0.0_r48android-13.0.0_r47android-13.0.0_r46android-13.0.0_r45android-13.0.0_r44android-13.0.0_r43android-13.0.0_r42android-13.0.0_r41android-13.0.0_r40android-13.0.0_r39android-13.0.0_r38android-13.0.0_r37android-13.0.0_r36android-13.0.0_r35android-13.0.0_r34android-13.0.0_r33android-13.0.0_r32aml_go_odp_330912000aml_go_ads_330915100aml_go_ads_330915000aml_go_ads_330913000android13-qpr3-s9-releaseandroid13-qpr3-s8-releaseandroid13-qpr3-s7-releaseandroid13-qpr3-s6-releaseandroid13-qpr3-s5-releaseandroid13-qpr3-s4-releaseandroid13-qpr3-s3-releaseandroid13-qpr3-s2-releaseandroid13-qpr3-s14-releaseandroid13-qpr3-s13-releaseandroid13-qpr3-s12-releaseandroid13-qpr3-s11-releaseandroid13-qpr3-s10-releaseandroid13-qpr3-s1-releaseandroid13-qpr3-releaseandroid13-qpr3-c-s8-releaseandroid13-qpr3-c-s7-releaseandroid13-qpr3-c-s6-releaseandroid13-qpr3-c-s5-releaseandroid13-qpr3-c-s4-releaseandroid13-qpr3-c-s3-releaseandroid13-qpr3-c-s2-releaseandroid13-qpr3-c-s12-releaseandroid13-qpr3-c-s11-releaseandroid13-qpr3-c-s10-releaseandroid13-qpr3-c-s1-releaseandroid13-qpr2-s9-releaseandroid13-qpr2-s8-releaseandroid13-qpr2-s7-releaseandroid13-qpr2-s6-releaseandroid13-qpr2-s5-releaseandroid13-qpr2-s3-releaseandroid13-qpr2-s2-releaseandroid13-qpr2-s12-releaseandroid13-qpr2-s11-releaseandroid13-qpr2-s10-releaseandroid13-qpr2-s1-releaseandroid13-qpr2-releaseandroid13-qpr2-b-s1-releaseandroid13-mainline-go-adservices-releaseandroid13-frc-odp-releaseandroid13-devandroid13-d4-s2-releaseandroid13-d4-s1-releaseandroid13-d4-releaseandroid13-d3-s1-release
Original change: https://android-review.googlesource.com/c/platform/external/wmediumd/+/1990341
Change-Id: I754dacb6a1e3fd5a6da4cbf24687835e520ff0da
-rw-r--r-- | Android.bp | 14 | ||||
-rw-r--r-- | wmediumd/api.h | 26 | ||||
-rw-r--r-- | wmediumd/wmediumd.c | 60 |
3 files changed, 94 insertions, 6 deletions
@@ -73,3 +73,17 @@ cc_binary_host { stl: "none", static_executable: true, } + +cc_library_headers { + name: "wmediumd_headers", + export_include_dirs: [ + ".", + ], + visibility: [ + "//device/google/cuttlefish/host/libs/wmediumd_controller", + "//device/google/cuttlefish/host/commands/wmediumd_control", + ], + stl: "none", + host_supported: true, + vendor_available: true, +} diff --git a/wmediumd/api.h b/wmediumd/api.h index d157e5c..ba507e4 100644 --- a/wmediumd/api.h +++ b/wmediumd/api.h @@ -7,6 +7,8 @@ #define _WMEDIUMD_API_H #include <stdint.h> +#include "ieee80211.h" + enum wmediumd_message { /* invalid message */ WMEDIUMD_MSG_INVALID, @@ -37,10 +39,7 @@ enum wmediumd_message { */ WMEDIUMD_MSG_TX_START, - /* - * TODO(@jaeman) Get list of currnet nodes. - */ - WMEDIUMD_MSG_GET_NODES, + WMEDIUMD_MSG_GET_STATIONS, /* * Set SNR between two nodes. @@ -69,6 +68,8 @@ enum wmediumd_message { * Stop packet capture */ WMEDIUMD_MSG_STOP_PCAP, + + WMEDIUMD_MSG_STATIONS_LIST, }; struct wmediumd_message_header { @@ -127,4 +128,21 @@ struct wmediumd_start_pcap { char pcap_path[0]; }; +#pragma pack(push, 1) +struct wmediumd_station_info { + char addr[ETH_ALEN]; + char hwaddr[ETH_ALEN]; + + double x; + double y; + + int tx_power; +}; + +struct wmediumd_station_infos { + uint32_t count; + struct wmediumd_station_info stations[0]; +}; +#pragma pack(pop) + #endif /* _WMEDIUMD_API_H */ diff --git a/wmediumd/wmediumd.c b/wmediumd/wmediumd.c index 9c1eeeb..6b3ae5d 100644 --- a/wmediumd/wmediumd.c +++ b/wmediumd/wmediumd.c @@ -1106,6 +1106,42 @@ static int process_reload_current_config_message(struct wmediumd *ctx) { return result; } +static int process_get_stations_message(struct wmediumd *ctx, ssize_t *response_len, unsigned char **response_data) { + struct station *station; + int station_count = 0; + + list_for_each_entry(station, &ctx->stations, list) { + if (station->client != NULL) { + ++station_count; + } + } + + *response_len = sizeof(uint32_t) + sizeof(struct wmediumd_station_info) * station_count; + struct wmediumd_station_infos *station_infos = malloc(*response_len); + + station_infos->count = station_count; + int station_index = 0; + + list_for_each_entry(station, &ctx->stations, list) { + if (station->client != NULL) { + struct wmediumd_station_info *station_info = &station_infos->stations[station_index]; + memcpy(station_info->addr, station->addr, ETH_ALEN); + memcpy(station_info->hwaddr, station->hwaddr, ETH_ALEN); + + station_info->x = station->x; + station_info->y = station->y; + + station_info->tx_power = station->tx_power; + + station_index++; + } + } + + *response_data = (unsigned char *)station_infos; + + return 0; +} + static const struct usfstl_vhost_user_ops wmediumd_vu_ops = { .connected = wmediumd_vu_connected, .handle = wmediumd_vu_handle, @@ -1134,6 +1170,8 @@ static void wmediumd_api_handler(struct usfstl_loop_entry *entry) struct wmediumd_message_control control = {}; struct nl_msg *nlmsg; unsigned char *data; + ssize_t response_len = 0; + unsigned char *response_data = NULL; ssize_t len; len = read(entry->fd, &hdr, sizeof(hdr)); @@ -1196,7 +1234,11 @@ static void wmediumd_api_handler(struct usfstl_loop_entry *entry) client->flags = control.flags; break; - case WMEDIUMD_MSG_GET_NODES: + case WMEDIUMD_MSG_GET_STATIONS: + if (process_get_stations_message(ctx, &response_len, &response_data) < 0) { + response = WMEDIUMD_MSG_INVALID; + } + response = WMEDIUMD_MSG_STATIONS_LIST; break; case WMEDIUMD_MSG_SET_SNR: if (process_set_snr_message(ctx, (struct wmediumd_set_snr *)data) < 0) { @@ -1233,11 +1275,25 @@ static void wmediumd_api_handler(struct usfstl_loop_entry *entry) /* return a response */ hdr.type = response; - hdr.data_len = 0; + hdr.data_len = response_len; len = write(entry->fd, &hdr, sizeof(hdr)); if (len != sizeof(hdr)) goto disconnect; + if (response_data != NULL) { + if (response_len != 0) { + len = write(entry->fd, response_data, response_len); + + if (len != response_len) { + free(response_data); + goto disconnect; + } + } + + free(response_data); + response_data = NULL; + } + return; disconnect: usfstl_loop_unregister(&client->loop); |