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 constexpr auto BUFSIZE = 4096;
15 
16 /** General rtnetlink server which waits for the POLLIN event
17     and calls the  call back once it gets the event.
18     Usage would be create the server with the  call back
19     and call the run method.
20  */
21 class Server
22 {
23   public:
24     /** @brief Constructor
25      *
26      *  @details Sets up the server to handle incoming RTNETLINK events
27      *
28      *  @param[in] eventPtr - Unique ptr reference to sd_event.
29      *  @param[in] manager  - The network manager that receives updates
30      */
31     Server(sdeventplus::Event& event, Manager& manager);
32 
33     /** @brief Gets the socket associated with this netlink server */
34     inline stdplus::Fd& getSock()
35     {
36         return sock;
37     }
38 
39   private:
40     stdplus::ManagedFd sock;
41     sdeventplus::source::IO io;
42 };
43 
44 } // namespace netlink
45 } // namespace network
46 } // namespace phosphor
47