Moving Forwarding policies

Vladimir Vesely Vladimir Vesely 2015-02-02

removed src/DIF/RA/policies
removed src/DIF/RA/policies/Forwarding
removed src/DIF/RA/policies/Forwarding/DistanceVector
removed src/DIF/RA/policies/Forwarding/StaticRouting
removed src/DIF/RA/policies/Forwarding/IntPDUFTGPolicy.ned
removed src/DIF/RA/policies/Forwarding/PDUFTGPolicy.cc
removed src/DIF/RA/policies/Forwarding/PDUFTGPolicy.h
changed src/DIF/RA/ResourceAllocator.ned
changed .cproject
copied src/DIF/RA/policies/Forwarding/DistanceVector/DVPInfo.cc -> src/policies/DIF/RA/Forwarding/DistanceVector/DVPInfo.cc
copied src/DIF/RA/policies/Forwarding/DistanceVector/DVPInfo.h -> src/policies/DIF/RA/Forwarding/DistanceVector/DVPInfo.h
copied src/DIF/RA/policies/Forwarding/DistanceVector/DistanceVectorPolicy.cc -> src/policies/DIF/RA/Forwarding/DistanceVector/DistanceVectorPolicy.cc
copied src/DIF/RA/policies/Forwarding/DistanceVector/DistanceVectorPolicy.h -> src/policies/DIF/RA/Forwarding/DistanceVector/DistanceVectorPolicy.h
copied src/DIF/RA/policies/Forwarding/DistanceVector/DistanceVectorPolicy.ned -> src/policies/DIF/RA/Forwarding/DistanceVector/DistanceVectorPolicy.ned
copied src/DIF/RA/policies/Forwarding/StaticRouting/StaticRoutingPolicy.cc -> src/policies/DIF/RA/Forwarding/PDUFTGPolicy.h
copied src/DIF/RA/policies/Forwarding/StaticRouting/StaticRoutingPolicy.h -> src/policies/DIF/RA/Forwarding/PDUFTGPolicy.cc
copied src/DIF/RA/policies/Forwarding/StaticRouting/StaticRoutingPolicy.ned -> src/policies/DIF/RA/Forwarding/IntPDUFTGPolicy.ned
src/DIF/RA/policies
File was removed.
src/DIF/RA/policies/Forwarding
File was removed.
src/DIF/RA/ResourceAllocator.ned Diff Switch to side-by-side view
Loading...
.cproject Diff Switch to side-by-side view
Loading...
src/DIF/RA/policies/Forwarding/DistanceVector/DistanceVectorPolicy.ned to src/policies/DIF/RA/Forwarding/DistanceVector/DistanceVectorPolicy.ned
--- a/src/DIF/RA/policies/Forwarding/DistanceVector/DistanceVectorPolicy.ned
+++ b/src/policies/DIF/RA/Forwarding/DistanceVector/DistanceVectorPolicy.ned
@@ -15,9 +15,11 @@
 
 // Author: Kewin Rausch (kewin.rausch@create-net.org)
 
-package rina.DIF.RA.policies.Forwarding.DistanceVector;
+package rina.policies.DIF.RA.Forwarding.DistanceVector;
 
