Browse Source

[iwmgmt] Add wireless management commands and text for common errors

Add commands `iwstat' (to list 802.11-specific status information for
802.11 devices) and `iwlist' (to scan for available networks and print
a list along with security information).

Signed-off-by: Marty Connor <mdc@etherboot.org>
tags/v1.0.0-rc1
Joshua Oreman 15 years ago
parent
commit
1327a787eb

+ 1
- 0
src/config/config.c View File

@@ -204,6 +204,7 @@ REQUIRE_OBJECT ( config_cmd );
204 204
 #ifdef IFMGMT_CMD
205 205
 REQUIRE_OBJECT ( ifmgmt_cmd );
206 206
 #endif
207
+/* IWMGMT_CMD is brought in by net80211.c if requested */
207 208
 #ifdef ROUTE_CMD
208 209
 REQUIRE_OBJECT ( route_cmd );
209 210
 #endif

+ 33
- 0
src/config/config_net80211.c View File

@@ -0,0 +1,33 @@
1
+/*
2
+ * This program is free software; you can redistribute it and/or
3
+ * modify it under the terms of the GNU General Public License as
4
+ * published by the Free Software Foundation; either version 2, or (at
5
+ * your option) any later version.
6
+ */
7
+
8
+FILE_LICENCE ( GPL2_OR_LATER );
9
+
10
+#include <config/general.h>
11
+
12
+/** @file
13
+ *
14
+ * 802.11 configuration options
15
+ *
16
+ */
17
+
18
+/*
19
+ * Drag in 802.11-specific commands
20
+ *
21
+ */
22
+#ifdef IWMGMT_CMD
23
+REQUIRE_OBJECT ( iwmgmt_cmd );
24
+#endif
25
+
26
+/*
27
+ * Drag in 802.11 error message tables
28
+ *
29
+ */
30
+#ifdef ERRMSG_80211
31
+REQUIRE_OBJECT ( wireless_errors );
32
+#endif
33
+

+ 7
- 0
src/config/general.h View File

@@ -99,6 +99,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
99 99
 #define	NVO_CMD			/* Non-volatile option storage commands */
100 100
 #define	CONFIG_CMD		/* Option configuration console */
101 101
 #define	IFMGMT_CMD		/* Interface management commands */
102
+#define	IWMGMT_CMD		/* Wireless interface management commands */
102 103
 #define	ROUTE_CMD		/* Routing table management commands */
103 104
 #define IMAGE_CMD		/* Image management commands */
104 105
 #define DHCP_CMD		/* DHCP management commands */
@@ -108,6 +109,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
108 109
 #undef	DIGEST_CMD		/* Image crypto digest commands */
109 110
 //#undef	PXE_CMD			/* PXE commands */
110 111
 
112
+/*
113
+ * Error message tables to include
114
+ *
115
+ */
116
+#undef	ERRMSG_80211		/* All 802.11 error descriptions (~3.3kb) */
117
+
111 118
 /*
112 119
  * Obscure configuration options
113 120
  *

+ 69
- 0
src/hci/commands/iwmgmt_cmd.c View File

@@ -0,0 +1,69 @@
1
+/*
2
+ * Copyright (C) 2009 Joshua Oreman <oremanj@rwcr.net>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
19
+FILE_LICENCE ( GPL2_OR_LATER );
20
+
21
+#include <gpxe/netdevice.h>
22
+#include <gpxe/net80211.h>
23
+#include <gpxe/command.h>
24
+#include <usr/iwmgmt.h>
25
+#include <hci/ifmgmt_cmd.h>
26
+
27
+/* "iwstat" command */
28
+
29
+static int iwstat_payload ( struct net_device *netdev ) {
30
+	struct net80211_device *dev = net80211_get ( netdev );
31
+
32
+	if ( dev )
33
+		iwstat ( dev );
34
+
35
+	return 0;
36
+}
37
+
38
+static int iwstat_exec ( int argc, char **argv ) {
39
+	return ifcommon_exec ( argc, argv,
40
+			       iwstat_payload, "Display wireless status of" );
41
+}
42
+
43
+/* "iwlist" command */
44
+
45
+static int iwlist_payload ( struct net_device *netdev ) {
46
+	struct net80211_device *dev = net80211_get ( netdev );
47
+
48
+	if ( dev )
49
+		return iwlist ( dev );
50
+
51
+	return 0;
52
+}
53
+
54
+static int iwlist_exec ( int argc, char **argv ) {
55
+	return ifcommon_exec ( argc, argv, iwlist_payload,
56
+			       "List wireless networks available via" );
57
+}
58
+
59
+/** Wireless interface management commands */
60
+struct command iwmgmt_commands[] __command = {
61
+	{
62
+		.name = "iwstat",
63
+		.exec = iwstat_exec,
64
+	},
65
+	{
66
+		.name = "iwlist",
67
+		.exec = iwlist_exec,
68
+	},
69
+};

