iPXE
iwmgmt_cmd.c
Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  */
19 
20 FILE_LICENCE ( GPL2_OR_LATER );
21 
22 #include <ipxe/netdevice.h>
23 #include <ipxe/net80211.h>
24 #include <ipxe/command.h>
25 #include <ipxe/parseopt.h>
26 #include <usr/iwmgmt.h>
27 #include <hci/ifmgmt_cmd.h>
28 
29 /** @file
30  *
31  * Wireless interface management commands
32  *
33  */
34 
35 /** "iwstat" options */
36 struct iwstat_options {};
37 
38 /** "iwstat" option list */
39 static struct option_descriptor iwstat_opts[] = {};
40 
41 /**
42  * "iwstat" payload
43  *
44  * @v netdev Network device
45  * @v opts Command options
46  * @ret rc Return status code
47  */
48 static int iwstat_payload ( struct net_device *netdev,
49  struct iwstat_options *opts __unused ) {
50  struct net80211_device *dev = net80211_get ( netdev );
51 
52  if ( dev )
53  iwstat ( dev );
54 
55  return 0;
56 }
57 
58 /** "iwstat" command descriptor */
61  0, MAX_ARGUMENTS, "[<interface>...]",
62  iwstat_payload, 0 );
63 
64 /**
65  * The "iwstat" command
66  *
67  * @v argc Argument count
68  * @v argv Argument list
69  * @ret rc Return status code
70  */
71 static int iwstat_exec ( int argc, char **argv ) {
72  return ifcommon_exec ( argc, argv, &iwstat_cmd );
73 }
74 
75 /** "iwlist" options */
76 struct iwlist_options {};
77 
78 /** "iwlist" option list */
79 static struct option_descriptor iwlist_opts[] = {};
80 
81 /**
82  * "iwlist" payload
83  *
84  * @v netdev Network device
85  * @v opts Command options
86  * @ret rc Return status code
87  */
88 static int iwlist_payload ( struct net_device *netdev,
89  struct iwlist_options *opts __unused ) {
90  struct net80211_device *dev = net80211_get ( netdev );
91 
92  if ( dev )
93  return iwlist ( dev );
94 
95  return 0;
96 }
97 
98 /** "iwlist" command descriptor */
101  0, MAX_ARGUMENTS, "[<interface>...]",
102  iwlist_payload, 0 );
103 
104 /**
105  * The "iwlist" command
106  *
107  * @v argc Argument count
108  * @v argv Argument list
109  * @ret rc Return status code
110  */
111 static int iwlist_exec ( int argc, char **argv ) {
112  return ifcommon_exec ( argc, argv, &iwlist_cmd );
113 }
114 
115 /** Wireless interface management commands */
116 struct command iwmgmt_commands[] __command = {
117  {
118  .name = "iwstat",
119  .exec = iwstat_exec,
120  },
121  {
122  .name = "iwlist",
123  .exec = iwlist_exec,
124  },
125 };
static int iwstat_payload(struct net_device *netdev, struct iwstat_options *opts __unused)
"iwstat" payload
Definition: iwmgmt_cmd.c:48
static struct option_descriptor iwlist_opts[]
"iwlist" option list
Definition: iwmgmt_cmd.c:79
int iwlist(struct net80211_device *dev)
Scan for wireless networks using 802.11 device.
Definition: iwmgmt.c:120
static int iwstat_exec(int argc, char **argv)
The "iwstat" command.
Definition: iwmgmt_cmd.c:71
A command-line command.
Definition: command.h:9
An "if<xxx>" command descriptor.
Definition: ifmgmt_cmd.h:34
#define MAX_ARGUMENTS
No maximum number of arguments.
Definition: parseopt.h:97
static struct net_device * netdev
Definition: gdbudp.c:52
Wireless network interface management.
static int iwlist_exec(int argc, char **argv)
The "iwlist" command.
Definition: iwmgmt_cmd.c:111
static struct ifcommon_command_descriptor iwlist_cmd
"iwlist" command descriptor
Definition: iwmgmt_cmd.c:99
The iPXE 802.11 MAC layer.
Structure encapsulating the complete state of an 802.11 device.
Definition: net80211.h:786
Command line option parsing.
A network device.
Definition: netdevice.h:352
static struct option_descriptor iwstat_opts[]
"iwstat" option list
Definition: iwmgmt_cmd.c:39
struct net80211_device * net80211_get(struct net_device *netdev)
Get 802.11 device from wrapping network device.
Definition: net80211.c:624
static union @437 opts
"cert<xxx>" option list
const char * name
Name of the command.
Definition: command.h:11
Network device management.
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
void iwstat(struct net80211_device *dev)
Print status of 802.11 device.
Definition: iwmgmt.c:41
FILE_LICENCE(GPL2_OR_LATER)
"iwlist" options
Definition: iwmgmt_cmd.c:76
int ifcommon_exec(int argc, char **argv, struct ifcommon_command_descriptor *ifcmd)
Execute if<xxx> command.
Definition: ifmgmt_cmd.c:51
static struct ifcommon_command_descriptor iwstat_cmd
"iwstat" command descriptor
Definition: iwmgmt_cmd.c:59
"iwstat" options
Definition: iwmgmt_cmd.c:36
A command-line option descriptor.
Definition: parseopt.h:23
static int iwlist_payload(struct net_device *netdev, struct iwlist_options *opts __unused)
"iwlist" payload
Definition: iwmgmt_cmd.c:88
#define IFCOMMON_COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage, _payload, _stop_on_first_success)
Construct "if<xxx>" command descriptor.
Definition: ifmgmt_cmd.h:57
struct command iwmgmt_commands [] __command
Wireless interface management commands.
Definition: iwmgmt_cmd.c:116