blob: 51cf7bb14423676caebabc2c7f879cbd272b25ab [file] [log] [blame]
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +05301#pragma once
2
3#include "types.hpp"
4
5#include <systemd/sd-event.h>
6
7namespace phosphor
8{
9namespace network
10{
11namespace rtnetlink
12{
13
14constexpr auto BUFSIZE = 4096;
15
16/** General rtnetlink server which waits for the POLLIN event
17 and calls the call back once it gets the event.
18 Usage would be create the server with the call back
19 and call the run method.
20 */
21
22class Server
23{
24
25 public:
26
27 /** @brief Constructor
28 *
29 * @param[in] event - Unique ptr reference to sd_event.
30 */
31
32 Server(EventPtr& event):
33 eventPtr(event) {};
34
35 Server(const Server&) = delete;
36 Server& operator=(const Server&) = delete;
37 Server(Server&&) = default;
38 Server& operator=(Server &&) = default;
39
40 /** @brief Initialise the event loop and add the handler for incoming
41 * RTNETLINK events.
42 *
43 * @return EXIT_SUCCESS on success and EXIT_FAILURE on failure.
44 */
45 int run();
46
47 private:
48 /** @brief reference to sd_event wrapped in unique_ptr */
49 EventPtr& eventPtr;
50
51};
52
53} //namespace rtnetlink
54} //namespce network
55} //namespace phosphor