net: refactor netlink socket handling
In preparation for generic netlink support
Change-Id: I69d93b69c08d4c3f7fd0dabbf3e51dbd49f9ef06
Refs: #4020
diff --git a/src/net/detail/network-monitor-impl-netlink.hpp b/src/net/detail/network-monitor-impl-netlink.hpp
index 4075437..0b461fb 100644
--- a/src/net/detail/network-monitor-impl-netlink.hpp
+++ b/src/net/detail/network-monitor-impl-netlink.hpp
@@ -31,28 +31,21 @@
#error "This file should not be included ..."
#endif
-#include <boost/asio/posix/stream_descriptor.hpp>
+#include "netlink-socket.hpp"
-#include <array>
#include <map>
namespace ndn {
namespace net {
-class NetlinkMessage;
-
class NetworkMonitorImplNetlink : public NetworkMonitorImpl
{
public:
- using Error = NetworkMonitor::Error;
-
/** \brief initialize netlink socket and start enumerating interfaces
*/
explicit
NetworkMonitorImplNetlink(boost::asio::io_service& io);
- ~NetworkMonitorImplNetlink();
-
uint32_t
getCapabilities() const final
{
@@ -74,22 +67,7 @@
isEnumerating() const;
void
- initSocket(int family);
-
- void
- joinGroup(int group);
-
- void
- sendDumpRequest(uint16_t nlmsgType);
-
- void
- asyncRead();
-
- void
- receiveMessage();
-
- void
- parseNetlinkMessage(const NetlinkMessage& nlmsg);
+ parseRtnlMessage(const NetlinkMessage& nlmsg);
void
parseLinkMessage(const NetlinkMessage& nlmsg);
@@ -103,15 +81,9 @@
void
parseErrorMessage(const NetlinkMessage& nlmsg);
- static void
- updateInterfaceState(NetworkInterface& interface, uint8_t operState);
-
private:
std::map<int, shared_ptr<NetworkInterface>> m_interfaces; ///< ifindex => interface
- std::array<uint8_t, 16384> m_buffer; ///< netlink messages received from the kernel
- shared_ptr<boost::asio::posix::stream_descriptor> m_socket; ///< the netlink socket
- uint32_t m_pid; ///< our port ID (unicast address for netlink sockets)
- uint32_t m_sequenceNo; ///< sequence number of the last netlink request sent to the kernel
+ RtnlSocket m_rtnlSocket; ///< rtnetlink socket
bool m_isEnumeratingLinks; ///< true if a dump of all links is in progress
bool m_isEnumeratingAddresses; ///< true if a dump of all addresses is in progress
};