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 | |
| 6 | namespace phosphor |
| 7 | { |
| 8 | namespace network |
| 9 | { |
William A. Kennington III | 71590bf | 2022-10-31 14:14:16 -0700 | [diff] [blame] | 10 | class Manager; |
William A. Kennington III | 5f165dc | 2022-10-24 15:58:55 -0700 | [diff] [blame] | 11 | namespace netlink |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 12 | { |
| 13 | |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 14 | /** General rtnetlink server which waits for the POLLIN event |
| 15 | and calls the call back once it gets the event. |
| 16 | Usage would be create the server with the call back |
| 17 | and call the run method. |
| 18 | */ |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 19 | class Server |
| 20 | { |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 21 | public: |
| 22 | /** @brief Constructor |
| 23 | * |
| 24 | * @details Sets up the server to handle incoming RTNETLINK events |
| 25 | * |
| 26 | * @param[in] eventPtr - Unique ptr reference to sd_event. |
William A. Kennington III | 71590bf | 2022-10-31 14:14:16 -0700 | [diff] [blame] | 27 | * @param[in] manager - The network manager that receives updates |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 28 | */ |
William A. Kennington III | 71590bf | 2022-10-31 14:14:16 -0700 | [diff] [blame] | 29 | Server(sdeventplus::Event& event, Manager& manager); |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 30 | |
William A. Kennington III | 32eef71 | 2022-01-24 17:03:03 -0800 | [diff] [blame] | 31 | /** @brief Gets the socket associated with this netlink server */ |
| 32 | inline stdplus::Fd& getSock() |
| 33 | { |
| 34 | return sock; |
| 35 | } |
| 36 | |
| 37 | private: |
| 38 | stdplus::ManagedFd sock; |
William A. Kennington III | 217bb3f | 2022-09-29 13:43:13 -0700 | [diff] [blame] | 39 | sdeventplus::source::IO io; |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 40 | }; |
| 41 | |
William A. Kennington III | 5f165dc | 2022-10-24 15:58:55 -0700 | [diff] [blame] | 42 | } // namespace netlink |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 43 | } // namespace network |
| 44 | } // namespace phosphor |