blob: 2e90b230ed45e9a8f457590406cd3e78a01fa9ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#pragma once
#include "ethernet_interface.hpp"
#include "xyz/openbmc_project/Network/VLAN/Create/server.hpp"
#include <sdbusplus/bus.hpp>
#include <ifaddrs.h>
#include <list>
#include <memory>
#include <string>
#include <vector>
namespace phosphor
{
namespace network
{
namespace details
{
template <typename T>
using ServerObject = typename sdbusplus::server::object::object<T>;
using VLANCreateIface =
details::ServerObject<sdbusplus::xyz::openbmc_project::
Network::VLAN::server::Create>;
using IntfName = std::string;
struct AddrInfo {
short addrType;
std::string ipaddress;
};
using Addr_t = ifaddrs*;
struct AddrDeleter
{
void operator()(Addr_t ptr) const
{
freeifaddrs(ptr);
}
};
using AddrPtr = std::unique_ptr<ifaddrs, AddrDeleter>;
using AddrList = std::list<AddrInfo>;
using IntfAddrMap = std::map<IntfName, AddrList>;
} // namespace details
/** @class Manager
* @brief OpenBMC network manager implementation.
*/
class Manager : public details::VLANCreateIface
{
public:
Manager() = delete;
Manager(const Manager&) = delete;
Manager& operator=(const Manager&) = delete;
Manager(Manager&&) = delete;
Manager& operator=(Manager&&) = delete;
virtual ~Manager() = default;
/** @brief Constructor to put object onto bus at a dbus path.
* @param[in] bus - Bus to attach to.
* @param[in] objPath - Path to attach at.
*/
Manager(sdbusplus::bus::bus& bus, const char* objPath);
void vLAN(details::IntfName interfaceName, uint16_t id) override;
private:
/** @brief Get all the interfaces from the system.
* @returns list of interface names.
*/
details::IntfAddrMap getInterfaceAndaddrs() const;
/** @brief Persistent map of EthernetInterface dbus objects and their names */
std::map<details::IntfName, std::unique_ptr<EthernetInterface>> interfaces;
};
} // namespace network
} // namespace phosphor
|