diff options
author | Susant Sahani <ssahani@gmail.com> | 2018-11-27 10:58:54 +0530 |
---|---|---|
committer | Susant Sahani <ssahani@gmail.com> | 2018-11-28 20:06:28 +0530 |
commit | 926062f08345c02d360414feae58c964de2b6415 (patch) | |
tree | 010ab395d80fa2c7cc092fd87428fd9c4769c684 /src/basic/parse-util.c | |
parent | 59a2a18e27435ed00741fc8703e19866de37e3d3 (diff) | |
download | systemd-926062f08345c02d360414feae58c964de2b6415.tar.gz |
networkd: add support to configure ip rule port range and protocol.
Please see:
iprule: support for ip_proto, sport and dport match options
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=f686f764682745daf6a93b0a6330ba42a961f858
Closes 10622
Diffstat (limited to 'src/basic/parse-util.c')
-rw-r--r-- | src/basic/parse-util.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c index a9085348b5..ce8bb12670 100644 --- a/src/basic/parse-util.c +++ b/src/basic/parse-util.c @@ -710,6 +710,26 @@ int parse_ip_port(const char *s, uint16_t *ret) { return 0; } +int parse_ip_port_range(const char *s, uint16_t *low, uint16_t *high) { + unsigned l, h; + int r; + + r = parse_range(s, &l, &h); + if (r < 0) + return r; + + if (l <= 0 || l > 65535 || h <= 0 || h > 65535) + return -EINVAL; + + if (h < l) + return -EINVAL; + + *low = l; + *high = h; + + return 0; +} + int parse_dev(const char *s, dev_t *ret) { unsigned x, y; dev_t d; |