Download this file

IntPDUFG.cc    66 lines (53 with data), 2.0 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
#include "IntPDUFG.h"
#include <vector>
IntPDUFG::IntPDUFG(){}
IntPDUFG::~ IntPDUFG(){}
void IntPDUFG::initialize(){
// Display active policy name.
cDisplayString& disp = getDisplayString();
disp.setTagArg("t", 1, "t");
disp.setTagArg("t", 0, getClassName());
//Set Forwarding policy
fwd = check_and_cast<IntPDUForwarding *>
(getModuleByPath("^.^.relayAndMux.pduForwardingPolicy"));
onPolicyInit();
}
PDUFGNeighbor * IntPDUFG::getNextNeighbor(const Address &destination, const unsigned short &qos){
std::vector<RMTPort *> ports = fwd->lookup(destination, qos);
if(ports.size() >= 0){
for(std::vector<RMTPort *>::iterator it = ports.begin(); it != ports.end(); it++){
RMTPort * p = (*it);
for(EIter it2 = neiState.begin(); it2 != neiState.end(); ++it2 ){
PDUFGNeighbor * e = (*it2);
// Found the port used for the forwarding table; so it's the next neighbor.
if(p == e->getPort()){
return e;
}
}
}
}
return NULL;
}
void IntPDUFG::insertFlowInfo(Address addr, unsigned short qos, RMTPort * port) {
EV << "New flow -> <" << addr << " , " << qos << "> at " << port->getFullName()<<endl;
//Insert Flow into neighbour state
neiState.push_back(new PDUFGNeighbor(addr, qos, port));
// Inform child policy of changes
insertedFlow(addr, qos, port);
}
void IntPDUFG::removeFlowInfo(RMTPort * port)
{
for(EIter it = neiState.begin(); it != neiState.end(); ++it )
{
PDUFGNeighbor * e = (*it);
if(port == e->getPort()) {
Address addr = e->getDestAddr();
unsigned short qos = e->getQosId();
// Remove flow from neighbour state
neiState.erase(it);
// Inform child policy of changes
removedFlow(addr, qos, port);
return;
}
}
}