1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 #pragma once 3 4 #include "sd-device.h" 5 #include "sd-netlink.h" 6 7 #include "ether-addr-util.h" 8 9 typedef struct LinkInfo { 10 int ifindex; 11 uint16_t iftype; /* ARPHRD_* (type) */ 12 13 struct hw_addr_data hw_addr; /* IFLA_ADDRESS (address, addr_len) */ 14 struct hw_addr_data broadcast; /* IFLA_BROADCAST (broadcast) */ 15 char *ifname; /* IFLA_IFNAME */ 16 uint32_t mtu; /* IFLA_MTU (mtu) */ 17 uint32_t iflink; /* IFLA_LINK (iflink) */ 18 uint8_t link_mode; /* IFLA_LINKMODE (link_mode) */ 19 char *ifalias; /* IFLA_IFALIAS (ifalias) */ 20 uint32_t group; /* IFLA_GROUP (netdev_group) */ 21 uint8_t *phys_port_id; /* IFLA_PHYS_PORT_ID (phys_port_id) */ 22 size_t phys_port_id_len; 23 uint8_t *phys_switch_id; /* IFLA_PHYS_SWITCH_ID (phys_switch_id) */ 24 size_t phys_switch_id_len; 25 char *phys_port_name; /* IFLA_PHYS_PORT_NAME (phys_port_name) */ 26 27 bool phys_port_id_supported; 28 bool phys_switch_id_supported; 29 bool phys_port_name_supported; 30 } LinkInfo; 31 32 #define LINK_INFO_NULL ((LinkInfo) {}) 33 34 void link_info_clear(LinkInfo *info); 35 int link_info_get(sd_netlink **rtnl, int ifindex, LinkInfo *ret); 36 int device_cache_sysattr_from_link_info(sd_device *device, LinkInfo *info); 37 int device_get_sysattr_value_maybe_from_netlink( 38 sd_device *device, 39 sd_netlink **rtnl, 40 const char *sysattr, 41 const char **ret_value); 42