summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-network/sd-network.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-09-08 13:50:52 +0200
committerTom Gundersen <teg@jklm.no>2014-09-08 15:09:07 +0200
commitadc5b2e2ebcb91ee18b6a32681b8ec1e52793473 (patch)
tree8a15c0a594c734d67fcd3dae14100cf3a35c6d4d /src/libsystemd/sd-network/sd-network.c
parentb70c73fcf1885b717b464353edecaf650a1e520a (diff)
sd-network: add _get_network_file api
Diffstat (limited to 'src/libsystemd/sd-network/sd-network.c')
-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;