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 | |
| 26 | public: |
| 27 | |
| 28 | /** @brief Constructor |
| 29 | * |
Vishwanatha Subbanna | 18891c6 | 2017-10-17 15:22:46 +0530 | [diff] [blame] | 30 | * @details Sets up the server to handle incoming RTNETLINK events |
| 31 | * |
| 32 | * @param[in] eventPtr - Unique ptr reference to sd_event. |
Ratan Gupta | f665738 | 2017-11-10 17:58:17 +0530 | [diff] [blame] | 33 | * @param[in] socket - netlink socket. |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 34 | */ |
Ratan Gupta | f665738 | 2017-11-10 17:58:17 +0530 | [diff] [blame] | 35 | Server(EventPtr& eventPtr, const phosphor::Descriptor& socket); |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 36 | |
Vishwanatha Subbanna | 18891c6 | 2017-10-17 15:22:46 +0530 | [diff] [blame] | 37 | Server() = delete; |
| 38 | ~Server() = default; |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 39 | Server(const Server&) = delete; |
| 40 | Server& operator=(const Server&) = delete; |
| 41 | Server(Server&&) = default; |
| 42 | Server& operator=(Server &&) = default; |
Ratan Gupta | 0f9dc1b | 2017-09-03 17:57:50 +0530 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | } //namespace rtnetlink |
| 46 | } //namespce network |
| 47 | } //namespace phosphor |