-simple DistanceVectorPolicy like rina.DIF.RA.policies.Forwarding.IntPDUFTGPolicy
+import rina.policies.DIF.RA.Forwarding.IntPDUFTGPolicy;
+
+simple DistanceVectorPolicy like IntPDUFTGPolicy
 {
     parameters:
         @display("i=block/socket");
src/DIF/RA/policies/Forwarding/StaticRouting/StaticRoutingPolicy.cc to src/policies/DIF/RA/Forwarding/PDUFTGPolicy.h
--- a/src/DIF/RA/policies/Forwarding/StaticRouting/StaticRoutingPolicy.cc
+++ b/src/policies/DIF/RA/Forwarding/PDUFTGPolicy.h
@@ -13,95 +13,56 @@
 // along with this program.  If not, see http://www.gnu.org/licenses/.
 //
 
-/* Author: Kewin Rausch (kewin.rausch@create-net.org) */
+// Author: Kewin Rausch (kewin.rausch@create-net.org)
 
-#include "StaticRoutingPolicy.h"
-#include "PDUFwdTabGenerator.h"
+#ifndef __RINA_PDUFTGPOLICY_H
+#define __RINA_PDUFTGPOLICY_H
+
+#include <omnetpp.h>
+
+#include "Flow.h"
+#include "RMTPort.h"
 #include "PDUFTGUpdate.h"
 
-Define_Module(StaticRoutingPolicy);
+// Forwarding declaration.
+class PDUFwdTabGenerator;
 
+// Provides a base class for every policy used in the PDUFTG module.
 //
-// Class constructor/destructors stuff.
-//
+class PDUFTGPolicy :
+        public cSimpleModule
+{
+private:
 
-StaticRoutingPolicy::StaticRoutingPolicy()
-{
-    // Do nothing...
-}
+protected:
+    PDUFwdTabGenerator * fwdtg;
 
-StaticRoutingPolicy::~StaticRoutingPolicy()
-{
-    // Do nothing...
-}
+    void handleMessage(cMessage *msg);
+    void initialize();
 
-//
-// Class procedures sorted by name.
-//
+public:
+    PDUFTGPolicy();
+    ~PDUFTGPolicy();
 
-void StaticRoutingPolicy::computeForwardingTable()
-{
-    NeighborState * m = fwdtg->getNeighborhoodState();
+    // Computes the initial state of the forwarding table.
+    //
+    virtual void computeForwardingTable();
 
-    for(EIter it = m->begin(); it != m->end(); ++it )
-    {
-        PDUFTGNeighbor * e = (*it);
+    // Evaluated in term of policy defined flow if a flow exists.
+    //
+    virtual PDUFTGInfo * flowExists(Address addr, unsigned short qos);
 
-        fwdtg->getForwardingTable()->insert(
-            e->getDestAddr(),
-            e->getQosId(),
-            e->getPort());
-    }
-}
+    // Insert a new flow which has been open locally to this IPC Process.
+    //
+    virtual void insertNewFlow(Address addr, unsigned short qos, RMTPort * port);
 
-void StaticRoutingPolicy::handleMessage(cMessage *msg)
-{
-    // Do nothing...
-}
+    // Merge an incoming information with the existing ones.
+    //
+    virtual void mergeForwardingInfo(PDUFTGUpdate * info);
 
-void StaticRoutingPolicy::initialize()
-{
-    PDUFTGPolicy::initialize();
+    // Removes a local opened flow.
+    //
+    virtual void removeFlow(Address addr, unsigned short qos);
+};
 
-    difA = check_and_cast<DA *>(
-        getModuleByPath("^.^.^.difAllocator.da"));
-}
-
-void StaticRoutingPolicy::insertNewFlow(Address addr, short unsigned int qos, RMTPort * port)
-{
-    // Direct insert the entry into the forwarding table.
-    fwdtg->getForwardingTable()->insert(addr, qos, port);
-
-    //
-    // Imported from RA to clean the code from policy oriented procedures.
-    // This little loop make possible for static routing APs to communicate
-    // with each other, using resolution with DA magic procedures.
-    //
-
-    const APNList* remoteApps = difA->findNeigborApns(addr.getApname());
-    NM1FlowTableItem * item = fwdtg->getNM1FlowTable()->findFlowByDstApni(
-        addr.getApname().getName(),
-        qos);
-
-    if (remoteApps)
-    {
-        for (ApnCItem it = remoteApps->begin(); it != remoteApps->end(); ++it)
-        {
-            Address addr = Address(it->getName());
-            fwdtg->getForwardingTable()->insert(
-                addr,
-                qos,
-                item->getRmtPort());
-        }
-    }
-}
-
-void StaticRoutingPolicy::mergeForwardingInfo(PDUFTGUpdate * info)
-{
-    // Do nothing...
-}
-
-void StaticRoutingPolicy::removeFlow(Address addr, short unsigned int qos)
-{
-    fwdtg->getForwardingTable()->remove(addr, qos);
-}
+#endif // __PDUFTGPOLICY_H
src/DIF/RA/policies/Forwarding/StaticRouting/StaticRoutingPolicy.h to src/policies/DIF/RA/Forwarding/PDUFTGPolicy.cc
--- a/src/DIF/RA/policies/Forwarding/StaticRouting/StaticRoutingPolicy.h
+++ b/src/policies/DIF/RA/Forwarding/PDUFTGPolicy.cc
@@ -13,53 +13,67 @@
 // along with this program.  If not, see http://www.gnu.org/licenses/.
 //
 
-// Author: Kewin Rausch (kewin.rausch@create-net.org)
+/* Author: Kewin Rausch (kewin.rausch@create-net.org) */
 
-#ifndef __RINA_STATICROUTINGPOLICY_H
-#define __RINA_STATICROUTINGPOLICY_H
+#include "PDUFTGPolicy.h"
+#include "PDUFwdTabGenerator.h"
 
-#include <omnetpp.h>
+Define_Module(PDUFTGPolicy);
 
-#include "DA.h"
-#include "PDUFTGPolicy.h"
+/*
+ * Class constructor/destructors stuff.
+ */
 
-// Static routing follows the operations already done by the first version of
-// rinasim, when no forwarding of information existed. It simply update the
-// Forwarding table during the flow creation.
-//
-// This policy does not apply any logic organization of the data received
-// because it assumes that everything has been already done in the definition
-// of the base data.
-//
-class StaticRoutingPolicy :
-        public PDUFTGPolicy
+PDUFTGPolicy::PDUFTGPolicy()
 {
-private:
-    DA * difA;
 
-protected:
-    void initialize();
-    void handleMessage(cMessage *msg);
+}
 
-public:
-    StaticRoutingPolicy();
-    ~StaticRoutingPolicy();
+PDUFTGPolicy::~PDUFTGPolicy()
+{
+    // Do nothing...
+}
 
-    // Computes the initial state of the forwarding table.
-    //
-    void computeForwardingTable();
+/*
+ * Class procedures sorted by name.
+ */
 
-    // Insert a new flow which has been open locally to this IPC Process.
-    //
-    void insertNewFlow(Address addr, short unsigned int qos, RMTPort * port);
+void PDUFTGPolicy::computeForwardingTable()
+{
+    // Do nothing...
+}
 
-    // Merge an incoming information with the existing ones.
-    //
-    void mergeForwardingInfo(PDUFTGUpdate * info);
+PDUFTGInfo * PDUFTGPolicy::flowExists(Address addr, unsigned short qos)
+{
+    return NULL;
+}
 
-    // Removes a local opened flow.
-    //
-    void removeFlow(Address addr, short unsigned int qos);
-};
+void PDUFTGPolicy::handleMessage(cMessage *msg)
+{
+    // Do nothing...
+}
 
