]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd/sd-network/network-util.c
724c2b85495b4711d62b473f9156ac6920a1fae8
[thirdparty/systemd.git] / src / libsystemd / sd-network / network-util.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 /***
3 Copyright 2014 Lennart Poettering
4 ***/
5
6 #include "alloc-util.h"
7 #include "fd-util.h"
8 #include "network-util.h"
9 #include "strv.h"
10
11 bool network_is_online(void) {
12 _cleanup_free_ char *state = NULL;
13 int r;
14
15 r = sd_network_get_operational_state(&state);
16 if (r < 0) /* if we don't know anything, we consider the system online */
17 return true;
18
19 if (STR_IN_SET(state, "routable", "degraded"))
20 return true;
21
22 return false;
23 }