Download this file

PDUForwardingTable.cc    126 lines (109 with data), 3.2 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
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
/**
* @file PDUForwardingTable.cc
* @author Tomas Hykel (xhykel01@stud.fit.vutbr.cz)
* @brief PDU forwarding (routing) table used by RMT relay.
* @detail
*/
#include "PDUForwardingTable.h"
Define_Module(PDUForwardingTable);
void PDUForwardingTable::initialize()
{
WATCH_LIST(fwTable);
}
PDUForwardingTable::PDUForwardingTable()
{
}
void PDUForwardingTable::handleMessage(cMessage *msg)
{
}
/**
* Dumps the contents of the forwarding table to OMNeT++ output console.
*
*/
void PDUForwardingTable::printAll()
{
// EV << this->getFullPath() << " Printing the whole forwarding table: " << endl;
//
// for(PDUFwTable::iterator it = this->FwTable.begin(); it!= FwTable.end(); ++it)
// {
// PDUTableEntry a = *it;
// EV << this->getFullPath() << " destination: " << a.getDestAddr()
// << "; QoS ID: " << a.getQosId() << "; port-id: " << a.getPortId() << endl;
// }
}
/**
* Looks up a port-id to be used for given address and Qos-id.
*
* @param destAddr destination IPC process address
* @param QoSid QoS-id
* @return port-id
*/
RMTQueue* PDUForwardingTable::lookup(Address& destAddr, int QoSid)
{
for(PDUFwIter it = fwTable.begin(); it != fwTable.end(); ++it )
{
PDUTableEntry a = *it;
// can't compare DIF names at this moment
if ((a.getDestAddr().getApname() == destAddr.getApname()) && ((a.getQosId() == QoSid) || QoSid == -1))
{
return a.getQueueId();
}
}
return NULL;
}
/**
* Inserts a prepared forwarding table entry into the table.
*
* @param entry table entry to be inserted
*/
void PDUForwardingTable::insert(const PDUTableEntry* entry)
{
Enter_Method("insert()");
fwTable.push_back(*entry);
}
/**
* Constructs a new forwarding table entry and adds it into the table.
*
* @param destAddr destination IPC process address
* @param qosId flow QoS ID
*/
void PDUForwardingTable::insert(Address destAddr, int qosId, RMTQueue* queue)
{
Enter_Method("insert()");
PDUTableEntry entry = PDUTableEntry(destAddr, qosId, queue);
fwTable.push_back(entry);
}
/**
* Removes entries with matching port-id from the forwarding table.
*
* @param portId target port-id
*/
void PDUForwardingTable::remove(RMTQueue* portId)
{
PDUFwIter i = fwTable.begin();
while (i != fwTable.end())
{
if (i->getQueueId() == portId)
{
i = fwTable.erase(i);
}
else
{
++i;
}
}
}