blob: e792a3e4de3bf9975e7ee2b4d42901006d2484a6 [file] [log] [blame]
Ratan Gupta82549cc2017-04-21 08:45:23 +05301#pragma once
2
Ratan Gupta3681a502017-06-17 19:20:04 +05303#include <ifaddrs.h>
4
Ratan Gupta82549cc2017-04-21 08:45:23 +05305#include <list>
6#include <string>
7#include <vector>
8#include <map>
Ratan Gupta3681a502017-06-17 19:20:04 +05309#include <memory>
Ratan Gupta82549cc2017-04-21 08:45:23 +053010
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053011#include <systemd/sd-event.h>
12
Ratan Gupta82549cc2017-04-21 08:45:23 +053013namespace phosphor
14{
15namespace network
16{
Ratan Guptabc886292017-07-25 18:29:57 +053017namespace systemd
18{
19namespace config
20{
21
22constexpr auto networkFilePrefix = "00-bmc-";
23constexpr auto networkFileSuffix = ".network";
24constexpr auto deviceFileSuffix = ".netdev";
25
26}// namespace config
27}// namespace systemd
Ratan Gupta82549cc2017-04-21 08:45:23 +053028
29using IntfName = std::string;
30
31struct AddrInfo {
32 uint8_t addrType;
33 std::string ipaddress;
34 uint16_t prefix;
35};
36
Ratan Gupta3681a502017-06-17 19:20:04 +053037using Addr_t = ifaddrs*;
38
39struct AddrDeleter
40{
41 void operator()(Addr_t ptr) const
42 {
43 freeifaddrs(ptr);
44 }
45};
46
47using AddrPtr = std::unique_ptr<ifaddrs, AddrDeleter>;
48
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053049/* Need a custom deleter for freeing up sd_event */
50struct EventDeleter
51{
52 void operator()(sd_event* event) const
53 {
54 event = sd_event_unref(event);
55 }
56};
57using EventPtr = std::unique_ptr<sd_event, EventDeleter>;
58
59template<typename T>
60using UniquePtr = std::unique_ptr<T, std::function<void(T*)>>;
Ratan Gupta3681a502017-06-17 19:20:04 +053061
Ratan Gupta82549cc2017-04-21 08:45:23 +053062using AddrList = std::list<AddrInfo>;
63using IntfAddrMap = std::map<IntfName, AddrList>;
64
65
66}//namespace network
67}//namespace phosphor