blob: 7785c397042ab2ffa986bf8ec4540a4e326c94e6 [file] [log] [blame]
William A. Kennington III2e09d272022-10-14 17:15:00 -07001#pragma once
2#include "types.hpp"
3
William A. Kennington IIIfd862be2022-10-09 18:40:55 -07004#include <net/ethernet.h>
William A. Kennington III2e09d272022-10-14 17:15:00 -07005
6#include <cstdint>
7#include <optional>
8#include <stdplus/zstring.hpp>
9#include <stdplus/zstring_view.hpp>
William A. Kennington IIIfd862be2022-10-09 18:40:55 -070010#include <string>
William A. Kennington III2e09d272022-10-14 17:15:00 -070011#include <string_view>
William A. Kennington IIIfd862be2022-10-09 18:40:55 -070012#include <vector>
13
14struct nlmsghdr;
William A. Kennington III2e09d272022-10-14 17:15:00 -070015
16namespace phosphor::network::system
17{
William A. Kennington III2e09d272022-10-14 17:15:00 -070018struct EthInfo
19{
20 bool autoneg;
21 uint16_t speed;
22};
23EthInfo getEthInfo(stdplus::zstring_view ifname);
24
25bool intfIsRunning(std::string_view ifname);
26
William A. Kennington III2e09d272022-10-14 17:15:00 -070027std::optional<unsigned> getMTU(stdplus::zstring_view ifname);
28
29void setMTU(std::string_view ifname, unsigned mtu);
30
31void setNICUp(std::string_view ifname, bool up);
32
William A. Kennington III6a923632022-11-06 18:17:33 -080033struct AddressFilter
34{
35 unsigned ifidx = 0;
36};
37
William A. Kennington IIIa8426902022-11-07 15:37:41 -080038struct NeighborFilter
39{
40 unsigned ifidx = 0;
41};
42
William A. Kennington IIIfd862be2022-10-09 18:40:55 -070043namespace detail
44{
William A. Kennington III6a923632022-11-06 18:17:33 -080045bool validateNewAddr(const AddressInfo& info,
46 const AddressFilter& filter) noexcept;
William A. Kennington IIIa8426902022-11-07 15:37:41 -080047bool validateNewNeigh(const NeighborInfo& info,
48 const NeighborFilter& filter) noexcept;
William A. Kennington IIIfd862be2022-10-09 18:40:55 -070049} // namespace detail
50
William A. Kennington III2e09d272022-10-14 17:15:00 -070051/** @brief Get all the interfaces from the system.
52 * @returns list of interface names.
53 */
William A. Kennington IIIfd862be2022-10-09 18:40:55 -070054std::vector<InterfaceInfo> getInterfaces();
William A. Kennington III2e09d272022-10-14 17:15:00 -070055
William A. Kennington III6a923632022-11-06 18:17:33 -080056/** @brief Get all the addreses from the system.
57 * @returns list of addresses
58 */
59std::vector<AddressInfo> getAddresses(const AddressFilter& filter);
60
William A. Kennington IIIa8426902022-11-07 15:37:41 -080061/** @brief Returns a list of system neighbor table
62 */
63std::vector<NeighborInfo> getNeighbors(const NeighborFilter& filter);
64
William A. Kennington III2e09d272022-10-14 17:15:00 -070065} // namespace phosphor::network::system