-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMAC_table.h
61 lines (50 loc) · 1.4 KB
/
MAC_table.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// Created by root on 15.10.2017.
//
#ifndef SWITCH_PROJECT_MAC_TABLE_H
#define SWITCH_PROJECT_MAC_TABLE_H
#include <tins/tins.h>
#include <list>
#include <mutex>
#include <QtCore/QThread>
#include <QtGui/QWidgetItem>
#include <QtGui/QListWidgetItem>
using namespace std;
using namespace Tins;
class MAC_table : public QThread {
Q_OBJECT
private:
mutex table_handle_mutex;
unsigned int global_timer;
signals:
void tableChanged(QVector<string>);
void entryChanged(QString);
public slots:
void restore_timer(HWAddress<6> address);
void clear_table();
public:
struct Entry {
HWAddress<6> addr;
string port;
unsigned int timer;
};
vector<Entry> table;
explicit MAC_table(QObject *parent = 0);
bool isEmpty();
bool has_entry(HWAddress<6> address, string port);
bool add_entry(HWAddress<6>address, string port);
bool remove_entry(HWAddress<6> address);
int remove_entry(string port); // returns the number of removed entries
Entry *get_entry(HWAddress<6> address);
vector<Entry> get_entry(string port);
vector<Entry> get_table();
unsigned long get_size();
void decrement_timers();
void print_MAC_table();
unsigned int getTimer();
void setTimer(unsigned int t);
QVector<QListWidgetItem> tableToQList();
QVector<string> vectorToQvecStr();
void run() override;
};
#endif //SWITCH_PROJECT_MAC_TABLE_H