#pragma once #include "types.hpp" #include #include #include #include #include #include #include #include struct nlmsghdr; namespace phosphor::network::system { struct EthInfo { bool autoneg; uint16_t speed; }; EthInfo getEthInfo(stdplus::zstring_view ifname); bool intfIsRunning(std::string_view ifname); std::optional getMTU(stdplus::zstring_view ifname); void setMTU(std::string_view ifname, unsigned mtu); void setNICUp(std::string_view ifname, bool up); /** @class InterfaceInfo * @brief Information about interfaces from the kernel */ struct InterfaceInfo { unsigned idx; unsigned flags; std::optional name = std::nullopt; std::optional mac = std::nullopt; std::optional mtu = std::nullopt; std::optional parent_idx = std::nullopt; std::optional kind = std::nullopt; std::optional vlan_id = std::nullopt; constexpr bool operator==(const InterfaceInfo& rhs) const noexcept { return idx == rhs.idx && flags == rhs.flags && name == rhs.name && mac == rhs.mac && mtu == rhs.mtu && parent_idx == rhs.parent_idx && kind == rhs.kind && vlan_id == rhs.vlan_id; } }; struct AddressFilter { unsigned ifidx = 0; }; namespace detail { InterfaceInfo parseInterface(const nlmsghdr& hdr, std::string_view msg); bool validateNewInterface(const InterfaceInfo& info); bool validateNewAddr(const AddressInfo& info, const AddressFilter& filter) noexcept; } // namespace detail /** @brief Get all the interfaces from the system. * @returns list of interface names. */ std::vector getInterfaces(); /** @brief Get all the addreses from the system. * @returns list of addresses */ std::vector getAddresses(const AddressFilter& filter); } // namespace phosphor::network::system