iw currently works, but the error handling is a bit off, many error
messages are absent, and the help text is flat-out wrong. This
partially fixes the above and should make it possible for noobs to add
and remove interfaces without reading the entire source.
Signed-Off-By: Andy Lutomirski <luto@myrealbox.com>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
static int handle_interface_add(struct nl80211_state *state,
char *phy, char *dev, int argc, char **argv)
{
- char *name = argv[0];
+ char *name;
enum nl80211_iftype type;
int tpset, err;
struct nl_msg *msg;
return -1;
}
+ name = argv[0];
argc--;
argv++;
- if (argc) {
- tpset = get_if_type(&argc, &argv, &type);
- if (tpset < 0)
- return -1;
- }
+ tpset = get_if_type(&argc, &argv, &type);
+ if (tpset == 0)
+ fprintf(stderr, "you must specify an interface type\n");
+ if (tpset <= 0)
+ return -1;
if (argc) {
fprintf(stderr, "too many arguments\n");
{
char *cmd = argv[0];
- if (argc < 1)
+ if (argc < 1) {
+ fprintf(stderr, "you must specify an interface command\n");
return -1;
+ }
argc--;
argv++;
void usage(char *argv0)
{
- fprintf(stderr, "Usage: %s [options] {dev <phydev>} {interface <interface> } {COMMAND}\n"
- "where COMMAND := { add | del }\n", argv0);
+ fprintf(stderr, "Usage: %s dev <phydev> interface <COMMAND> [OPTIONS]\n"
+ "where COMMAND := { add | del }\n"
+ "\n"
+ "For add, OPTIONS := <name> type <type>\n"
+ "For del, OPTIONS should be blank and phydev is the interface to delete.\n", argv0);
}
int main(int argc, char **argv)