Functions | |
| int | net80211_prepare_assoc (struct net80211_device *dev, struct net80211_wlan *wlan) |
| Prepare 802.11 device channel and rate set for communication. | |
| int | net80211_send_auth (struct net80211_device *dev, struct net80211_wlan *wlan, int method) |
| Send 802.11 initial authentication frame. | |
| int | net80211_send_assoc (struct net80211_device *dev, struct net80211_wlan *wlan) |
| Send 802.11 association frame. | |
| void | net80211_deauthenticate (struct net80211_device *dev, int rc) |
| Deauthenticate from current network and try again. | |
| int net80211_prepare_assoc | ( | struct net80211_device * | dev, | |
| struct net80211_wlan * | wlan | |||
| ) |
Prepare 802.11 device channel and rate set for communication.
| dev | 802.11 device | |
| wlan | WLAN to prepare for communication with |
| rc | Return status code |
Definition at line 2118 of file net80211.c.
References assert, net80211_wlan::beacon, net80211_wlan::bssid, net80211_device::bssid, net80211_wlan::channel, net80211_device_operations::config, net80211_device::crypto, ieee80211_frame::data, io_buffer::data, DBGC, ENOMEM, ENOTSUP, net80211_wlan::essid, net80211_device::essid, ETH_ALEN, for_each_table_entry, free(), net80211_device::gcrypto, net80211_device::handshaker, net80211_wlan::handshaking, ieee80211_beacon, net80211_handshaker::init, net80211_device::last_beacon_timestamp, memcpy, NET80211_ASSOCIATED, NET80211_CFG_RATE, net80211_change_channel(), NET80211_HANDSHAKERS, net80211_process_capab(), net80211_process_ie(), NET80211_SECPROT_NONE, net80211_set_state(), net80211_device::netdev, netdev_is_open(), NULL, net80211_device::op, net80211_handshaker::priv, net80211_device::rate, net80211_device::rsn_ie, net80211_handshaker::started, net80211_handshaker::stop, strcpy(), io_buffer::tail, net80211_device::tx_beacon_interval, and zalloc().
Referenced by net80211_step_associate().
02120 { 02121 struct ieee80211_frame *hdr = wlan->beacon->data; 02122 struct ieee80211_beacon *beacon = 02123 ( struct ieee80211_beacon * ) hdr->data; 02124 struct net80211_handshaker *handshaker; 02125 int rc; 02126 02127 assert ( netdev_is_open ( dev->netdev ) ); 02128 02129 net80211_set_state ( dev, NET80211_ASSOCIATED, 0, 0 ); 02130 memcpy ( dev->bssid, wlan->bssid, ETH_ALEN ); 02131 strcpy ( dev->essid, wlan->essid ); 02132 02133 free ( dev->rsn_ie ); 02134 dev->rsn_ie = NULL; 02135 02136 dev->last_beacon_timestamp = beacon->timestamp; 02137 dev->tx_beacon_interval = 1024 * beacon->beacon_interval; 02138 02139 /* Barring an IE that tells us the channel outright, assume 02140 the channel we heard this AP best on is the channel it's 02141 communicating on. */ 02142 net80211_change_channel ( dev, wlan->channel ); 02143 02144 rc = net80211_process_capab ( dev, beacon->capability ); 02145 if ( rc ) 02146 return rc; 02147 02148 rc = net80211_process_ie ( dev, beacon->info_element, 02149 wlan->beacon->tail ); 02150 if ( rc ) 02151 return rc; 02152 02153 /* Associate at the lowest rate so we know it'll get through */ 02154 dev->rate = 0; 02155 dev->op->config ( dev, NET80211_CFG_RATE ); 02156 02157 /* Free old handshaker and crypto, if they exist */ 02158 if ( dev->handshaker && dev->handshaker->stop && 02159 dev->handshaker->started ) 02160 dev->handshaker->stop ( dev ); 02161 free ( dev->handshaker ); 02162 dev->handshaker = NULL; 02163 free ( dev->crypto ); 02164 free ( dev->gcrypto ); 02165 dev->crypto = dev->gcrypto = NULL; 02166 02167 /* Find new security handshaker to use */ 02168 for_each_table_entry ( handshaker, NET80211_HANDSHAKERS ) { 02169 if ( handshaker->protocol == wlan->handshaking ) { 02170 dev->handshaker = zalloc ( sizeof ( *handshaker ) + 02171 handshaker->priv_len ); 02172 if ( ! dev->handshaker ) 02173 return -ENOMEM; 02174 02175 memcpy ( dev->handshaker, handshaker, 02176 sizeof ( *handshaker ) ); 02177 dev->handshaker->priv = ( ( void * ) dev->handshaker + 02178 sizeof ( *handshaker ) ); 02179 break; 02180 } 02181 } 02182 02183 if ( ( wlan->handshaking != NET80211_SECPROT_NONE ) && 02184 ! dev->handshaker ) { 02185 DBGC ( dev, "802.11 %p no support for handshaking scheme %d\n", 02186 dev, wlan->handshaking ); 02187 return -( ENOTSUP | ( wlan->handshaking << 8 ) ); 02188 } 02189 02190 /* Initialize security handshaker */ 02191 if ( dev->handshaker ) { 02192 rc = dev->handshaker->init ( dev ); 02193 if ( rc < 0 ) 02194 return rc; 02195 } 02196 02197 return 0; 02198 }
| int net80211_send_auth | ( | struct net80211_device * | dev, | |
| struct net80211_wlan * | wlan, | |||
| int | method | |||
| ) |
Send 802.11 initial authentication frame.
| dev | 802.11 device | |
| wlan | WLAN to authenticate with | |
| method | Authentication method |
| rc | Return status code |
Definition at line 2213 of file net80211.c.
References ieee80211_auth::algorithm, alloc_iob(), net80211_wlan::bssid, IEEE80211_STYPE_AUTH, IEEE80211_TYP_FRAME_HEADER_LEN, iob_put, iob_reserve, net80211_set_state(), net80211_tx_mgmt(), NET80211_WAITING, ieee80211_auth::status, and ieee80211_auth::tx_seq.
Referenced by net80211_step_associate().
02215 { 02216 struct io_buffer *iob = alloc_iob ( 64 ); 02217 struct ieee80211_auth *auth; 02218 02219 net80211_set_state ( dev, 0, NET80211_WAITING, 0 ); 02220 iob_reserve ( iob, IEEE80211_TYP_FRAME_HEADER_LEN ); 02221 auth = iob_put ( iob, sizeof ( *auth ) ); 02222 auth->algorithm = method; 02223 auth->tx_seq = 1; 02224 auth->status = 0; 02225 02226 return net80211_tx_mgmt ( dev, IEEE80211_STYPE_AUTH, wlan->bssid, iob ); 02227 }
| int net80211_send_assoc | ( | struct net80211_device * | dev, | |
| struct net80211_wlan * | wlan | |||
| ) |
Send 802.11 association frame.
| dev | 802.11 device | |
| wlan | WLAN to associate with |
| rc | Return status code |
Definition at line 2300 of file net80211.c.
References alloc_iob(), net80211_wlan::bssid, ieee80211_assoc_req::capability, net80211_wlan::crypto, io_buffer::data, DBGP, DBGP_HD, net80211_hw_info::flags, net80211_device::hw, IEEE80211_CAPAB_MANAGED, IEEE80211_CAPAB_PRIVACY, IEEE80211_CAPAB_SHORT_PMBL, IEEE80211_CAPAB_SHORT_SLOT, IEEE80211_STYPE_ASSOC_REQ, IEEE80211_TYP_FRAME_HEADER_LEN, ieee80211_assoc_req::info_element, iob_put, iob_reserve, ieee80211_assoc_req::listen_interval, net80211_marshal_request_info(), net80211_set_state(), net80211_tx_mgmt(), and NET80211_WAITING.
Referenced by net80211_step_associate().
02302 { 02303 struct io_buffer *iob = alloc_iob ( 128 ); 02304 struct ieee80211_assoc_req *assoc; 02305 union ieee80211_ie *ie; 02306 02307 net80211_set_state ( dev, 0, NET80211_WAITING, 0 ); 02308 02309 iob_reserve ( iob, IEEE80211_TYP_FRAME_HEADER_LEN ); 02310 assoc = iob->data; 02311 02312 assoc->capability = IEEE80211_CAPAB_MANAGED; 02313 if ( ! ( dev->hw->flags & NET80211_HW_NO_SHORT_PREAMBLE ) ) 02314 assoc->capability |= IEEE80211_CAPAB_SHORT_PMBL; 02315 if ( ! ( dev->hw->flags & NET80211_HW_NO_SHORT_SLOT ) ) 02316 assoc->capability |= IEEE80211_CAPAB_SHORT_SLOT; 02317 if ( wlan->crypto ) 02318 assoc->capability |= IEEE80211_CAPAB_PRIVACY; 02319 02320 assoc->listen_interval = 1; 02321 02322 ie = net80211_marshal_request_info ( dev, assoc->info_element ); 02323 02324 DBGP ( "802.11 %p about to send association request:\n", dev ); 02325 DBGP_HD ( iob->data, ( void * ) ie - iob->data ); 02326 02327 iob_put ( iob, ( void * ) ie - iob->data ); 02328 02329 return net80211_tx_mgmt ( dev, IEEE80211_STYPE_ASSOC_REQ, 02330 wlan->bssid, iob ); 02331 }
| void net80211_deauthenticate | ( | struct net80211_device * | dev, | |
| int | rc | |||
| ) |
Deauthenticate from current network and try again.
| dev | 802.11 device | |
| rc | Return status code indicating reason |
Definition at line 2403 of file net80211.c.
References net80211_device::assoc_rc, IEEE80211_REASON_UNSPECIFIED, net80211_autoassociate(), net80211_send_disassoc(), net80211_device::netdev, and netdev_link_err().
Referenced by wpa_fail(), and wpa_psk_start().
02404 { 02405 net80211_send_disassoc ( dev, IEEE80211_REASON_UNSPECIFIED, 1 ); 02406 dev->assoc_rc = rc; 02407 netdev_link_err ( dev->netdev, rc ); 02408 02409 net80211_autoassociate ( dev ); 02410 }
1.5.7.1