Switch to unified view

a b/src/policies/DIF/RMT/PDUForwarding/DomainTable/DomainTable.h
1
//
2
// This program is free software: you can redistribute it and/or modify
3
// it under the terms of the GNU Lesser General Public License as published by
4
// the Free Software Foundation, either version 3 of the License, or
5
// (at your option) any later version.
6
// 
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
// GNU Lesser General Public License for more details.
11
// 
12
// You should have received a copy of the GNU Lesser General Public License
13
// along with this program.  If not, see http://www.gnu.org/licenses/.
14
// 
15
16
#ifndef SimpleTable_H_
17
#define SimpleTable_H_
18
19
#include <IntPDUForwarding.h>
20
21
#include <map>
22
#include <string>
23
#include <vector>
24
25
namespace DomainTable {
26
27
using namespace std;
28
29
typedef vector<string> sList;
30
typedef sList::iterator sListIt;
31
32
typedef map<string, RMTPort*> s2Port;
33
struct  domainSet {
34
    unsigned short len;
35
    s2Port entries;
36
37
    domainSet():len(0){}
38
    domainSet(const unsigned short &_len):len(_len){}
39
};
40
typedef map<string, domainSet> FWDTable;
41
42
typedef s2Port::iterator s2PortIt;
43
typedef FWDTable::iterator FWDTableIt;
44
45
struct pAddr {
46
    string domain;
47
    string addr;
48
    pAddr (const string &_domain, const string &_addr)
49
        : domain(_domain), addr(_addr) {}
50
};
51
52
class DomainTable: public IntPDUForwarding {
53
54
public:
55
    // Lookup function, return a list of RMTPorts to forward a PDU/Address+qos.
56
    vector<RMTPort * > lookup(const PDU * pdu);
57
    vector<RMTPort * > lookup(const Address &dst, const unsigned short &qos);
58
59
    // Returns a representation of the Forwarding Knowledge
60
    string toString();
61
62
    // Create Domain
63
    void addDomain(const string &domain);
64
    void removeDomain(const string &domain);
65
66
    //Insert/Remove an entry
67
    void insert(const string &domain, const string &addr, RMTPort * port);
68
    void remove(const string &domain, const string &addr);
69
70
    void finish();
71
    pAddr parseAddr(const string &addr);
72
73
protected:
74
    sList domains;
75
    FWDTable table;
76
77
    // Called after initialize
78
    void onPolicyInit();
79
};
80
81
}
82
83
#endif /* SimpleTable_H_ */