blob: 3e7c44bb21ea42396d5981d224310efe6b496aec [file] [log] [blame]
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +05301#pragma once
William A. Kennington III217bb3f2022-09-29 13:43:13 -07002#include <sdeventplus/event.hpp>
3#include <sdeventplus/source/io.hpp>
William A. Kennington III32eef712022-01-24 17:03:03 -08004#include <stdplus/fd/managed.hpp>
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +05305
6namespace phosphor
7{
8namespace network
9{
William A. Kennington III71590bf2022-10-31 14:14:16 -070010class Manager;
William A. Kennington III5f165dc2022-10-24 15:58:55 -070011namespace netlink
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053012{
13
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053014/** 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 */
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053019class Server
20{
Gunnar Mills57d9c502018-09-14 14:42:34 -050021 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.
William A. Kennington III71590bf2022-10-31 14:14:16 -070027 * @param[in] manager - The network manager that receives updates
Gunnar Mills57d9c502018-09-14 14:42:34 -050028 */
William A. Kennington III71590bf2022-10-31 14:14:16 -070029 Server(sdeventplus::Event& event, Manager& manager);
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053030
William A. Kennington III32eef712022-01-24 17:03:03 -080031 /** @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;
William A. Kennington III217bb3f2022-09-29 13:43:13 -070039 sdeventplus::source::IO io;
Ratan Gupta0f9dc1b2017-09-03 17:57:50 +053040};
41
William A. Kennington III5f165dc2022-10-24 15:58:55 -070042} // namespace netlink
Gunnar Mills57d9c502018-09-14 14:42:34 -050043} // namespace network
44} // namespace phosphor