|
a |
|
b/src/policies/DIF/Routing/DomainRouting/DV/DV.h |
|
|
1 |
/*
|
|
|
2 |
* DV.h
|
|
|
3 |
*
|
|
|
4 |
* Created on: Mar 23, 2015
|
|
|
5 |
* Author: gaixas1
|
|
|
6 |
*/
|
|
|
7 |
|
|
|
8 |
#ifndef DV_H_
|
|
|
9 |
#define DV_H_
|
|
|
10 |
|
|
|
11 |
#include <DomainRouting/rModule.h>
|
|
|
12 |
|
|
|
13 |
namespace DMRnmsDV {
|
|
|
14 |
|
|
|
15 |
using namespace DMRnms;
|
|
|
16 |
|
|
|
17 |
///////////////////////////////////////////////////////////////////////
|
|
|
18 |
// Data structures
|
|
|
19 |
|
|
|
20 |
struct rtEntry {
|
|
|
21 |
std::string addr;
|
|
|
22 |
unsigned short metric;
|
|
|
23 |
rtEntry()
|
|
|
24 |
:addr(""), metric(UINT16_MAX){}
|
|
|
25 |
rtEntry(const std::string &_addr, const unsigned short &_metric)
|
|
|
26 |
:addr(_addr), metric(_metric){}
|
|
|
27 |
};
|
|
|
28 |
typedef std::vector<rtEntry> entriesL;
|
|
|
29 |
typedef std::vector<rtEntry>::iterator entriesIt;
|
|
|
30 |
|
|
|
31 |
typedef std::map<Address, unsigned short> neighMetric;
|
|
|
32 |
typedef neighMetric::iterator neighMetricIt;
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
struct tEntry {
|
|
|
36 |
Address addr;
|
|
|
37 |
unsigned short metric;
|
|
|
38 |
tEntry()
|
|
|
39 |
:addr(""), metric(UINT16_MAX){}
|
|
|
40 |
tEntry(const std::string &_addr, const unsigned short &_metric)
|
|
|
41 |
:addr(_addr), metric(_metric){}
|
|
|
42 |
};
|
|
|
43 |
typedef std::map<std::string, tEntry> tTable;
|
|
|
44 |
typedef tTable::iterator tTableIt;
|
|
|
45 |
|
|
|
46 |
typedef std::set<std::string> sSet;
|
|
|
47 |
typedef sSet::iterator sSetIt;
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
///////////////////////////////////////////////////////////////////////
|
|
|
52 |
// Update Message
|
|
|
53 |
|
|
|
54 |
class DVUpdate : public RoutingUpdate {
|
|
|
55 |
public:
|
|
|
56 |
DVUpdate(const Address &_addr, const std::string &_domain);
|
|
|
57 |
|
|
|
58 |
void addEntry(rtEntry _e);
|
|
|
59 |
|
|
|
60 |
entriesIt entriesBegin();
|
|
|
61 |
entriesIt entriesEnd();
|
|
|
62 |
|
|
|
63 |
protected:
|
|
|
64 |
entriesL entries;
|
|
|
65 |
};
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
///////////////////////////////////////////////////////////////////////
|
|
|
70 |
// Routing Module
|
|
|
71 |
|
|
|
72 |
class DomainRouting;
|
|
|
73 |
|
|
|
74 |
class DV: public rModule {
|
|
|
75 |
public:
|
|
|
76 |
DV(Routing * parent, const Address &_nAddr,const std::string &_domain, const std::string &_addr);
|
|
|
77 |
|
|
|
78 |
bool processUpdate(RoutingUpdate * update);
|
|
|
79 |
void addFlow(const Address &_nAddr, const std::string &_addr, const unsigned short &_metric);
|
|
|
80 |
void removeFlow(const Address &_nAddr, const std::string &_addr);
|
|
|
81 |
|
|
|
82 |
void addAddr(const std::string &_addr);
|
|
|
83 |
void removeAddr(const std::string &_addr);
|
|
|
84 |
|
|
|
85 |
void setInfMetric(const unsigned short &inf);
|
|
|
86 |
|
|
|
87 |
dmNxt getChanges();
|
|
|
88 |
dmNxt getAll();
|
|
|
89 |
|
|
|
90 |
void handleMessage(cMessage *msg);
|
|
|
91 |
|
|
|
92 |
protected:
|
|
|
93 |
tTable table;
|
|
|
94 |
neighMetric nei;
|
|
|
95 |
unsigned short infMetric;
|
|
|
96 |
s2A changes;
|
|
|
97 |
sSet changedEntries;
|
|
|
98 |
sSet myAddrSet;
|
|
|
99 |
|
|
|
100 |
bool scheduledUpdate;
|
|
|
101 |
void scheduleUpdate();
|
|
|
102 |
};
|
|
|
103 |
|
|
|
104 |
} /* namespace DomainRoutingDV */
|
|
|
105 |
|
|
|
106 |
#endif /* DV_H_ */
|