return 0;
}
+static int network_link_get_boolean(int ifindex, const char *key) {
+ _cleanup_free_ char *s = NULL;
+ int r;
+
+ r = network_link_get_string(ifindex, key, &s);
+ if (r < 0)
+ return r;
+
+ return parse_boolean(s);
+}
+
static int network_link_get_strv(int ifindex, const char *key, char ***ret) {
char path[STRLEN("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex)];
_cleanup_strv_free_ char **a = NULL;
}
int sd_network_link_get_dns_default_route(int ifindex) {
- char path[STRLEN("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex)];
- _cleanup_free_ char *s = NULL;
- int r;
-
- assert_return(ifindex > 0, -EINVAL);
-
- xsprintf(path, "/run/systemd/netif/links/%i", ifindex);
-
- r = parse_env_file(NULL, path, "DNS_DEFAULT_ROUTE", &s);
- if (r < 0)
- return r;
- if (isempty(s))
- return -ENODATA;
- return parse_boolean(s);
+ return network_link_get_boolean(ifindex, "DNS_DEFAULT_ROUTE");
}
static int network_link_get_ifindexes(int ifindex, const char *key, int **ret) {