William A. Kennington III | 2e09d27 | 2022-10-14 17:15:00 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | #include "types.hpp" |
| 3 | |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 4 | #include <net/ethernet.h> |
William A. Kennington III | 2e09d27 | 2022-10-14 17:15:00 -0700 | [diff] [blame] | 5 | |
| 6 | #include <cstdint> |
| 7 | #include <optional> |
| 8 | #include <stdplus/zstring.hpp> |
| 9 | #include <stdplus/zstring_view.hpp> |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 10 | #include <string> |
William A. Kennington III | 2e09d27 | 2022-10-14 17:15:00 -0700 | [diff] [blame] | 11 | #include <string_view> |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 12 | #include <vector> |
| 13 | |
| 14 | struct nlmsghdr; |
William A. Kennington III | 2e09d27 | 2022-10-14 17:15:00 -0700 | [diff] [blame] | 15 | |
| 16 | namespace phosphor::network::system |
| 17 | { |
William A. Kennington III | 2e09d27 | 2022-10-14 17:15:00 -0700 | [diff] [blame] | 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 | |
William A. Kennington III | 2e09d27 | 2022-10-14 17:15:00 -0700 | [diff] [blame] | 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 | |
William A. Kennington III | 6a92363 | 2022-11-06 18:17:33 -0800 | [diff] [blame] | 33 | struct AddressFilter |
| 34 | { |
| 35 | unsigned ifidx = 0; |
| 36 | }; |
| 37 | |
William A. Kennington III | a842690 | 2022-11-07 15:37:41 -0800 | [diff] [blame] | 38 | struct NeighborFilter |
| 39 | { |
| 40 | unsigned ifidx = 0; |
| 41 | }; |
| 42 | |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 43 | namespace detail |
| 44 | { |
William A. Kennington III | 6a92363 | 2022-11-06 18:17:33 -0800 | [diff] [blame] | 45 | bool validateNewAddr(const AddressInfo& info, |
| 46 | const AddressFilter& filter) noexcept; |
William A. Kennington III | a842690 | 2022-11-07 15:37:41 -0800 | [diff] [blame] | 47 | bool validateNewNeigh(const NeighborInfo& info, |
| 48 | const NeighborFilter& filter) noexcept; |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 49 | } // namespace detail |
| 50 | |
William A. Kennington III | 2e09d27 | 2022-10-14 17:15:00 -0700 | [diff] [blame] | 51 | /** @brief Get all the interfaces from the system. |
| 52 | * @returns list of interface names. |
| 53 | */ |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 54 | std::vector<InterfaceInfo> getInterfaces(); |
William A. Kennington III | 2e09d27 | 2022-10-14 17:15:00 -0700 | [diff] [blame] | 55 | |
William A. Kennington III | 6a92363 | 2022-11-06 18:17:33 -0800 | [diff] [blame] | 56 | /** @brief Get all the addreses from the system. |
| 57 | * @returns list of addresses |
| 58 | */ |
| 59 | std::vector<AddressInfo> getAddresses(const AddressFilter& filter); |
| 60 | |
William A. Kennington III | a842690 | 2022-11-07 15:37:41 -0800 | [diff] [blame] | 61 | /** @brief Returns a list of system neighbor table |
| 62 | */ |
| 63 | std::vector<NeighborInfo> getNeighbors(const NeighborFilter& filter); |
| 64 | |
William A. Kennington III | 2e09d27 | 2022-10-14 17:15:00 -0700 | [diff] [blame] | 65 | } // namespace phosphor::network::system |