Skip to content
Snippets Groups Projects
Verified Commit 3de0d359 authored by Benny Baumann's avatar Benny Baumann
Browse files

Basic interface for using libnl3 (for interface monitoring)

parent efa2eb9e
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,9 @@ CFLAGS += -Wno-error=sign-conversion
CXXFLAGS += -Wno-error=sign-conversion
endif
CFLAGS += `pkg-config --cflags libnl-3.0`
CXXFLAGS += `pkg-config --cflags libnl-3.0`
CC ?= gcc
CXX ?= g++
......
......@@ -4,6 +4,7 @@
#include <thread>
#include "lib/ev/ev.hpp"
#include "lib/nl/nl.hpp"
#include "mumta/evloop.hpp"
......@@ -14,6 +15,9 @@ int main() {
if(!check_version_libev()) {
return 1;
}
if (!check_version_libnl()) {
return 1;
}
dctl_status_msg("Initializing");
dctl_status_msg("Reading configuration");
......
`pkg-config --cflags --libs libsystemd`
`pkg-config --cflags --libs libnl-3.0`
-lev
-pthread
#include <lib/nl/nl.hpp>
#include <iomanip>
#include <sstream>
#include <string>
#include <netlink/utils.h>
#include "service/daemonctl.hpp"
bool check_version_libnl()
{
auto nl_major{nl_ver_maj};
auto nl_minor{nl_ver_min};
constexpr auto exp_major{LIBNL_VER_MAJ};
constexpr auto exp_minor{LIBNL_VER_MIN};
std::stringstream str;
str << "Checking dependency: libnl: detected " << std::dec << nl_major << "." << std::setw(2) << std::setfill('0') << nl_minor << ", compiled " << std::dec << exp_major << "." << std::setw(2) << std::setfill('0') << exp_minor;
dctl_status_msg(str.str().c_str());
if (nl_major != exp_major) {
dctl_status_err("Checking dependency: libnl: failed version check: Major API version mismatch.\n");
return false;
}
if (nl_minor < exp_minor) {
dctl_status_err("Checking dependency: libnl: failed version check: Minor API version too old.\n");
return false;
}
return true;
}
#pragma once
bool check_version_libnl();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment