Go to the source code of this file.
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| void | iwstat (struct net80211_device *dev) |
| Print status of 802.11 device. | |
| int | iwlist (struct net80211_device *dev) |
| Scan for wireless networks using 802.11 device. | |
Definition in file iwmgmt.h.
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| void iwstat | ( | struct net80211_device * | dev | ) |
Print status of 802.11 device.
| dev | 802.11 device |
Definition at line 42 of file iwmgmt.c.
References net80211_device::associating, net80211_device::channel, net80211_channel::channel_nr, net80211_device::channels, net80211_wlan::essid, net80211_device::essid, net80211_device::hw, ifstat(), net80211_device::last_signal, NET80211_ASSOCIATED, NET80211_WORKING, net80211_device::netdev, net80211_device::nr_channels, net80211_device::nr_rates, printf(), net80211_device::rate, net80211_device::rates, net80211_device::rx_beacon_interval, net80211_hw_info::signal_max, net80211_hw_info::signal_type, net80211_device::state, and net80211_device::tx_beacon_interval.
Referenced by iwstat_payload().
00042 { 00043 00044 ifstat ( dev->netdev ); 00045 00046 printf ( " [802.11 "); 00047 if ( dev->state & NET80211_ASSOCIATED ) { 00048 printf ( "SSID '%s', ", dev->essid ); 00049 } else { 00050 printf ( "not associated, " ); 00051 } 00052 if ( dev->channel < dev->nr_channels && dev->rate < dev->nr_rates ) { 00053 printf ( "Ch:%d Sig:%d", dev->channels[dev->channel].channel_nr, 00054 dev->last_signal ); 00055 switch ( dev->hw->signal_type ) { 00056 case NET80211_SIGNAL_NONE: 00057 printf ( "?" ); 00058 break; 00059 case NET80211_SIGNAL_ARBITRARY: 00060 printf ( "/%d", dev->hw->signal_max ); 00061 break; 00062 case NET80211_SIGNAL_DB: 00063 printf ( "/%d dB", dev->hw->signal_max ); 00064 break; 00065 case NET80211_SIGNAL_DBM: 00066 printf ( " dBm" ); 00067 break; 00068 } 00069 printf ( ", Qual:%d%% Rate:%d Mbps]\n", 00070 ( dev->rx_beacon_interval == 0 ? 0 : 00071 100 * dev->tx_beacon_interval / 00072 dev->rx_beacon_interval ), 00073 dev->rates[dev->rate] / 10 ); 00074 } else { 00075 printf ( "antenna off]\n" ); 00076 } 00077 00078 if ( dev->state & NET80211_WORKING ) { 00079 printf ( " [associating" ); 00080 if ( dev->associating ) 00081 printf ( " to '%s'", dev->associating->essid ); 00082 printf ( "...]\n" ); 00083 } 00084 }
| int iwlist | ( | struct net80211_device * | dev | ) |
Scan for wireless networks using 802.11 device.
| dev | 802.11 device | |
| active | Whether to use active scanning |
This function is safe to call at all times, whether the 802.11 device is open or not, but if called while the auto-association task is running it will return an error indication.
Definition at line 121 of file iwmgmt.c.
References auth_types, net80211_hw_info::bands, net80211_wlan::bssid, net80211_wlan::channel, net80211_device::channel, net80211_channel::channel_nr, net80211_device::channels, net80211_wlan::crypto, crypto_types, EINVAL, ENOMEM, net80211_wlan::essid, eth_ntoa(), net80211_wlan::handshaking, net80211_device::hw, net80211_wlan::list, list_empty(), list_for_each_entry, net_device::name, net80211_change_channel(), net80211_free_wlanlist(), NET80211_NO_ASSOC, net80211_prepare_probe(), net80211_probe_finish_all(), net80211_probe_start(), net80211_probe_step(), NET80211_WORKING, net80211_device::netdev, netdev_close(), netdev_is_open(), netdev_open(), NR_AUTH_TYPES, NR_CRYPTO_TYPES, printf(), net80211_wlan::signal, snprintf(), net80211_device::state, step(), strerror(), and strlen().
Referenced by iwlist_payload().
00121 { 00122 struct net80211_probe_ctx *ctx; 00123 struct list_head *networks; 00124 struct net80211_wlan *wlan; 00125 char ssid_buf[22]; 00126 int rc; 00127 unsigned i; 00128 int was_opened = netdev_is_open ( dev->netdev ); 00129 int was_channel = dev->channels[dev->channel].channel_nr; 00130 00131 if ( ! was_opened ) { 00132 dev->state |= NET80211_NO_ASSOC; 00133 rc = netdev_open ( dev->netdev ); 00134 if ( rc < 0 ) 00135 goto err; 00136 } 00137 00138 if ( dev->state & NET80211_WORKING ) { 00139 rc = -EINVAL; 00140 goto err_close_netdev; 00141 } 00142 00143 if ( ! was_opened ) { 00144 rc = net80211_prepare_probe ( dev, dev->hw->bands, 0 ); 00145 if ( rc < 0 ) 00146 goto err_close_netdev; 00147 } 00148 00149 ctx = net80211_probe_start ( dev, "", 0 ); 00150 if ( ! ctx ) { 00151 rc = -ENOMEM; 00152 goto err_close_netdev; 00153 } 00154 00155 while ( ! ( rc = net80211_probe_step ( ctx ) ) ) { 00156 step(); 00157 } 00158 00159 networks = net80211_probe_finish_all ( ctx ); 00160 00161 if ( list_empty ( networks ) ) { 00162 goto err_free_networks; 00163 } 00164 00165 rc = 0; 00166 00167 printf ( "Networks on %s:\n\n", dev->netdev->name ); 00168 00169 /* Output format: 00170 * 0 1 2 3 4 5 6 00171 * 0123456789012345678901234567890123456789012345678901234567890 00172 * [Sig] SSID BSSID Ch Crypt/Auth 00173 * ------------------------------------------------------------- 00174 * [ 15] abcdefghijklmnopqrst> 00:00:00:00:00:00 11 Open 00175 * ... or WPA PSK etc. 00176 */ 00177 00178 /* Quoting the dashes and spaces verbatim uses less code space 00179 than generating them programmatically. */ 00180 printf ( "[Sig] SSID BSSID Ch Crypt/Auth\n" 00181 "-------------------------------------------------------------\n" ); 00182 00183 list_for_each_entry ( wlan, networks, list ) { 00184 00185 /* Format SSID into 22-character string, space-padded, 00186 with '>' indicating truncation */ 00187 00188 snprintf ( ssid_buf, sizeof ( ssid_buf ), "%s", wlan->essid ); 00189 for ( i = strlen ( ssid_buf ); i < sizeof ( ssid_buf ) - 1; 00190 i++ ) 00191 ssid_buf[i] = ' '; 00192 if ( ssid_buf[sizeof ( ssid_buf ) - 2] != ' ' ) 00193 ssid_buf[sizeof ( ssid_buf ) - 2] = '>'; 00194 ssid_buf[sizeof ( ssid_buf ) - 1] = 0; 00195 00196 /* Sanity check */ 00197 if ( wlan->crypto >= NR_CRYPTO_TYPES || 00198 wlan->handshaking >= NR_AUTH_TYPES ) 00199 continue; 00200 00201 printf ( "[%3d] %s %s %2d %s %s\n", 00202 wlan->signal < 0 ? 100 + wlan->signal : wlan->signal, 00203 ssid_buf, eth_ntoa ( wlan->bssid ), wlan->channel, 00204 crypto_types[wlan->crypto], 00205 auth_types[wlan->handshaking] ); 00206 } 00207 printf ( "\n" ); 00208 00209 err_free_networks: 00210 net80211_free_wlanlist ( networks ); 00211 00212 err_close_netdev: 00213 if ( ! was_opened ) { 00214 dev->state &= ~NET80211_NO_ASSOC; 00215 netdev_close ( dev->netdev ); 00216 } else { 00217 net80211_change_channel ( dev, was_channel ); 00218 } 00219 00220 if ( ! rc ) 00221 return 0; 00222 00223 err: 00224 printf ( "Scanning for networks on %s: %s\n", 00225 dev->netdev->name, strerror ( rc ) ); 00226 return rc; 00227 }
1.5.7.1