summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-network
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd/sd-network')
-rw-r--r--src/libsystemd/sd-network/sd-network.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c
index 3a3f53576f..d63e6f9dfa 100644
--- a/src/libsystemd/sd-network/sd-network.c
+++ b/src/libsystemd/sd-network/sd-network.c
@@ -120,6 +120,30 @@ _public_ int sd_network_link_get_setup_state(int ifindex, char **state) {
return 0;
}
+_public_ int sd_network_link_get_network_file(int ifindex, char **filename) {
+ _cleanup_free_ char *s = NULL, *p = NULL;
+ int r;
+
+ assert_return(ifindex > 0, -EINVAL);
+ assert_return(filename, -EINVAL);
+
+ if (asprintf(&p, "/run/systemd/netif/links/%d", ifindex) < 0)
+ return -ENOMEM;
+
+ r = parse_env_file(p, NEWLINE, "NETWORK_FILE", &s, NULL);
+ if (r == -ENOENT)
+ return -ENODATA;
+ if (r < 0)
+ return r;
+ if (isempty(s))
+ return -ENODATA;
+
+ *filename = s;
+ s = NULL;
+
+ return 0;
+}
+
_public_ int sd_network_link_get_operational_state(int ifindex, char **state) {
_cleanup_free_ char *s = NULL, *p = NULL;
int r;