Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / hci / commands / iwmgmt_cmd.c
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 */
59 static struct ifcommon_command_descriptor iwstat_cmd =
60         IFCOMMON_COMMAND_DESC ( struct iwstat_options, iwstat_opts,
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 */
99 static struct ifcommon_command_descriptor iwlist_cmd =
100         IFCOMMON_COMMAND_DESC ( struct iwlist_options, iwlist_opts,
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 };