RINASim  October 2016
Documentation of framework for OMNeT++
IntPDUFG.cc
Go to the documentation of this file.
1 // The MIT License (MIT)
2 //
3 // Copyright (c) 2014-2016 Brno University of Technology, PRISTINE project
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 
23 #include "IntPDUFG.h"
24 #include <vector>
25 
27 
29 
31  // Display active policy name.
33 
34  //Set Forwarding policy
35  fwd = getRINAModule<IntPDUForwarding *>(this, 2, {MOD_RELAYANDMUX, MOD_POL_RMT_PDUFWD});
36  onPolicyInit();
37 
38  ipcAddr = Address( getModuleByPath("^.^")->par("ipcAddress").stringValue(),
39  getModuleByPath("^.^")->par("difName").stringValue());
40 }
41 
42 PDUFGNeighbor * IntPDUFG::getNextNeighbor(const Address &destination, const std::string& qos){
43  EV << "Search for " << destination << " with QoS "<< qos << endl;
44  if(ipcAddr.getDifName().getName() != destination.getDifName().getName()) {
45  EV << "Invalid search at "<< ipcAddr << endl;
46  } else {
47  RMTPorts ports = fwd->lookup(destination, qos);
48  //TODO: Vesely : Changed tautological comparison from >=0 to >0
49  if(ports.size() > 0){
50  for(RMTPorts::iterator it = ports.begin(); it != ports.end(); it++){
51  RMTPort * p = (*it);
52  for(EIter it2 = neiState.begin(); it2 != neiState.end(); ++it2 ){
53  PDUFGNeighbor * e = (*it2);
54  // Found the port used for the forwarding table; so it's the next neighbor.
55  if(p == e->getPort()){
56  EV<< "Found "<< e->getDestAddr() << " -> "<< e->getPort()->getFullPath()<<endl;
57  return e;
58  }
59  }
60  }
61  }
62  EV<< "Not found"<<endl;
63  }
64  return nullptr;
65 
66 }
67 
69  EV << "New flow -> <" << addr << " , " << qos.getQosId() << "> at " << port->getFullPath()<<endl;
70 
71  //Insert Flow into neighbour state
72  neiState.push_back(new PDUFGNeighbor(addr, qos, port));
73 
74  // Inform child policy of changes
75  insertedFlow(addr, qos, port);
76 }
77 
79  for(EIter it = neiState.begin(); it != neiState.end(); ++it )
80  {
81  PDUFGNeighbor * e = (*it);
82  if(port == e->getPort()) {
83  Address addr = e->getDestAddr();
84  QoSCube& qos = e->getQoSCube();
85 
86  // Remove flow from neighbour state
87  neiState.erase(it);
88 
89  // Inform child policy of changes
90  removedFlow(addr, qos, port);
91  return;
92  }
93  }
94 }
const DAP & getDifName() const
Getter of common DIF name.
Definition: Address.cc:73
virtual void onPolicyInit()=0
virtual std::vector< RMTPort * > lookup(const PDU *pdu)=0
NeighborState neiState
Definition: IntPDUFG.h:67
IntPDUFG()
Definition: IntPDUFG.cc:26
Address & getDestAddr()
IntPDUForwarding * fwd
Definition: IntPDUFG.h:77
std::vector< RMTPort * > RMTPorts
Definition: RMTPort.h:234
virtual void removedFlow(const Address &addr, const QoSCube &qos, RMTPort *port)=0
QoSCube & getQoSCube()
void insertFlowInfo(Address addr, QoSCube qos, RMTPort *port)
Definition: IntPDUFG.cc:68
RMTPort * getPort()
~IntPDUFG()
Definition: IntPDUFG.cc:28
const char * MOD_RELAYANDMUX
Definition: ExternConsts.cc:57
virtual void insertedFlow(const Address &addr, const QoSCube &qos, RMTPort *port)=0
NeighborState::iterator EIter
Definition: IntPDUFG.h:35
const std::string & getName() const
Gets DAP string name representation.
Definition: DAP.cc:49
virtual PDUFGNeighbor * getNextNeighbor(const Address &destination, const std::string &qos)
Definition: IntPDUFG.cc:42
void setPolicyDisplayString(cModule *mod, const char *str)
Definition: Utils.cc:69
void removeFlowInfo(RMTPort *port)
Definition: IntPDUFG.cc:78
Class representing QoSCube with all its properties that is primarily used by FA, RMT and RA Specifica...
Definition: QoSCube.h:57
void initialize()
Definition: IntPDUFG.cc:30
std::string getQosId() const
Gets QoSCube identifier.
Definition: QoSCube.cc:364
Address ipcAddr
Definition: IntPDUFG.h:68
const char * MOD_POL_RMT_PDUFWD
Definition: ExternConsts.cc:73
Address class holds IPC Process identification.
Definition: Address.h:42