return 0;
}
-bool link_has_carrier(Link *link) {
- /* see Documentation/networking/operstates.txt in the kernel sources */
-
- if (link->kernel_operstate == IF_OPER_UP)
- return true;
-
- if (link->kernel_operstate == IF_OPER_UNKNOWN)
- /* operstate may not be implemented, so fall back to flags */
- if (FLAGS_SET(link->flags, IFF_LOWER_UP | IFF_RUNNING) &&
- !FLAGS_SET(link->flags, IFF_DORMANT))
- return true;
-
- return false;
-}
-
static bool link_is_enslaved(Link *link) {
if (link->flags & IFF_SLAVE)
return true;
#include "ether-addr-util.h"
#include "log-link.h"
+#include "netif-util.h"
#include "network-util.h"
#include "networkd-util.h"
#include "ordered-set.h"
void link_update_operstate(Link *link, bool also_update_bond_master);
-bool link_has_carrier(Link *link);
+static inline bool link_has_carrier(Link *link) {
+ assert(link);
+ return netif_has_carrier(link->kernel_operstate, link->flags);
+}
bool link_ipv6_enabled(Link *link);
bool link_ipv6ll_enabled(Link *link);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <linux/if.h>
#include <linux/if_arp.h>
#include "arphrd-util.h"
#include "sparse-endian.h"
#include "strv.h"
+bool netif_has_carrier(uint8_t operstate, unsigned flags) {
+ /* see Documentation/networking/operstates.txt in the kernel sources */
+
+ if (operstate == IF_OPER_UP)
+ return true;
+
+ if (operstate != IF_OPER_UNKNOWN)
+ return false;
+
+ /* operstate may not be implemented, so fall back to flags */
+ return FLAGS_SET(flags, IFF_LOWER_UP | IFF_RUNNING) &&
+ !FLAGS_SET(flags, IFF_DORMANT);
+}
+
int net_get_type_string(sd_device *device, uint16_t iftype, char **ret) {
const char *t;
char *p;
#include "ether-addr-util.h"
+bool netif_has_carrier(uint8_t operstate, unsigned flags);
int net_get_type_string(sd_device *device, uint16_t iftype, char **ret);
const char *net_get_persistent_name(sd_device *device);
int net_get_unique_predictable_data(sd_device *device, bool use_sysname, uint64_t *ret);