62 #include <linux/if_arp.h>
66 #include <asm/uaccess.h>
83 extern dbg_info_t *DbgInfo;
94 { 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 };
114 memcpy(<v->
u.
u8[buf_idx], &key[0], 16);
126 memcpy(<v->
u.
u8[buf_idx], &key[16], 8);
130 memcpy(<v->
u.
u8[buf_idx], &key[24], 8);
154 memcpy(<v->
u.
u8[buf_idx], key, key_len);
171 static int hermes_clear_tkip_keys(
ltv_t *ltv,
u16 key_idx,
u8 *addr)
177 if (!is_broadcast_ether_addr(addr)) {
203 u8 *key,
size_t key_len,
212 DBG_WARNING(DbgInfo,
"WEP not supported on this device\n");
217 DBG_NOTICE(DbgInfo,
"pointer: %p, length: %d\n",
226 if ((key_idx < 0) || (key_idx >=
MAX_KEYS))
238 DBG_NOTICE(DbgInfo,
"encoding.length: %d\n", key_len);
244 if ((key_idx == tk) && (lp->
DefaultKeys.key[tk].len > 0))
251 if (set_tx && (key_idx >= 0) && (key_idx <
MAX_KEYS)) {
252 DBG_NOTICE(DbgInfo,
"index: %d; len: %d\n", key_idx,
259 DBG_WARNING(DbgInfo,
"Problem setting the current TxKey\n");
280 DBG_TRACE(DbgInfo,
"encryption_state : %d\n", encryption_state);
282 DBG_TRACE(DbgInfo,
"erq->length : %d\n", key_len);
340 wl_lock( lp, &flags );
348 wl_unlock(lp, &flags);
379 DBG_FUNC(
"wireless_get_protocol" );
386 strcpy(name,
"IEEE 802.11b");
424 DBG_FUNC(
"wireless_set_frequency" );
441 int f = freq->
m / 100000;
454 channel = channel | 0x100;
458 wl_lock( lp, &flags );
473 wl_unlock(lp, &flags);
511 DBG_FUNC(
"wireless_get_frequency" );
519 wl_lock( lp, &flags );
527 if( ret == HCF_SUCCESS ) {
536 wl_unlock(lp, &flags);
589 wl_lock( lp, &flags );
602 if( status != HCF_SUCCESS ) {
604 DBG_TRACE( DbgInfo,
"Get CFG_CUR_TX_RATE failed: 0x%x\n", status );
610 wl_unlock(lp, &flags);
611 wl_lock( lp, &flags );
614 if ( status != HCF_SUCCESS ) {
615 DBG_TRACE( DbgInfo,
"reset failed: 0x%x\n", status );
622 wl_unlock(lp, &flags);
623 wl_lock( lp, &flags );
628 DBG_TRACE( DbgInfo,
"Get CFG_CUR_TX_RATE failed: %d retries\n", retries );
635 wl_unlock(lp, &flags);
636 wl_lock( lp, &flags );
643 DBG_TRACE( DbgInfo,
"Get CFG_CUR_TX_RATE succes: %d retries\n", retries );
675 if( status == HCF_SUCCESS ) {
676 for( count = 0; count <
MAX_RATES; count++ )
682 DBG_TRACE( DbgInfo,
"CFG_SUPPORTED_DATA_RATES: 0x%x\n", status );
698 wl_unlock(lp, &flags);
699 wl_lock( lp, &flags );
725 wl_unlock(lp, &flags);
726 wl_lock( lp, &flags );
728 DBG_TRACE( DbgInfo,
"calling wl_wireless_stats\n" );
731 DBG_TRACE( DbgInfo,
"wl_wireless_stats done\n" );
749 wl_unlock(lp, &flags);
781 #if 1 //;? (HCF_TYPE) & HCF_TYPE_STA
795 wl_lock( lp, &flags );
809 #if 1 //;? (HCF_TYPE) & HCF_TYPE_STA
818 if( status == HCF_SUCCESS ) {
826 #endif // (HCF_TYPE) & HCF_TYPE_STA
830 wl_unlock(lp, &flags);
889 wl_lock( lp, &flags );
901 DBG_TRACE( DbgInfo,
"CFG_SCAN_CHANNELS_2GHZ result: 0x%x\n", ret );
909 DBG_TRACE( DbgInfo,
"CFG_SCAN_SSID to 'any' ret: 0x%x\n", ret );
921 wl_unlock(lp, &flags);
923 if( ret == HCF_SUCCESS ) {
924 DBG_TRACE( DbgInfo,
"SUCCESSFULLY INITIATED SCAN...\n" );
925 while( (*p).scan_complete ==
FALSE && ret == HCF_SUCCESS ) {
926 DBG_TRACE( DbgInfo,
"Waiting for scan results...\n" );
934 for( count = 0; count < 100; count ++ ) {
943 if ( ret != HCF_SUCCESS ) {
944 DBG_ERROR( DbgInfo,
"timeout waiting for scan results\n" );
946 num_aps = (*p).num_aps;
953 (
sizeof(
struct sockaddr ) * num_aps );
962 for( count = 0; count < num_aps; count++ ) {
964 memcpy( hwa[count].sa_data,
966 #else //;?why use BSSID and bssid as names in seemingly very comparable situations
968 (*p).ProbeTable[count].BSSID);
969 memcpy( hwa[count].sa_data,
975 (*p).scan_complete =
FALSE;
1012 unsigned long flags;
1014 int dens = sens->
value;
1018 DBG_FUNC(
"wireless_set_sensitivity" );
1026 if(( dens < 1 ) || ( dens > 3 )) {
1031 wl_lock( lp, &flags );
1040 wl_unlock(lp, &flags);
1078 DBG_FUNC(
"wireless_get_sensitivity" );
1121 unsigned long flags;
1137 wl_lock( lp, &flags );
1144 if( data->
flags == 0 ) {
1157 DBG_NOTICE( DbgInfo,
"set NetworkName: %s\n", ssid );
1167 wl_unlock(lp, &flags);
1202 unsigned long flags;
1217 wl_lock( lp, &flags );
1225 #if 1 //;? (HCF_TYPE) & HCF_TYPE_STA
1233 #if 1 //;? (HCF_TYPE) & HCF_TYPE_AP
1244 if( status == HCF_SUCCESS ) {
1260 #if 1 //;? (HCF_TYPE) & HCF_TYPE_STA
1264 if( pName->
name[0] ==
'\0' ) {
1271 if( status == HCF_SUCCESS ) {
1302 wl_unlock(lp, &flags);
1335 unsigned long flags;
1350 wl_lock(lp, &flags);
1354 ret = hermes_set_wep_keys(lp, key_idx, keybuf, erq->
length,
1363 wl_unlock(lp, &flags);
1393 unsigned long flags;
1415 wl_lock( lp, &flags );
1437 if(( index < 0 ) || ( index >=
MAX_KEYS )) {
1441 erq->
flags |= index + 1;
1452 wl_unlock(lp, &flags);
1485 unsigned long flags;
1490 DBG_FUNC(
"wireless_set_nickname" );
1498 #if 0 //;? Needed, was present in original code but not in 7.18 Linux 2.6 kernel version
1512 wl_lock( lp, &flags );
1525 wl_unlock(lp, &flags);
1558 unsigned long flags;
1565 DBG_FUNC(
"wireless_get_nickname" );
1573 wl_lock( lp, &flags );
1583 if( status == HCF_SUCCESS ) {
1602 wl_unlock(lp, &flags);
1635 unsigned long flags;
1641 DBG_FUNC(
"wireless_set_porttype" );
1649 wl_lock( lp, &flags );
1678 #if 0 //;? (HCF_TYPE) & HCF_TYPE_AP
1700 if( portType != 0 ) {
1716 wl_unlock(lp, &flags);
1750 unsigned long flags;
1757 DBG_FUNC(
"wireless_get_porttype" );
1765 wl_lock( lp, &flags );
1775 if( status == HCF_SUCCESS ) {
1778 *pPortType = CNV_LITTLE_TO_INT( *pPortType );
1780 switch( *pPortType ) {
1784 #if (HCF_TYPE) & HCF_TYPE_AP
1826 wl_unlock(lp, &flags);
1859 unsigned long flags;
1872 DBG_PRINT(
"THIS CORRUPTS PMEnabled ;?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" );
1874 #if 0 //;? Needed, was present in original code but not in 7.18 Linux 2.6 kernel version
1883 wl_lock( lp, &flags );
1899 wl_unlock(lp, &flags);
1933 unsigned long flags;
1944 DBG_PRINT(
"THIS IS PROBABLY AN OVER-SIMPLIFICATION ;?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" );
1946 wl_lock( lp, &flags );
1961 wl_unlock(lp, &flags);
1994 unsigned long flags;
1997 DBG_FUNC(
"wireless_get_tx_power" );
2005 wl_lock( lp, &flags );
2009 #ifdef USE_POWER_DBM
2021 wl_unlock(lp, &flags);
2055 unsigned long flags;
2056 int rthr = rts->
value;
2060 DBG_FUNC(
"wireless_set_rts_threshold" );
2068 if(rts->
fixed == 0) {
2077 if(( rthr < 256 ) || ( rthr > 2347 )) {
2082 wl_lock( lp, &flags );
2092 wl_unlock(lp, &flags);
2126 unsigned long flags;
2129 DBG_FUNC(
"wireless_get_rts_threshold" );
2137 wl_lock( lp, &flags );
2149 wl_unlock(lp, &flags);
2183 unsigned long flags;
2200 wl_lock( lp, &flags );
2213 if( status == HCF_SUCCESS ) {
2214 index = ( CNV_LITTLE_TO_INT( lp->
ltvRecord.
u.
u16[0] ) & 0x100 ) ? 1 : 0;
2218 DBG_ERROR( DbgInfo,
"Could not determine radio frequency\n" );
2224 if( rrq->
value > 0 &&
2230 if( rrq->
fixed == 1 ) {
2238 if( rrq->
fixed == 1 ) {
2246 if( rrq->
fixed == 1 ) {
2254 if( rrq->
fixed == 1 ) {
2262 if( rrq->
fixed == 1 ) {
2270 if( rrq->
fixed == 1 ) {
2278 if( rrq->
fixed == 1 ) {
2286 if( rrq->
fixed == 1 ) {
2294 if( rrq->
fixed == 1 ) {
2302 if( rrq->
fixed == 1 ) {
2310 if( rrq->
fixed == 1 ) {
2316 else if( rrq->
fixed == 0 ) {
2329 if( rrq->
value > 0 &&
2357 else if( rrq->
fixed == 0 ) {
2377 wl_unlock(lp, &flags);
2411 unsigned long flags;
2426 wl_lock( lp, &flags );
2436 if( status == HCF_SUCCESS ) {
2441 if( txRate & 0x0001 ) {
2444 else if( txRate & 0x0002 ) {
2447 else if( txRate & 0x0004 ) {
2450 else if( txRate & 0x0008 ) {
2453 else if( txRate & 0x00010 ) {
2456 else if( txRate & 0x00020 ) {
2459 else if( txRate & 0x00040 ) {
2462 else if( txRate & 0x00080 ) {
2465 else if( txRate & 0x00100 ) {
2468 else if( txRate & 0x00200 ) {
2471 else if( txRate & 0x00400 ) {
2474 else if( txRate & 0x00800 ) {
2492 wl_unlock(lp, &flags);
2503 #if 0 //;? Not used anymore
2524 int wireless_get_private_interface(
struct iwreq *wrq,
struct wl_private *lp )
2530 DBG_FUNC(
"wireless_get_private_interface" );
2593 unsigned long flags;
2609 wl_lock( lp, &flags );
2622 DBG_TRACE( DbgInfo,
"CARD is in DEFUNCT mode, reset it to bring it back to life\n" );
2647 DBG_TRACE( DbgInfo,
"CFG_SCAN_CHANNEL result : 0x%x\n", status );
2650 wl_unlock(lp, &flags);
2651 wl_lock( lp, &flags );
2653 if( status != HCF_SUCCESS ) {
2657 DBG_TRACE( DbgInfo,
"Reset card to recover, attempt: %d\n", retries );
2661 wl_unlock(lp, &flags);
2662 wl_lock( lp, &flags );
2678 wl_unlock(lp, &flags);
2679 wl_lock( lp, &flags );
2681 DBG_TRACE( DbgInfo,
"CFG_SCAN_SSID to 'any' status: 0x%x\n", status );
2688 if( status == HCF_SUCCESS ) {
2689 DBG_TRACE( DbgInfo,
"SUCCESSFULLY INITIATED SCAN...\n" );
2691 DBG_TRACE( DbgInfo,
"INITIATE SCAN FAILED...\n" );
2696 wl_unlock(lp, &flags);
2729 unsigned long flags;
2750 wl_lock( lp, &flags );
2760 DBG_TRACE( DbgInfo,
"SCAN COMPLETE, Num of APs: %d\n",
2772 memset( &iwe, 0,
sizeof( iwe ));
2779 buf = iwe_stream_add_event(info, buf, buf_end,
2784 memset( &iwe, 0,
sizeof( iwe ));
2796 buf = iwe_stream_add_event(info, buf, buf_end,
2800 memset(&iwe, 0,
sizeof(iwe));
2803 iwe.u.qual.level =
dbm(probe_resp->signal);
2804 iwe.u.qual.noise =
dbm(probe_resp->silence);
2805 iwe.u.qual.qual = iwe.u.qual.level - iwe.u.qual.noise;
2809 buf = iwe_stream_add_event(info, buf, buf_end,
2814 if( probe_resp->rawData[1] > 0 ) {
2815 memset( &iwe, 0,
sizeof( iwe ));
2818 iwe.u.data.length = probe_resp->rawData[1];
2819 iwe.u.data.flags = 1;
2821 buf = iwe_stream_add_point(info, buf, buf_end,
2822 &iwe, &probe_resp->rawData[2]);
2827 memset( &iwe, 0,
sizeof( iwe ));
2830 iwe.u.data.length = 0;
2840 buf = iwe_stream_add_point(info, buf, buf_end, &iwe,
NULL);
2844 memset( &iwe, 0,
sizeof( iwe ));
2851 buf = iwe_stream_add_event(info, buf, buf_end,
2856 memset( &iwe, 0,
sizeof( iwe ));
2857 memset( msg, 0,
sizeof( msg ));
2860 sprintf( msg,
"beacon_interval=%d", probe_resp->beaconInterval );
2861 iwe.u.data.length =
strlen( msg );
2863 buf = iwe_stream_add_point(info, buf, buf_end, &iwe, msg);
2871 if( wpa_ie !=
NULL ) {
2872 memset(&iwe, 0,
sizeof(iwe));
2875 iwe.u.data.length = wpa_ie_len;
2877 buf = iwe_stream_add_point(info, buf, buf_end,
2890 wl_unlock(lp, &flags);
2899 static const char *
const auth_names[] = {
2900 "IW_AUTH_WPA_VERSION",
2901 "IW_AUTH_CIPHER_PAIRWISE",
2902 "IW_AUTH_CIPHER_GROUP",
2904 "IW_AUTH_TKIP_COUNTERMEASURES",
2905 "IW_AUTH_DROP_UNENCRYPTED",
2906 "IW_AUTH_80211_AUTH_ALG",
2907 "IW_AUTH_WPA_ENABLED",
2908 "IW_AUTH_RX_UNENCRYPTED_EAPOL",
2909 "IW_AUTH_ROAMING_CONTROL",
2910 "IW_AUTH_PRIVACY_INVOKED",
2911 "IW_AUTH_CIPHER_GROUP_MGMT",
2917 static int wireless_set_auth(
struct net_device *dev,
2919 struct iw_param *data,
char *extra)
2922 unsigned long flags;
2926 int iwa_val = data->
value;
2936 wl_lock( lp, &flags );
2942 DBG_TRACE(DbgInfo,
"%s\n", auth_names[iwa_idx]);
2954 DBG_TRACE(DbgInfo,
"val = %d\n", iwa_val);
3032 DBG_TRACE(DbgInfo,
"IW_AUTH_?? (%d) unknown\n", iwa_idx);
3040 wl_unlock(lp, &flags);
3061 for (count = 0; count < 100; count++) {
3070 if (ltv.
u.
u16[0] == 0)
3075 DBG_TRACE(DbgInfo,
"Timed out waiting for TxQ flush!\n");
3079 static int wireless_set_encodeext(
struct net_device *dev,
3081 struct iw_point *erq,
char *keybuf)
3084 unsigned long flags;
3090 bool set_tx =
false;
3107 wl_lock(lp, &flags);
3111 memset(<v, 0,
sizeof(ltv));
3115 DBG_TRACE(DbgInfo,
"IW_ENCODE_ALG_TKIP: key(%d)\n", key_idx);
3117 if (
sizeof(ext->
rx_seq) != 8) {
3118 DBG_TRACE(DbgInfo,
"rx_seq size mismatch\n");
3124 ret = hermes_set_tkip_keys(<v, key_idx, ext->
addr.sa_data,
3129 DBG_TRACE(DbgInfo,
"hermes_set_tkip_keys returned != 0, key not set\n");
3142 DBG_TRACE(DbgInfo,
"IW_ENCODE_ALG_WEP: key(%d)\n", key_idx);
3145 DBG_WARNING(DbgInfo,
"IW_ENCODE_RESTRICTED invalid\n");
3150 ret = hermes_set_wep_keys(lp, key_idx, ext->
key, ext->
key_len,
3156 DBG_TRACE(DbgInfo,
"IW_ENCODE_ALG_CCMP: key(%d)\n", key_idx);
3161 DBG_TRACE(DbgInfo,
"IW_ENCODE_ALG_NONE: key(%d)\n", key_idx);
3164 ret = hermes_clear_tkip_keys(<v, key_idx,
3171 ret = hermes_set_wep_keys(lp, key_idx,
3181 DBG_TRACE( DbgInfo,
"IW_ENCODE_??: key(%d)\n", key_idx);
3190 wl_unlock(lp, &flags);
3200 static int wireless_set_genie(
struct net_device *dev,
3202 struct iw_point *data,
char *extra)
3252 pStats = &( lp->wstats );
3253 pStats->
qual.updated = 0x00;
3257 CFG_COMMS_QUALITY_STRCT *pQual;
3270 pQual = (CFG_COMMS_QUALITY_STRCT *)&( lp->
ltvRecord );
3272 pStats->
qual.qual = (
u_char) CNV_LITTLE_TO_INT( pQual->coms_qual );
3273 pStats->
qual.level = (
u_char)
dbm( CNV_LITTLE_TO_INT( pQual->signal_lvl ));
3274 pStats->
qual.noise = (
u_char)
dbm( CNV_LITTLE_TO_INT( pQual->noise_lvl ));
3338 unsigned long flags;
3343 DBG_FUNC(
"wl_get_wireless_stats" );
3346 wl_lock( lp, &flags );
3351 if( lp->useRTS == 1 ) {
3352 DBG_TRACE( DbgInfo,
"Skipping wireless stats, in RTS mode\n" );
3360 wl_unlock(lp, &flags);
3396 if (!lp->spy_data.spy_number) {
3402 memset( stats, 0,
sizeof(stats));
3406 desc[0].BUF_SIZE =
sizeof(
stats);
3455 memset( &wrqu, 0,
sizeof( wrqu ));
3495 memset( &wrqu, 0,
sizeof( wrqu ));
3538 memset( &wrqu, 0,
sizeof( wrqu ));
3546 wrqu.
essid.flags = 1;
3584 memset( &wrqu, 0,
sizeof( wrqu ));
3595 #if 1 //;? (HCF_TYPE) & HCF_TYPE_AP
3606 #endif // HCF_TYPE_AP
3667 memset( &wrqu, 0,
sizeof( wrqu ));
3707 memset( &wrqu, 0,
sizeof( wrqu ));
3744 memset( &wrqu, 0,
sizeof( wrqu ));
3783 memset( &wrqu, 0,
sizeof( wrqu ));
3837 DBG_PRINT(
"MIC FAIL - KEY USED : %d, STATUS : 0x%04x\n", key_idx,
3840 memset(&wrqu, 0,
sizeof(wrqu));
3841 memset(&wxmic, 0,
sizeof(wxmic));
3844 wxmic.
flags |= (addr1[0] & 1) ?
3849 wrqu.
data.length =
sizeof(wxmic);
3889 memset( &wrqu, 0,
sizeof( wrqu ));
3904 wrqu.
data.length = wpa_ie[1] + 2;
3933 #if 1 //;? (HCF_TYPE) & HCF_TYPE_STA
3957 static const iw_handler wl_private_handler[] =
3961 wvlan_set_station_nickname,
3962 wvlan_get_station_nickname,
3963 #if 1 //;? (HCF_TYPE) & HCF_TYPE_STA
3974 #if 1 //;? #if (HCF_TYPE) & HCF_TYPE_STA
3982 .num_private =
sizeof(wl_private_handler) /
sizeof(
iw_handler),
3983 .private = (
iw_handler *) wl_private_handler,
3986 .num_standard =
sizeof(wl_handler) /
sizeof(
iw_handler),