Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

route_cmd.c 1.8KB

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