[Click] [PATCH] Roofnet (1/3)
roberto.riggio at create-net.org
roberto.riggio at create-net.org
Mon Aug 11 06:08:24 EDT 2008
I'm submitting 3 set of patches for roofnet. This one contains minor changes and
fixes (the LinkTable element was never used in this element)
Signed-off-by: Roberto Riggio <roberto.riggio at create-net.org>
--
diff --git a/roofnet/sr2/sr2forwarder.cc b/roofnet/sr2/sr2forwarder.cc
index 07a6800..ac43b77 100644
--- a/roofnet/sr2/sr2forwarder.cc
+++ b/roofnet/sr2/sr2forwarder.cc
@@ -29,13 +29,14 @@
#include "elements/ethernet/arptable.hh"
CLICK_DECLS
+enum { H_STATS };
+
SR2Forwarder::SR2Forwarder()
: _ip(),
_eth(),
_et(0),
_datas(0),
_databytes(0),
- _link_table(0),
_arp_table(0)
{
}
@@ -53,8 +54,6 @@ SR2Forwarder::configure (Vector<String> &conf, ErrorHandler *errh)
"IP", 0, cpIPAddress, &_ip,
"ETH", 0, cpEtherAddress, &_eth,
"ARP", 0, cpElement, &_arp_table,
- /* below not required */
- "LT", 0, cpElement, &_link_table,
cpEnd);
if (!_et)
@@ -69,9 +68,6 @@ SR2Forwarder::configure (Vector<String> &conf, ErrorHandler *errh)
if (_arp_table->cast("ARPTable") == 0)
return errh->error("ARPTable element is not a ARPTable");
- if (_link_table && _link_table->cast("LinkTable") == 0)
- return errh->error("LinkTable element is not a LinkTable");
-
if (res < 0) {
return res;
}
@@ -84,21 +80,6 @@ SR2Forwarder::initialize (ErrorHandler *)
return 0;
}
-bool
-SR2Forwarder::update_link(IPAddress from, IPAddress to,
- uint32_t seq, uint32_t age, uint32_t metric)
-{
- if (_link_table && !_link_table->update_link(from, to, seq, age, metric)) {
- click_chatter("%{element} couldn't update link %s > %d > %s\n",
- this,
- from.unparse().c_str(),
- metric,
- to.unparse().c_str());
- return false;
- }
- return true;
-}
-
Packet *
SR2Forwarder::encap(Packet *p_in, Vector<IPAddress> r, int flags)
{
@@ -111,8 +92,8 @@ SR2Forwarder::encap(Packet *p_in, Vector<IPAddress> r, int flags)
WritablePacket *p = p_in->push(extra);
assert(extra + payload_len == p_in->length());
-
-
+
+
int next = index_of(r, _ip) + 1;
if (next < 0 || next >= r.size()) {
click_chatter("SR2Forwarder %s: encap couldn't find %s (%d) in path %s",
@@ -223,12 +204,19 @@ SR2Forwarder::push(int port, Packet *p_in)
}
-String
-SR2Forwarder::static_print_stats(Element *f, void *)
-{
- SR2Forwarder *d = (SR2Forwarder *) f;
- return d->print_stats();
-}
+void SR2Forwarder::add_handlers(){
+ add_read_handler("stats", read_handler, (void*)H_STATS);
+}
+
+String SR2Forwarder::read_handler(Element *e, void *thunk){
+ SR2Forwarder *c = (SR2Forwarder *)e;
+ switch ((intptr_t)thunk) {
+ case H_STATS:
+ return(c->print_stats());
+ default:
+ return "<error>\n";
+ }
+}
String
SR2Forwarder::print_stats()
@@ -236,11 +224,5 @@ SR2Forwarder::print_stats()
return String(_datas) + " datas sent\n" + String(_databytes) + " bytes of data sent\n";
}
-void
-SR2Forwarder::add_handlers()
-{
- add_read_handler("stats", static_print_stats, 0);
-}
-
CLICK_ENDDECLS
EXPORT_ELEMENT(SR2Forwarder)
diff --git a/roofnet/sr2/sr2forwarder.hh b/roofnet/sr2/sr2forwarder.hh
index be2f344..b87e2bc 100644
--- a/roofnet/sr2/sr2forwarder.hh
+++ b/roofnet/sr2/sr2forwarder.hh
@@ -5,15 +5,15 @@
#include <click/timer.hh>
#include <click/ipaddress.hh>
#include <click/etheraddress.hh>
-#include <elements/wifi/linktable.hh>
#include <click/vector.hh>
#include <elements/wifi/path.hh>
+#include <click/hashmap.hh>
CLICK_DECLS
/*
=c
-SR2Forwarder(ETHERTYPE, IP, ETH, ARPTable element, LT LinkTable element
+SR2Forwarder(ETHERTYPE, IP, ETH, ARPTable element,
[ETT element], [METRIC GridGenericMetric] )
=s Wifi, Wireless Routing
@@ -46,12 +46,7 @@ class SR2Forwarder : public Element {
/* handler stuff */
void add_handlers();
-
- static String static_print_stats(Element *e, void *);
String print_stats();
- static String static_print_routes(Element *e, void *);
- String print_routes();
-
void push(int, Packet *);
Packet *encap(Packet *, Vector<IPAddress>, int flags);
@@ -61,12 +56,10 @@ private:
IPAddress _ip; // My IP address.
EtherAddress _eth; // My ethernet address.
uint16_t _et; // This protocol's ethertype
-// uint32_t _et; // This protocol's ethertype
// Statistics for handlers.
int _datas;
int _databytes;
- class LinkTable *_link_table;
class ARPTable *_arp_table;
class PathInfo {
@@ -80,9 +73,9 @@ private:
};
typedef HashMap<Path, PathInfo> PathTable;
PathTable _paths;
-
- bool update_link(IPAddress from, IPAddress to,
- uint32_t seq, uint32_t age, uint32_t metric);
+
+ static String read_handler(Element *, void *);
+
};
diff --git a/roofnet/sr2/sr2querier.cc b/roofnet/sr2/sr2querier.cc
index 53a44b6..ef97018 100644
--- a/roofnet/sr2/sr2querier.cc
+++ b/roofnet/sr2/sr2querier.cc
@@ -21,7 +21,6 @@
#include <click/confparse.hh>
#include <click/error.hh>
#include <click/glue.hh>
-#include "sr2linkmetric.hh"
#include <click/straccum.hh>
#include <clicknet/ether.h>
#include "sr2packet.hh"
diff --git a/roofnet/sr2/sr2checkheader.cc b/roofnet/sr2/sr2checkheader.cc
index 36122aa..0793714 100644
--- a/roofnet/sr2/sr2checkheader.cc
+++ b/roofnet/sr2/sr2checkheader.cc
@@ -74,18 +74,13 @@ SR2CheckHeader::simple_action(Packet *p)
}
if (pk->_version != _sr2_version) {
- static bool version_warning = false;
_bad_table.insert(EtherAddress(eh->ether_shost), pk->_version);
- if (!version_warning) {
- version_warning = true;
- click_chatter ("%s: unknown sr version %x from %s",
+ click_chatter ("%s: unknown sr version %x from %s",
name().c_str(),
pk->_version,
EtherAddress(eh->ether_shost).unparse().c_str());
- }
-
goto bad;
}
More information about the click
mailing list