diff options
Diffstat (limited to 'src/libsystemd/sd-network/network-util.c')
-rw-r--r-- | src/libsystemd/sd-network/network-util.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libsystemd/sd-network/network-util.c b/src/libsystemd/sd-network/network-util.c new file mode 100644 index 0000000..df5ce86 --- /dev/null +++ b/src/libsystemd/sd-network/network-util.c @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ + +#include "alloc-util.h" +#include "fd-util.h" +#include "network-util.h" +#include "strv.h" + +bool network_is_online(void) { + _cleanup_free_ char *state = NULL; + int r; + + r = sd_network_get_operational_state(&state); + if (r < 0) /* if we don't know anything, we consider the system online */ + return true; + + if (STR_IN_SET(state, "routable", "degraded")) + return true; + + return false; +} |