Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 1 | #pragma once |
William A. Kennington III | 217bb3f | 2022-09-29 13:43:13 -0700 | [diff] [blame^] | 2 | #include <sdeventplus/event.hpp> |
| 3 | #include <sdeventplus/source/io.hpp> |
William A. Kennington III | 32eef71 | 2022-01-24 17:03:03 -0800 | [diff] [blame] | 4 | #include <stdplus/fd/managed.hpp> |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 5 | |
William A. Kennington III | 217bb3f | 2022-09-29 13:43:13 -0700 | [diff] [blame^] | 6 | namespace sdeventplus |
| 7 | { |
| 8 | class Event; |
| 9 | } |
| 10 | |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 11 | namespace phosphor |
| 12 | { |
| 13 | namespace network |
| 14 | { |
| 15 | namespace rtnetlink |
| 16 | { |
| 17 | |
| 18 | constexpr 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 | |
| 26 | class Server |
| 27 | { |
| 28 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 29 | 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 III | 217bb3f | 2022-09-29 13:43:13 -0700 | [diff] [blame^] | 37 | Server(sdeventplus::Event& event); |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 38 | |
William A. Kennington III | 32eef71 | 2022-01-24 17:03:03 -0800 | [diff] [blame] | 39 | /** @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 III | 217bb3f | 2022-09-29 13:43:13 -0700 | [diff] [blame^] | 47 | sdeventplus::source::IO io; |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 48 | }; |
| 49 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 50 | } // namespace rtnetlink |
| 51 | } // namespace network |
| 52 | } // namespace phosphor |