~ubuntu-branches/ubuntu/precise/wpasupplicant/precise-security

« back to all changes in this revision

Viewing changes to wpa_supplicant/scan.c

  • Committer: Bazaar Package Importer
  • Author(s): Kel Modderman
  • Date: 2009-05-16 03:47:08 UTC
  • mfrom: (4.1.5 karmic)
  • Revision ID: james.westby@ubuntu.com-20090516034708-pkqje2dgvhj6tb2i
Tags: 0.6.9-3
Drop debian/patches/12_syslog_supplement.patch. It adds code which
attempts to prettify output but doesn't handle large output well.
(Closes: #528639)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include "config.h"
20
20
#include "wpa_supplicant_i.h"
21
21
#include "mlme.h"
22
 
#include "uuid.h"
 
22
#include "wps_supplicant.h"
23
23
 
24
24
 
25
25
static void wpa_supplicant_gen_assoc_event(struct wpa_supplicant *wpa_s)
41
41
}
42
42
 
43
43
 
 
44
#ifdef CONFIG_WPS
 
45
static int wpas_wps_in_use(struct wpa_config *conf,
 
46
                           enum wps_request_type *req_type)
 
47
{
 
48
        struct wpa_ssid *ssid;
 
49
        int wps = 0;
 
50
 
 
51
        for (ssid = conf->ssid; ssid; ssid = ssid->next) {
 
52
                if (!(ssid->key_mgmt & WPA_KEY_MGMT_WPS))
 
53
                        continue;
 
54
 
 
55
                wps = 1;
 
56
                *req_type = wpas_wps_get_req_type(ssid);
 
57
                if (!ssid->eap.phase1)
 
58
                        continue;
 
59
 
 
60
                if (os_strstr(ssid->eap.phase1, "pbc=1"))
 
61
                        return 2;
 
62
        }
 
63
 
 
64
        return wps;
 
65
}
 
66
#endif /* CONFIG_WPS */
 
67
 
44
68
static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
45
69
{
46
70
        struct wpa_supplicant *wpa_s = eloop_ctx;
47
71
        struct wpa_ssid *ssid;
48
72
        int enabled, scan_req = 0, ret;
 
73
        struct wpabuf *wps_ie = NULL;
49
74
        const u8 *extra_ie = NULL;
50
75
        size_t extra_ie_len = 0;
 
76
        int wps = 0;
 
77
#ifdef CONFIG_WPS
 
78
        enum wps_request_type req_type = WPS_REQ_ENROLLEE_INFO;
 
79
#endif /* CONFIG_WPS */
51
80
 
52
81
        if (wpa_s->disconnected && !wpa_s->scan_req)
53
82
                return;
70
99
        wpa_s->scan_req = 0;
71
100
 
72
101
        if (wpa_s->conf->ap_scan != 0 &&
73
 
            wpa_s->driver && os_strcmp(wpa_s->driver->name, "wired") == 0) {
74
 
                wpa_printf(MSG_DEBUG, "Using wired driver - overriding "
75
 
                           "ap_scan configuration");
 
102
            wpa_s->driver && IS_WIRED(wpa_s->driver)) {
 
103
                wpa_printf(MSG_DEBUG, "Using wired authentication - "
 
104
                           "overriding ap_scan configuration");
76
105
                wpa_s->conf->ap_scan = 0;
77
106
        }
78
107
 
134
163
        } else
135
164
                wpa_s->prev_scan_ssid = BROADCAST_SSID_SCAN;
136
165
 
 
166
#ifdef CONFIG_WPS
 
167
        wps = wpas_wps_in_use(wpa_s->conf, &req_type);
 
168
#endif /* CONFIG_WPS */
 
169
 
137
170
        if (wpa_s->scan_res_tried == 0 && wpa_s->conf->ap_scan == 1 &&
138
 
            !wpa_s->use_client_mlme) {
 
171
            !wpa_s->use_client_mlme && wps != 2) {
139
172
                wpa_s->scan_res_tried++;
 
173
                wpa_s->scan_req = scan_req;
140
174
                wpa_printf(MSG_DEBUG, "Trying to get current scan results "
141
175
                           "first without requesting a new scan to speed up "
142
176
                           "initial association");
144
178
                return;
145
179
        }
146
180
 
 
181
#ifdef CONFIG_WPS
 
182
        if (wps) {
 
183
                wps_ie = wps_build_probe_req_ie(wps == 2, &wpa_s->wps->dev,
 
184
                                                wpa_s->wps->uuid, req_type);
 
185
                if (wps_ie) {
 
186
                        extra_ie = wpabuf_head(wps_ie);
 
187
                        extra_ie_len = wpabuf_len(wps_ie);
 
188
                }
 
189
        }
 
190
#endif /* CONFIG_WPS */
 
191
 
147
192
        if (wpa_s->use_client_mlme) {
148
193
                ieee80211_sta_set_probe_req_ie(wpa_s, extra_ie, extra_ie_len);
149
194
                ret = ieee80211_sta_req_scan(wpa_s, ssid ? ssid->ssid : NULL,
154
199
                                   ssid ? ssid->ssid_len : 0);
155
200
        }
156
201
 
 
202
        wpabuf_free(wps_ie);
 
203
 
157
204
        if (ret) {
158
205
                wpa_printf(MSG_WARNING, "Failed to initiate AP scan.");
159
206
                wpa_supplicant_req_scan(wpa_s, 10, 0);
160
 
        }
 
207
        } else
 
208
                wpa_s->scan_runs++;
161
209
}
162
210
 
163
211