Dear Michael and PATS,

This is fantastic!! Thank you so much for making this available. And I love, love, love to see new Git repositories :)

Attached are two patches for the AODV elements to bring them up to date with mainline. The first uses cp_va_kparse; the second switches Timestamp in for timeval. I hope they are useful.

Any chance we can format these as a package? What would be the best way to get them used?

Eddie


Michael Voorhaen wrote:
Dear all,

It is our pleasure to announce to you that we have released of our AODV and OLSR 
implementations for Click Modular Router at <http://github.com/patsgit>.

The OLSR implementation was written for Click 1.5 and the AODV implementation 
for Click 1.6. However, we have decided to release them in a tree that contains 
the current Click git release. Our two trees are actually git forks of the 
Click git repository. Currently things compile with --enable-aodv or 
--enable-olsr, however some work is needed to improve compatibility with the 
click-git. e.g. in the OLSR implementation there are still some calls to 
deprecated classes and functions.

Be sure to read the README files, they contain valuable information on known 
bugs. We welcome any patches, hoping this can improve the quality of our 
implementations and help the community.

We have chosen to release this code as is. The code is often maintained by 
different people in our group, who find use for it in their projects. To allow 
others to use and improve this code we have made it available through github. 
We are hoping that fixes and improvements flow back to the main branch through 
the community.

Best regards,
the PATS research group









_______________________________________________
click mailing list
[email protected]
https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>From 2e0e0fe51aa976c22715c378b412ee809030fee9 Mon Sep 17 00:00:00 2001
From: Eddie Kohler <[email protected]>
Date: Tue, 1 Dec 2009 16:54:37 -0800
Subject: [PATCH 1/2] AODV elements: Use cp_va_kparse instead of cp_va_parse.

As well, update the documentation (minimally) to list keywords.
---
 elements/aodv/aodv_destinationclassifier.cc   |    9 +++------
 elements/aodv/aodv_destinationclassifier.hh   |    2 +-
 elements/aodv/aodv_generatererr.cc            |   10 +++-------
 elements/aodv/aodv_generatererr.hh            |    2 +-
 elements/aodv/aodv_generaterrep.cc            |   18 ++++--------------
 elements/aodv/aodv_generaterrep.hh            |    2 +-
 elements/aodv/aodv_generaterreq.cc            |   17 ++++-------------
 elements/aodv/aodv_generaterreq.hh            |    2 +-
 elements/aodv/aodv_hellogenerator.cc          |   10 +++-------
 elements/aodv/aodv_hellogenerator.hh          |    2 +-
 elements/aodv/aodv_knownclassifier.cc         |   11 +++--------
 elements/aodv/aodv_knownclassifier.hh         |    2 +-
 elements/aodv/aodv_linkneighboursdiscovery.cc |   16 ++++------------
 elements/aodv/aodv_linkneighboursdiscovery.hh |    2 +-
 elements/aodv/aodv_lookuproute.cc             |   10 +++-------
 elements/aodv/aodv_lookuproute.hh             |    2 +-
 elements/aodv/aodv_neighbours.cc              |    5 +++--
 elements/aodv/aodv_neighbours.hh              |    2 +-
 elements/aodv/aodv_trackneighbours.cc         |   16 ++++------------
 elements/aodv/aodv_trackneighbours.hh         |    2 +-
 elements/aodv/aodv_updateneighbours.cc        |   10 +++-------
 elements/aodv/aodv_updateneighbours.hh        |    2 +-
 elements/aodv/aodv_waitingfordiscovery.cc     |   16 ++++------------
 elements/aodv/aodv_waitingfordiscovery.hh     |    2 +-
 24 files changed, 53 insertions(+), 119 deletions(-)

