priority = atoi(*argv);
} else if (strcmp(*argv, "state") == 0) {
NEXT_ARG();
- state = atoi(*argv);
+ char *endptr;
+ size_t nstates = sizeof(port_states) / sizeof(*port_states);
+ state = strtol(*argv, &endptr, 10);
+ if (!(**argv != '\0' && *endptr == '\0')) {
+ for (state = 0; state < nstates; state++)
+ if (strcmp(port_states[state], *argv) == 0)
+ break;
+ if (state == nstates) {
+ fprintf(stderr,
+ "Error: invalid STP port state\n");
+ exit(-1);
+ }
+ }
} else if (strcmp(*argv, "hwmode") == 0) {
NEXT_ARG();
flags = BRIDGE_FLAGS_SELF;
.TP
.BI state " STATE "
the operation state of the port. This is primarily used by user space STP/RSTP
-implementation. The following is a list of valid values:
+implementation. One may enter a lowercased port state name, or one of the
+numbers below. Negative inputs are ignored, and unrecognized names return an
+error.
.B 0
- port is DISABLED. Make this port completely inactive.