Download this file

MiniTable.cc    71 lines (53 with data), 1.6 kB

 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
62
63
64
65
66
67
68
69
70
#include <MiniTable/MiniTable.h>
Register_Class(MiniTable::MiniTable);
namespace MiniTable {
using namespace std;
#include <sstream>
// Lookup function, return a list of RMTPorts to forward a PDU/Address+qos.
vector<RMTPort * > MiniTable::lookup(const PDU * pdu){
return lookup(pdu->getDstAddr(), pdu->getConnId().getQoSId());
}
vector<RMTPort * > MiniTable::lookup(const Address &dst, const unsigned short &qos){
vector<RMTPort* > ret;
string dstAddr = dst.getIpcAddress().getName();
FWDTableIt it = table.find(dstAddr);
if(it != table.end()){
ret.push_back(it->second);
EV << "MT Found => "<<dst<<endl;
} else {
EV << "MT NOT Found => "<<dst<<endl;
EV << toString() << endl;
}
return ret;
}
// Returns a representation of the Forwarding Knowledge
string MiniTable::toString(){
std::ostringstream os;
os << this->getName()<<endl;
for(FWDTableIt tIt = table.begin(); tIt != table.end(); tIt++){
os << "\t" <<tIt->first << " -> " <<tIt->second->getFullPath() << endl;
}
return os.str();
}
//Insert/Remove an entry
void MiniTable::insert(const Address &addr, RMTPort * port){
insert(addr.getIpcAddress().getName(), port);
}
void MiniTable::remove(const Address &addr){
remove(addr.getIpcAddress().getName());
}
void MiniTable::insert(const string &addr, RMTPort * port){
table[addr] = port;
}
void MiniTable::remove(const string &addr){
table.erase(addr);
}
void MiniTable::clean(){
table.clear();
}
// Called after initialize
void MiniTable::onPolicyInit(){}
void MiniTable::finish(){
// EV << toString() <<endl;
}
}