diff options
author | Tom Gundersen <teg@jklm.no> | 2014-05-08 17:21:37 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-05-08 17:21:37 +0200 |
commit | bbf7c04821a71fec67eaf0e7a34d17afc5913c13 (patch) | |
tree | c713e0a13d98e87c2462947c508b025c25dd827c /src/network/sd-network.c | |
parent | e0e5ce237b11f2d97189cd7725bf339b4b8a78de (diff) |
sd-network: expose global operational state
Diffstat (limited to 'src/network/sd-network.c')
-rw-r--r-- | src/network/sd-network.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/network/sd-network.c b/src/network/sd-network.c index c867812209..492e97c73f 100644 --- a/src/network/sd-network.c +++ b/src/network/sd-network.c @@ -95,6 +95,27 @@ _public_ int sd_network_get_link_state(unsigned index, char **state) { return 0; } +_public_ int sd_network_get_operational_state(char **state) { + _cleanup_free_ char *s = NULL; + int r; + + assert_return(state, -EINVAL); + + r = parse_env_file("/run/systemd/network/state", NEWLINE, "OPER_STATE", + &s, NULL); + if (r == -ENOENT) + return -ENODATA; + else if (r < 0) + return r; + else if (!s) + return -EIO; + + *state = s; + s = NULL; + + return 0; +} + _public_ int sd_network_get_link_operational_state(unsigned index, char **state) { _cleanup_free_ char *s = NULL, *p = NULL; int r; |