chiark / gitweb /
importd: create a loopback btrfs file system for /var/lib/machines, if necessary
[elogind.git] / src / network / networkd-route.c
index 4e389db5ef6194b1f45874e8a841ef870e43bfd1..7f110a5217f1cdf7cca923b735ca8a3728f3fcad 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <net/if.h>
 
 #include "networkd.h"
 #include "networkd-link.h"
 
-#include "utf8.h"
 #include "util.h"
 #include "conf-parser.h"
-#include "network-internal.h"
 
 int route_new_static(Network *network, unsigned section, Route **ret) {
         _cleanup_route_free_ Route *route = NULL;
@@ -353,6 +350,12 @@ int config_parse_destination(const char *unit,
                 return 0;
         }
 
+        if (f != AF_INET && f != AF_INET6) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+                           "Unknown address family, ignoring assignment: %s", address);
+                return 0;
+        }
+
         /* prefixlen */
         if (e) {
                 r = safe_atou8(e + 1, &prefixlen);
@@ -362,7 +365,7 @@ int config_parse_destination(const char *unit,
                         return 0;
                 }
         } else {
-                switch (n->family) {
+                switch (f) {
                         case AF_INET:
                                 prefixlen = 32;
                                 break;
@@ -421,3 +424,44 @@ int config_parse_route_priority(const char *unit,
 
         return 0;
 }
+
+int config_parse_route_scope(const char *unit,
+                             const char *filename,
+                             unsigned line,
+                             const char *section,
+                             unsigned section_line,
+                             const char *lvalue,
+                             int ltype,
+                             const char *rvalue,
+                             void *data,
+                             void *userdata) {
+        Network *network = userdata;
+        _cleanup_route_free_ Route *n = NULL;
+        int r;
+
+        assert(filename);
+        assert(section);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        r = route_new_static(network, section_line, &n);
+        if (r < 0)
+                return r;
+
+        if (streq(rvalue, "host"))
+                n->scope = RT_SCOPE_HOST;
+        else if (streq(rvalue, "link"))
+                n->scope = RT_SCOPE_LINK;
+        else if (streq(rvalue, "global"))
+                n->scope = RT_SCOPE_UNIVERSE;
+        else {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+                           "Unknown route scope: %s", rvalue);
+                return 0;
+        }
+
+        n = NULL;
+
+        return 0;
+}