Network *network = userdata;
_cleanup_(route_freep) Route *n = NULL;
- union in_addr_union buffer;
- int r, f;
+ int r;
assert(filename);
assert(section);
if (r < 0)
return r;
- r = in_addr_from_string_auto(rvalue, &f, &buffer);
+ r = in_addr_from_string_auto(rvalue, &n->family, &n->gw);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Route is invalid, ignoring assignment: %s", rvalue);
return 0;
}
- n->family = f;
- n->gw = buffer;
TAKE_PTR(n);
return 0;
Network *network = userdata;
_cleanup_(route_freep) Route *n = NULL;
- union in_addr_union buffer;
- int r, f;
+ int r;
assert(filename);
assert(section);
if (r < 0)
return r;
- r = in_addr_from_string_auto(rvalue, &f, &buffer);
+ r = in_addr_from_string_auto(rvalue, &n->family, &n->prefsrc);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Preferred source is invalid, ignoring assignment: %s", rvalue);
return 0;
}
- n->family = f;
- n->prefsrc = buffer;
TAKE_PTR(n);
return 0;
Network *network = userdata;
_cleanup_(route_freep) Route *n = NULL;
- union in_addr_union buffer;
- unsigned char prefixlen;
+ union in_addr_union *buffer;
+ unsigned char *prefixlen;
int r;
assert(filename);
if (r < 0)
return r;
- r = in_addr_prefix_from_string(rvalue, AF_INET, &buffer, &prefixlen);
- if (r < 0) {
- r = in_addr_prefix_from_string(rvalue, AF_INET6, &buffer, &prefixlen);
- if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, r,
- "Route %s= prefix is invalid, ignoring assignment: %s",
- lvalue, rvalue);
- return 0;
- }
-
- n->family = AF_INET6;
- } else
- n->family = AF_INET;
-
if (streq(lvalue, "Destination")) {
- n->dst = buffer;
- n->dst_prefixlen = prefixlen;
+ buffer = &n->dst;
+ prefixlen = &n->dst_prefixlen;
} else if (streq(lvalue, "Source")) {
- n->src = buffer;
- n->src_prefixlen = prefixlen;
+ buffer = &n->src;
+ prefixlen = &n->src_prefixlen;
} else
assert_not_reached(lvalue);
+ r = in_addr_prefix_from_string_auto(rvalue, &n->family, buffer, prefixlen);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, r,
+ "Route %s= prefix is invalid, ignoring assignment: %s",
+ lvalue, rvalue);
+ return 0;
+ }
+
TAKE_PTR(n);
return 0;
}
_cleanup_(routing_policy_rule_freep) RoutingPolicyRule *n = NULL;
Network *network = userdata;
- union in_addr_union buffer;
- uint8_t prefixlen;
+ union in_addr_union *buffer;
+ uint8_t *prefixlen;
int r;
assert(filename);
if (r < 0)
return r;
- r = in_addr_prefix_from_string(rvalue, AF_INET, &buffer, &prefixlen);
- if (r < 0) {
- r = in_addr_prefix_from_string(rvalue, AF_INET6, &buffer, &prefixlen);
- if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, r, "RPDB rule prefix is invalid, ignoring assignment: %s", rvalue);
- return 0;
- }
-
- n->family = AF_INET6;
- } else
- n->family = AF_INET;
-
if (streq(lvalue, "To")) {
- n->to = buffer;
- n->to_prefixlen = prefixlen;
+ buffer = &n->to;
+ prefixlen = &n->to_prefixlen;
} else {
- n->from = buffer;
- n->from_prefixlen = prefixlen;
+ buffer = &n->from;
+ prefixlen = &n->from_prefixlen;
+ }
+
+ r = in_addr_prefix_from_string_auto(rvalue, &n->family, buffer, prefixlen);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, r, "RPDB rule prefix is invalid, ignoring assignment: %s", rvalue);
+ return 0;
}
n = NULL;
for (;;) {
_cleanup_free_ char *word = NULL, *a = NULL, *b = NULL;
- union in_addr_union buffer;
- uint8_t prefixlen;
r = extract_first_word(&p, &word, NULL, 0);
if (r < 0)
continue;
if (STR_IN_SET(a, "from", "to")) {
-
- r = in_addr_prefix_from_string(b, AF_INET, &buffer, &prefixlen);
- if (r < 0) {
- r = in_addr_prefix_from_string(b, AF_INET6, &buffer, &prefixlen);
- if (r < 0) {
- log_error_errno(r, "RPDB rule prefix is invalid, ignoring assignment: %s", b);
- continue;
- }
-
- rule->family = AF_INET6;
- } else
- rule->family = AF_INET;
+ union in_addr_union *buffer;
+ uint8_t *prefixlen;
if (streq(a, "to")) {
- rule->to = buffer;
- rule->to_prefixlen = prefixlen;
+ buffer = &rule->to;
+ prefixlen = &rule->to_prefixlen;
} else {
- rule->from = buffer;
- rule->from_prefixlen = prefixlen;
+ buffer = &rule->from;
+ prefixlen = &rule->from_prefixlen;
}
+
+ r = in_addr_prefix_from_string_auto(b, &rule->family, buffer, prefixlen);
+ if (r < 0) {
+ log_error_errno(r, "RPDB rule prefix is invalid, ignoring assignment: %s", b);
+ continue;
+ }
+
} else if (streq(a, "tos")) {
r = safe_atou8(b, &rule->tos);
if (r < 0) {