network: Rework address lookup to use only events

In order to get the IP address of an interface, we can get the
information out of NEWADDR events without needed to call getifaddrs().
And when now events are expected, we can requests a dump of all
addresses and handle addresses changes the same way via handleEvents()
only.
This commit is contained in:
Anthony PERARD
2021-05-15 16:38:00 +01:00
parent c9bbaa7241
commit 0fc7ef6685
2 changed files with 87 additions and 92 deletions

View File

@ -2,7 +2,6 @@
#include <arpa/inet.h>
#include <fmt/format.h>
#include <ifaddrs.h>
#include <linux/nl80211.h>
#include <net/if.h>
#include <netlink/genl/ctrl.h>
@ -37,7 +36,6 @@ class Network : public ALabel {
void createInfoSocket();
void createEventSocket();
int getExternalInterface(int skip_idx = -1) const;
void getInterfaceAddress();
int netlinkRequest(void*, uint32_t, uint32_t groups = 0) const;
int netlinkResponse(void*, uint32_t, uint32_t groups = 0) const;
void parseEssid(struct nlattr**);
@ -63,6 +61,7 @@ class Network : public ALabel {
std::mutex mutex_;
bool want_link_dump_;
bool want_addr_dump_;
bool dump_in_progress_;
unsigned long long bandwidth_down_total_;