Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "types.hpp" |
| 4 | |
William A. Kennington III | 32eef71 | 2022-01-24 17:03:03 -0800 | [diff] [blame] | 5 | #include <stdplus/fd/managed.hpp> |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 6 | |
| 7 | namespace phosphor |
| 8 | { |
| 9 | namespace network |
| 10 | { |
| 11 | namespace rtnetlink |
| 12 | { |
| 13 | |
| 14 | constexpr 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 | |
| 22 | class Server |
| 23 | { |
| 24 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 25 | 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 III | 32eef71 | 2022-01-24 17:03:03 -0800 | [diff] [blame] | 33 | Server(EventPtr& eventPtr); |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 34 | |
William A. Kennington III | 32eef71 | 2022-01-24 17:03:03 -0800 | [diff] [blame] | 35 | /** @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 Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 43 | }; |
| 44 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 45 | } // namespace rtnetlink |
| 46 | } // namespace network |
| 47 | } // namespace phosphor |