--- a/src/Common/Flow.cc
+++ b/src/Common/Flow.cc
@@ -22,20 +22,27 @@
Register_Class(Flow);
Flow::Flow() :
+ srcApni(APNamingInfo()), dstApni(APNamingInfo()),
+ srcPortId(VAL_UNDEF_PORTADDR), dstPortId(VAL_UNDEF_PORTADDR),
+ srcAddr(Address()), dstAddr(Address()),
+ srcNeighbor(Address()), dstNeighbor(Address()),
+ conId(ConnectionId()),
+ createFlowRetries(0), maxCreateFlowRetries(VAL_MAXCREATERETRIES), hopCount(VAL_MAXHOPCOUNT) {
+}
+
+Flow::Flow(APNamingInfo src, APNamingInfo dst) :
+ srcApni(src), dstApni(dst),
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;
+ srcNeighbor(Address()), dstNeighbor(Address()),
+ conId(ConnectionId()),
+ createFlowRetries(0), maxCreateFlowRetries(VAL_MAXCREATERETRIES), hopCount(VAL_MAXHOPCOUNT)
+{
}
Flow::~Flow() {
+ this->srcApni = APNamingInfo();
+ this->dstApni = APNamingInfo();
this->srcPortId = VAL_UNDEF_PORTADDR;
this->dstPortId = VAL_UNDEF_PORTADDR;
this->srcAddr = Address();
@@ -43,16 +50,19 @@
this->createFlowRetries = 0;
this->maxCreateFlowRetries = 0;
this->hopCount = 0;
+ srcNeighbor = Address();
+ dstNeighbor = Address();
}
//Free function
-bool Flow::operator ==(const Flow& other) {
+bool Flow::operator ==(const Flow& other) const {
return (srcApni == other.srcApni && dstApni == other.dstApni &&
srcPortId == other.srcPortId && dstPortId == other.dstPortId &&
- srcAddr == other.srcAddr && dstAddr == other.dstAddr);
-}
-
-ConnectionId& Flow::getConId() {
+ srcAddr == other.srcAddr && dstAddr == other.dstAddr &&
+ conId == other.conId);
+}
+
+const ConnectionId& Flow::getConId() const {
return conId;
}
@@ -138,10 +148,97 @@
Flow* Flow::dup() const {
Flow* flow = new Flow();
- flow->setQosParameters(this->getQosParameters());
flow->setSrcApni(this->getSrcApni());
flow->setDstApni(this->getDstApni());
+ flow->setSrcAddr(this->getSrcAddr());
+ flow->setDstAddr(this->getDstAddr());
+ flow->setSrcPortId(this->getSrcPortId());
+ flow->setDstPortId(this->getDstPortId());
+ flow->setConId(this->getConId());
+ flow->setMaxCreateFlowRetries(this->getMaxCreateFlowRetries());
+ flow->setHopCount(this->getHopCount());
+ flow->setCreateFlowRetries(this->getCreateFlowRetries());
+ flow->setQosParameters(this->getQosParameters());
+
return flow;
+}
+
+std::string Flow::getFlowName() const {
+ std::stringstream os;
+ os << srcApni << "<=>" << dstApni;
+ return os.str();
+}
+
+ConnectionId& Flow::getConnectionId() {
+ return conId;
+}
+
+void Flow::swapPortIds() {
+ int tmp = srcPortId;
+ srcPortId = dstPortId;
+ dstPortId = tmp;
+}
+
+void Flow::swapAddresses() {
+ Address tmpa = srcAddr;
+ srcAddr = dstAddr;
+ dstAddr = tmpa;
+}
+
+void Flow::swapCepIds() {
+ conId = conId.swapCepIds();
+}
+
+std::string Flow::infoSource() const {
+ std::stringstream os;
+ os << "SRC> " << srcApni
+ << "\n address: " << srcAddr
+ << "\n neighbor: " << srcNeighbor
+ << "\n port: " << srcPortId
+ << "\n cep: " << conId.getSrcCepId();
+ return os.str();
+}
+
+std::string Flow::infoDestination() const {
+ std::stringstream os;
+ os << "DST> " << dstApni
+ << "\n address: " << dstAddr
+ << "\n neighbor: " << dstNeighbor
+ << "\n port: " << dstPortId
+ << "\n cep: " << conId.getDstCepId();
+ return os.str();
+}
+
+std::string Flow::infoOther() const {
+ std::stringstream os;
+ os << "Hop Count: " << hopCount << endl
+ << "Retries: " << createFlowRetries << "/" << maxCreateFlowRetries;
+ return os.str();
+}
+
+std::string Flow::infoQoS() const {
+ std::stringstream os;
+ os << "Chosen RA's QoS cube>" << conId.getQoSId();
+ //os << qosParameters.info();
+ return os.str();
+}
+
+void Flow::swapApni() {
+ APNamingInfo tmpapni = srcApni;
+ srcApni = dstApni;
+ dstApni = tmpapni;
+}
+
+Flow& Flow::swapFlow() {
+ swapApni();
+
+ swapAddresses();
+
+ swapPortIds();
+
+ swapCepIds();
+
+ return *this;
}
void Flow::setQosParameters(const QosCube& qosParameters) {
@@ -150,11 +247,10 @@
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;
+ os << infoSource() << endl;
+ os << infoDestination() << endl;
+ os << infoOther() << endl;
+ os << infoQoS() << endl;
return os.str();
}
@@ -162,3 +258,18 @@
return os << fl.info();
}
+const Address& Flow::getDstNeighbor() const {
+ return dstNeighbor;
+}
+
+void Flow::setDstNeighbor(const Address& dstNeighbor) {
+ this->dstNeighbor = dstNeighbor;
+}
+
+const Address& Flow::getSrcNeighbor() const {
+ return srcNeighbor;
+}
+
+void Flow::setSrcNeighbor(const Address& srcNeighbor) {
+ this->srcNeighbor = srcNeighbor;
+}