chiark / gitweb /
networkd-wait-online: improve interoptability and enable by default
[elogind.git] / src / libsystemd-network / network-internal.c
index 52e614c4eab38dbc80b1160275b8d373643c9146..e7ba628fc71e8ef2030d0986c9f5d71a4b0cb5f1 100644 (file)
@@ -326,3 +326,17 @@ int net_parse_inaddr(const char *address, unsigned char *family, void *dst) {
 
         return 0;
 }
+
+bool link_has_carrier(unsigned flags, uint8_t operstate) {
+        /* see Documentation/networking/operstates.txt in the kernel sources */
+
+        if (operstate == IF_OPER_UP)
+                return true;
+
+        if (operstate == IF_OPER_UNKNOWN)
+                /* operstate may not be implemented, so fall back to flags */
+                if ((flags & IFF_LOWER_UP) && !(flags & IFF_DORMANT))
+                        return true;
+
+        return false;
+}