[efi] Nullify interfaces and leak memory on uninstallation failure
[ipxe.git] / src / include / hci / ifmgmt_cmd.h
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., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 *
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.
22 */
23
24 #ifndef _IFMGMT_CMD_H
25 #define _IFMGMT_CMD_H
26
27 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
28
29 #include <ipxe/parseopt.h>
30
31 struct net_device;
32
33 /** An "if<xxx>" command descriptor */
34 struct ifcommon_command_descriptor {
35 /** Command descriptor */
36 struct command_descriptor cmd;
37 /** Payload
38 *
39 * @v netdev Network device
40 * @v opts Command options
41 * @ret rc Return status code
42 */
43 int ( * payload ) ( struct net_device *netdev, void *opts );
44 /** Stop on first success */
45 int stop_on_first_success;
46 };
47
48 /**
49 * Construct "if<xxx>" command descriptor
50 *
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
56 */
57 #define IFCOMMON_COMMAND_DESC( _struct, _options, _min_args, \
58 _max_args, _usage, _payload, \
59 _stop_on_first_success ) \
60 { \
61 .cmd = COMMAND_DESC ( _struct, _options, _min_args, \
62 _max_args, _usage ), \
63 .payload = ( ( int ( * ) ( struct net_device *netdev, \
64 void *opts ) ) \
65 ( ( ( ( int ( * ) ( struct net_device *, \
66 _struct * ) ) NULL ) \
67 == ( typeof ( _payload ) * ) NULL ) \
68 ? _payload : _payload ) ), \
69 .stop_on_first_success = _stop_on_first_success, \
70 }
71
72 extern int ifcommon_exec ( int argc, char **argv,
73 struct ifcommon_command_descriptor *cmd );
74 extern int ifconf_exec ( int argc, char **argv );
75
76 #endif /* _IFMGMT_CMD_H */