2 * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
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.
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.
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
23 FILE_LICENCE ( GPL2_OR_LATER );
25 #include <ipxe/parseopt.h>
29 /** An "if<xxx>" command descriptor */
30 struct ifcommon_command_descriptor {
31 /** Command descriptor */
32 struct command_descriptor cmd;
35 * @v netdev Network device
36 * @v opts Command options
37 * @ret rc Return status code
39 int ( * payload ) ( struct net_device *netdev, void *opts );
40 /** Stop on first success */
41 int stop_on_first_success;
45 * Construct "if<xxx>" command descriptor
47 * @v _struct Options structure type
48 * @v _options Option descriptor array
49 * @v _check_args Remaining argument checker
50 * @v _usage Command usage
51 * @ret _command Command descriptor
53 #define IFCOMMON_COMMAND_DESC( _struct, _options, _min_args, \
54 _max_args, _usage, _payload, \
55 _stop_on_first_success ) \
57 .cmd = COMMAND_DESC ( _struct, _options, _min_args, \
58 _max_args, _usage ), \
59 .payload = ( ( int ( * ) ( struct net_device *netdev, \
61 ( ( ( ( int ( * ) ( struct net_device *, \
62 _struct * ) ) NULL ) \
63 == ( typeof ( _payload ) * ) NULL ) \
64 ? _payload : _payload ) ), \
65 .stop_on_first_success = _stop_on_first_success, \
68 extern int ifcommon_exec ( int argc, char **argv,
69 struct ifcommon_command_descriptor *cmd );
70 extern int ifconf_exec ( int argc, char **argv );
72 #endif /* _IFMGMT_CMD_H */