+ 118
- 0
src/hci/wireless_errors.c View File

@@ -0,0 +1,118 @@
1
+/*
2
+ * Copyright (C) 2009 Joshua Oreman <oremanj@rwcr.net>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
19
+FILE_LICENCE ( GPL2_OR_LATER );
20
+
21
+#include <errno.h>
22
+#include <gpxe/errortab.h>
23
+
24
+/* Record errors as though they come from the 802.11 stack */
25
+#undef ERRFILE
26
+#define ERRFILE ERRFILE_net80211
27
+
28
+/** All 802.11 errors
29
+ *
30
+ * These follow the 802.11 standard as much as is feasible, but most
31
+ * have been abbreviated to fit the 50-character limit imposed by
32
+ * strerror.
33
+ */
34
+struct errortab wireless_errors[] __errortab = {
35
+	/* gPXE 802.11 stack errors */
36
+	{ EINVAL | EUNIQ_01, "Packet too short" },
37
+	{ EINVAL | EUNIQ_02, "Packet 802.11 version not supported" },
38
+	{ EINVAL | EUNIQ_03, "Packet not a data packet" },
39
+	{ EINVAL | EUNIQ_04, "Packet not from an Access Point" },
40
+	{ EINVAL | EUNIQ_05, "Packet has invalid LLC header" },
41
+	{ EINVAL | EUNIQ_06, "Packet decryption error", },
42
+	{ EINVAL | EUNIQ_07, "Invalid active scan requested" },
43
+
44
+	/* 802.11 status codes (IEEE Std 802.11-2007, Table 7-23) */
45
+	/* Maximum error length: 50 chars                                            | */
46
+	{ ECONNREFUSED | EUNIQ_01, "Unspecified failure" },
47
+	{ ECONNREFUSED | EUNIQ_0A, "Cannot support all requested capabilities" },
48
+	{ ECONNREFUSED | EUNIQ_0B, "Reassociation denied due to lack of association" },
49
+	{ ECONNREFUSED | EUNIQ_0C, "Association denied for another reason" },
50
+	{ ECONNREFUSED | EUNIQ_0D, "Authentication algorithm unsupported" },
51
+	{ ECONNREFUSED | EUNIQ_0E, "Authentication sequence number unexpected" },
52
+	{ ECONNREFUSED | EUNIQ_0F, "Authentication rejected due to challenge failure" },
53
+	{ ECONNREFUSED | EUNIQ_10, "Authentication rejected due to timeout" },
54
+	{ ECONNREFUSED | EUNIQ_11, "Association denied because AP is out of resources" },
55
+	{ ECONNREFUSED | EUNIQ_12, "Association denied; basic rate support required" },
56
+	{ ECONNREFUSED | EUNIQ_13, "Association denied; short preamble support req'd" },
57
+	{ ECONNREFUSED | EUNIQ_14, "Association denied; PBCC modulation support req'd" },
58
+	{ ECONNREFUSED | EUNIQ_15, "Association denied; Channel Agility support req'd" },
59
+	{ ECONNREFUSED | EUNIQ_16, "Association denied; Spectrum Management required" },
60
+	{ ECONNREFUSED | EUNIQ_17, "Association denied; Power Capability unacceptable" },
61
+	{ ECONNREFUSED | EUNIQ_18, "Association denied; Supported Channels unacceptable" },
62
+	{ ECONNREFUSED | EUNIQ_19, "Association denied; Short Slot Tume support req'd" },
63
+	{ ECONNREFUSED | EUNIQ_1A, "Association denied; DSSS-OFDM support required" },
64
+	{ EHOSTUNREACH,            "Unspecified, QoS-related failure" },
65
+	{ EHOSTUNREACH | EUNIQ_01, "Association denied; QoS AP out of QoS resources" },
66
+	{ EHOSTUNREACH | EUNIQ_02, "Association denied due to excessively poor link" },
67
+	{ EHOSTUNREACH | EUNIQ_03, "Association denied; QoS support required" },
68
+	{ EHOSTUNREACH | EUNIQ_05, "The request has been declined" },
69
+	{ EHOSTUNREACH | EUNIQ_06, "Request unsuccessful due to invalid parameters" },
70
+	{ EHOSTUNREACH | EUNIQ_07, "TS not created due to bad specification" },
71
+	{ EHOSTUNREACH | EUNIQ_08, "Invalid information element" },
72
+	{ EHOSTUNREACH | EUNIQ_09, "Invalid group cipher" },
73
+	{ EHOSTUNREACH | EUNIQ_0A, "Invalid pairwise cipher" },
74
+	{ EHOSTUNREACH | EUNIQ_0B, "Invalid AKMP" },
75
+	{ EHOSTUNREACH | EUNIQ_0C, "Unsupported RSN information element version" },
76
+	{ EHOSTUNREACH | EUNIQ_0D, "Invalid RSN information element capabilities" },
77
+	{ EHOSTUNREACH | EUNIQ_0E, "Cipher suite rejected because of security policy" },
78
+	{ EHOSTUNREACH | EUNIQ_0F, "TS not created due to insufficient delay" },
79
+	{ EHOSTUNREACH | EUNIQ_10, "Direct link is not allowed in the BSS by policy" },
80
+	{ EHOSTUNREACH | EUNIQ_11, "The Destination STA is not present within the BSS" },
81
+	{ EHOSTUNREACH | EUNIQ_12, "The Destination STA is not a QoS STA" },
82
+	{ EHOSTUNREACH | EUNIQ_13, "Association denied; Listen Interval is too large" },
83
+
84
+	/* 802.11 reason codes (IEEE Std 802.11-2007, Table 7-22) */
85
+	/* Maximum error length: 50 chars                                          | */
86
+	{ ECONNRESET | EUNIQ_01, "Unspecified reason" },
87
+	{ ECONNRESET | EUNIQ_02, "Previous authentication no longer valid" },
88
+	{ ECONNRESET | EUNIQ_03, "Deauthenticated due to leaving network" },
89
+	{ ECONNRESET | EUNIQ_04, "Disassociated due to inactivity" },
90
+	{ ECONNRESET | EUNIQ_05, "Disassociated because AP is out of resources" },
91
+	{ ECONNRESET | EUNIQ_06, "Class 2 frame received from nonauthenticated STA" },
92
+	{ ECONNRESET | EUNIQ_07, "Class 3 frame received from nonassociated STA" },
93
+	{ ECONNRESET | EUNIQ_08, "Disassociated due to roaming" },
94
+	{ ECONNRESET | EUNIQ_09, "STA requesting (re)association not authenticated" },
95
+	{ ECONNRESET | EUNIQ_0A, "Disassociated; Power Capability unacceptable" },
96
+	{ ECONNRESET | EUNIQ_0B, "Disassociated; Supported Channels unacceptable" },
97
+	{ ECONNRESET | EUNIQ_0D, "Invalid information element" },
98
+	{ ECONNRESET | EUNIQ_0E, "Message integrity code (MIC) failure" },
99
+	{ ECONNRESET | EUNIQ_0F, "4-Way Handshake timeout" },
100
+	{ ECONNRESET | EUNIQ_10, "Group Key Handshake timeout" },
101
+	{ ECONNRESET | EUNIQ_11, "4-Way Handshake information element changed unduly" },
102
+	{ ECONNRESET | EUNIQ_12, "Invalid group cipher" },
103
+	{ ECONNRESET | EUNIQ_13, "Invalid pairwise cipher" },
104
+	{ ECONNRESET | EUNIQ_14, "Invalid AKMP" },
105
+	{ ECONNRESET | EUNIQ_15, "Unsupported RSN information element version" },
106
+	{ ECONNRESET | EUNIQ_16, "Invalid RSN information element capabilities" },
107
+	{ ECONNRESET | EUNIQ_17, "IEEE 802.1X authentication failed" },
108
+	{ ECONNRESET | EUNIQ_18, "Cipher suite rejected because of security policy" },
109
+	{ ENETRESET,            "Disassociated for unspecified, QoS-related reason" },
110
+	{ ENETRESET | EUNIQ_01, "Disassociated; QoS AP is out of QoS resources" },
111
+	{ ENETRESET | EUNIQ_02, "Disassociated due to excessively poor link" },
112
+	{ ENETRESET | EUNIQ_03, "Disassociated due to TXOP limit violation" },
113
+	{ ENETRESET | EUNIQ_04, "Requested; STA is leaving the BSS (or resetting)" },
114
+	{ ENETRESET | EUNIQ_05, "Requested; does not want to use the mechanism" },
115
+	{ ENETRESET | EUNIQ_06, "Requested; setup is required" },
116
+	{ ENETRESET | EUNIQ_07, "Requested from peer STA due to timeout" },
117
+	{ ENETRESET | EUNIQ_0D, "Peer STA does not support requested cipher suite" },
118
+};

