ipaddress.cpp (1d25ca4e2988e50dfd8897779028792f209403a5) ipaddress.cpp (9b2a20d3cfa1131521456b9ebfde7a7bb8b234bb)
1#include "ipaddress.hpp"
2
3#include "ethernet_interface.hpp"
4#include "network_manager.hpp"
5#include "util.hpp"
6
7#include <phosphor-logging/elog-errors.hpp>
8#include <phosphor-logging/lg2.hpp>

--- 8 unchanged lines hidden (view full) ---

17namespace network
18{
19
20using namespace phosphor::logging;
21using namespace sdbusplus::xyz::openbmc_project::Common::Error;
22using NotAllowed = sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed;
23using Reason = xyz::openbmc_project::Common::NotAllowed::REASON;
24
1#include "ipaddress.hpp"
2
3#include "ethernet_interface.hpp"
4#include "network_manager.hpp"
5#include "util.hpp"
6
7#include <phosphor-logging/elog-errors.hpp>
8#include <phosphor-logging/lg2.hpp>

--- 8 unchanged lines hidden (view full) ---

17namespace network
18{
19
20using namespace phosphor::logging;
21using namespace sdbusplus::xyz::openbmc_project::Common::Error;
22using NotAllowed = sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed;
23using Reason = xyz::openbmc_project::Common::NotAllowed::REASON;
24
25static auto makeObjPath(std::string_view root, IfAddr addr)
25static auto makeObjPath(std::string_view root, stdplus::SubnetAny addr)
26{
27 auto ret = sdbusplus::message::object_path(std::string(root));
26{
27 auto ret = sdbusplus::message::object_path(std::string(root));
28 ret /= std::to_string(addr);
28 stdplus::ToStrHandle<stdplus::ToStr<stdplus::SubnetAny>> tsh;
29 ret /= tsh(addr);
29 return ret;
30}
31
32template <typename T>
33struct Proto
34{};
35
36template <>
30 return ret;
31}
32
33template <typename T>
34struct Proto
35{};
36
37template <>
37struct Proto<in_addr>
38struct Proto<stdplus::In4Addr>
38{
39 static inline constexpr auto value = IP::Protocol::IPv4;
40};
41
42template <>
39{
40 static inline constexpr auto value = IP::Protocol::IPv4;
41};
42
43template <>
43struct Proto<in6_addr>
44struct Proto<stdplus::In6Addr>
44{
45 static inline constexpr auto value = IP::Protocol::IPv6;
46};
47
48IPAddress::IPAddress(sdbusplus::bus_t& bus, std::string_view objRoot,
45{
46 static inline constexpr auto value = IP::Protocol::IPv6;
47};
48
49IPAddress::IPAddress(sdbusplus::bus_t& bus, std::string_view objRoot,
49 stdplus::PinnedRef<EthernetInterface> parent, IfAddr addr,
50 AddressOrigin origin) :
50 stdplus::PinnedRef<EthernetInterface> parent,
51 stdplus::SubnetAny addr, AddressOrigin origin) :
51 IPAddress(bus, makeObjPath(objRoot, addr), parent, addr, origin)
52{}
53
54IPAddress::IPAddress(sdbusplus::bus_t& bus,
55 sdbusplus::message::object_path objPath,
52 IPAddress(bus, makeObjPath(objRoot, addr), parent, addr, origin)
53{}
54
55IPAddress::IPAddress(sdbusplus::bus_t& bus,
56 sdbusplus::message::object_path objPath,
56 stdplus::PinnedRef<EthernetInterface> parent, IfAddr addr,
57 AddressOrigin origin) :
57 stdplus::PinnedRef<EthernetInterface> parent,
58 stdplus::SubnetAny addr, AddressOrigin origin) :
58 IPIfaces(bus, objPath.str.c_str(), IPIfaces::action::defer_emit),
59 parent(parent), objPath(std::move(objPath))
60{
59 IPIfaces(bus, objPath.str.c_str(), IPIfaces::action::defer_emit),
60 parent(parent), objPath(std::move(objPath))
61{
61 IP::address(std::to_string(addr.getAddr()), true);
62 IP::address(stdplus::toStr(addr.getAddr()), true);
62 IP::prefixLength(addr.getPfx(), true);
63 IP::type(std::visit([](auto v) { return Proto<decltype(v)>::value; },
64 addr.getAddr()),
65 true);
66 IP::origin(origin, true);
67 emit_object_added();
68}
69std::string IPAddress::address(std::string /*ipAddress*/)

--- 48 unchanged lines hidden ---
63 IP::prefixLength(addr.getPfx(), true);
64 IP::type(std::visit([](auto v) { return Proto<decltype(v)>::value; },
65 addr.getAddr()),
66 true);
67 IP::origin(origin, true);
68 emit_object_added();
69}
70std::string IPAddress::address(std::string /*ipAddress*/)

--- 48 unchanged lines hidden ---