Child: [65cd22] (diff)

Download this file

Flow.cc    165 lines (131 with data), 4.4 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//
// 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/.
//
#include "Flow.h"
const int VAL_UNDEF_PORTADDR = -1;
const int VAL_MAXHOPCOUNT = 16;
const int VAL_MAXCREATERETRIES = 3;
Register_Class(Flow);
Flow::Flow() :
srcPortId(VAL_UNDEF_PORTADDR), dstPortId(VAL_UNDEF_PORTADDR),
srcAddr(Address()), dstAddr(Address()),
createFlowRetries(0), maxCreateFlowRetries(VAL_MAXCREATERETRIES), hopCount(VAL_MAXHOPCOUNT) {
}
Flow::Flow(APNamingInfo src, APNamingInfo dst) :
srcPortId(VAL_UNDEF_PORTADDR), dstPortId(VAL_UNDEF_PORTADDR),
srcAddr(Address()), dstAddr(Address()),
createFlowRetries(0), maxCreateFlowRetries(VAL_MAXCREATERETRIES), hopCount(VAL_MAXHOPCOUNT) {
this->srcApni = src;
this->dstApni = dst;
}
Flow::~Flow() {
this->srcPortId = VAL_UNDEF_PORTADDR;
this->dstPortId = VAL_UNDEF_PORTADDR;
this->srcAddr = Address();
this->dstAddr = Address();
this->createFlowRetries = 0;
this->maxCreateFlowRetries = 0;
this->hopCount = 0;
}
//Free function
bool Flow::operator ==(const Flow& other) {
return (srcApni == other.srcApni && dstApni == other.dstApni &&
srcPortId == other.srcPortId && dstPortId == other.dstPortId &&
srcAddr == other.srcAddr && dstAddr == other.dstAddr);
}
ConnectionId& Flow::getConId() {
return conId;
}
void Flow::setConId(const ConnectionId& conId) {
this->conId = conId;
}
uint32_t Flow::getCreateFlowRetries() const {
return createFlowRetries;
}
void Flow::setCreateFlowRetries(uint32_t createFlowRetries) {
this->createFlowRetries = createFlowRetries;
}
const APNamingInfo& Flow::getDstApni() const {
return dstApni;
}
void Flow::setDstApni(const APNamingInfo& dstApni) {
this->dstApni = dstApni;
}
int Flow::getDstPortId() const {
return dstPortId;
}
void Flow::setDstPortId(int dstPortId) {
this->dstPortId = dstPortId;
}
uint32_t Flow::getHopCount() const {
return hopCount;
}
void Flow::setHopCount(uint32_t hopCount) {
this->hopCount = hopCount;
}
uint32_t Flow::getMaxCreateFlowRetries() const {
return maxCreateFlowRetries;
}
void Flow::setMaxCreateFlowRetries(uint32_t maxCreateFlowRetries) {
this->maxCreateFlowRetries = maxCreateFlowRetries;
}
const APNamingInfo& Flow::getSrcApni() const {
return srcApni;
}
void Flow::setSrcApni(const APNamingInfo& srcApni) {
this->srcApni = srcApni;
}
int Flow::getSrcPortId() const {
return srcPortId;
}
void Flow::setSrcPortId(int srcPortId) {
this->srcPortId = srcPortId;
}
const Address& Flow::getDstAddr() const {
return dstAddr;
}
void Flow::setDstAddr(const Address& dstAddr) {
this->dstAddr = dstAddr;
}
const Address& Flow::getSrcAddr() const {
return srcAddr;
}
void Flow::setSrcAddr(const Address& srcAddr) {
this->srcAddr = srcAddr;
}
const QosCube& Flow::getQosParameters() const {
return qosParameters;
}
Flow* Flow::dup() const {
Flow* flow = new Flow();
flow->setQosParameters(this->getQosParameters());
flow->setSrcApni(this->getSrcApni());
flow->setDstApni(this->getDstApni());
return flow;
}
void Flow::setQosParameters(const QosCube& qosParameters) {
this->qosParameters = qosParameters;
}
std::string Flow::info() const {
std::stringstream os;
os << "SRC>\t" << srcApni << "\tport: " << srcPortId << "\taddr: " << srcAddr << "\tcep:" << conId.getSrcCepId() << endl
<< "DST>\t" << dstApni << "\tport: " << dstPortId << "\taddr: " << dstAddr << "\tcep:" << conId.getDstCepId() << endl
<< "Hop Count: " << hopCount << endl
<< "Retries: " << createFlowRetries << "/" << maxCreateFlowRetries << endl
<< qosParameters;
return os.str();
}
std::ostream& operator<< (std::ostream& os, const Flow& fl) {
return os << fl.info();
}