+ 1
- 0
src/include/gpxe/errfile.h View File

@@ -192,6 +192,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
192 192
 #define ERRFILE_x509		      ( ERRFILE_OTHER | 0x00160000 )
193 193
 #define ERRFILE_login_ui	      ( ERRFILE_OTHER | 0x00170000 )
194 194
 #define ERRFILE_ib_srpboot	      ( ERRFILE_OTHER | 0x00180000 )
195
+#define ERRFILE_iwmgmt		      ( ERRFILE_OTHER | 0x00190000 )
195 196
 
196 197
 /** @} */
197 198
 

+ 17
- 0
src/include/usr/iwmgmt.h View File

@@ -0,0 +1,17 @@
1
+#ifndef _USR_IWMGMT_H
2
+#define _USR_IWMGMT_H
3
+
4
+/** @file
5
+ *
6
+ * Wireless network interface management
7
+ *
8
+ */
9
+
10
+FILE_LICENCE ( GPL2_OR_LATER );
11
+
12
+struct net80211_device;
13
+
14
+extern void iwstat ( struct net80211_device *dev );
15
+extern int iwlist ( struct net80211_device *dev );
16
+
17
+#endif /* _USR_IWMGMT_H */

+ 244
- 0
src/usr/iwmgmt.c View File

@@ -0,0 +1,244 @@
1
+/*
2
+ * Copyright (C) 2009 Joshua Oreman <oremanj@rwcr.net>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
19
+FILE_LICENCE ( GPL2_OR_LATER );
20
+
21
+#include <stdio.h>
22
+#include <console.h>
23
+#include <string.h>
24
+#include <errno.h>
25
+#include <gpxe/net80211.h>
26
+#include <gpxe/ethernet.h>
27
+#include <usr/ifmgmt.h>
28
+#include <usr/iwmgmt.h>
29
+#include <gpxe/errortab.h>
30
+
31
+/** @file
32
+ *
33
+ * Wireless network interface management
34
+ *
35
+ */
36
+
37
+/**
38
+ * Print status of 802.11 device
39
+ *
40
+ * @v dev	802.11 device
41
+ */
42
+void iwstat ( struct net80211_device *dev ) {
43
+
44
+	ifstat ( dev->netdev );
45
+
46
+	printf ( "  [802.11 ");
47
+	if ( dev->state & NET80211_ASSOCIATED ) {
48
+		printf ( "SSID '%s', ", dev->essid );
49
+	} else {
50
+		printf ( "not associated, " );
51
+	}
52
+	if ( dev->channel < dev->nr_channels && dev->rate < dev->nr_rates ) {
53
+		printf ( "Ch:%d Sig:%d", dev->channels[dev->channel].channel_nr,
54
+			 dev->last_signal );
55
+		switch ( dev->hw->signal_type ) {
56
+		case NET80211_SIGNAL_NONE:
57
+			printf ( "?" );
58
+			break;
59
+		case NET80211_SIGNAL_ARBITRARY:
60
+			printf ( "/%d", dev->hw->signal_max );
61
+			break;
62
+		case NET80211_SIGNAL_DB:
63
+			printf ( "/%d dB", dev->hw->signal_max );
64
+			break;
65
+		case NET80211_SIGNAL_DBM:
66
+			printf ( " dBm" );
67
+			break;
68
+		}
69
+		printf ( ", Qual:%d%% Rate:%d Mbps]\n",
70
+			 ( dev->rx_beacon_interval == 0 ? 0 :
71
+			   100 * dev->tx_beacon_interval /
72
+			   dev->rx_beacon_interval ),
73
+			 dev->rates[dev->rate] / 10 );
74
+	} else {
75
+		printf ( "antenna off]\n" );
76
+	}
77
+
78
+	if ( dev->state & NET80211_WORKING ) {
79
+		printf ( "  [associating" );
80
+		if ( dev->associating )
81
+			printf ( " to '%s'", dev->associating->essid );
82
+		printf ( "...]\n" );
83
+	}
84
+}
85
+
86
+/** Identifiers for 802.11 cryptography types, indexed by type number */
87
+static const char *crypto_types[] = {
88
+	[NET80211_CRYPT_NONE] = "Open",
89
+	[NET80211_CRYPT_WEP] = "WEP ",
90
+	[NET80211_CRYPT_TKIP] = "WPA ",
91
+	[NET80211_CRYPT_CCMP] = "WPA2",
92
+	[NET80211_CRYPT_UNKNOWN] = "UNK ",
93
+};
94
+
95
+/** Number of 802.11 cryptography types defined */
96
+#define NR_CRYPTO_TYPES ( sizeof ( crypto_types ) / sizeof ( crypto_types[0] ) )
97
+
98
+/** Identifiers for 802.11 authentication types, indexed by type number */
99
+static const char *auth_types[] = {
100
+	[NET80211_SECPROT_NONE] = "",
101
+	[NET80211_SECPROT_PSK] = "PSK",
102
+	[NET80211_SECPROT_EAP] = "802.1X",
103
+	[NET80211_SECPROT_UNKNOWN] = "UNK",
104
+};
105
+
106
+/** Number of 802.11 authentication types defined */
107
+#define NR_AUTH_TYPES ( sizeof ( auth_types ) / sizeof ( auth_types[0] ) )
108
+
109
+/**
110
+ * Scan for wireless networks using 802.11 device
111
+ *
112
+ * @v dev	802.11 device
113
+ * @v active	Whether to use active scanning
114
+ *
115
+ * The list of networks found will be printed in tabular format.
116
+ *
117
+ * This function is safe to call at all times, whether the 802.11
118
+ * device is open or not, but if called while the auto-association
119
+ * task is running it will return an error indication.
120
+ */
121
+int iwlist ( struct net80211_device *dev ) {
122
+	struct net80211_probe_ctx *ctx;
123
+	struct list_head *networks;
124
+	struct net80211_wlan *wlan;
125
+	char ssid_buf[22];
126
+	int rc;
127
+	unsigned i;
128
+	int was_opened = dev->netdev->state & NETDEV_OPEN;
129
+	int was_channel = dev->channels[dev->channel].channel_nr;
130
+
131
+	if ( ! was_opened ) {
132
+		dev->state |= NET80211_NO_ASSOC;
133
+		rc = netdev_open ( dev->netdev );
134
+		if ( rc < 0 )
135
+			goto err;
136
+	}
137
+
138
+	if ( dev->state & NET80211_WORKING ) {
139
+		rc = -EINVAL;
140
+		goto err_close_netdev;
141
+	}
142
+
143
+	if ( ! was_opened ) {
144
+		rc = net80211_prepare_probe ( dev, dev->hw->bands, 0 );
145
+		if ( rc < 0 )
146
+			goto err_close_netdev;
147
+	}
148
+
149
+	ctx = net80211_probe_start ( dev, "", 0 );
150
+	if ( ! ctx ) {
151
+		rc = -ENOMEM;
152
+		goto err_close_netdev;
153
+	}
154
+
155
+	while ( ! ( rc = net80211_probe_step ( ctx ) ) ) {
156
+		step();
157
+	}
158
+
159
+	networks = net80211_probe_finish_all ( ctx );
160
+
161
+	if ( list_empty ( networks ) ) {
162
+		goto err_free_networks;
163
+	}
164
+
165
+	rc = 0;
166
+
167
+	printf ( "Networks on %s:\n\n", dev->netdev->name );
168
+
169
+	/* Output format:
170
+	 * 0         1         2         3         4         5         6
171
+	 * 0123456789012345678901234567890123456789012345678901234567890
172
+	 * [Sig] SSID                  BSSID              Ch  Crypt/Auth
173
+	 * -------------------------------------------------------------
174
+	 * [ 15] abcdefghijklmnopqrst> 00:00:00:00:00:00  11  Open
175
+	 *                                             ... or WPA   PSK etc.
176
+	 */
177
+
178
+	/* Quoting the dashes and spaces verbatim uses less code space
179
+	   than generating them programmatically. */
180
+	printf ( "[Sig] SSID                  BSSID              Ch  Crypt/Auth\n"
181
+		 "-------------------------------------------------------------\n" );
182
+
183
+	list_for_each_entry ( wlan, networks, list ) {
184
+
185
+		/* Format SSID into 22-character string, space-padded,
186
+		   with '>' indicating truncation */
187
+
188
+		snprintf ( ssid_buf, sizeof ( ssid_buf ), "%s", wlan->essid );
189
+		for ( i = strlen ( ssid_buf ); i < sizeof ( ssid_buf ) - 1;
190
+		      i++ )
191
+			ssid_buf[i] = ' ';
192
+		if ( ssid_buf[sizeof ( ssid_buf ) - 2] != ' ' )
193
+			ssid_buf[sizeof ( ssid_buf ) - 2] = '>';
194
+		ssid_buf[sizeof ( ssid_buf ) - 1] = 0;
195
+
196
+		/* Sanity check */
197
+		if ( wlan->crypto >= NR_CRYPTO_TYPES ||
198
+		     wlan->handshaking >= NR_AUTH_TYPES )
199
+			continue;
200
+
201
+		printf ( "[%3d] %s %s  %2d  %s  %s\n",
202
+			 wlan->signal < 0 ? 100 + wlan->signal : wlan->signal,
203
+			 ssid_buf, eth_ntoa ( wlan->bssid ), wlan->channel,
204
+			 crypto_types[wlan->crypto],
205
+			 auth_types[wlan->handshaking] );
206
+	}
207
+	printf ( "\n" );
208
+
209
+ err_free_networks:
210
+	net80211_free_wlanlist ( networks );
211
+
212
+ err_close_netdev:
213
+	if ( ! was_opened ) {
214
+		dev->state &= ~NET80211_NO_ASSOC;
215
+		netdev_close ( dev->netdev );
216
+	} else {
217
+		net80211_change_channel ( dev, was_channel );
218
+	}
219
+
220
+	if ( ! rc )
221
+		return 0;
222
+
223
+ err:
224
+	printf ( "Scanning for networks on %s: %s\n",
225
+		 dev->netdev->name, strerror ( rc ) );
226
+	return rc;
227
+}
228
+
229
+
230
+/* Record error codes as though they come from the 802.11 stack */
231
+#undef ERRFILE
232
+#define ERRFILE ERRFILE_net80211
233
+
234
+/** Common 802.11 errors */
235
+struct errortab common_wireless_errors[] __errortab = {
236
+	{ EINVAL | EUNIQ_06, "Packet decryption error" },
237
+	{ ECONNRESET | EUNIQ_01, "Unspecified reason" },
238
+	{ ECONNRESET | EUNIQ_04, "Disassociated due to inactivity" },
239
+	{ ECONNRESET | EUNIQ_0F, "4-Way Handshake timeout" },
240
+	{ ECONNRESET | EUNIQ_17, "IEEE 802.1X authentication failed" },
241
+	{ ECONNREFUSED | EUNIQ_01, "Unspecified failure" },
242
+	{ ECONNREFUSED | EUNIQ_0C, "Association denied" },
243
+	{ ECONNREFUSED | EUNIQ_0D, "Authentication method not supported" },
244
+};

Loading…
Cancel
Save