Switch to unified view

a b/src/policies/DIF/Routing/SimpleRouting/SimpleDV/SimpleDV.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 SimpleDV_H_
17
#define SimpleDV_H_
18
19
#include <IntSimpleRouting.h>
20
21
namespace SimpleDV {
22
23
struct rtEntry {
24
    std::string addr;
25
    unsigned short metric;
26
    rtEntry(){
27
        addr = "";
28
        metric = UINT16_MAX;
29
    }
30
    rtEntry(const std::string &_addr, const unsigned short &_metric){
31
        addr = _addr;
32
        metric = _metric;
33
    }
34
};
35
36
typedef std::vector<rtEntry> entriesL;
37
typedef std::vector<rtEntry>::iterator entriesIt;
38
39
typedef std::map<Address, unsigned short> neighMetric;
40
typedef std::map<unsigned short, neighMetric> qosNeighMetric;
41
typedef neighMetric::iterator neighMetricIt;
42
typedef qosNeighMetric::iterator qosNeighMetricIt;
43
44
typedef std::map<std::string, rtEntry> tTable;
45
typedef std::map<unsigned short, tTable> rtTable;
46
typedef tTable::iterator tTableIt;
47
typedef rtTable::iterator rtTableIt;
48
49
50
51
class RoutingUpdate : public IntRoutingUpdate {
52
public:
53
    RoutingUpdate(const Address &_addr, const std::string &_src, const unsigned short &_qos);
54
55
    std::string getSrc();
56
    unsigned short getQoS();
57
58
    void addEntry(rtEntry);
59
60
    entriesIt entriesBegin();
61
    entriesIt entriesEnd();
62
63
protected:
64
    std::string src;
65
    unsigned short qos;
66
    entriesL entries;
67
};
68
69
class SimpleDV: public IntSimpleRouting {
70
public:
71
    //Process a Routing Update, return true => inform FWDG of the update
72
    bool processUpdate(IntRoutingUpdate * update);
73
74
75
    //Flow inserted/removed
76
    void insertFlow(const Address &addr, const std::string &dst, const unsigned short &qos, const unsigned short &metric);
77
    void removeFlow(const Address &addr, const std::string &dst, const unsigned short &qos);
78
79
80
    //Get Changes
81
    entries2Next getChanges();
82
    entries2Next getAll();
83
84
    void handleMessage(cMessage *msg);
85
    void finish();
86
87
protected:
88
    // Called after initialize
89
    void onPolicyInit();
90
91
private:
92
    unsigned short infMetric;
93
    std::string myAddr;
94
    qosNeighMetric neig;
95
    rtTable table;
96
97
    entries2Next changes;
98
};
99
100
}
101
102
#endif /* SimpleDV_H_ */