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
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
27 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
29 #include <ipxe/parseopt.h>
33 /** An "if<xxx>" command descriptor */
34 struct ifcommon_command_descriptor {
35 /** Command descriptor */
36 struct command_descriptor cmd;
39 * @v netdev Network device
40 * @v opts Command options
41 * @ret rc Return status code
43 int ( * payload ) ( struct net_device *netdev, void *opts );
44 /** Stop on first success */
45 int stop_on_first_success;
49 * Construct "if<xxx>" command descriptor
51 * @v _struct Options structure type
52 * @v _options Option descriptor array
53 * @v _check_args Remaining argument checker
54 * @v _usage Command usage
55 * @ret _command Command descriptor
57 #define IFCOMMON_COMMAND_DESC( _struct, _options, _min_args, \
58 _max_args, _usage, _payload, \
59 _stop_on_first_success ) \
61 .cmd = COMMAND_DESC ( _struct, _options, _min_args, \
62 _max_args, _usage ), \
63 .payload = ( ( int ( * ) ( struct net_device *netdev, \
65 ( ( ( ( int ( * ) ( struct net_device *, \
66 _struct * ) ) NULL ) \
67 == ( typeof ( _payload ) * ) NULL ) \
68 ? _payload : _payload ) ), \
69 .stop_on_first_success = _stop_on_first_success, \
72 extern int ifcommon_exec ( int argc, char **argv,
73 struct ifcommon_command_descriptor *cmd );
74 extern int ifconf_exec ( int argc, char **argv );
76 #endif /* _IFMGMT_CMD_H */