Skip to content

Commit

Permalink
[iwmgmt] Add wireless management commands and text for common errors
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rwcr authored and Marty Connor committed Jan 5, 2010
1 parent dd8a3e2 commit 1327a78
Show file tree
Hide file tree
Showing 8 changed files with 490 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/config/config.c
Expand Up @@ -204,6 +204,7 @@ REQUIRE_OBJECT ( config_cmd );
#ifdef IFMGMT_CMD
REQUIRE_OBJECT ( ifmgmt_cmd );
#endif
/* IWMGMT_CMD is brought in by net80211.c if requested */
#ifdef ROUTE_CMD
REQUIRE_OBJECT ( route_cmd );
#endif
Expand Down
33 changes: 33 additions & 0 deletions src/config/config_net80211.c
@@ -0,0 +1,33 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2, or (at
* your option) any later version.
*/

FILE_LICENCE ( GPL2_OR_LATER );

#include <config/general.h>

/** @file
*
* 802.11 configuration options
*
*/

/*
* Drag in 802.11-specific commands
*
*/
#ifdef IWMGMT_CMD
REQUIRE_OBJECT ( iwmgmt_cmd );
#endif

/*
* Drag in 802.11 error message tables
*
*/
#ifdef ERRMSG_80211
REQUIRE_OBJECT ( wireless_errors );
#endif

7 changes: 7 additions & 0 deletions src/config/general.h
Expand Up @@ -99,6 +99,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#define NVO_CMD /* Non-volatile option storage commands */
#define CONFIG_CMD /* Option configuration console */
#define IFMGMT_CMD /* Interface management commands */
#define IWMGMT_CMD /* Wireless interface management commands */
#define ROUTE_CMD /* Routing table management commands */
#define IMAGE_CMD /* Image management commands */
#define DHCP_CMD /* DHCP management commands */
Expand All @@ -108,6 +109,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
#undef DIGEST_CMD /* Image crypto digest commands */
//#undef PXE_CMD /* PXE commands */

/*
* Error message tables to include
*
*/
#undef ERRMSG_80211 /* All 802.11 error descriptions (~3.3kb) */

/*
* Obscure configuration options
*
Expand Down
69 changes: 69 additions & 0 deletions src/hci/commands/iwmgmt_cmd.c
@@ -0,0 +1,69 @@
/*
* Copyright (C) 2009 Joshua Oreman <oremanj@rwcr.net>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

FILE_LICENCE ( GPL2_OR_LATER );

#include <gpxe/netdevice.h>
#include <gpxe/net80211.h>
#include <gpxe/command.h>
#include <usr/iwmgmt.h>
#include <hci/ifmgmt_cmd.h>

/* "iwstat" command */

static int iwstat_payload ( struct net_device *netdev ) {
struct net80211_device *dev = net80211_get ( netdev );

if ( dev )
iwstat ( dev );

return 0;
}

static int iwstat_exec ( int argc, char **argv ) {
return ifcommon_exec ( argc, argv,
iwstat_payload, "Display wireless status of" );
}

/* "iwlist" command */

static int iwlist_payload ( struct net_device *netdev ) {
struct net80211_device *dev = net80211_get ( netdev );

if ( dev )
return iwlist ( dev );

return 0;
}

static int iwlist_exec ( int argc, char **argv ) {
return ifcommon_exec ( argc, argv, iwlist_payload,
"List wireless networks available via" );
}

/** Wireless interface management commands */
struct command iwmgmt_commands[] __command = {
{
.name = "iwstat",
.exec = iwstat_exec,
},
{
.name = "iwlist",
.exec = iwlist_exec,
},
};
118 changes: 118 additions & 0 deletions src/hci/wireless_errors.c
@@ -0,0 +1,118 @@
/*
* Copyright (C) 2009 Joshua Oreman <oremanj@rwcr.net>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

FILE_LICENCE ( GPL2_OR_LATER );

#include <errno.h>
#include <gpxe/errortab.h>

/* Record errors as though they come from the 802.11 stack */
#undef ERRFILE
#define ERRFILE ERRFILE_net80211

