a/src/Common/Flow.cc b/src/Common/Flow.cc
...
...
20
const int VAL_MAXCREATERETRIES = 3;
20
const int VAL_MAXCREATERETRIES = 3;
21
21
22
Register_Class(Flow);
22
Register_Class(Flow);
23
23
24
Flow::Flow() :
24
Flow::Flow() :
25
    srcApni(APNamingInfo()), dstApni(APNamingInfo()),
26
    srcPortId(VAL_UNDEF_PORTADDR), dstPortId(VAL_UNDEF_PORTADDR),
27
    srcAddr(Address()), dstAddr(Address()),
28
    srcNeighbor(Address()), dstNeighbor(Address()),
29
    conId(ConnectionId()),
30
    createFlowRetries(0), maxCreateFlowRetries(VAL_MAXCREATERETRIES), hopCount(VAL_MAXHOPCOUNT) {
31
}
32
33
Flow::Flow(APNamingInfo src, APNamingInfo dst) :
34
        srcApni(src), dstApni(dst),
25
        srcPortId(VAL_UNDEF_PORTADDR), dstPortId(VAL_UNDEF_PORTADDR),
35
        srcPortId(VAL_UNDEF_PORTADDR), dstPortId(VAL_UNDEF_PORTADDR),
26
        srcAddr(Address()), dstAddr(Address()),
36
        srcAddr(Address()), dstAddr(Address()),
37
        srcNeighbor(Address()), dstNeighbor(Address()),
38
        conId(ConnectionId()),
