Files
amnezia-client/client/platforms/linux/daemon/linuxroutemonitor.h
T

46 lines
1.2 KiB
C++
Raw Normal View History

2023-09-17 17:06:24 -04:00
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef LINUXROUTEMONITOR_H
#define LINUXROUTEMONITOR_H
#include <QByteArray>
#include <QHostAddress>
#include <QList>
#include <QObject>
#include <QSocketNotifier>
#include "ipaddress.h"
class LinuxRouteMonitor final : public QObject {
Q_OBJECT
public:
LinuxRouteMonitor(const QString& ifname, QObject* parent = nullptr);
~LinuxRouteMonitor();
bool insertRoute(const IPAddress& prefix);
bool deleteRoute(const IPAddress& prefix);
bool addExclusionRoute(const IPAddress& prefix);
bool deleteExclusionRoute(const IPAddress& prefix);
private:
static QString addrToString(const struct sockaddr* sa);
static QString addrToString(const QByteArray& data);
2023-09-19 17:59:04 -04:00
bool rtmSendRoute(int action, int flags, int type,
const IPAddress& prefix);
2023-09-17 17:06:24 -04:00
QString m_ifname;
unsigned int m_ifindex = 0;
2023-09-19 17:59:04 -04:00
int m_nlsock = -1;
int m_nlseq = 0;
2023-09-17 17:06:24 -04:00
QSocketNotifier* m_notifier = nullptr;
2023-09-19 17:59:04 -04:00
private slots:
void nlsockReady();
2023-09-17 17:06:24 -04:00
};
#endif // LINUXROUTEMONITOR_H