Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50c25280 authored by chrisweir's avatar chrisweir
Browse files

Add support for poll()-ing nlsockets

Adding support for polling netlink sockets.

Bug: 168050726
Test: Verify that Netlink Proxy works
Change-Id: I1e363a9c5cb77b10f247d27cc4e6a2428aa92211
parent d4d6796b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -153,6 +153,10 @@ std::optional<unsigned> Socket::getPid() {
    return sa.nl_pid;
}

pollfd Socket::preparePoll(short events) {
    return {mFd.get(), events, 0};
}

Socket::receive_iterator::receive_iterator(Socket& socket, bool end)
    : mSocket(socket), mIsEnd(end) {
    if (!end) receive();
+9 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <libnl++/MessageFactory.h>

#include <linux/netlink.h>
#include <poll.h>

#include <optional>
#include <set>
@@ -173,6 +174,14 @@ class Socket {
     */
    std::optional<unsigned> getPid();

    /**
     * Creates a pollfd object for the socket.
     *
     * \param events Value for pollfd.events.
     * \return A populated pollfd object.
     */
    pollfd preparePoll(short events = 0);

    /**
     * Live iterator continuously receiving messages from Netlink socket.
     *