blob: 0991ae0c35dbe2f2a49c1015ccb7c0aab5ed30a0 [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
26 public:
27
28 /** @brief Constructor
29 *
Vishwanatha Subbanna18891c62017-10-17 15:22:46 +053030 * @details Sets up the server to handle incoming RTNETLINK events
31 *
32 * @param[in] eventPtr - Unique ptr reference to sd_event.
Ratan Guptaf6657382017-11-10 17:58:17 +053033 * @param[in] socket - netlink socket.
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053034 */
Ratan Guptaf6657382017-11-10 17:58:17 +053035 Server(EventPtr& eventPtr, const phosphor::Descriptor& socket);
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053036
Vishwanatha Subbanna18891c62017-10-17 15:22:46 +053037 Server() = delete;
38 ~Server() = default;
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053039 Server(const Server&) = delete;
40 Server& operator=(const Server&) = delete;
41 Server(Server&&) = default;
42 Server& operator=(Server &&) = default;
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053043};
44
45} //namespace rtnetlink
46} //namespce network
47} //namespace phosphor