~ubuntu-branches/ubuntu/lucid/wpasupplicant/lucid-updates

« back to all changes in this revision

Viewing changes to wpa_supplicant.c

  • Committer: Bazaar Package Importer
  • Author(s): Kel Modderman
  • Date: 2006-10-05 08:04:01 UTC
  • mfrom: (1.1.5 upstream) (3 etch)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20061005080401-r8lqlix4390yos7b
Tags: 0.5.5-2
* Update madwifi headers to latest SVN. (Closes: #388316)
* Remove failed attempt at action locking. [debian/functions.sh,
  debian/wpa_action.sh]
* Add hysteresis checking functions, to avoid "event loops" while
  using wpa-roam. [debian/functions.sh, debian/wpa_action.sh]
* Change of co-maintainer email address.
* Add ishex() function to functions.sh to determine wpa-psk value type in
  plaintext or hex. This effectively eliminates the need for the bogus and
  somewhat confusing wpa-passphrase contruct specific to our scripts and
  allows wpa-psk to work with either a 8 to 63 character long plaintext
  string or 64 character long hex string.
* Adjust README.modes to not refer to the redundant wpa-passphrase stuff.
* Add big fat NOTE about acceptable wpa-psk's to top of example gallery.
* Strip surrounding quotes from wpa-ssid if present, instead of just whining
  about them.
* Update email address in copyright blurb of functions.sh, ifupdown.sh and
  wpa_action.sh.  

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
 
107
107
extern struct wpa_driver_ops *wpa_supplicant_drivers[];
108
108
 
 
109
extern int wpa_debug_use_file;
109
110
extern int wpa_debug_level;
110
111
extern int wpa_debug_show_keys;
111
112
extern int wpa_debug_timestamp;
277
278
                                 const u8 *key, size_t keylen)
278
279
{
279
280
        struct wpa_supplicant *wpa_s = ctx;
 
281
        if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
 
282
                int cipher = (keylen == 5) ? WPA_CIPHER_WEP40 :
 
283
                        WPA_CIPHER_WEP104;
 
284
                if (unicast)
 
285
                        wpa_s->pairwise_cipher = cipher;
 
286
                else
 
287
                        wpa_s->group_cipher = cipher;
 
288
        }
280
289
        return wpa_drv_set_key(wpa_s, WPA_ALG_WEP,
281
290
                               unicast ? wpa_s->bssid :
282
291
                               (u8 *) "\xff\xff\xff\xff\xff\xff",
840
849
        wpa_printf(MSG_DEBUG, "State: %s -> %s",
841
850
                   wpa_supplicant_state_txt(wpa_s->wpa_state),
842
851
                   wpa_supplicant_state_txt(state));
 
852
 
 
853
        wpa_supplicant_dbus_notify_state_change(wpa_s, state,
 
854
                                                wpa_s->wpa_state);
 
855
 
843
856
        if (state == WPA_COMPLETED && wpa_s->new_connection) {
844
857
#if defined(CONFIG_CTRL_IFACE) || !defined(CONFIG_NO_STDOUT_DEBUG)
845
858
                struct wpa_ssid *ssid = wpa_s->current_ssid;
886
899
}
887
900
 
888
901
 
 
902
static void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s)
 
903
{
 
904
        wpa_s->pairwise_cipher = 0;
 
905
        wpa_s->group_cipher = 0;
 
906
        wpa_s->key_mgmt = 0;
 
907
        wpa_s->wpa_state = 0;
 
908
}
 
909
 
 
910
 
889
911
/**
890
912
 * wpa_supplicant_reload_configuration - Reload configuration data
891
913
 * @wpa_s: Pointer to wpa_supplicant data
933
955
        wpa_s->conf = conf;
934
956
        if (reconf_ctrl)
935
957
                wpa_s->ctrl_iface = wpa_supplicant_ctrl_iface_init(wpa_s);
 
958
 
 
959
        wpa_supplicant_clear_status(wpa_s);
936
960
        wpa_s->reassociate = 1;
937
961
        wpa_supplicant_req_scan(wpa_s, 0, 0);
938
962
        wpa_msg(wpa_s, MSG_DEBUG, "Reconfiguration completed");
1030
1054
                 * ap_scan=2 mode - try to associate with each SSID instead of
1031
1055
                 * scanning for each scan_ssid=1 network.
1032
1056
                 */
1033
 
                if (ssid == NULL)
 
1057
                if (ssid == NULL) {
 
1058
                        wpa_printf(MSG_DEBUG, "wpa_supplicant_scan: Reached "
 
1059
                                   "end of scan list - go back to beginning");
 
1060
                        wpa_s->prev_scan_ssid = BROADCAST_SSID_SCAN;
 
1061
                        wpa_supplicant_req_scan(wpa_s, 0, 0);
1034
1062
                        return;
 
1063
                }
