1 #pragma once 2 #include <sdeventplus/event.hpp> 3 #include <sdeventplus/source/io.hpp> 4 #include <stdplus/fd/managed.hpp> 5 6 namespace phosphor 7 { 8 namespace network 9 { 10 class Manager; 11 namespace netlink 12 { 13 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 */ 19 class Server 20 { 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. 27 * @param[in] manager - The network manager that receives updates 28 */ 29 Server(sdeventplus::Event& event, Manager& manager); 30 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; 39 sdeventplus::source::IO io; 40 }; 41 42 } // namespace netlink 43 } // namespace network 44 } // namespace phosphor 45