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

« back to all changes in this revision

Viewing changes to driver_ndis.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:
477
477
        NDISUIO_SET_OID *o;
478
478
        size_t buflen, reallen;
479
479
        DWORD written;
 
480
        char txt[50];
 
481
 
 
482
        snprintf(txt, sizeof(txt), "NDIS: Set OID %08x", oid);
 
483
        wpa_hexdump_key(MSG_MSGDUMP, txt, data, len);
480
484
 
481
485
        buflen = sizeof(*o) + len;
482
486
        reallen = buflen - sizeof(o->Data);
498
502
#else /* CONFIG_USE_NDISUIO */
499
503
        char *buf;
500
504
        PACKET_OID_DATA *o;
 
505
        char txt[50];
 
506
 
 
507
        snprintf(txt, sizeof(txt), "NDIS: Set OID %08x", oid);
 
508
        wpa_hexdump_key(MSG_MSGDUMP, txt, data, len);
501
509
 
502
510
        buf = wpa_zalloc(sizeof(*o) + len);
503
511
        if (buf == NULL)
784
792
                                        bss->SupportedRates[j] & 0x7f;
785
793
                        }
786
794
                }
 
795
                if (((char *) bss->IEs) + bss->IELength  > (char *) b + blen) {
 
796
                        /*
 
797
                         * Some NDIS drivers have been reported to include an
 
798
                         * entry with an invalid IELength in scan results and
 
799
                         * this has crashed wpa_supplicant, so validate the
 
800
                         * returned value before using it.
 
801
                         */
 
802
                        wpa_printf(MSG_DEBUG, "NDIS: skipped invalid scan "
 
803
                                   "result IE (BSSID=" MACSTR ") IELength=%d",
 
804
                                   MAC2STR(results[i].bssid),
 
805
                                   (int) bss->IELength);
 
806
                        break;
 
807
                }
787
808
                wpa_driver_ndis_get_ies(&results[i], bss->IEs, bss->IELength);
788
809
                pos += bss->Length;
789
810
                if (pos > (char *) b + blen)
849
870
        wep->KeyLength = key_len;
850
871
        memcpy(wep->KeyMaterial, key, key_len);
851
872
 
852
 
        wpa_hexdump_key(MSG_MSGDUMP, "NDIS: OIS_802_11_ADD_WEP",
 
873
        wpa_hexdump_key(MSG_MSGDUMP, "NDIS: OID_802_11_ADD_WEP",
853
874
                        (char *) wep, len);
854
875
        res = ndis_set_oid(drv, OID_802_11_ADD_WEP, (char *) wep, len);
855
876
 
918
939
                memcpy(nkey->KeyMaterial, key, key_len);
919
940
        }
920
941
 
921
 
        wpa_hexdump_key(MSG_MSGDUMP, "NDIS: OIS_802_11_ADD_KEY",
 
942
        wpa_hexdump_key(MSG_MSGDUMP, "NDIS: OID_802_11_ADD_KEY",
922
943
                        (char *) nkey, len);
923
944
        res = ndis_set_oid(drv, OID_802_11_ADD_KEY, (char *) nkey, len);
924
945
        free(nkey);
955
976
                /* Try to continue anyway */
956
977
        }
957
978
 
 
979
        if (params->key_mgmt_suite == KEY_MGMT_NONE ||
 
980
            params->key_mgmt_suite == KEY_MGMT_802_1X_NO_WPA) {
 
981
                /* Re-set WEP keys if static WEP configuration is used. */
 
982
                u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
 
983
                int i;
 
984
                for (i = 0; i < 4; i++) {
 
985
                        if (!params->wep_key[i])
 
986
                                continue;
 
987
                        wpa_printf(MSG_DEBUG, "NDIS: Re-setting static WEP "
 
988
                                   "key %d", i);
 
989
                        wpa_driver_ndis_set_key(drv, WPA_ALG_WEP, bcast, i,
 
990
                                                i == params->wep_tx_keyidx,
 
991
                                                NULL, 0, params->wep_key[i],
 
992
                                                params->wep_key_len[i]);
 
993
                }
 
994
        }
 
995
 
