util.cpp (3becda7020c72437fe1d1b2aeb44ba65e736f2cb) util.cpp (01c816f25b391435213421825413ada89d1ffd15)
1#include "config.h"
2
3#include "util.hpp"
4
5#include "config_parser.hpp"
6#include "types.hpp"
7
8#include <fmt/compile.h>
9#include <fmt/format.h>
10#include <sys/wait.h>
11
12#include <cctype>
13#include <charconv>
14#include <fstream>
15#ifdef SYNC_MAC_FROM_INVENTORY
16#include <nlohmann/json.hpp>
17#endif
18#include <phosphor-logging/elog-errors.hpp>
19#include <phosphor-logging/log.hpp>
1#include "config.h"
2
3#include "util.hpp"
4
5#include "config_parser.hpp"
6#include "types.hpp"
7
8#include <fmt/compile.h>
9#include <fmt/format.h>
10#include <sys/wait.h>
11
12#include <cctype>
13#include <charconv>
14#include <fstream>
15#ifdef SYNC_MAC_FROM_INVENTORY
16#include <nlohmann/json.hpp>
17#endif
18#include <phosphor-logging/elog-errors.hpp>
19#include <phosphor-logging/log.hpp>
20#include <stdexcept>
21#include <stdplus/raw.hpp>
22#include <string>
23#include <string_view>
24#include <variant>
25#include <xyz/openbmc_project/Common/error.hpp>
26
27namespace phosphor
28{
29namespace network

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

126const std::unordered_set<std::string_view>& getIgnoredInterfaces()
127{
128 static auto ignoredInterfaces = parseInterfaces(getIgnoredInterfacesEnv());
129 return ignoredInterfaces;
130}
131
132} // namespace internal
133
20#include <string>
21#include <string_view>
22#include <variant>
23#include <xyz/openbmc_project/Common/error.hpp>
24
25namespace phosphor
26{
27namespace network

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

124const std::unordered_set<std::string_view>& getIgnoredInterfaces()
125{
126 static auto ignoredInterfaces = parseInterfaces(getIgnoredInterfacesEnv());
127 return ignoredInterfaces;
128}
129
130} // namespace internal
131
134constexpr auto familyVisit(auto&& visitor, int family)
135{
136 if (family == AF_INET)
137 {
138 return visitor.template operator()<AF_INET>();
139 }
140 else if (family == AF_INET6)
141 {
142 return visitor.template operator()<AF_INET6>();
143 }
144 throw std::invalid_argument("Invalid addr family");
145}
146
147template <int family>
148typename FamilyTraits<family>::addr addrFromBuf(std::string_view buf)
149{
150 return stdplus::raw::copyFromStrict<typename FamilyTraits<family>::addr>(
151 buf);
152}
153
154InAddrAny addrFromBuf(int family, std::string_view buf)
155{
156 return familyVisit(
157 [=]<int f>() -> InAddrAny { return addrFromBuf<f>(buf); }, family);
158}
159
160void deleteInterface(stdplus::const_zstring intf)
161{
162 pid_t pid = fork();
163 int status{};
164
165 if (pid == 0)
166 {
167

--- 253 unchanged lines hidden ---
132void deleteInterface(stdplus::const_zstring intf)
133{
134 pid_t pid = fork();
135 int status{};
136
137 if (pid == 0)
138 {
139

--- 253 unchanged lines hidden ---