aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbuytenh <buytenh>2001-12-07 14:27:43 +0000
committerbuytenh <buytenh>2001-12-07 14:27:43 +0000
commit757498e8e254e269d05a4e03ae80db5eb4377d40 (patch)
tree4f27e4dc2e60ff158ab3d2d752485d39afab93c1
parentb2282c7ff1059ed1915a69a5fe41d9049c7b14c4 (diff)
downloadbridge-utils-757498e8e254e269d05a4e03ae80db5eb4377d40.tar.gz
Check if correct number of arguments given to an option.
Handle ELOOP return condition from br_add_bridge.
-rw-r--r--brctl/brctl.c5
-rw-r--r--brctl/brctl.h7
-rw-r--r--brctl/brctl_cmd.c38
3 files changed, 31 insertions, 19 deletions
diff --git a/brctl/brctl.c b/brctl/brctl.c
index ba1a802..f4d137a 100644
--- a/brctl/brctl.c
+++ b/brctl/brctl.c
@@ -83,6 +83,11 @@ int main(int argc, char *argv[])
argindex++;
}
+ if (argc - argindex != cmd->num_string_arguments) {
+ fprintf(stderr, "incorrect number of arguments for command\n");
+ return 1;
+ }
+
cmd->func(br, argv[argindex], argv[argindex+1]);
return 0;
diff --git a/brctl/brctl.h b/brctl/brctl.h
index fac71c9..c582f47 100644
--- a/brctl/brctl.h
+++ b/brctl/brctl.h
@@ -21,9 +21,10 @@
struct command
{
- int needs_bridge_argument;
- char *name;
- void (*func)(struct bridge *br, char *arg0, char *arg1);
+ int needs_bridge_argument;
+ int num_string_arguments;
+ char *name;
+ void (*func)(struct bridge *br, char *arg0, char *arg1);
};
struct command *br_command_lookup(char *cmd);
diff --git a/brctl/brctl_cmd.c b/brctl/brctl_cmd.c
index 03d1fc6..264a27d 100644
--- a/brctl/brctl_cmd.c
+++ b/brctl/brctl_cmd.c
@@ -89,6 +89,12 @@ void br_cmd_addif(struct bridge *br, char *ifname, char *arg1)
br->ifname);
break;
+ case ELOOP:
+ fprintf(stderr, "device %s is a bridge device itself; "
+ "can't enslave a bridge device to a bridge device.\n",
+ ifname);
+ break;
+
default:
perror("br_add_interface");
break;
@@ -295,22 +301,22 @@ void br_cmd_showmacs(struct bridge *br, char *arg0, char *arg1)
}
static struct command commands[] = {
- {0, "addbr", br_cmd_addbr},
- {1, "addif", br_cmd_addif},
- {0, "delbr", br_cmd_delbr},
- {1, "delif", br_cmd_delif},
- {1, "setageing", br_cmd_setageing},
- {1, "setbridgeprio", br_cmd_setbridgeprio},
- {1, "setfd", br_cmd_setfd},
- {1, "setgcint", br_cmd_setgcint},
- {1, "sethello", br_cmd_sethello},
- {1, "setmaxage", br_cmd_setmaxage},
- {1, "setpathcost", br_cmd_setpathcost},
- {1, "setportprio", br_cmd_setportprio},
- {0, "show", br_cmd_show},
- {1, "showmacs", br_cmd_showmacs},
- {1, "showstp", br_cmd_showstp},
- {1, "stp", br_cmd_stp},
+ {0, 1, "addbr", br_cmd_addbr},
+ {1, 1, "addif", br_cmd_addif},
+ {0, 1, "delbr", br_cmd_delbr},
+ {1, 1, "delif", br_cmd_delif},
+ {1, 1, "setageing", br_cmd_setageing},
+ {1, 1, "setbridgeprio", br_cmd_setbridgeprio},
+ {1, 1, "setfd", br_cmd_setfd},
+ {1, 1, "setgcint", br_cmd_setgcint},
+ {1, 1, "sethello", br_cmd_sethello},
+ {1, 1, "setmaxage", br_cmd_setmaxage},
+ {1, 2, "setpathcost", br_cmd_setpathcost},
+ {1, 2, "setportprio", br_cmd_setportprio},
+ {0, 0, "show", br_cmd_show},
+ {1, 0, "showmacs", br_cmd_showmacs},
+ {1, 0, "showstp", br_cmd_showstp},
+ {1, 1, "stp", br_cmd_stp},
};
struct command *br_command_lookup(char *cmd)