]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/parse-util.c
networkd: add support to configure ip rule port range and protocol.
[thirdparty/systemd.git] / src / basic / parse-util.c
index a9085348b555b64c733e42b10c858d9073660649..ce8bb12670bea1cb2f584670bb97b49b4515d78a 100644 (file)
@@ -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;