|
|
@@ -34,9 +34,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|
34
|
34
|
*
|
|
35
|
35
|
*/
|
|
36
|
36
|
|
|
37
|
|
-/** "if<xxx>" command options */
|
|
38
|
|
-struct option_descriptor ifcommon_opts[0];
|
|
39
|
|
-
|
|
40
|
37
|
/**
|
|
41
|
38
|
* Execute if<xxx> command
|
|
42
|
39
|
*
|
|
|
@@ -48,16 +45,15 @@ struct option_descriptor ifcommon_opts[0];
|
|
48
|
45
|
* @ret rc Return status code
|
|
49
|
46
|
*/
|
|
50
|
47
|
int ifcommon_exec ( int argc, char **argv,
|
|
51
|
|
- struct command_descriptor *cmd,
|
|
52
|
|
- int ( * payload ) ( struct net_device * ),
|
|
53
|
|
- int stop_on_first_success ) {
|
|
54
|
|
- struct ifcommon_options opts;
|
|
|
48
|
+ struct ifcommon_command_descriptor *ifcmd ) {
|
|
|
49
|
+ struct command_descriptor *cmd = &ifcmd->cmd;
|
|
|
50
|
+ uint8_t opts[cmd->len];
|
|
55
|
51
|
struct net_device *netdev;
|
|
56
|
52
|
int i;
|
|
57
|
53
|
int rc;
|
|
58
|
54
|
|
|
59
|
55
|
/* Parse options */
|
|
60
|
|
- if ( ( rc = parse_options ( argc, argv, cmd, &opts ) ) != 0 )
|
|
|
56
|
+ if ( ( rc = parse_options ( argc, argv, cmd, opts ) ) != 0 )
|
|
61
|
57
|
return rc;
|
|
62
|
58
|
|
|
63
|
59
|
if ( optind != argc ) {
|
|
|
@@ -65,8 +61,8 @@ int ifcommon_exec ( int argc, char **argv,
|
|
65
|
61
|
for ( i = optind ; i < argc ; i++ ) {
|
|
66
|
62
|
if ( ( rc = parse_netdev ( argv[i], &netdev ) ) != 0 )
|
|
67
|
63
|
continue;
|
|
68
|
|
- if ( ( ( rc = payload ( netdev ) ) == 0 ) &&
|
|
69
|
|
- stop_on_first_success ) {
|
|
|
64
|
+ if ( ( ( rc = ifcmd->payload ( netdev, opts ) ) == 0 )
|
|
|
65
|
+ && ifcmd->stop_on_first_success ) {
|
|
70
|
66
|
return 0;
|
|
71
|
67
|
}
|
|
72
|
68
|
}
|
|
|
@@ -74,8 +70,8 @@ int ifcommon_exec ( int argc, char **argv,
|
|
74
|
70
|
/* Try all interfaces */
|
|
75
|
71
|
rc = -ENODEV;
|
|
76
|
72
|
for_each_netdev ( netdev ) {
|
|
77
|
|
- if ( ( ( rc = payload ( netdev ) ) == 0 ) &&
|
|
78
|
|
- stop_on_first_success ) {
|
|
|
73
|
+ if ( ( ( rc = ifcmd->payload ( netdev, opts ) ) == 0 )
|
|
|
74
|
+ && ifcmd->stop_on_first_success ) {
|
|
79
|
75
|
return 0;
|
|
80
|
76
|
}
|
|
81
|
77
|
}
|
|
|
@@ -84,21 +80,30 @@ int ifcommon_exec ( int argc, char **argv,
|
|
84
|
80
|
return rc;
|
|
85
|
81
|
}
|
|
86
|
82
|
|
|
87
|
|
-/** "ifopen" command descriptor */
|
|
88
|
|
-static struct command_descriptor ifopen_cmd =
|
|
89
|
|
- COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
|
|
90
|
|
- "[<interface>...]" );
|
|
|
83
|
+/** "ifopen" options */
|
|
|
84
|
+struct ifopen_options {};
|
|
|
85
|
+
|
|
|
86
|
+/** "ifopen" option list */
|
|
|
87
|
+static struct option_descriptor ifopen_opts[] = {};
|
|
91
|
88
|
|
|
92
|
89
|
/**
|
|
93
|
90
|
* "ifopen" payload
|
|
94
|
91
|
*
|
|
95
|
92
|
* @v netdev Network device
|
|
|
93
|
+ * @v opts Command options
|
|
96
|
94
|
* @ret rc Return status code
|
|
97
|
95
|
*/
|
|
98
|
|
-static int ifopen_payload ( struct net_device *netdev ) {
|
|
|
96
|
+static int ifopen_payload ( struct net_device *netdev,
|
|
|
97
|
+ struct ifopen_options *opts __unused ) {
|
|
99
|
98
|
return ifopen ( netdev );
|
|
100
|
99
|
}
|
|
101
|
100
|
|
|
|
101
|
+/** "ifopen" command descriptor */
|
|
|
102
|
+static struct ifcommon_command_descriptor ifopen_cmd =
|
|
|
103
|
+ IFCOMMON_COMMAND_DESC ( struct ifopen_options, ifopen_opts,
|
|
|
104
|
+ 0, MAX_ARGUMENTS, "[<interface>...]",
|
|
|
105
|
+ ifopen_payload, 0 );
|
|
|
106
|
+
|
|
102
|
107
|
/**
|
|
103
|
108
|
* The "ifopen" command
|
|
104
|
109
|
*
|
|
|
@@ -107,25 +112,34 @@ static int ifopen_payload ( struct net_device *netdev ) {
|
|
107
|
112
|
* @ret rc Return status code
|
|
108
|
113
|
*/
|
|
109
|
114
|
static int ifopen_exec ( int argc, char **argv ) {
|
|
110
|
|
- return ifcommon_exec ( argc, argv, &ifopen_cmd, ifopen_payload, 0 );
|
|
|
115
|
+ return ifcommon_exec ( argc, argv, &ifopen_cmd );
|
|
111
|
116
|
}
|
|
112
|
117
|
|
|
113
|
|
-/** "ifclose" command descriptor */
|
|
114
|
|
-static struct command_descriptor ifclose_cmd =
|
|
115
|
|
- COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
|
|
116
|
|
- "[<interface>...]" );
|
|
|
118
|
+/** "ifclose" options */
|
|
|
119
|
+struct ifclose_options {};
|
|
|
120
|
+
|
|
|
121
|
+/** "ifclose" option list */
|
|
|
122
|
+static struct option_descriptor ifclose_opts[] = {};
|
|
117
|
123
|
|
|
118
|
124
|
/**
|
|
119
|
125
|
* "ifclose" payload
|
|
120
|
126
|
*
|
|
121
|
127
|
* @v netdev Network device
|
|
|
128
|
+ * @v opts Command options
|
|
122
|
129
|
* @ret rc Return status code
|
|
123
|
130
|
*/
|
|
124
|
|
-static int ifclose_payload ( struct net_device *netdev ) {
|
|
|
131
|
+static int ifclose_payload ( struct net_device *netdev,
|
|
|
132
|
+ struct ifclose_options *opts __unused ) {
|
|
125
|
133
|
ifclose ( netdev );
|
|
126
|
134
|
return 0;
|
|
127
|
135
|
}
|
|
128
|
136
|
|
|
|
137
|
+/** "ifclose" command descriptor */
|
|
|
138
|
+static struct ifcommon_command_descriptor ifclose_cmd =
|
|
|
139
|
+ IFCOMMON_COMMAND_DESC ( struct ifclose_options, ifclose_opts,
|
|
|
140
|
+ 0, MAX_ARGUMENTS, "[<interface>...]",
|
|
|
141
|
+ ifclose_payload, 0 );
|
|
|
142
|
+
|
|
129
|
143
|
/**
|
|
130
|
144
|
* The "ifclose" command
|
|
131
|
145
|
*
|
|
|
@@ -134,25 +148,34 @@ static int ifclose_payload ( struct net_device *netdev ) {
|
|
134
|
148
|
* @ret rc Return status code
|
|
135
|
149
|
*/
|
|
136
|
150
|
static int ifclose_exec ( int argc, char **argv ) {
|
|
137
|
|
- return ifcommon_exec ( argc, argv, &ifclose_cmd, ifclose_payload, 0 );
|
|
|
151
|
+ return ifcommon_exec ( argc, argv, &ifclose_cmd );
|
|
138
|
152
|
}
|
|
139
|
153
|
|
|
140
|
|
-/** "ifstat" command descriptor */
|
|
141
|
|
-static struct command_descriptor ifstat_cmd =
|
|
142
|
|
- COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
|
|
143
|
|
- "[<interface>...]" );
|
|
|
154
|
+/** "ifstat" options */
|
|
|
155
|
+struct ifstat_options {};
|
|
|
156
|
+
|
|
|
157
|
+/** "ifstat" option list */
|
|
|
158
|
+static struct option_descriptor ifstat_opts[] = {};
|
|
144
|
159
|
|
|
145
|
160
|
/**
|
|
146
|
161
|
* "ifstat" payload
|
|
147
|
162
|
*
|
|
148
|
163
|
* @v netdev Network device
|
|
|
164
|
+ * @v opts Command options
|
|
149
|
165
|
* @ret rc Return status code
|
|
150
|
166
|
*/
|
|
151
|
|
-static int ifstat_payload ( struct net_device *netdev ) {
|
|
|
167
|
+static int ifstat_payload ( struct net_device *netdev,
|
|
|
168
|
+ struct ifstat_options *opts __unused ) {
|
|
152
|
169
|
ifstat ( netdev );
|
|
153
|
170
|
return 0;
|
|
154
|
171
|
}
|
|
155
|
172
|
|
|
|
173
|
+/** "ifstat" command descriptor */
|
|
|
174
|
+static struct ifcommon_command_descriptor ifstat_cmd =
|
|
|
175
|
+ IFCOMMON_COMMAND_DESC ( struct ifstat_options, ifstat_opts,
|
|
|
176
|
+ 0, MAX_ARGUMENTS, "[<interface>...]",
|
|
|
177
|
+ ifstat_payload, 0 );
|
|
|
178
|
+
|
|
156
|
179
|
/**
|
|
157
|
180
|
* The "ifstat" command
|
|
158
|
181
|
*
|
|
|
@@ -161,7 +184,7 @@ static int ifstat_payload ( struct net_device *netdev ) {
|
|
161
|
184
|
* @ret rc Return status code
|
|
162
|
185
|
*/
|
|
163
|
186
|
static int ifstat_exec ( int argc, char **argv ) {
|
|
164
|
|
- return ifcommon_exec ( argc, argv, &ifstat_cmd, ifstat_payload, 0 );
|
|
|
187
|
+ return ifcommon_exec ( argc, argv, &ifstat_cmd );
|
|
165
|
188
|
}
|
|
166
|
189
|
|
|
167
|
190
|
/** Interface management commands */
|