27
        createFlowRetries(0), maxCreateFlowRetries(VAL_MAXCREATERETRIES), hopCount(VAL_MAXHOPCOUNT) {
39
        createFlowRetries(0), maxCreateFlowRetries(VAL_MAXCREATERETRIES), hopCount(VAL_MAXHOPCOUNT)
28
}
40
{
29
30
Flow::Flow(APNamingInfo src, APNamingInfo dst) :
31
        srcPortId(VAL_UNDEF_PORTADDR), dstPortId(VAL_UNDEF_PORTADDR),
32
        srcAddr(Address()), dstAddr(Address()),
33
        createFlowRetries(0), maxCreateFlowRetries(VAL_MAXCREATERETRIES), hopCount(VAL_MAXHOPCOUNT) {
34
    this->srcApni = src;
35
    this->dstApni = dst;
36
}
41
}
37
42
38
Flow::~Flow() {
43
Flow::~Flow() {
44
    this->srcApni = APNamingInfo();
45
    this->dstApni = APNamingInfo();
39
    this->srcPortId = VAL_UNDEF_PORTADDR;
46
    this->srcPortId = VAL_UNDEF_PORTADDR;
40
    this->dstPortId = VAL_UNDEF_PORTADDR;
47
    this->dstPortId = VAL_UNDEF_PORTADDR;
41
    this->srcAddr = Address();
48
    this->srcAddr = Address();
42
    this->dstAddr = Address();
49
    this->dstAddr = Address();
43
    this->createFlowRetries = 0;
50
    this->createFlowRetries = 0;
44
    this->maxCreateFlowRetries = 0;
51
    this->maxCreateFlowRetries = 0;
45
    this->hopCount = 0;
52
    this->hopCount = 0;
53
    srcNeighbor = Address();
54
    dstNeighbor = Address();
46
}
55
}
47
56
48
//Free function
57
//Free function
49
bool Flow::operator ==(const Flow& other) {
58
bool Flow::operator ==(const Flow& other) const {
50
    return (srcApni == other.srcApni && dstApni == other.dstApni &&
59
    return (srcApni == other.srcApni && dstApni == other.dstApni &&
51
            srcPortId == other.srcPortId && dstPortId == other.dstPortId &&
60
            srcPortId == other.srcPortId && dstPortId == other.dstPortId &&
52
            srcAddr == other.srcAddr && dstAddr == other.dstAddr);
61
            srcAddr == other.srcAddr && dstAddr == other.dstAddr &&
62
            conId == other.conId);
53
}
63
}
54
64
55
ConnectionId& Flow::getConId() {
65
const ConnectionId& Flow::getConId() const {
56
    return conId;
66
    return conId;
57
}
67
}
58
68
59
void Flow::setConId(const ConnectionId& conId) {
69
void Flow::setConId(const ConnectionId& conId) {
60
    this->conId = conId;
70
    this->conId = conId;
...
...
136
    return qosParameters;
146
    return qosParameters;
137
}
147
}
138
148
139
Flow* Flow::dup() const {
149
Flow* Flow::dup() const {
140
    Flow* flow = new Flow();
150
    Flow* flow = new Flow();
141
    flow->setQosParameters(this->getQosParameters());
142
    flow->setSrcApni(this->getSrcApni());
151
    flow->setSrcApni(this->getSrcApni());
143
    flow->setDstApni(this->getDstApni());
152
    flow->setDstApni(this->getDstApni());
153
    flow->setSrcAddr(this->getSrcAddr());
154
    flow->setDstAddr(this->getDstAddr());
155
    flow->setSrcPortId(this->getSrcPortId());
156
    flow->setDstPortId(this->getDstPortId());
157
    flow->setConId(this->getConId());
158
    flow->setMaxCreateFlowRetries(this->getMaxCreateFlowRetries());
159
    flow->setHopCount(this->getHopCount());
160
    flow->setCreateFlowRetries(this->getCreateFlowRetries());
161
    flow->setQosParameters(this->getQosParameters());
162
144
    return flow;
163
    return flow;
164
}
165
166
std::string Flow::getFlowName() const {
167
    std::stringstream os;
168
    os << srcApni << "<=>" << dstApni;
169
    return os.str();
170
}
171
172
ConnectionId& Flow::getConnectionId() {
173
    return conId;
174
}
175
176
void Flow::swapPortIds() {
177
    int tmp = srcPortId;
178
    srcPortId = dstPortId;
179
    dstPortId = tmp;
180
}
181
182
void Flow::swapAddresses() {
183
    Address tmpa = srcAddr;
184
    srcAddr = dstAddr;
185
    dstAddr = tmpa;
186
}
187
188
void Flow::swapCepIds() {
189
    conId = conId.swapCepIds();
190
}
191
192
std::string Flow::infoSource() const {
193
    std::stringstream os;
194
    os << "SRC> " << srcApni
195
       << "\n   address:  " << srcAddr
196
       << "\n   neighbor: " << srcNeighbor
197
       << "\n   port: " << srcPortId
198
       << "\n   cep: " << conId.getSrcCepId();
199
    return os.str();
200
}
201
202
std::string Flow::infoDestination() const {
203
    std::stringstream os;
204
    os << "DST> " << dstApni
205
       << "\n   address:  " << dstAddr
206
       << "\n   neighbor: " << dstNeighbor
207
       << "\n   port: " << dstPortId
208
       << "\n   cep: " << conId.getDstCepId();
209
    return os.str();
210
}
211
212
std::string Flow::infoOther() const {
213
    std::stringstream os;
214
    os << "Hop Count: " << hopCount << endl
215
       << "Retries: " << createFlowRetries << "/" << maxCreateFlowRetries;
216
    return os.str();
217
}
218
219
std::string Flow::infoQoS() const {
220
    std::stringstream os;
221
    os << "Chosen RA's QoS cube>" << conId.getQoSId();
222
    //os << qosParameters.info();
223
    return os.str();
224
}
225
226
void Flow::swapApni() {
227
    APNamingInfo tmpapni = srcApni;
228
    srcApni = dstApni;
229
    dstApni = tmpapni;
230
}
231
232
Flow& Flow::swapFlow() {
233
    swapApni();
234
235
    swapAddresses();
236
237
    swapPortIds();
238
239
    swapCepIds();
240
241
    return *this;
145
}
242
}
146
243
147
void Flow::setQosParameters(const QosCube& qosParameters) {
244
void Flow::setQosParameters(const QosCube& qosParameters) {
148
    this->qosParameters = qosParameters;
245
    this->qosParameters = qosParameters;
149
}
246
}
150
247
151
std::string Flow::info() const {
248
std::string Flow::info() const {
152
    std::stringstream os;
249
    std::stringstream os;
153
    os << "SRC>\t" << srcApni <<  "\tport: " << srcPortId << "\taddr: " << srcAddr << "\tcep:" << conId.getSrcCepId() << endl
250
    os << infoSource() << endl;
154
       << "DST>\t" << dstApni <<  "\tport: " << dstPortId << "\taddr: " << dstAddr << "\tcep:" << conId.getDstCepId() << endl
251
    os << infoDestination() << endl;
155
       << "Hop Count: " << hopCount << endl
252
    os << infoOther() << endl;
156
       << "Retries: " << createFlowRetries << "/" << maxCreateFlowRetries << endl
253
    os << infoQoS() << endl;
157
       <<  qosParameters;
158
    return os.str();
254
    return os.str();
159
}
255
}
160
256
161
std::ostream& operator<< (std::ostream& os, const Flow& fl) {
257
std::ostream& operator<< (std::ostream& os, const Flow& fl) {
162
    return os << fl.info();
258
    return os << fl.info();
163
}
259
}
164
260
261
const Address& Flow::getDstNeighbor() const {
262
    return dstNeighbor;
263
}
264
265
void Flow::setDstNeighbor(const Address& dstNeighbor) {
266
    this->dstNeighbor = dstNeighbor;
267
}
268
269
const Address& Flow::getSrcNeighbor() const {
270
    return srcNeighbor;
271
}
272
273
void Flow::setSrcNeighbor(const Address& srcNeighbor) {
274
    this->srcNeighbor = srcNeighbor;
275
}