diff options
Diffstat (limited to 'isys')
-rw-r--r-- | isys/iface.c | 20 | ||||
-rw-r--r-- | isys/iface.h | 6 |
2 files changed, 26 insertions, 0 deletions
diff --git a/isys/iface.c b/isys/iface.c index 1df5fa0cd..137180275 100644 --- a/isys/iface.c +++ b/isys/iface.c @@ -356,6 +356,26 @@ int iface_have_in6_addr(struct in6_addr *addr6) { return _iface_have_valid_addr(addr6, AF_INET6, INET6_ADDRSTRLEN); } +/* Check if NM has an active connection */ +gboolean is_nm_connected(void) { + NMState state; + NMClient *client = NULL; + + g_type_init(); + + client = nm_client_new(); + if (!client) + return FALSE; + + state = nm_client_get_state(client); + g_object_unref(client); + + if (state == NM_STATE_CONNECTED) + return TRUE; + else + return FALSE; +} + /* Check if NM is already running */ gboolean is_nm_running(void) { gboolean running; diff --git a/isys/iface.h b/isys/iface.h index c95c39bd6..16257bc89 100644 --- a/isys/iface.h +++ b/isys/iface.h @@ -26,6 +26,7 @@ #include <net/if.h> #include <netlink/cache.h> #include <netlink/socket.h> +#include <glib.h> /* Enumerated types used in iface.c as well as loader's network code */ enum { IPUNUSED, IPV4, IPV6 }; @@ -141,6 +142,11 @@ int iface_have_in_addr(struct in_addr *addr); int iface_have_in6_addr(struct in6_addr *addr6); /* + * Checks if NetworkManager has an active connection. + */ +gboolean is_nm_connected(void); + +/* * Start NetworkManager */ int iface_start_NetworkManager(void); |