Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "types.hpp" |
Vishwanatha Subbanna | 18891c6 | 2017-10-17 15:22:46 +0530 | [diff] [blame] | 4 | #include "util.hpp" |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 5 | |
| 6 | #include <systemd/sd-event.h> |
| 7 | |
| 8 | namespace phosphor |
| 9 | { |
| 10 | namespace network |
| 11 | { |
| 12 | namespace rtnetlink |
| 13 | { |
| 14 | |
| 15 | constexpr auto BUFSIZE = 4096; |
| 16 | |
| 17 | /** General rtnetlink server which waits for the POLLIN event |
| 18 | and calls the call back once it gets the event. |
| 19 | Usage would be create the server with the call back |
| 20 | and call the run method. |
| 21 | */ |
| 22 | |
| 23 | class Server |
| 24 | { |
| 25 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 26 | public: |
| 27 | /** @brief Constructor |
| 28 | * |
| 29 | * @details Sets up the server to handle incoming RTNETLINK events |
| 30 | * |
| 31 | * @param[in] eventPtr - Unique ptr reference to sd_event. |
| 32 | * @param[in] socket - netlink socket. |
| 33 | */ |
| 34 | Server(EventPtr& eventPtr, const phosphor::Descriptor& socket); |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 35 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 36 | Server() = delete; |
| 37 | ~Server() = default; |
| 38 | Server(const Server&) = delete; |
| 39 | Server& operator=(const Server&) = delete; |
| 40 | Server(Server&&) = default; |
| 41 | Server& operator=(Server&&) = default; |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 42 | }; |
| 43 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 44 | } // namespace rtnetlink |
| 45 | } // namespace network |
| 46 | } // namespace phosphor |