iPXE
ifmgmt_cmd.h
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., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301, USA.
00018  *
00019  * You can also choose to distribute this program under the terms of
00020  * the Unmodified Binary Distribution Licence (as given in the file
00021  * COPYING.UBDL), provided that you have satisfied its requirements.
00022  */
00023 
00024 #ifndef _IFMGMT_CMD_H
00025 #define _IFMGMT_CMD_H
00026 
00027 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00028 
00029 #include <ipxe/parseopt.h>
00030 
00031 struct net_device;
00032 
00033 /** An "if<xxx>" command descriptor */
00034 struct ifcommon_command_descriptor {
00035         /** Command descriptor */
00036         struct command_descriptor cmd;
00037         /** Payload
00038          *
00039          * @v netdev            Network device
00040          * @v opts              Command options
00041          * @ret rc              Return status code
00042          */
00043         int ( * payload ) ( struct net_device *netdev, void *opts );
00044         /** Stop on first success */
00045         int stop_on_first_success;
00046 };
00047 
00048 /**
00049  * Construct "if<xxx>" command descriptor
00050  *
00051  * @v _struct           Options structure type
00052  * @v _options          Option descriptor array
00053  * @v _check_args       Remaining argument checker
00054  * @v _usage            Command usage
00055  * @ret _command        Command descriptor
00056  */
00057 #define IFCOMMON_COMMAND_DESC( _struct, _options, _min_args,            \
00058                                _max_args, _usage, _payload,             \
00059                                _stop_on_first_success )                 \
00060         {                                                               \
00061                 .cmd = COMMAND_DESC ( _struct, _options, _min_args,     \
00062                                       _max_args, _usage ),              \
00063                 .payload = ( ( int ( * ) ( struct net_device *netdev,   \
00064                                            void *opts ) )               \
00065                              ( ( ( ( int ( * ) ( struct net_device *,   \
00066                                                  _struct * ) ) NULL )   \
00067                                  == ( typeof ( _payload ) * ) NULL )    \
00068                                ? _payload : _payload ) ),               \
00069                 .stop_on_first_success = _stop_on_first_success,        \
00070         }
00071 
00072 extern int ifcommon_exec (  int argc, char **argv,
00073                             struct ifcommon_command_descriptor *cmd );
00074 extern int ifconf_exec ( int argc, char **argv );
00075 
00076 #endif /* _IFMGMT_CMD_H */