#include "conf-parser.h"
#include "net-util.h"
-int route_new(Network *network, unsigned section, Route **ret) {
+int route_new_static(Network *network, unsigned section, Route **ret) {
_cleanup_route_free_ Route *route = NULL;
if (section) {
route->network = network;
- LIST_PREPEND(routes, network->routes, route);
+ LIST_PREPEND(static_routes, network->static_routes, route);
if (section) {
route->section = section;
return 0;
}
+int route_new_dynamic(Route **ret) {
+ _cleanup_route_free_ Route *route = NULL;
+
+ route = new0(Route, 1);
+ if (!route)
+ return -ENOMEM;
+
+ *ret = route;
+ route = NULL;
+
+ return 0;
+}
+
void route_free(Route *route) {
if (!route)
return;
- LIST_REMOVE(routes, route->network->routes, route);
+ if (route->network) {
+ LIST_REMOVE(static_routes, route->network->static_routes, route);
- if (route->section)
- hashmap_remove(route->network->routes_by_section,
- &route->section);
+ if (route->section)
+ hashmap_remove(route->network->routes_by_section,
+ &route->section);
+ }
free(route);
}
section_line = 0;
}
- r = route_new(network, section_line, &n);
+ r = route_new_static(network, section_line, &n);
if (r < 0)
return r;
assert(rvalue);
assert(data);
- r = route_new(network, section_line, &n);
+ r = route_new_static(network, section_line, &n);
if (r < 0)
return r;
return log_oom();
}
- r = net_parse_inaddr(address, &n->family, &n->dst_addr);
+ r = net_parse_inaddr(address, &n->dst_family, &n->dst_addr);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Destination is invalid, ignoring assignment: %s", address);
n->dst_prefixlen = (unsigned char) i;
} else {
- switch (n->family) {
+ switch (n->dst_family) {
case AF_INET:
n->dst_prefixlen = 32;
break;