iPXE
iwmgmt_cmd.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009 Joshua Oreman <oremanj@rwcr.net>.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301, USA.
00018  */
00019 
00020 FILE_LICENCE ( GPL2_OR_LATER );
00021 
00022 #include <ipxe/netdevice.h>
00023 #include <ipxe/net80211.h>
00024 #include <ipxe/command.h>
00025 #include <ipxe/parseopt.h>
00026 #include <usr/iwmgmt.h>
00027 #include <hci/ifmgmt_cmd.h>
00028 
00029 /** @file
00030  *
00031  * Wireless interface management commands
00032  *
00033  */
00034 
00035 /** "iwstat" options */
00036 struct iwstat_options {};
00037 
00038 /** "iwstat" option list */
00039 static struct option_descriptor iwstat_opts[] = {};
00040 
00041 /**
00042  * "iwstat" payload
00043  *
00044  * @v netdev            Network device
00045  * @v opts              Command options
00046  * @ret rc              Return status code
00047  */
00048 static int iwstat_payload ( struct net_device *netdev,
00049                             struct iwstat_options *opts __unused ) {
00050         struct net80211_device *dev = net80211_get ( netdev );
00051 
00052         if ( dev )
00053                 iwstat ( dev );
00054 
00055         return 0;
00056 }
00057 
00058 /** "iwstat" command descriptor */
00059 static struct ifcommon_command_descriptor iwstat_cmd =
00060         IFCOMMON_COMMAND_DESC ( struct iwstat_options, iwstat_opts,
00061                                 0, MAX_ARGUMENTS, "[<interface>...]",
00062                                 iwstat_payload, 0 );
00063 
00064 /**
00065  * The "iwstat" command
00066  *
00067  * @v argc              Argument count
00068  * @v argv              Argument list
00069  * @ret rc              Return status code
00070  */
00071 static int iwstat_exec ( int argc, char **argv ) {
00072         return ifcommon_exec ( argc, argv, &iwstat_cmd );
00073 }
00074 
00075 /** "iwlist" options */
00076 struct iwlist_options {};
00077 
00078 /** "iwlist" option list */
00079 static struct option_descriptor iwlist_opts[] = {};
00080 
00081 /**
00082  * "iwlist" payload
00083  *
00084  * @v netdev            Network device
00085  * @v opts              Command options
00086  * @ret rc              Return status code
00087  */
00088 static int iwlist_payload ( struct net_device *netdev,
00089                             struct iwlist_options *opts __unused ) {
00090         struct net80211_device *dev = net80211_get ( netdev );
00091 
00092         if ( dev )
00093                 return iwlist ( dev );
00094 
00095         return 0;
00096 }
00097 
00098 /** "iwlist" command descriptor */
00099 static struct ifcommon_command_descriptor iwlist_cmd =
00100         IFCOMMON_COMMAND_DESC ( struct iwlist_options, iwlist_opts,
00101                                 0, MAX_ARGUMENTS, "[<interface>...]",
00102                                 iwlist_payload, 0 );
00103 
00104 /**
00105  * The "iwlist" command
00106  *
00107  * @v argc              Argument count
00108  * @v argv              Argument list
00109  * @ret rc              Return status code
00110  */
00111 static int iwlist_exec ( int argc, char **argv ) {
00112         return ifcommon_exec ( argc, argv, &iwlist_cmd );
00113 }
00114 
00115 /** Wireless interface management commands */
00116 struct command iwmgmt_commands[] __command = {
00117         {
00118                 .name = "iwstat",
00119                 .exec = iwstat_exec,
00120         },
00121         {
00122                 .name = "iwlist",
00123                 .exec = iwlist_exec,
00124         },
00125 };