summaryrefslogtreecommitdiffstats
path: root/rtnetlink_server.hpp
blob: 51cf7bb14423676caebabc2c7f879cbd272b25ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once

#include "types.hpp"

#include <systemd/sd-event.h>

namespace phosphor
{
namespace network
{
namespace rtnetlink
{

constexpr auto BUFSIZE = 4096;

/** General rtnetlink server which waits for the POLLIN event
    and calls the  call back once it gets the event.
    Usage would be create the server with the  call back
    and call the run method.
 */

class Server
{

    public:

        /** @brief Constructor
         *
         *  @param[in] event - Unique ptr reference to sd_event.
         */

        Server(EventPtr& event):
            eventPtr(event) {};

        Server(const Server&) = delete;
        Server& operator=(const Server&) = delete;
        Server(Server&&) = default;
        Server& operator=(Server &&) = default;

        /** @brief Initialise the event loop and add the handler for incoming
         *         RTNETLINK events.
         *
         *  @return EXIT_SUCCESS on success and EXIT_FAILURE on failure.
         */
        int run();

    private:
        /** @brief reference to sd_event wrapped in unique_ptr */
        EventPtr& eventPtr;

};

} //namespace rtnetlink
} //namespce network
} //namespace phosphor
OpenPOWER on IntegriCloud