-#endif // __RINA_STATICROUTINGPOLICY_H
+void PDUFTGPolicy::initialize()
+{
+    fwdtg = ModuleAccess<PDUFwdTabGenerator>("pduFwdTabGenerator").get();
+
+    // Display active policy name.
+    cDisplayString& disp = getDisplayString();
+    disp.setTagArg("t", 1, "t");
+    disp.setTagArg("t", 0, getClassName());
+}
+
+void PDUFTGPolicy::insertNewFlow(Address addr, short unsigned int qos, RMTPort * port)
+{
+    // Do nothing...
+}
+
+void PDUFTGPolicy::mergeForwardingInfo(PDUFTGUpdate * info)
+{
+    // Do nothing...
+}
+
+void PDUFTGPolicy::removeFlow(Address addr, unsigned short qos)
+{
+    // Do nothing...
+}
src/DIF/RA/policies/Forwarding/StaticRouting/StaticRoutingPolicy.ned to src/policies/DIF/RA/Forwarding/IntPDUFTGPolicy.ned
--- a/src/DIF/RA/policies/Forwarding/StaticRouting/StaticRoutingPolicy.ned
+++ b/src/policies/DIF/RA/Forwarding/IntPDUFTGPolicy.ned
@@ -15,9 +15,9 @@
 
 // Author: Kewin Rausch (kewin.rausch@create-net.org)
 
-package rina.DIF.RA.policies.Forwarding.StaticRouting;
+package rina.policies.DIF.RA.Forwarding;
 
-simple StaticRoutingPolicy like rina.DIF.RA.policies.Forwarding.IntPDUFTGPolicy
+moduleinterface IntPDUFTGPolicy
 {
     parameters:
         @display("i=block/socket");