diff --git a/elements/aodv/aodv_destinationclassifier.cc b/elements/aodv/aodv_destinationclassifier.cc
index 98e6155..a0dfe6f 100755
--- a/elements/aodv/aodv_destinationclassifier.cc
+++ b/elements/aodv/aodv_destinationclassifier.cc
@@ -24,13 +24,10 @@ AODVDestinationClassifier::~AODVDestinationClassifier()
 int
 AODVDestinationClassifier::configure(Vector<String> &conf, ErrorHandler *errh)
 {
-	Element* neighbour_table_element;
-	int res = cp_va_parse(conf, this, errh, cpElement, "AODVNeighbour table", &neighbour_table_element, 0);
+	int res = cp_va_kparse(conf, this, errh,
+			       "NEIGHBOURS", cpkP+cpkM, cpElementCast, "AODVNeighbours", &neighbour_table,
+			       cpEnd);
 	if(res < 0) return res;
-	if (!(neighbour_table=(AODVNeighbours*)neighbour_table_element->cast("AODVNeighbours"))){
-		return errh->error("Supplied element is not a valid AODVNeighbours element (cast failed)");
-	}
-	
 	myIP = &neighbour_table->getMyIP();
 
 	return 0;
diff --git a/elements/aodv/aodv_destinationclassifier.hh b/elements/aodv/aodv_destinationclassifier.hh
index f17c8b6..cd56f39 100755
--- a/elements/aodv/aodv_destinationclassifier.hh
+++ b/elements/aodv/aodv_destinationclassifier.hh
@@ -6,7 +6,7 @@
 
 /*
  * =c
- * AODVDestinationClassifier()
+ * AODVDestinationClassifier(NEIGHBOURS)
  * =s AODV
  * =a AODVNeighbours
  * =d
diff --git a/elements/aodv/aodv_generatererr.cc b/elements/aodv/aodv_generatererr.cc
index a18befe..c5f3539 100755
--- a/elements/aodv/aodv_generatererr.cc
+++ b/elements/aodv/aodv_generatererr.cc
@@ -27,13 +27,9 @@ AODVGenerateRERR::~AODVGenerateRERR()
 int
 AODVGenerateRERR::configure(Vector<String> &conf, ErrorHandler *errh)
 {
-	Element* neighbour_table_element;
-	int res = cp_va_parse(conf, this, errh, cpElement, "AODVNeighbour table", &neighbour_table_element, 0);
-	if(res < 0) return res;
-	if (!(neighbour_table=(AODVNeighbours*)neighbour_table_element->cast("AODVNeighbours"))){
-		return errh->error("Supplied element is not a valid AODVNeighbours element (cast failed)");
-	}
-	return 0;
+    return cp_va_kparse(conf, this, errh,
+			"NEIGHBOURS", cpkP+cpkM, cpElementCast, "AODVNeighbours", &neighbour_table,
+			cpEnd);
 }
 
 void AODVGenerateRERR::push (int port, Packet * packet){
diff --git a/elements/aodv/aodv_generatererr.hh b/elements/aodv/aodv_generatererr.hh
index e2cb156..0d2aa1e 100755
--- a/elements/aodv/aodv_generatererr.hh
+++ b/elements/aodv/aodv_generatererr.hh
@@ -6,7 +6,7 @@
 
 /*
  * =c
- * AODVGenerateRERR()
+ * AODVGenerateRERR(NEIGHBOURS)
  * =s AODV
  * =a 
  * =d
diff --git a/elements/aodv/aodv_generaterrep.cc b/elements/aodv/aodv_generaterrep.cc
index 6376bb4..4ca1fd7 100755
--- a/elements/aodv/aodv_generaterrep.cc
+++ b/elements/aodv/aodv_generaterrep.cc
@@ -28,22 +28,12 @@ AODVGenerateRREP::~AODVGenerateRREP()
 int
 AODVGenerateRREP::configure(Vector<String> &conf, ErrorHandler *errh)
 {
-	Element* neighbour_table_element;
-	Element* setrrepheaders_element;
-	int res = cp_va_parse(conf, this, errh, 
-		cpElement, "AODVNeighbour table", &neighbour_table_element,
-		cpElement, "AODVSetRREPHeaders", &setrrepheaders_element,
-		0);
+	int res = cp_va_kparse(conf, this, errh,
+		"NEIGHBOURS", cpkP+cpkM, cpElementCast, "AODVNeighbours", &neighbour_table,
+		"SETRREP", cpkP+cpkM, cpElementCast, "AODVSetRREPHeaders", &setrrepheaders,
+		cpEnd);
 	if(res < 0) return res;
-	if (!(neighbour_table=(AODVNeighbours*)neighbour_table_element->cast("AODVNeighbours"))){
-		return errh->error("Supplied element is not a valid AODVNeighbours element (cast failed)");
-	}
-	if (!(setrrepheaders=(AODVSetRREPHeaders*)setrrepheaders_element->cast("AODVSetRREPHeaders"))){
-		return errh->error("Supplied element is not a valid AODVSetRREPHeaders element (cast failed)");
-	}
-	
 	myIP = &neighbour_table->getMyIP();
-	
 	return res;
 }
 
diff --git a/elements/aodv/aodv_generaterrep.hh b/elements/aodv/aodv_generaterrep.hh
index eb0b49c..1d8c76f 100755
--- a/elements/aodv/aodv_generaterrep.hh
+++ b/elements/aodv/aodv_generaterrep.hh
@@ -6,7 +6,7 @@
 
 /*
  * =c
- * AODVGenerateRREP()
+ * AODVGenerateRREP(NEIGHBOURS, SETRREP)
  * =s AODV
  * =a AODVNeighbours
  * =d
diff --git a/elements/aodv/aodv_generaterreq.cc b/elements/aodv/aodv_generaterreq.cc
index 36977b9..9a4acf1 100755
--- a/elements/aodv/aodv_generaterreq.cc
+++ b/elements/aodv/aodv_generaterreq.cc
@@ -30,21 +30,12 @@ AODVGenerateRREQ::~AODVGenerateRREQ()
 int
 AODVGenerateRREQ::configure(Vector<String> &conf, ErrorHandler *errh)
 {
-	Element* neighbour_table_element;
-	Element* known_classifier_element;
-	int res = cp_va_parse(conf, this, errh, 
-		cpElement, "AODVNeighbour table", &neighbour_table_element, 
-		cpElement, "AODVKnownClassifier", &known_classifier_element,0);
+	int res = cp_va_kparse(conf, this, errh,
+		"NEIGHBOURS", cpkP+cpkM, cpElementCast, "AODVNeighbours", &neighbour_table,
+		"KNOWNCLASSIFIER", cpkP+cpkM, cpElementCast, "AODVKnownClassifier", &known_classifier,
+		cpEnd);
 	if(res < 0) return res;
-	if (!(neighbour_table=(AODVNeighbours*)neighbour_table_element->cast("AODVNeighbours"))){
-		return errh->error("Supplied element is not a valid AODVNeighbours element (cast failed)");
-	}
-	if (!(known_classifier=(AODVKnownClassifier*)known_classifier_element->cast("AODVKnownClassifier"))){
-		return errh->error("Supplied element is not a valid AODVKnownClassifier element (cast failed)");
-	}
-	
 	myIP = &neighbour_table->getMyIP();
-
 	return res;
 }
 
diff --git a/elements/aodv/aodv_generaterreq.hh b/elements/aodv/aodv_generaterreq.hh
index ca78975..9ce8f9f 100755
--- a/elements/aodv/aodv_generaterreq.hh
+++ b/elements/aodv/aodv_generaterreq.hh
@@ -6,7 +6,7 @@
 
 /*
  * =c
- * AODVGenerateRREQ(AODVNeighbours,AODVKnownClassifier)
+ * AODVGenerateRREQ(NEIGHBOURS, KNOWNCLASSIFIER)
  * =s AODV
  * =a AODVNeighbours, AODVKnownClassifier
  * =d
diff --git a/elements/aodv/aodv_hellogenerator.cc b/elements/aodv/aodv_hellogenerator.cc
index a856893..4d11f5b 100755
--- a/elements/aodv/aodv_hellogenerator.cc
+++ b/elements/aodv/aodv_hellogenerator.cc
@@ -37,15 +37,11 @@ AODVHelloGenerator::initialize(ErrorHandler *)
 int
 AODVHelloGenerator::configure(Vector<String> &conf, ErrorHandler *errh)
 {
-	Element * neighbour_table_element;
-	int res = cp_va_parse(conf, this, errh, cpElement, "AODVNeighbour table", &neighbour_table_element, 0);
+	int res = cp_va_kparse(conf, this, errh,
+		"NEIGHBOURS", cpkP+cpkM, cpElementCast, "AODVNeighbours", &neighbour_table,
+		cpEnd);
 	if(res < 0) return res;
-	if (!(neighbour_table=(AODVNeighbours*)neighbour_table_element->cast("AODVNeighbours"))){
-		return errh->error("Supplied element is not a valid AODVNeighbours element (cast failed)");
-	}
-	
 	myIP = &neighbour_table->getMyIP();
-
 	return 0;
 }
 
diff --git a/elements/aodv/aodv_hellogenerator.hh b/elements/aodv/aodv_hellogenerator.hh
index f883aa1..bdd0336 100755
--- a/elements/aodv/aodv_hellogenerator.hh
+++ b/elements/aodv/aodv_hellogenerator.hh
@@ -6,7 +6,7 @@
 
 /*
  * =c
- * AODVHelloGenerator(IP)
+ * AODVHelloGenerator(NEIGHBOURS)
  * =s AODV
  * =a AODVNeighbours, AODVUpdateNeighbours
  * =d
diff --git a/elements/aodv/aodv_knownclassifier.cc b/elements/aodv/aodv_knownclassifier.cc
index 33f7410..1fd0e47 100755
--- a/elements/aodv/aodv_knownclassifier.cc
+++ b/elements/aodv/aodv_knownclassifier.cc
@@ -25,16 +25,11 @@ AODVKnownClassifier::~AODVKnownClassifier()
 int
 AODVKnownClassifier::configure(Vector<String> &conf, ErrorHandler *errh)
 {
-	Element* neighbour_table_element;
-	int res = cp_va_parse(conf, this, errh, 
-		cpElement, "AODVNeighbour table", &neighbour_table_element, 0);
+	int res = cp_va_kparse(conf, this, errh,
+		"NEIGHBOURS", cpkP+cpkM, cpElementCast, "AODVNeighbours", &neighbour_table,
+		cpEnd);
 	if(res < 0) return res;
-	if (!(neighbour_table=(AODVNeighbours*)neighbour_table_element->cast("AODVNeighbours"))){
-		return errh->error("Supplied element is not a valid AODVNeighbours element (cast failed)");
-	}
-	
 	myIP = &neighbour_table->getMyIP();
-
 	return res;
 }
 
diff --git a/elements/aodv/aodv_knownclassifier.hh b/elements/aodv/aodv_knownclassifier.hh
index 0d4c2f8..9b23940 100755
--- a/elements/aodv/aodv_knownclassifier.hh
+++ b/elements/aodv/aodv_knownclassifier.hh
@@ -7,7 +7,7 @@
 
 /*
  * =c
- * AODVKnownClassifier()
+ * AODVKnownClassifier(NEIGHBOURS)
  * =s AODV
  * =a AODVNeighbours
  * =d
diff --git a/elements/aodv/aodv_linkneighboursdiscovery.cc b/elements/aodv/aodv_linkneighboursdiscovery.cc
index c0bf23a..21a46d6 100644
--- a/elements/aodv/aodv_linkneighboursdiscovery.cc
+++ b/elements/aodv/aodv_linkneighboursdiscovery.cc
@@ -24,18 +24,10 @@ AODVLinkNeighboursDiscovery::~AODVLinkNeighboursDiscovery()
 int
 AODVLinkNeighboursDiscovery::configure(Vector<String> &conf, ErrorHandler *errh)
 {
-	Element * neighbour_table_element;
-	Element * discovery_element;
-	int res = cp_va_parse(conf, this, errh, cpElement, "AODVNeighbour table", &neighbour_table_element,
-	cpElement, "AODVWaitingForDiscovery", &discovery_element, 0);
-	if(res < 0) return res;
-	if (!(neighbour_table=(AODVNeighbours*)neighbour_table_element->cast("AODVNeighbours"))){
-		return errh->error("Supplied element is not a valid AODVNeighbours element (cast failed)");
-	}
-	if (!(discovery=(AODVWaitingForDiscovery*)discovery_element->cast("AODVWaitingForDiscovery"))){
-		return errh->error("Supplied element is not a valid AODVWaitingForDiscovery element (cast failed)");
-	}
-	return 0;
+	return cp_va_kparse(conf, this, errh,
+		"NEIGHBOURS", cpkP+cpkM, cpElementCast, "AODVNeighbours", &neighbour_table,
+		"DISCOVERY", cpkP+cpkM, cpElementCast, "AODVWaitingForDiscovery", &discovery,
+		cpEnd);
 }
 
 int AODVLinkNeighboursDiscovery::initialize(ErrorHandler *)
diff --git a/elements/aodv/aodv_linkneighboursdiscovery.hh b/elements/aodv/aodv_linkneighboursdiscovery.hh
index 31b3d9d..50f9c4f 100644
--- a/elements/aodv/aodv_linkneighboursdiscovery.hh
+++ b/elements/aodv/aodv_linkneighboursdiscovery.hh
@@ -6,7 +6,7 @@
 
 /* 
  * =c
- * AODVLinkNeighboursDiscovry(AODVNeighbours,AODVWaitingForDiscovery)
+ * AODVLinkNeighboursDiscovry(NEIGHBOURS, DISCOVERY)
  * =s AODV
  * =a AODVNeighbours, AODVWaitingForDiscovery
  * =d
diff --git a/elements/aodv/aodv_lookuproute.cc b/elements/aodv/aodv_lookuproute.cc
index 0123aa3..28c844f 100755
--- a/elements/aodv/aodv_lookuproute.cc
+++ b/elements/aodv/aodv_lookuproute.cc
@@ -26,15 +26,11 @@ AODVLookUpRoute::~AODVLookUpRoute()
 int
 AODVLookUpRoute::configure(Vector<String> &conf, ErrorHandler *errh)
 {
-	Element* neighbour_table_element;
-	int res = cp_va_parse(conf, this, errh, cpElement, "AODVNeighbour table", &neighbour_table_element, 0);
+	int res = cp_va_kparse(conf, this, errh,
+		"NEIGHBOURS", cpkP+cpkM, cpElementCast, "AODVNeighbours", &neighbour_table,
+		cpEnd);
 	if(res < 0) return res;
-	if (!(neighbour_table=(AODVNeighbours*)neighbour_table_element->cast("AODVNeighbours"))){
-		return errh->error("Supplied element is not a valid AODVNeighbours element (cast failed)");
-	}
-	
 	myIP = &neighbour_table->getMyIP();
-
 	return 0;
 }
 
diff --git a/elements/aodv/aodv_lookuproute.hh b/elements/aodv/aodv_lookuproute.hh
index 84a217d..dda5797 100755
--- a/elements/aodv/aodv_lookuproute.hh
+++ b/elements/aodv/aodv_lookuproute.hh
@@ -5,7 +5,7 @@
 
 /*
  * =c
- * AODVLookUpRoute()
+ * AODVLookUpRoute(NEIGHBOURS)
  * =s AODV
  * =a AODVNeighbours
  * =d
diff --git a/elements/aodv/aodv_neighbours.cc b/elements/aodv/aodv_neighbours.cc
index d08ead2..caceed6 100755
--- a/elements/aodv/aodv_neighbours.cc
+++ b/elements/aodv/aodv_neighbours.cc
@@ -25,8 +25,9 @@ AODVNeighbours::~AODVNeighbours()
 int
 AODVNeighbours::configure(Vector<String> &conf, ErrorHandler *errh)
 {
-	int res = cp_va_parse(conf, this, errh, cpIPAddress, "my IPAddress", &myIP, 0);
-	return res;
+    return cp_va_kparse(conf, this, errh,
+			"ADDR", cpkP+cpkM, cpIPAddress, &myIP,
+			cpEnd);
 }
 
 void AODVNeighbours::setRouteUpdateWatcher(AODVRouteUpdateWatcher* w){
diff --git a/elements/aodv/aodv_neighbours.hh b/elements/aodv/aodv_neighbours.hh
index 7e280d3..caa8212 100755
--- a/elements/aodv/aodv_neighbours.hh
+++ b/elements/aodv/aodv_neighbours.hh
@@ -8,7 +8,7 @@
 
 /*
  * =c
- * AODVNeighbours()
+ * AODVNeighbours(ADDR)
  * =s AODV
  * =a AODVRouteUpdateWatcher
  * 
diff --git a/elements/aodv/aodv_trackneighbours.cc b/elements/aodv/aodv_trackneighbours.cc
index 69bf0b0..df50682 100755
--- a/elements/aodv/aodv_trackneighbours.cc
+++ b/elements/aodv/aodv_trackneighbours.cc
@@ -25,20 +25,12 @@ AODVTrackNeighbours::~AODVTrackNeighbours()
 int
 AODVTrackNeighbours::configure(Vector<String> &conf, ErrorHandler *errh)
 {
-	Element* generateRerrElement;
-	Element* neighbour_table_element;
-	int res = cp_va_parse(conf, this, errh,
-		cpElement, "AODVGenerateRERR", &generateRerrElement,
-		cpElement, "AODVNeighbours", &neighbour_table_element, 0);
+	int res = cp_va_kparse(conf, this, errh,
+		"GENERATERERR", cpkP+cpkM, cpElementCast, "AODVGenerateRERR", &generateRerr,
+		"NEIGHBOURS", cpkP+cpkM, cpElementCast, "AODVNeighbours", &neighbour_table,
+		cpEnd);
 	if(res < 0) return res;
-	if (!(generateRerr=(AODVGenerateRERR*)generateRerrElement->cast("AODVGenerateRERR"))){
-		return errh->error("Supplied element is not a valid AODVGenerateRERR element (cast failed)");
-	}
-	if (!(neighbour_table=(AODVNeighbours*)neighbour_table_element->cast("AODVNeighbours"))){
-		return errh->error("Supplied element is not a valid AODVNeighbours element (cast failed)");
-	}
 	myIP = &neighbour_table->getMyIP();
-	
 	return res;
 }
 
diff --git a/elements/aodv/aodv_trackneighbours.hh b/elements/aodv/aodv_trackneighbours.hh
index ba4d480..a043dc4 100755
--- a/elements/aodv/aodv_trackneighbours.hh
+++ b/elements/aodv/aodv_trackneighbours.hh
@@ -7,7 +7,7 @@
 
 /*
  * =c
- * AODVTrackNeighbours()
+ * AODVTrackNeighbours(GENERATERERR)
  * =s AODV
  * =a AODVNeighbours, AODVGenerateRERR
  * =d
diff --git a/elements/aodv/aodv_updateneighbours.cc b/elements/aodv/aodv_updateneighbours.cc
index ab6cfb6..d7c4c6a 100755
--- a/elements/aodv/aodv_updateneighbours.cc
+++ b/elements/aodv/aodv_updateneighbours.cc
@@ -27,13 +27,9 @@ AODVUpdateNeighbours::~AODVUpdateNeighbours()
 int
 AODVUpdateNeighbours::configure(Vector<String> &conf, ErrorHandler *errh)
 {
-	Element* neighbour_table_element;
-	int res = cp_va_parse(conf, this, errh, cpElement, "AODVNeighbour table", &neighbour_table_element, 0);
-	if(res < 0) return res;
-	if (!(neighbour_table=(AODVNeighbours*)neighbour_table_element->cast("AODVNeighbours"))){
-		return errh->error("Supplied element is not a valid AODVNeighbours element (cast failed)");
-	}
-	return 0;
+    return cp_va_kparse(conf, this, errh,
+		"NEIGHBOURS", cpkP+cpkM, cpElementCast, "AODVNeighbours", &neighbour_table,
+		cpEnd);
 }
 
 // RFC 6.2
diff --git a/elements/aodv/aodv_updateneighbours.hh b/elements/aodv/aodv_updateneighbours.hh
index 68a06e5..36b38ce 100755
--- a/elements/aodv/aodv_updateneighbours.hh
+++ b/elements/aodv/aodv_updateneighbours.hh
@@ -5,7 +5,7 @@
 
 /*
  * =c
- * AODVUpdateNeighbours()
+ * AODVUpdateNeighbours(NEIGHBOURS)
  * =s AODV
  * =a AODVNeighbours
  * =d
diff --git a/elements/aodv/aodv_waitingfordiscovery.cc b/elements/aodv/aodv_waitingfordiscovery.cc
index 6fa07e6..f5e6875 100755
--- a/elements/aodv/aodv_waitingfordiscovery.cc
+++ b/elements/aodv/aodv_waitingfordiscovery.cc
@@ -27,18 +27,10 @@ AODVWaitingForDiscovery::~AODVWaitingForDiscovery()
 int
 AODVWaitingForDiscovery::configure(Vector<String> &conf, ErrorHandler *errh)
 {
-	Element* generate_rreq_element;
-	Element* neighbour_table_element;
-	int res = cp_va_parse(conf, this, errh, cpElement, "AODVGenerateRREQ", &generate_rreq_element,
-		cpElement, "AODVNeighbour table", &neighbour_table_element, 0);
-	if(res < 0) return res;
-	if (!(rreq=(AODVGenerateRREQ*)generate_rreq_element->cast("AODVGenerateRREQ"))){
-		return errh->error("Supplied element is not a valid AODVGenerateRREQ element (cast failed)");
-	}
-	if (!(neighbour_table=(AODVNeighbours*)neighbour_table_element->cast("AODVNeighbours"))){
-		return errh->error("Supplied element is not a valid AODVNeighbours element (cast failed)");
-	}
-	return 0;
+    return cp_va_kparse(conf, this, errh,
+		"GENERATERREQ", cpkP+cpkM, cpElementCast, "AODVGenerateRREQ", &rreq,
+		"NEIGHBOURS", cpkP+cpkM, cpElementCast, "AODVNeighbours", &neighbour_table,
+		cpEnd);
 }
 
 void AODVWaitingForDiscovery::runTask(const IPAddress & destination, TimerData* data){
diff --git a/elements/aodv/aodv_waitingfordiscovery.hh b/elements/aodv/aodv_waitingfordiscovery.hh
index b31680f..e71e748 100755
--- a/elements/aodv/aodv_waitingfordiscovery.hh
+++ b/elements/aodv/aodv_waitingfordiscovery.hh
@@ -9,7 +9,7 @@
 
 /*
  * =c
- * AODVWaitingForDiscovery()
+ * AODVWaitingForDiscovery(GENERATERREQ, NEIGHBOURS)
  * =s AODV
  * =a AODVGenerateRREQ, AODVNeighbours
  * =d
-- 
1.6.3.3

>From 9f6e83ba03016199d36ce7134934cd86b1e5101f Mon Sep 17 00:00:00 2001
From: Eddie Kohler <[email protected]>
Date: Tue, 1 Dec 2009 16:59:52 -0800
Subject: [PATCH 2/2] AODV elements: Use Timestamp methods instead of timeval.

---
 elements/aodv/aodv_neighbours.cc |   22 +++++++---------------
 elements/aodv/aodv_neighbours.hh |    5 ++++-
 2 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/elements/aodv/aodv_neighbours.cc b/elements/aodv/aodv_neighbours.cc
index caceed6..cb9be39 100755
--- a/elements/aodv/aodv_neighbours.cc
+++ b/elements/aodv/aodv_neighbours.cc
@@ -139,14 +139,14 @@ void AODVNeighbours::addLifeTime(const IPAddress & destination, uint32_t ms){
 	assert(ms > 0);
 	NeighbourMap::Pair* pair = neighbours.find_pair(destination);
 	if (!pair) return; // route didn't exist / already expunged
-	const struct timeval & newer = calculateTimeval(ms);
-	const struct timeval & old = pair->value.expiry->expiry().timeval();
+	Timestamp newer = calculateTimeval(ms);
+	const Timestamp & old = pair->value.expiry->expiry();
 	if (old < newer) pair->value.expiry->schedule_at(newer);
 }
 
 void AODVNeighbours::updateLifetime(NeighbourMap::Pair* pair){
-	const struct timeval & newer = calculateTimeval(calculateLifetime(-1)); // use existing code
-	const struct timeval & old = pair->value.expiry->expiry().timeval();
+	Timestamp newer = calculateTimeval(calculateLifetime(-1)); // use existing code
+	const Timestamp & old = pair->value.expiry->expiry();
 	pair->value.valid = true;
 	if (old < newer) pair->value.expiry->schedule_at(newer);
 }
@@ -225,10 +225,9 @@ const IPAddress & AODVNeighbours::getMyIP() const{
 uint32_t AODVNeighbours::getLifetime(const IPAddress & ip) const{
 	NeighbourMap::Pair* pair = neighbours.find_pair(ip);
 	assert(pair);
-	struct timeval expiry = pair->value.expiry->expiry().timeval();
-	struct timeval now;
-	click_gettimeofday(&now);
-	uint32_t result = (expiry.tv_sec - now.tv_sec) * 1000 + (expiry.tv_usec - now.tv_usec) / 1000;
+	const Timestamp & expiry = pair->value.expiry->expiry();
+	Timestamp now = Timestamp::now();
+	uint32_t result = (expiry - now).msecval();
 	return (result == 0)?1:result; // avoid returning 0 to avoid confusion: this entry is still valid!
 }
 
@@ -274,13 +273,6 @@ bool AODVNeighbours::largerSequenceNumber(uint32_t first, uint32_t second){
 	return signedFirst > signedSecond;
 }
 
-timeval AODVNeighbours::calculateTimeval(int ms){
-	struct timeval lifetimestruct;
-	click_gettimeofday(&lifetimestruct);
-	
-	return lifetimestruct += make_timeval(ms / 1000, (ms % 1000) * 1000);
-}
-
 // macro magic to use bighashmap
 #include <click/bighashmap.cc>
 #if EXPLICIT_TEMPLATE_INSTANCES
diff --git a/elements/aodv/aodv_neighbours.hh b/elements/aodv/aodv_neighbours.hh
index caa8212..25ba0ff 100755
--- a/elements/aodv/aodv_neighbours.hh
+++ b/elements/aodv/aodv_neighbours.hh
@@ -83,7 +83,10 @@ class AODVNeighbours : public Element {
 		// some usefull time functions, for general usage
 		static int calculateLifetime(int lifetime);
 		static void updateLifetime(NeighbourMap::Pair* pair);
-		static timeval calculateTimeval(int ms);
+
+		static inline Timestamp calculateTimeval(int ms) {
+			return Timestamp::now() + Timestamp::make_msec(ms);
+		}
 };
 
 CLICK_ENDDECLS
-- 
1.6.3.3

_______________________________________________
click mailing list
[email protected]
https://amsterdam.lcs.mit.edu/mailman/listinfo/click

Reply via email to