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 
24   public:
25     /** @brief Constructor
26      *
27      *  @details Sets up the server to handle incoming RTNETLINK events
28      *
29      *  @param[in] eventPtr - Unique ptr reference to sd_event.
30      *  @param[in] manager  - The network manager that receives updates
31      */
32     Server(sdeventplus::Event& event, Manager& manager);
33 
34     /** @brief Gets the socket associated with this netlink server */
35     inline stdplus::Fd& getSock()
36     {
37         return sock;
38     }
39 
40   private:
41     stdplus::ManagedFd sock;
42     sdeventplus::source::IO io;
43 };
44 
45 } // namespace netlink
46 } // namespace network
47 } // namespace phosphor
48