#include <stdio.h>
#include <getopt.h>
#include <gpxe/netdevice.h>
#include <gpxe/command.h>
#include <usr/ifmgmt.h>
#include <hci/ifmgmt_cmd.h>
Go to the source code of this file.
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| static void | ifcommon_syntax (char **argv, const char *verb) |
| Print syntax of if<xxx> command. | |
| static int | ifcommon_do_all (int(*payload)(struct net_device *)) |
| Execute if<xxx> command over all network devices. | |
| static int | ifcommon_do_list (int(*payload)(struct net_device *), char **list, unsigned int count) |
| Execute if<xxx> command over list of network devices. | |
| int | ifcommon_exec (int argc, char **argv, int(*payload)(struct net_device *), const char *verb) |
| Execute if<xxx> command. | |
| static int | ifopen_payload (struct net_device *netdev) |
| static int | ifopen_exec (int argc, char **argv) |
| static int | ifclose_payload (struct net_device *netdev) |
| static int | ifclose_exec (int argc, char **argv) |
| static int | ifstat_payload (struct net_device *netdev) |
| static int | ifstat_exec (int argc, char **argv) |
Variables | |
| static struct option | ifcommon_longopts [] |
| Options shared by all if<xxx> commands. | |
| struct command ifmgmt_commands[] | __command |
| Interface management commands. | |
Definition in file ifmgmt_cmd.c.
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| static void ifcommon_syntax | ( | char ** | argv, | |
| const char * | verb | |||
| ) | [static] |
Print syntax of if<xxx> command.
| argv | Command arguments | |
| verb | Verb describing the action of the command |
Definition at line 46 of file ifmgmt_cmd.c.
References printf().
Referenced by ifcommon_exec().
00046 { 00047 printf ( "Usage:\n" 00048 " %s [<interface>] [<interface>...]\n" 00049 "\n" 00050 "%s the specified network interfaces\n", 00051 argv[0], verb ); 00052 }
| static int ifcommon_do_all | ( | int(*)(struct net_device *) | payload | ) | [static] |
Execute if<xxx> command over all network devices.
| payload | Command to execute |
| rc | Exit code |
Definition at line 60 of file ifmgmt_cmd.c.
References for_each_netdev, and netdev.
Referenced by ifcommon_exec().
00060 { 00061 struct net_device *netdev; 00062 int rc = 0; 00063 00064 /* Execute payload for each network device */ 00065 for_each_netdev ( netdev ) { 00066 if ( payload ( netdev ) != 0 ) 00067 rc = 1; 00068 } 00069 return rc; 00070 }
| static int ifcommon_do_list | ( | int(*)(struct net_device *) | payload, | |
| char ** | list, | |||
| unsigned int | count | |||
| ) | [static] |
Execute if<xxx> command over list of network devices.
| payload | Command to execute |
| rc | Exit code |
Definition at line 78 of file ifmgmt_cmd.c.
References find_netdev(), netdev, and printf().
Referenced by ifcommon_exec().
00079 { 00080 const char *netdev_name; 00081 struct net_device *netdev; 00082 int rc = 0; 00083 00084 while ( count-- ) { 00085 netdev_name = *(list++); 00086 netdev = find_netdev ( netdev_name ); 00087 if ( ! netdev ) { 00088 printf ( "%s: no such interface\n", netdev_name ); 00089 rc = 1; 00090 continue; 00091 } 00092 if ( payload ( netdev ) != 0 ) 00093 rc = 1; 00094 } 00095 return rc; 00096 }
| int ifcommon_exec | ( | int | argc, | |
| char ** | argv, | |||
| int(*)(struct net_device *) | payload, | |||
| const char * | verb | |||
| ) |
Execute if<xxx> command.
| argc | Argument count | |
| argv | Argument list | |
| payload | Command to execute | |
| verb | Verb describing the action of the command |
| rc | Exit code |
Definition at line 107 of file ifmgmt_cmd.c.
References getopt_long(), ifcommon_do_all(), ifcommon_do_list(), ifcommon_syntax(), NULL, and optind.
Referenced by ifclose_exec(), ifopen_exec(), ifstat_exec(), iwlist_exec(), iwstat_exec(), and startpxe_exec().
00109 { 00110 int c; 00111 00112 /* Parse options */ 00113 while ( ( c = getopt_long ( argc, argv, "h", ifcommon_longopts, 00114 NULL ) ) >= 0 ) { 00115 switch ( c ) { 00116 case 'h': 00117 /* Display help text */ 00118 default: 00119 /* Unrecognised/invalid option */ 00120 ifcommon_syntax ( argv, verb ); 00121 return 1; 00122 } 00123 } 00124 00125 if ( optind == argc ) { 00126 return ifcommon_do_all ( payload ); 00127 } else { 00128 return ifcommon_do_list ( payload, &argv[optind], 00129 ( argc - optind ) ); 00130 } 00131 }
| static int ifopen_payload | ( | struct net_device * | netdev | ) | [static] |
Definition at line 135 of file ifmgmt_cmd.c.
References ifopen().
Referenced by ifopen_exec().
00135 { 00136 return ifopen ( netdev ); 00137 }
| static int ifopen_exec | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Definition at line 139 of file ifmgmt_cmd.c.
References ifcommon_exec(), and ifopen_payload().
00139 { 00140 return ifcommon_exec ( argc, argv, ifopen_payload, "Open" ); 00141 }
| static int ifclose_payload | ( | struct net_device * | netdev | ) | [static] |
Definition at line 145 of file ifmgmt_cmd.c.
References ifclose().
Referenced by ifclose_exec().
00145 { 00146 ifclose ( netdev ); 00147 return 0; 00148 }
| static int ifclose_exec | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Definition at line 150 of file ifmgmt_cmd.c.
References ifclose_payload(), and ifcommon_exec().
00150 { 00151 return ifcommon_exec ( argc, argv, ifclose_payload, "Close" ); 00152 }
| static int ifstat_payload | ( | struct net_device * | netdev | ) | [static] |
Definition at line 156 of file ifmgmt_cmd.c.
References ifstat().
Referenced by ifstat_exec().
00156 { 00157 ifstat ( netdev ); 00158 return 0; 00159 }
| static int ifstat_exec | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Definition at line 161 of file ifmgmt_cmd.c.
References ifcommon_exec(), and ifstat_payload().
00161 { 00162 return ifcommon_exec ( argc, argv, 00163 ifstat_payload, "Display status of" ); 00164 }
struct option ifcommon_longopts[] [static] |
Initial value:
{
{
.name = "ifopen",
.exec = ifopen_exec,
},
{
.name = "ifclose",
.exec = ifclose_exec,
},
{
.name = "ifstat",
.exec = ifstat_exec,
},
}
Definition at line 167 of file ifmgmt_cmd.c.
1.5.7.1