958
996
        if (params->wpa_ie == NULL || params->wpa_ie_len == 0) {
959
997
                if (params->auth_alg & AUTH_ALG_SHARED_KEY) {
960
998
                        if (params->auth_alg & AUTH_ALG_OPEN_SYSTEM)
1567
1605
        size_t i;
1568
1606
        NDIS_802_11_CAPABILITY *c;
1569
1607
 
1570
 
        drv->capa.flags = WPA_DRIVER_FLAGS_DRIVER_IE |
1571
 
                WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC;
 
1608
        drv->capa.flags = WPA_DRIVER_FLAGS_DRIVER_IE;
1572
1609
 
1573
1610
        len = ndis_get_oid(drv, OID_802_11_CAPABILITY, buf, sizeof(buf));
1574
1611
        if (len < 0) {
1764
1801
                   drv->adapter_desc);
1765
1802
 
1766
1803
        return 0;
1767
 
#else /* CONFIG_USE_NDISUO */
1768
 
        PTSTR names, pos, pos2;
 
1804
#else /* CONFIG_USE_NDISUIO */
 
1805
        PTSTR _names;
 
1806
        char *names, *pos, *pos2;
1769
1807
        ULONG len;
1770
1808
        BOOLEAN res;
1771
1809
#define MAX_ADAPTERS 32
1778
1816
                   PacketGetVersion());
1779
1817
 
1780
1818
        len = 8192;
1781
 
        names = wpa_zalloc(len);
1782
 
        if (names == NULL)
 
1819
        _names = wpa_zalloc(len);
 
1820
        if (_names == NULL)
1783
1821
                return -1;
1784
1822
 
1785
 
        res = PacketGetAdapterNames(names, &len);
 
1823
        res = PacketGetAdapterNames(_names, &len);
1786
1824
        if (!res && len > 8192) {
1787
 
                free(names);
1788
 
                names = wpa_zalloc(len);
1789
 
                if (names == NULL)
 
1825
                free(_names);
 
1826
                _names = wpa_zalloc(len);
 
1827
                if (_names == NULL)
1790
1828
                        return -1;
1791
 
                res = PacketGetAdapterNames(names, &len);
 
1829
                res = PacketGetAdapterNames(_names, &len);
1792
1830
        }
1793
1831
 
1794
1832
        if (!res) {
1795
1833
                wpa_printf(MSG_ERROR, "NDIS: Failed to get adapter list "
1796
1834
                           "(PacketGetAdapterNames)");
1797
 
                free(names);
 
1835
                free(_names);
1798
1836
                return -1;
1799
1837
        }
1800
1838
 
1801
 
        /* wpa_hexdump_ascii(MSG_DEBUG, "NDIS: AdapterNames", names, len); */
1802
 
 
 
1839
        names = (char *) _names;
1803
1840
        if (names[0] && names[1] == '\0' && names[2] && names[3] == '\0') {
1804
1841
                wpa_printf(MSG_DEBUG, "NDIS: Looks like adapter names are in "
1805
1842
                           "UNICODE");
1939
1976
                   drv->adapter_desc);
1940
1977
 
1941
1978
        return 0;
1942
 
#endif /* CONFIG_USE_NDISUO */
 
1979
#endif /* CONFIG_USE_NDISUIO */
1943
1980
}
1944
1981
 
1945
1982
 
2015
2052
        WCHAR *pos;
2016
2053
        DWORD flags, i;
2017
2054
 
2018
 
        hm = LoadLibrary("wzcsapi.dll");
 
2055
        hm = LoadLibrary(TEXT("wzcsapi.dll"));
2019
2056
        if (hm == NULL) {
2020
2057
                wpa_printf(MSG_DEBUG, "NDIS: Failed to load wzcsapi.dll (%u) "
2021
2058
                           "- WZC probably not running",
2279
2316
        else if (strncmp(ifname, "\\DEVICE\\", 8) == 0)
2280
2317
                ifname += 8;
2281
2318
        strncpy(drv->ifname, ifname, sizeof(drv->ifname));
2282
 
#ifndef CONFIG_NDIS_EVENTS_INTEGRATED
2283
 
        drv->event_sock = -1;
2284
 
#endif /* CONFIG_NDIS_EVENTS_INTEGRATED */
2285
2319
 
2286
2320
        if (wpa_driver_ndis_adapter_init(drv) < 0) {
2287
2321
                free(drv);
2317
2351
        eloop_register_timeout(1, 0, wpa_driver_ndis_poll_timeout, drv, NULL);
2318
2352
 
2319
2353
#ifdef CONFIG_NDIS_EVENTS_INTEGRATED
2320
 
        drv->events = ndis_events_init(&drv->events_pipe, &drv->event_avail);
 
2354
        drv->events = ndis_events_init(&drv->events_pipe, &drv->event_avail,
 
2355
                                       drv->ifname, drv->adapter_desc);
2321
2356
        if (drv->events == NULL) {
2322
2357
                wpa_driver_ndis_deinit(drv);
2323
2358
                return NULL;
2324
2359
        }
2325
 
        eloop_register_event(&drv->event_avail, sizeof(drv->event_avail),
 
2360
        eloop_register_event(drv->event_avail, sizeof(drv->event_avail),
2326
2361
                             wpa_driver_ndis_event_pipe_cb, drv, NULL);
2327
 
#else /* CONFIG_NDIS_EVENTS_INTEGRATED */
2328
 
        wpa_driver_register_event_cb(drv);
2329
2362
#endif /* CONFIG_NDIS_EVENTS_INTEGRATED */
2330
2363
 
2331
2364
        /* Set mode here in case card was configured for ad-hoc mode
2357
2390
 
2358
2391
#ifdef CONFIG_NDIS_EVENTS_INTEGRATED
2359
2392
        if (drv->events) {
2360
 
                eloop_unregister_event(&drv->event_avail,
 
2393
                eloop_unregister_event(drv->event_avail,
2361
2394
                                       sizeof(drv->event_avail));
2362
2395
                ndis_events_deinit(drv->events);
2363
2396
        }
2370
2403
                wpa_printf(MSG_DEBUG, "NDIS: failed to disassociate and turn "
2371
2404
                           "radio off");
2372
2405
        }
2373
 
#ifndef CONFIG_NDIS_EVENTS_INTEGRATED
2374
 
        if (drv->event_sock >= 0) {
2375
 
                eloop_unregister_read_sock(drv->event_sock);
2376
 
                close(drv->event_sock);
2377
 
        }
2378
 
#endif /* CONFIG_NDIS_EVENTS_INTEGRATED */
2379
2406
 
2380
2407
        wpa_driver_ndis_adapter_close(drv);
2381
2408