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.

ifmgmt_cmd.h 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
  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. * You can also choose to distribute this program under the terms of
  20. * the Unmodified Binary Distribution Licence (as given in the file
  21. * COPYING.UBDL), provided that you have satisfied its requirements.
  22. */
  23. #ifndef _IFMGMT_CMD_H
  24. #define _IFMGMT_CMD_H
  25. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  26. #include <ipxe/parseopt.h>
  27. struct net_device;
  28. /** An "if<xxx>" command descriptor */
  29. struct ifcommon_command_descriptor {
  30. /** Command descriptor */
  31. struct command_descriptor cmd;
  32. /** Payload
  33. *
  34. * @v netdev Network device
  35. * @v opts Command options
  36. * @ret rc Return status code
  37. */
  38. int ( * payload ) ( struct net_device *netdev, void *opts );
  39. /** Stop on first success */
  40. int stop_on_first_success;
  41. };
  42. /**
  43. * Construct "if<xxx>" command descriptor
  44. *
  45. * @v _struct Options structure type
  46. * @v _options Option descriptor array
  47. * @v _check_args Remaining argument checker
  48. * @v _usage Command usage
  49. * @ret _command Command descriptor
  50. */
  51. #define IFCOMMON_COMMAND_DESC( _struct, _options, _min_args, \
  52. _max_args, _usage, _payload, \
  53. _stop_on_first_success ) \
  54. { \
  55. .cmd = COMMAND_DESC ( _struct, _options, _min_args, \
  56. _max_args, _usage ), \
  57. .payload = ( ( int ( * ) ( struct net_device *netdev, \
  58. void *opts ) ) \
  59. ( ( ( ( int ( * ) ( struct net_device *, \
  60. _struct * ) ) NULL ) \
  61. == ( typeof ( _payload ) * ) NULL ) \
  62. ? _payload : _payload ) ), \
  63. .stop_on_first_success = _stop_on_first_success, \
  64. }
  65. extern int ifcommon_exec ( int argc, char **argv,
  66. struct ifcommon_command_descriptor *cmd );
  67. extern int ifconf_exec ( int argc, char **argv );
  68. #endif /* _IFMGMT_CMD_H */