/** All 802.11 errors
*
* These follow the 802.11 standard as much as is feasible, but most
* have been abbreviated to fit the 50-character limit imposed by
* strerror.
*/
struct errortab wireless_errors[] __errortab = {
/* gPXE 802.11 stack errors */
{ EINVAL | EUNIQ_01, "Packet too short" },
{ EINVAL | EUNIQ_02, "Packet 802.11 version not supported" },
{ EINVAL | EUNIQ_03, "Packet not a data packet" },
{ EINVAL | EUNIQ_04, "Packet not from an Access Point" },
{ EINVAL | EUNIQ_05, "Packet has invalid LLC header" },
{ EINVAL | EUNIQ_06, "Packet decryption error", },
{ EINVAL | EUNIQ_07, "Invalid active scan requested" },

/* 802.11 status codes (IEEE Std 802.11-2007, Table 7-23) */
/* Maximum error length: 50 chars | */
{ ECONNREFUSED | EUNIQ_01, "Unspecified failure" },
{ ECONNREFUSED | EUNIQ_0A, "Cannot support all requested capabilities" },
{ ECONNREFUSED | EUNIQ_0B, "Reassociation denied due to lack of association" },
{ ECONNREFUSED | EUNIQ_0C, "Association denied for another reason" },
{ ECONNREFUSED | EUNIQ_0D, "Authentication algorithm unsupported" },
{ ECONNREFUSED | EUNIQ_0E, "Authentication sequence number unexpected" },
{ ECONNREFUSED | EUNIQ_0F, "Authentication rejected due to challenge failure" },
{ ECONNREFUSED | EUNIQ_10, "Authentication rejected due to timeout" },
{ ECONNREFUSED | EUNIQ_11, "Association denied because AP is out of resources" },
{ ECONNREFUSED | EUNIQ_12, "Association denied; basic rate support required" },
{ ECONNREFUSED | EUNIQ_13, "Association denied; short preamble support req'd" },
{ ECONNREFUSED | EUNIQ_14, "Association denied; PBCC modulation support req'd" },
{ ECONNREFUSED | EUNIQ_15, "Association denied; Channel Agility support req'd" },
{ ECONNREFUSED | EUNIQ_16, "Association denied; Spectrum Management required" },
{ ECONNREFUSED | EUNIQ_17, "Association denied; Power Capability unacceptable" },
{ ECONNREFUSED | EUNIQ_18, "Association denied; Supported Channels unacceptable" },
{ ECONNREFUSED | EUNIQ_19, "Association denied; Short Slot Tume support req'd" },
{ ECONNREFUSED | EUNIQ_1A, "Association denied; DSSS-OFDM support required" },
{ EHOSTUNREACH, "Unspecified, QoS-related failure" },
{ EHOSTUNREACH | EUNIQ_01, "Association denied; QoS AP out of QoS resources" },
{ EHOSTUNREACH | EUNIQ_02, "Association denied due to excessively poor link" },
{ EHOSTUNREACH | EUNIQ_03, "Association denied; QoS support required" },
{ EHOSTUNREACH | EUNIQ_05, "The request has been declined" },
{ EHOSTUNREACH | EUNIQ_06, "Request unsuccessful due to invalid parameters" },
{ EHOSTUNREACH | EUNIQ_07, "TS not created due to bad specification" },
{ EHOSTUNREACH | EUNIQ_08, "Invalid information element" },
{ EHOSTUNREACH | EUNIQ_09, "Invalid group cipher" },
{ EHOSTUNREACH | EUNIQ_0A, "Invalid pairwise cipher" },
{ EHOSTUNREACH | EUNIQ_0B, "Invalid AKMP" },
{ EHOSTUNREACH | EUNIQ_0C, "Unsupported RSN information element version" },
{ EHOSTUNREACH | EUNIQ_0D, "Invalid RSN information element capabilities" },
{ EHOSTUNREACH | EUNIQ_0E, "Cipher suite rejected because of security policy" },
{ EHOSTUNREACH | EUNIQ_0F, "TS not created due to insufficient delay" },
{ EHOSTUNREACH | EUNIQ_10, "Direct link is not allowed in the BSS by policy" },
{ EHOSTUNREACH | EUNIQ_11, "The Destination STA is not present within the BSS" },
{ EHOSTUNREACH | EUNIQ_12, "The Destination STA is not a QoS STA" },
{ EHOSTUNREACH | EUNIQ_13, "Association denied; Listen Interval is too large" },

/* 802.11 reason codes (IEEE Std 802.11-2007, Table 7-22) */
/* Maximum error length: 50 chars | */
{ ECONNRESET | EUNIQ_01, "Unspecified reason" },
{ ECONNRESET | EUNIQ_02, "Previous authentication no longer valid" },
{ ECONNRESET | EUNIQ_03, "Deauthenticated due to leaving network" },
{ ECONNRESET | EUNIQ_04, "Disassociated due to inactivity" },
{ ECONNRESET | EUNIQ_05, "Disassociated because AP is out of resources" },
{ ECONNRESET | EUNIQ_06, "Class 2 frame received from nonauthenticated STA" },
{ ECONNRESET | EUNIQ_07, "Class 3 frame received from nonassociated STA" },
{ ECONNRESET | EUNIQ_08, "Disassociated due to roaming" },
{ ECONNRESET | EUNIQ_09, "STA requesting (re)association not authenticated" },
{ ECONNRESET | EUNIQ_0A, "Disassociated; Power Capability unacceptable" },
{ ECONNRESET | EUNIQ_0B, "Disassociated; Supported Channels unacceptable" },
{ ECONNRESET | EUNIQ_0D, "Invalid information element" },
{ ECONNRESET | EUNIQ_0E, "Message integrity code (MIC) failure" },
{ ECONNRESET | EUNIQ_0F, "4-Way Handshake timeout" },
{ ECONNRESET | EUNIQ_10, "Group Key Handshake timeout" },
{ ECONNRESET | EUNIQ_11, "4-Way Handshake information element changed unduly" },
{ ECONNRESET | EUNIQ_12, "Invalid group cipher" },
{ ECONNRESET | EUNIQ_13, "Invalid pairwise cipher" },
{ ECONNRESET | EUNIQ_14, "Invalid AKMP" },
{ ECONNRESET | EUNIQ_15, "Unsupported RSN information element version" },
{ ECONNRESET | EUNIQ_16, "Invalid RSN information element capabilities" },
{ ECONNRESET | EUNIQ_17, "IEEE 802.1X authentication failed" },
{ ECONNRESET | EUNIQ_18, "Cipher suite rejected because of security policy" },
{ ENETRESET, "Disassociated for unspecified, QoS-related reason" },
{ ENETRESET | EUNIQ_01, "Disassociated; QoS AP is out of QoS resources" },
{ ENETRESET | EUNIQ_02, "Disassociated due to excessively poor link" },
{ ENETRESET | EUNIQ_03, "Disassociated due to TXOP limit violation" },
{ ENETRESET | EUNIQ_04, "Requested; STA is leaving the BSS (or resetting)" },
{ ENETRESET | EUNIQ_05, "Requested; does not want to use the mechanism" },
{ ENETRESET | EUNIQ_06, "Requested; setup is required" },
{ ENETRESET | EUNIQ_07, "Requested from peer STA due to timeout" },
{ ENETRESET | EUNIQ_0D, "Peer STA does not support requested cipher suite" },
};
1 change: 1 addition & 0 deletions src/include/gpxe/errfile.h
Expand Up @@ -192,6 +192,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#define ERRFILE_x509 ( ERRFILE_OTHER | 0x00160000 )
#define ERRFILE_login_ui ( ERRFILE_OTHER | 0x00170000 )
#define ERRFILE_ib_srpboot ( ERRFILE_OTHER | 0x00180000 )
#define ERRFILE_iwmgmt ( ERRFILE_OTHER | 0x00190000 )

/** @} */

Expand Down
17 changes: 17 additions & 0 deletions src/include/usr/iwmgmt.h
@@ -0,0 +1,17 @@
#ifndef _USR_IWMGMT_H
#define _USR_IWMGMT_H

/** @file
*
* Wireless network interface management
*
*/

FILE_LICENCE ( GPL2_OR_LATER );

struct net80211_device;

extern void iwstat ( struct net80211_device *dev );
extern int iwlist ( struct net80211_device *dev );

#endif /* _USR_IWMGMT_H */

0 comments on commit 1327a78

Please sign in to comment.