Fix --dscp (#1162)

TOS = DSCP * 4; so shift DSCP << 2
This commit is contained in:
Preston Hunt 2021-11-15 11:38:29 -08:00 committed by GitHub
parent 071ee915ba
commit d424be34a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -136,10 +136,11 @@ parse_qos(const char *cp)
return ipqos[i].value;
}
/* Try parsing as an integer */
/* Max DSCP value is 2**6 - 1 */
val = strtol(cp, &ep, 0);
if (*cp == '\0' || *ep != '\0' || val < 0 || val > 255)
if (*cp == '\0' || *ep != '\0' || val < 0 || val > 63)
return -1;
return val;
return val << 2;
}
const char *

View File

@ -354,7 +354,8 @@ i.e. 52, 064 and 0x34 all specify the same value.
.TP
.BR "--dscp " \fIdscp\fR
set the IP DSCP bits. Both numeric and symbolic values are accepted. Numeric
values can be specified in decimal, octal and hex (see --tos above).
values can be specified in decimal, octal and hex (see --tos above). To set
both the DSCP bits and the ECN bits, use --tos.
.TP
.BR -L ", " --flowlabel " \fIn\fR"
set the IPv6 flow label (currently only supported on Linux)