1 #pragma once 2 #include "types.hpp" 3 4 #include <net/ethernet.h> 5 6 #include <cstdint> 7 #include <optional> 8 #include <stdplus/zstring.hpp> 9 #include <stdplus/zstring_view.hpp> 10 #include <string> 11 #include <string_view> 12 #include <vector> 13 14 struct nlmsghdr; 15 16 namespace phosphor::network::system 17 { 18 struct EthInfo 19 { 20 bool autoneg; 21 uint16_t speed; 22 }; 23 EthInfo getEthInfo(stdplus::zstring_view ifname); 24 25 bool intfIsRunning(std::string_view ifname); 26 27 std::optional<unsigned> getMTU(stdplus::zstring_view ifname); 28 29 void setMTU(std::string_view ifname, unsigned mtu); 30 31 void setNICUp(std::string_view ifname, bool up); 32 33 struct AddressFilter 34 { 35 unsigned ifidx = 0; 36 }; 37 38 struct NeighborFilter 39 { 40 unsigned ifidx = 0; 41 }; 42 43 namespace detail 44 { 45 bool validateNewAddr(const AddressInfo& info, 46 const AddressFilter& filter) noexcept; 47 bool validateNewNeigh(const NeighborInfo& info, 48 const NeighborFilter& filter) noexcept; 49 } // namespace detail 50 51 /** @brief Get all the interfaces from the system. 52 * @returns list of interface names. 53 */ 54 std::vector<InterfaceInfo> getInterfaces(); 55 56 /** @brief Get all the addreses from the system. 57 * @returns list of addresses 58 */ 59 std::vector<AddressInfo> getAddresses(const AddressFilter& filter); 60 61 /** @brief Returns a list of system neighbor table 62 */ 63 std::vector<NeighborInfo> getNeighbors(const NeighborFilter& filter); 64 65 } // namespace phosphor::network::system 66