#ifndef NETLINKMONITOR_H
#define NETLINKMONITOR_H

#include <QObject>
#include <QThread>

#include <sys/socket.h>
#include <linux/netlink.h>
#include <linux/connector.h>
#include <linux/cn_proc.h>
#include <unistd.h>

#include <signal.h>
#include <errno.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

#include "software/softwarefilter.h"

class NetLinkMonitorPrivate;
class NetLinkMonitor : public QThread
{
    Q_OBJECT
public:
    NetLinkMonitor(const QList<SoftwareFilter> filters, QObject* parent = Q_NULLPTR);
    ~NetLinkMonitor();

    int nl_connect();
    int set_proc_ev_listen(int nl_sock, bool enable);
    int handle_proc_ev(int nl_sock);
    void monitor();

Q_SIGNALS:
    void softwareStarted(int pid, const QString& cmd, const qint64 startup);
    void softwareStoped(int pid, const QString& cmd, const qint64 shutdown);

protected:
    void run();

private:
    QScopedPointer<NetLinkMonitorPrivate> dd_ptr;
    Q_DECLARE_PRIVATE_D(qGetPtrHelper(dd_ptr), NetLinkMonitor)
};

#endif // NETLINKMONITOR_H
