route_cmd.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 
00019 FILE_LICENCE ( GPL2_OR_LATER );
00020 
00021 #include <stdio.h>
00022 #include <getopt.h>
00023 #include <gpxe/command.h>
00024 #include <usr/route.h>
00025 
00026 /** @file
00027  *
00028  * Routing table management commands
00029  *
00030  */
00031 
00032 /**
00033  * "route" command syntax message
00034  *
00035  * @v argv              Argument list
00036  */
00037 static void route_syntax ( char **argv ) {
00038         printf ( "Usage:\n"
00039                  "  %s\n"
00040                  "\n"
00041                  "Displays the routing table\n",
00042                  argv[0] );
00043 }
00044 
00045 /**
00046  * The "route" command
00047  *
00048  * @v argc              Argument count
00049  * @v argv              Argument list
00050  * @ret rc              Exit code
00051  */
00052 static int route_exec ( int argc, char **argv ) {
00053         static struct option longopts[] = {
00054                 { "help", 0, NULL, 'h' },
00055                 { NULL, 0, NULL, 0 },
00056         };
00057 
00058         int c;
00059 
00060         /* Parse options */
00061         while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
00062                 switch ( c ) {
00063                 case 'h':
00064                         /* Display help text */
00065                 default:
00066                         /* Unrecognised/invalid option */
00067                         route_syntax ( argv );
00068                         return 1;
00069                 }
00070         }
00071 
00072         if ( optind != argc ) {
00073                 route_syntax ( argv );
00074                 return 1;
00075         }
00076 
00077         route();
00078         return 0;
00079 }
00080 
00081 /** Routing table management commands */
00082 struct command route_commands[] __command = {
00083         {
00084                 .name = "route",
00085                 .exec = route_exec,
00086         },
00087 };

Generated on Tue Apr 6 20:01:06 2010 for gPXE by  doxygen 1.5.7.1