1035
1064
                if (ssid->next) {
1036
1065
                        /* Continue from the next SSID on the next attempt. */
1037
1066
                        wpa_s->prev_scan_ssid = ssid;
1200
1229
                        ie.key_mgmt = ssid->key_mgmt;
1201
1230
                        wpa_printf(MSG_DEBUG, "WPA: Set cipher suites based "
1202
1231
                                   "on configuration");
1203
 
                }
 
1232
                } else
 
1233
                        proto = ie.proto;
1204
1234
        }
1205
1235
 
1206
1236
        wpa_printf(MSG_DEBUG, "WPA: Selected cipher suites: group %d "
1207
 
                   "pairwise %d key_mgmt %d",
1208
 
                   ie.group_cipher, ie.pairwise_cipher, ie.key_mgmt);
 
1237
                   "pairwise %d key_mgmt %d proto %d",
 
1238
                   ie.group_cipher, ie.pairwise_cipher, ie.key_mgmt, proto);
1209
1239
 
1210
1240
        wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_PROTO, proto);
1211
1241
 
1298
1328
{
1299
1329
        u8 wpa_ie[80];
1300
1330
        size_t wpa_ie_len;
1301
 
        int use_crypt, ret;
 
1331
        int use_crypt, ret, i;
1302
1332
        int algs = AUTH_ALG_OPEN_SYSTEM;
1303
1333
        wpa_cipher cipher_pairwise, cipher_group;
1304
1334
        struct wpa_driver_associate_params params;
1386
1416
        cipher_group = cipher_suite2driver(wpa_s->group_cipher);
1387
1417
        if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1388
1418
            wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
1389
 
                int i;
1390
1419
                if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE)
1391
1420
                        use_crypt = 0;
1392
1421
                for (i = 0; i < NUM_WEP_KEYS; i++) {
1441
1470
        params.key_mgmt_suite = key_mgmt2driver(wpa_s->key_mgmt);
1442
1471
        params.auth_alg = algs;
1443
1472
        params.mode = ssid->mode;
 
1473
        for (i = 0; i < NUM_WEP_KEYS; i++) {
 
1474
                if (ssid->wep_key_len[i])
 
1475
                        params.wep_key[i] = ssid->wep_key[i];
 
1476
                params.wep_key_len[i] = ssid->wep_key_len[i];
 
1477
        }
 
1478
        params.wep_tx_keyidx = ssid->wep_tx_keyidx;
 
1479
 
1444
1480
        if (wpa_s->use_client_mlme)
1445
1481
                ret = ieee80211_sta_associate(wpa_s, &params);
1446
1482
        else
2319
2355
        }
2320
2356
 
2321
2357
        wpa_s->global = global;
 
2358
 
 
2359
        /* Register the interface with the dbus control interface */
 
2360
        if (wpas_dbus_register_iface(wpa_s)) {
 
2361
                wpa_supplicant_deinit_iface(wpa_s);
 
2362
                free(wpa_s);
 
2363
                return NULL;
 
2364
        }
 
2365
                
2322
2366
        wpa_s->next = global->ifaces;
2323
2367
        global->ifaces = wpa_s;
2324
2368
 
2356
2400
                prev->next = wpa_s->next;
2357
2401
        }
2358
2402
 
 
2403
        wpas_dbus_unregister_iface(wpa_s);
 
2404
 
2359
2405
        wpa_printf(MSG_DEBUG, "Removing interface %s", wpa_s->ifname);
2360
2406
 
2361
2407
        wpa_supplicant_deinit_iface(wpa_s);
2401
2447
        if (params == NULL)
2402
2448
                return NULL;
2403
2449
 
 
2450
        wpa_debug_use_file = params->wpa_debug_use_file;
 
2451
        wpa_debug_open_file();
 
2452
 
2404
2453
        ret = eap_peer_register_methods();
2405
2454
        if (ret) {
2406
2455
                wpa_printf(MSG_ERROR, "Failed to register EAP methods");
2427
2476
                params->wpa_debug_show_keys;
2428
2477
        wpa_debug_timestamp = global->params.wpa_debug_timestamp =
2429
2478
                params->wpa_debug_timestamp;
 
2479
        wpa_debug_use_file = global->params.wpa_debug_use_file =
 
2480
                params->wpa_debug_use_file;
2430
2481
 
2431
2482
        if (eloop_init(global)) {
2432
2483
                wpa_printf(MSG_ERROR, "Failed to initialize event loop");
2523
2574
        free(global->params.ctrl_interface);
2524
2575
 
2525
2576
        free(global);
 
2577
        wpa_debug_close_file();
2526
2578
}