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.

route_cmd.c 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #include <stdio.h>
  19. #include <getopt.h>
  20. #include <gpxe/command.h>
  21. #include <usr/route.h>
  22. /** @file
  23. *
  24. * Routing table management commands
  25. *
  26. */
  27. /**
  28. * "route" command syntax message
  29. *
  30. * @v argv Argument list
  31. */
  32. static void route_syntax ( char **argv ) {
  33. printf ( "Usage:\n"
  34. " %s\n"
  35. "\n"
  36. "Displays the routing table\n",
  37. argv[0] );
  38. }
  39. /**
  40. * The "route" command
  41. *
  42. * @v argc Argument count
  43. * @v argv Argument list
  44. * @ret rc Exit code
  45. */
  46. static int route_exec ( int argc, char **argv ) {
  47. static struct option longopts[] = {
  48. { "help", 0, NULL, 'h' },
  49. { NULL, 0, NULL, 0 },
  50. };
  51. int c;
  52. /* Parse options */
  53. while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
  54. switch ( c ) {
  55. case 'h':
  56. /* Display help text */
  57. default:
  58. /* Unrecognised/invalid option */
  59. route_syntax ( argv );
  60. return 1;
  61. }
  62. }
  63. if ( optind != argc ) {
  64. route_syntax ( argv );
  65. return 1;
  66. }
  67. route();
  68. return 0;
  69. }
  70. /** Routing table management commands */
  71. struct command route_commands[] __command = {
  72. {
  73. .name = "route",
  74. .exec = route_exec,
  75. },
  76. };