summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-network/network-util.c
blob: 724c2b85495b4711d62b473f9156ac6920a1fae8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* SPDX-License-Identifier: LGPL-2.1+ */
/***
  Copyright 2014 Lennart Poettering
***/

#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;
}