blob: e62f51c03cbd6788eecaa7157924ce618484a1d5 [file] [log] [blame]
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +05301#pragma once
2
3#include "types.hpp"
Vishwanatha Subbanna18891c62017-10-17 15:22:46 +05304#include "util.hpp"
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +05305
6#include <systemd/sd-event.h>
7
8namespace phosphor
9{
10namespace network
11{
12namespace rtnetlink
13{
14
15constexpr auto BUFSIZE = 4096;
16
17/** General rtnetlink server which waits for the POLLIN event
18 and calls the call back once it gets the event.
19 Usage would be create the server with the call back
20 and call the run method.
21 */
22
23class Server
24{
25
Gunnar Mills57d9c502018-09-14 14:42:34 -050026 public:
27 /** @brief Constructor
28 *
29 * @details Sets up the server to handle incoming RTNETLINK events
30 *
31 * @param[in] eventPtr - Unique ptr reference to sd_event.
32 * @param[in] socket - netlink socket.
33 */
34 Server(EventPtr& eventPtr, const phosphor::Descriptor& socket);
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053035
Gunnar Mills57d9c502018-09-14 14:42:34 -050036 Server() = delete;
37 ~Server() = default;
38 Server(const Server&) = delete;
39 Server& operator=(const Server&) = delete;
40 Server(Server&&) = default;
41 Server& operator=(Server&&) = default;
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053042};
43
Gunnar Mills57d9c502018-09-14 14:42:34 -050044} // namespace rtnetlink
45} // namespace network
46} // namespace phosphor