Switch to unified view

a b/src/policies/DIF/RA/PDUFG/IntPDUFG.cc
1
#include "IntPDUFG.h"
2
#include <vector>
3
4
IntPDUFG::IntPDUFG(){}
5
6
IntPDUFG::~ IntPDUFG(){}
7
8
void IntPDUFG::initialize(){
9
    // Display active policy name.
10
    cDisplayString& disp = getDisplayString();
11
    disp.setTagArg("t", 1, "t");
12
    disp.setTagArg("t", 0, getClassName());
13
14
    //Set Forwarding policy
15
    fwd = check_and_cast<IntPDUForwarding *>
16
        (getModuleByPath("^.^.relayAndMux.pduForwardingPolicy"));
17
    onPolicyInit();
18
}
19
20
PDUFGNeighbor * IntPDUFG::getNextNeighbor(const Address &destination, const unsigned short &qos){
21
22
    std::vector<RMTPort *> ports = fwd->lookup(destination, qos);
23
    if(ports.size() >= 0){
24
        for(std::vector<RMTPort *>::iterator it = ports.begin(); it != ports.end(); it++){
25
            RMTPort * p = (*it);
26
            for(EIter it2 = neiState.begin(); it2 != neiState.end(); ++it2 ){
27
                PDUFGNeighbor * e = (*it2);
28
                // Found the port used for the forwarding table; so it's the next neighbor.
29
                if(p == e->getPort()){
30
                        return e;
31
                }
32
            }
33
        }
34
    }
35
36
    return NULL;
37
}
38
39
void IntPDUFG::insertFlowInfo(Address addr, unsigned short qos, RMTPort * port) {
40
    EV << "New flow -> <" << addr << " , " << qos << "> at " << port->getFullName()<<endl;
41
42
    //Insert Flow into neighbour state
43
    neiState.push_back(new PDUFGNeighbor(addr, qos, port));
44
45
    // Inform child policy of changes
46
    insertedFlow(addr, qos, port);
47
}
48
49
void IntPDUFG::removeFlowInfo(RMTPort * port)
50
{
51
    for(EIter it = neiState.begin(); it != neiState.end(); ++it )
52
    {
53
        PDUFGNeighbor * e = (*it);
54
        if(port == e->getPort()) {
55
            Address addr = e->getDestAddr();
56
            unsigned short qos = e->getQosId();
57
            // Remove flow from neighbour state
58
            neiState.erase(it);
59
60
            // Inform child policy of changes
61
            removedFlow(addr, qos, port);
62
            return;
63
        }
64
    }
65
}