• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythonwindowsphpgamebathyscaphegui翻訳comegattwitterframeworkbtronvb.net計画中(planning stage)testdomarduinodirectxpreviewerゲームエンジン

external/wpa_supplicant_6


Commit MetaInfo

Revisione579499f62982cc3493149d3947b9d2f67b105d6 (tree)
Zeit2011-02-19 09:48:12
AutorDmitry Shmidt <dimitrysh@goog...>
CommiterDmitry Shmidt

Log Message

WEXT: Add background scan command support

Change-Id: Ib9b37d4a4f43148c245942b2f59a0eee5629ec4d
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

Ändern Zusammenfassung

Diff

--- a/wpa_supplicant/src/drivers/driver_wext.c
+++ b/wpa_supplicant/src/drivers/driver_wext.c
@@ -33,7 +33,7 @@
3333 #include "wpa_common.h"
3434 #include "wpa_ctrl.h"
3535 #include "wpa_supplicant_i.h"
36-#include "config_ssid.h"
36+#include "config.h"
3737
3838
3939 static int wpa_driver_wext_flush_pmkid(void *priv);
@@ -2587,6 +2587,85 @@ static char *wpa_driver_get_country_code(int channels)
25872587 return country;
25882588 }
25892589
2590+static int wpa_driver_set_backgroundscan_params(void *priv)
2591+{
2592+ struct wpa_driver_wext_data *drv = priv;
2593+ struct wpa_supplicant *wpa_s;
2594+ struct iwreq iwr;
2595+ int ret = 0, i = 0, bp;
2596+ char buf[WEXT_PNO_MAX_COMMAND_SIZE];
2597+ struct wpa_ssid *ssid_conf;
2598+
2599+ if (drv == NULL){
2600+ wpa_printf(MSG_ERROR, "%s: drv is NULL. Exiting", __func__);
2601+ return -1;
2602+ }
2603+ if (drv->ctx == NULL){
2604+ wpa_printf(MSG_ERROR, "%s: drv->ctx is NULL. Exiting", __func__);
2605+ return -1;
2606+ }
2607+ wpa_s = (struct wpa_supplicant *)(drv->ctx);
2608+ if (wpa_s->conf == NULL) {
2609+ wpa_printf(MSG_ERROR, "%s: wpa_s->conf is NULL. Exiting", __func__);
2610+ return -1;
2611+ }
2612+ ssid_conf = wpa_s->conf->ssid;
2613+
2614+ bp = WEXT_PNOSETUP_HEADER_SIZE;
2615+ os_memcpy(buf, WEXT_PNOSETUP_HEADER, bp);
2616+ buf[bp++] = 'S';
2617+ buf[bp++] = WEXT_PNO_TLV_VERSION;
2618+ buf[bp++] = WEXT_PNO_TLV_SUBVERSION;
2619+ buf[bp++] = WEXT_PNO_TLV_RESERVED;
2620+
2621+ while ((i < WEXT_PNO_AMOUNT) && (ssid_conf != NULL)) {
2622+ /* Check that there is enough space needed for 1 more SSID, the other sections and null termination */
2623+ if ((bp + WEXT_PNO_SSID_HEADER_SIZE + IW_ESSID_MAX_SIZE + WEXT_PNO_NONSSID_SECTIONS_SIZE + 1) >= (int)sizeof(buf))
2624+ break;
2625+ if ((!ssid_conf->disabled) && (ssid_conf->ssid_len <= IW_ESSID_MAX_SIZE)){
2626+ wpa_printf(MSG_DEBUG, "For PNO Scan: %s", ssid_conf->ssid);
2627+ buf[bp++] = WEXT_PNO_SSID_SECTION;
2628+ buf[bp++] = ssid_conf->ssid_len;
2629+ os_memcpy(&buf[bp], ssid_conf->ssid, ssid_conf->ssid_len);
2630+ bp += ssid_conf->ssid_len;
2631+ i++;
2632+ }
2633+ ssid_conf = ssid_conf->next;
2634+ }
2635+
2636+ buf[bp++] = WEXT_PNO_SCAN_INTERVAL_SECTION;
2637+ os_snprintf(&buf[bp], WEXT_PNO_SCAN_INTERVAL_LENGTH + 1, "%x", WEXT_PNO_SCAN_INTERVAL);
2638+ bp += WEXT_PNO_SCAN_INTERVAL_LENGTH;
2639+
2640+ buf[bp++] = WEXT_PNO_REPEAT_SECTION;
2641+ os_snprintf(&buf[bp], WEXT_PNO_REPEAT_LENGTH + 1, "%x", WEXT_PNO_REPEAT);
2642+ bp += WEXT_PNO_REPEAT_LENGTH;
2643+
2644+ buf[bp++] = WEXT_PNO_MAX_REPEAT_SECTION;
2645+ os_snprintf(&buf[bp], WEXT_PNO_MAX_REPEAT_LENGTH + 1, "%x", WEXT_PNO_MAX_REPEAT);
2646+ bp += WEXT_PNO_MAX_REPEAT_LENGTH + 1;
2647+
2648+ os_memset(&iwr, 0, sizeof(iwr));
2649+ os_strncpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
2650+ iwr.u.data.pointer = buf;
2651+ iwr.u.data.length = bp;
2652+
2653+ ret = ioctl(drv->ioctl_sock, SIOCSIWPRIV, &iwr);
2654+
2655+ if (ret < 0) {
2656+ wpa_printf(MSG_ERROR, "ioctl[SIOCSIWPRIV] (pnosetup): %d", ret);
2657+ drv->errors++;
2658+ if (drv->errors > WEXT_NUMBER_SEQUENTIAL_ERRORS) {
2659+ drv->errors = 0;
2660+ wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "HANGED");
2661+ }
2662+ } else {
2663+ drv->errors = 0;
2664+ }
2665+ return ret;
2666+
2667+}
2668+
25902669 static int wpa_driver_priv_driver_cmd( void *priv, char *cmd, char *buf, size_t buf_len )
25912670 {
25922671 struct wpa_driver_wext_data *drv = priv;
@@ -2619,6 +2698,14 @@ static int wpa_driver_priv_driver_cmd( void *priv, char *cmd, char *buf, size_t
26192698 wpa_printf(MSG_DEBUG,"Reload command");
26202699 wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "HANGED");
26212700 return ret;
2701+ } else if( os_strcasecmp(cmd, "BGSCAN-START") == 0 ) {
2702+ ret = wpa_driver_set_backgroundscan_params(priv);
2703+ if (ret < 0) {
2704+ return ret;
2705+ }
2706+ os_strncpy(cmd, "PNOFORCE 1", MAX_DRV_CMD_SIZE);
2707+ } else if( os_strcasecmp(cmd, "BGSCAN-STOP") == 0 ) {
2708+ os_strncpy(cmd, "PNOFORCE 0", MAX_DRV_CMD_SIZE);
26222709 }
26232710
26242711 os_memset(&iwr, 0, sizeof(iwr));
--- a/wpa_supplicant/src/drivers/driver_wext.h
+++ b/wpa_supplicant/src/drivers/driver_wext.h
@@ -111,6 +111,38 @@ int wpa_driver_wext_keymgmt2wext(int keymgmt);
111111 #define WEXT_CSCAN_PASV_DWELL_TIME_DEF 250
112112 #define WEXT_CSCAN_PASV_DWELL_TIME_MAX 3000
113113 #define WEXT_CSCAN_HOME_DWELL_TIME 130
114+
115+#define WEXT_PNOSETUP_HEADER "PNOSETUP "
116+#define WEXT_PNOSETUP_HEADER_SIZE 9
117+#define WEXT_PNO_TLV_VERSION '1'
118+#define WEXT_PNO_TLV_SUBVERSION '2'
119+#define WEXT_PNO_TLV_RESERVED '0'
120+#define WEXT_PNO_VERSION_SIZE 4
121+#define WEXT_PNO_AMOUNT 16
122+#define WEXT_PNO_SSID_SECTION 'S'
123+/* SSID header size is SSID section type above + SSID length */
124+#define WEXT_PNO_SSID_HEADER_SIZE 2
125+#define WEXT_PNO_SCAN_INTERVAL_SECTION 'T'
126+#define WEXT_PNO_SCAN_INTERVAL_LENGTH 2
127+#define WEXT_PNO_SCAN_INTERVAL 30
128+/* Scan interval size is scan interval section type + scan interval length above*/
129+#define WEXT_PNO_SCAN_INTERVAL_SIZE (1 + WEXT_PNO_SCAN_INTERVAL_LENGTH)
130+#define WEXT_PNO_REPEAT_SECTION 'R'
131+#define WEXT_PNO_REPEAT_LENGTH 1
132+#define WEXT_PNO_REPEAT 4
133+/* Repeat section size is Repeat section type + Repeat value length above*/
134+#define WEXT_PNO_REPEAT_SIZE (1 + WEXT_PNO_REPEAT_LENGTH)
135+#define WEXT_PNO_MAX_REPEAT_SECTION 'M'
136+#define WEXT_PNO_MAX_REPEAT_LENGTH 1
137+#define WEXT_PNO_MAX_REPEAT 3
138+/* Max Repeat section size is Max Repeat section type + Max Repeat value length above*/
139+#define WEXT_PNO_MAX_REPEAT_SIZE (1 + WEXT_PNO_MAX_REPEAT_LENGTH)
140+/* This corresponds to the size of all sections expect SSIDs */
141+#define WEXT_PNO_NONSSID_SECTIONS_SIZE (WEXT_PNO_SCAN_INTERVAL_SIZE + WEXT_PNO_REPEAT_SIZE + WEXT_PNO_MAX_REPEAT_SIZE)
142+/* PNO Max command size is total of header, version, ssid and other sections + Null termination */
143+#define WEXT_PNO_MAX_COMMAND_SIZE (WEXT_PNOSETUP_HEADER_SIZE + WEXT_PNO_VERSION_SIZE \
144+ + WEXT_PNO_AMOUNT * (WEXT_PNO_SSID_HEADER_SIZE + IW_ESSID_MAX_SIZE) \
145+ + WEXT_PNO_NONSSID_SECTIONS_SIZE + 1)
114146 #endif
115147
116148 #endif /* DRIVER_WEXT_H */