blob: 1e849ee1a6dac7edb49410e841859adb8ed9c15d [file] [log] [blame]
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +05301#pragma once
William A. Kennington III217bb3f2022-09-29 13:43:13 -07002#include <sdeventplus/event.hpp>
3#include <sdeventplus/source/io.hpp>
William A. Kennington III32eef712022-01-24 17:03:03 -08004#include <stdplus/fd/managed.hpp>
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +05305
William A. Kennington III217bb3f2022-09-29 13:43:13 -07006namespace sdeventplus
7{
8class Event;
9}
10
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053011namespace phosphor
12{
13namespace network
14{
15namespace rtnetlink
16{
17
18constexpr auto BUFSIZE = 4096;
19
20/** General rtnetlink server which waits for the POLLIN event
21 and calls the call back once it gets the event.
22 Usage would be create the server with the call back
23 and call the run method.
24 */
25
26class Server
27{
28
Gunnar Mills57d9c502018-09-14 14:42:34 -050029 public:
30 /** @brief Constructor
31 *
32 * @details Sets up the server to handle incoming RTNETLINK events
33 *
34 * @param[in] eventPtr - Unique ptr reference to sd_event.
35 * @param[in] socket - netlink socket.
36 */
William A. Kennington III217bb3f2022-09-29 13:43:13 -070037 Server(sdeventplus::Event& event);
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053038
William A. Kennington III32eef712022-01-24 17:03:03 -080039 /** @brief Gets the socket associated with this netlink server */
40 inline stdplus::Fd& getSock()
41 {
42 return sock;
43 }
44
45 private:
46 stdplus::ManagedFd sock;
William A. Kennington III217bb3f2022-09-29 13:43:13 -070047 sdeventplus::source::IO io;
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053048};
49
Gunnar Mills57d9c502018-09-14 14:42:34 -050050} // namespace rtnetlink
51} // namespace network
52} // namespace phosphor