external/wpa_supplicant_6
Revisão | 9d919bf3263717f5b2049a32fdc2551fa365b096 (tree) |
---|---|
Hora | 2012-02-19 22:05:23 |
Autor | Stefan Seidel <android@stef...> |
Commiter | Stefan Seidel |
backport SIGNAL_POLL from wpa_supplicant 0.8.x to awext driver
@@ -1640,6 +1640,25 @@ static int wpa_supplicant_ctrl_iface_ap_scan( | ||
1640 | 1640 | } |
1641 | 1641 | |
1642 | 1642 | #ifdef ANDROID |
1643 | +static int wpa_supplicant_signal_poll(struct wpa_supplicant *wpa_s, char *buf, | |
1644 | + size_t buflen) | |
1645 | +{ | |
1646 | + struct wpa_signal_info si; | |
1647 | + int ret; | |
1648 | + | |
1649 | + ret = wpa_drv_signal_poll(wpa_s, &si); | |
1650 | + if (ret) | |
1651 | + return -1; | |
1652 | + | |
1653 | + ret = os_snprintf(buf, buflen, "RSSI=%d\nLINKSPEED=%d\n" | |
1654 | + "NOISE=%d\nFREQUENCY=%u\n", | |
1655 | + si.current_signal, si.current_txrate / 1000, | |
1656 | + si.current_noise, si.frequency); | |
1657 | + if (ret < 0 || (unsigned int) ret > buflen) | |
1658 | + return -1; | |
1659 | + return ret; | |
1660 | +} | |
1661 | + | |
1643 | 1662 | static int wpa_supplicant_driver_cmd(struct wpa_supplicant *wpa_s, |
1644 | 1663 | char *cmd, char *buf, size_t buflen) |
1645 | 1664 | { |
@@ -1839,6 +1858,8 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, | ||
1839 | 1858 | reply_len = wpa_supplicant_ctrl_iface_bss( |
1840 | 1859 | wpa_s, buf + 4, reply, reply_size); |
1841 | 1860 | #ifdef ANDROID |
1861 | + } else if (os_strncmp(buf, "SIGNAL_POLL", 11) == 0) { | |
1862 | + reply_len = wpa_supplicant_signal_poll(wpa_s, reply, reply_size); | |
1842 | 1863 | } else if (os_strncmp(buf, "DRIVER ", 7) == 0) { |
1843 | 1864 | reply_len = wpa_supplicant_driver_cmd(wpa_s, buf + 7, reply, reply_size); |
1844 | 1865 | #endif |
@@ -372,6 +372,17 @@ struct ieee80211_rx_status { | ||
372 | 372 | struct wpa_ssid; |
373 | 373 | |
374 | 374 | /** |
375 | + * struct wpa_signal_info - Information about channel signal quality | |
376 | + */ | |
377 | +struct wpa_signal_info { | |
378 | + u32 frequency; | |
379 | + int above_threshold; | |
380 | + int current_signal; | |
381 | + int current_noise; | |
382 | + int current_txrate; | |
383 | +}; | |
384 | + | |
385 | +/** | |
375 | 386 | * struct wpa_driver_ops - Driver interface API definition |
376 | 387 | * |
377 | 388 | * This structure defines the API that each driver interface needs to implement |
@@ -1037,6 +1048,13 @@ struct wpa_driver_ops { | ||
1037 | 1048 | struct wpa_interface_info * (*get_interfaces)(void *global_priv); |
1038 | 1049 | |
1039 | 1050 | #ifdef ANDROID |
1051 | + /** | |
1052 | + * signal_poll - Get current connection information | |
1053 | + * @priv: Private driver interface data | |
1054 | + * @signal_info: Connection info structure | |
1055 | + */ | |
1056 | + int (*signal_poll)(void *priv, struct wpa_signal_info *signal_info); | |
1057 | + | |
1040 | 1058 | /** |
1041 | 1059 | * driver_cmd - execute driver-specific command |
1042 | 1060 | * @priv: private driver interface data from init() |
@@ -663,6 +663,9 @@ int wpa_driver_awext_set_wpa(void *priv, int enabled) | ||
663 | 663 | } |
664 | 664 | |
665 | 665 | #ifdef ANDROID |
666 | +#define RSSI_CMD "RSSI" | |
667 | +#define LINKSPEED_CMD "LINKSPEED" | |
668 | + | |
666 | 669 | static int wpa_driver_priv_driver_cmd(void *priv, char *cmd, char *buf, size_t buf_len) |
667 | 670 | { |
668 | 671 |
@@ -872,6 +875,32 @@ static int wpa_driver_priv_driver_cmd(void *priv, char *cmd, char *buf, size_t b | ||
872 | 875 | } |
873 | 876 | return (ret); |
874 | 877 | } |
878 | + | |
879 | +static int wpa_driver_awext_signal_poll(void *priv, struct wpa_signal_info *si) | |
880 | +{ | |
881 | + char buf[MAX_DRV_CMD_SIZE]; | |
882 | + struct wpa_driver_awext_data *drv = priv; | |
883 | + char *prssi; | |
884 | + int res; | |
885 | + | |
886 | + os_memset(si, 0, sizeof(*si)); | |
887 | + res = wpa_driver_priv_driver_cmd(priv, RSSI_CMD, buf, sizeof(buf)); | |
888 | + /* Answer: SSID rssi -Val */ | |
889 | + if (res < 0) | |
890 | + return res; | |
891 | + prssi = strcasestr(buf, RSSI_CMD); | |
892 | + if (!prssi) | |
893 | + return -1; | |
894 | + si->current_signal = atoi(prssi + strlen(RSSI_CMD) + 1); | |
895 | + | |
896 | + res = wpa_driver_priv_driver_cmd(priv, LINKSPEED_CMD, buf, sizeof(buf)); | |
897 | + /* Answer: LinkSpeed Val */ | |
898 | + if (res < 0) | |
899 | + return res; | |
900 | + si->current_txrate = atoi(buf + strlen(LINKSPEED_CMD) + 1) * 1000; | |
901 | + | |
902 | + return 0; | |
903 | +} | |
875 | 904 | #endif |
876 | 905 | |
877 | 906 | const struct wpa_driver_ops wpa_driver_awext_ops = { |
@@ -908,6 +937,7 @@ const struct wpa_driver_ops wpa_driver_awext_ops = { | ||
908 | 937 | .mlme_remove_sta = wpa_driver_awext_mlme_remove_sta, |
909 | 938 | #endif /* CONFIG_CLIENT_MLME */ |
910 | 939 | #ifdef ANDROID |
940 | + .signal_poll = wpa_driver_awext_signal_poll, | |
911 | 941 | .driver_cmd = wpa_driver_priv_driver_cmd, |
912 | 942 | #endif |
913 | 943 | }; |
@@ -769,6 +769,14 @@ static inline int wpa_drv_set_probe_req_ie(struct wpa_supplicant *wpa_s, | ||
769 | 769 | } |
770 | 770 | |
771 | 771 | #ifdef ANDROID |
772 | +static inline int wpa_drv_signal_poll(struct wpa_supplicant *wpa_s, | |
773 | + struct wpa_signal_info *si) | |
774 | +{ | |
775 | + if (wpa_s->driver->signal_poll) | |
776 | + return wpa_s->driver->signal_poll(wpa_s->drv_priv, si); | |
777 | + return -1; | |
778 | +} | |
779 | + | |
772 | 780 | static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s, |
773 | 781 | char *cmd, char *buf, size_t buf_len) |
774 | 782 | { |