You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. FILE_LICENCE ( GPL2_OR_LATER );
  20. #include <ipxe/netdevice.h>
  21. #include <ipxe/net80211.h>
  22. #include <ipxe/command.h>
  23. #include <ipxe/parseopt.h>
  24. #include <usr/iwmgmt.h>
  25. #include <hci/ifmgmt_cmd.h>
  26. /** @file
  27. *
  28. * Wireless interface management commands
  29. *
  30. */
  31. /** "iwstat" options */
  32. struct iwstat_options {};
  33. /** "iwstat" option list */
  34. static struct option_descriptor iwstat_opts[] = {};
  35. /**
  36. * "iwstat" payload
  37. *
  38. * @v netdev Network device
  39. * @v opts Command options
  40. * @ret rc Return status code
  41. */
  42. static int iwstat_payload ( struct net_device *netdev,
  43. struct iwstat_options *opts __unused ) {
  44. struct net80211_device *dev = net80211_get ( netdev );
  45. if ( dev )
  46. iwstat ( dev );
  47. return 0;
  48. }
  49. /** "iwstat" command descriptor */
  50. static struct ifcommon_command_descriptor iwstat_cmd =
  51. IFCOMMON_COMMAND_DESC ( struct iwstat_options, iwstat_opts,
  52. 0, MAX_ARGUMENTS, "[<interface>...]",
  53. iwstat_payload, 0 );
  54. /**
  55. * The "iwstat" command
  56. *
  57. * @v argc Argument count
  58. * @v argv Argument list
  59. * @ret rc Return status code
  60. */
  61. static int iwstat_exec ( int argc, char **argv ) {
  62. return ifcommon_exec ( argc, argv, &iwstat_cmd );
  63. }
  64. /** "iwlist" options */
  65. struct iwlist_options {};
  66. /** "iwlist" option list */
  67. static struct option_descriptor iwlist_opts[] = {};
  68. /**
  69. * "iwlist" payload
  70. *
  71. * @v netdev Network device
  72. * @v opts Command options
  73. * @ret rc Return status code
  74. */
  75. static int iwlist_payload ( struct net_device *netdev,
  76. struct iwlist_options *opts __unused ) {
  77. struct net80211_device *dev = net80211_get ( netdev );
  78. if ( dev )
  79. return iwlist ( dev );
  80. return 0;
  81. }
  82. /** "iwlist" command descriptor */
  83. static struct ifcommon_command_descriptor iwlist_cmd =
  84. IFCOMMON_COMMAND_DESC ( struct iwlist_options, iwlist_opts,
  85. 0, MAX_ARGUMENTS, "[<interface>...]",
  86. iwlist_payload, 0 );
  87. /**
  88. * The "iwlist" command
  89. *
  90. * @v argc Argument count
  91. * @v argv Argument list
  92. * @ret rc Return status code
  93. */
  94. static int iwlist_exec ( int argc, char **argv ) {
  95. return ifcommon_exec ( argc, argv, &iwlist_cmd );
  96. }
  97. /** Wireless interface management commands */
  98. struct command iwmgmt_commands[] __command = {
  99. {
  100. .name = "iwstat",
  101. .exec = iwstat_exec,
  102. },
  103. {
  104. .name = "iwlist",
  105. .exec = iwlist_exec,
  106. },
  107. };