blob: aca3744cad638daa367669f69b5d14cc7a07f69e [file] [log] [blame]
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +05301#pragma once
2
3#include "types.hpp"
4
William A. Kennington III32eef712022-01-24 17:03:03 -08005#include <stdplus/fd/managed.hpp>
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +05306
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
Gunnar Mills57d9c502018-09-14 14:42:34 -050025 public:
26 /** @brief Constructor
27 *
28 * @details Sets up the server to handle incoming RTNETLINK events
29 *
30 * @param[in] eventPtr - Unique ptr reference to sd_event.
31 * @param[in] socket - netlink socket.
32 */
William A. Kennington III32eef712022-01-24 17:03:03 -080033 Server(EventPtr& eventPtr);
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053034
William A. Kennington III32eef712022-01-24 17:03:03 -080035 /** @brief Gets the socket associated with this netlink server */
36 inline stdplus::Fd& getSock()
37 {
38 return sock;
39 }
40
41 private:
42 stdplus::ManagedFd sock;
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053043};
44
Gunnar Mills57d9c502018-09-14 14:42:34 -050045} // namespace rtnetlink
46} // namespace network
47} // namespace phosphor