Skip to content

Commit

Permalink
radixiplookup: add flush handler
Browse files Browse the repository at this point in the history
Signed-off-by: Cliff Frey <[email protected]>
  • Loading branch information
Cliff Frey committed Feb 15, 2013
1 parent 5949db5 commit 70d83e2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
25 changes: 25 additions & 0 deletions elements/ip/radixiplookup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ RadixIPLookup::cleanup(CleanupStage)
_radix = 0;
}

void
RadixIPLookup::add_handlers()
{
IPRouteTable::add_handlers();
add_write_handler("flush", flush_handler, 0, Handler::BUTTON);
}

String
RadixIPLookup::dump_routes()
Expand Down Expand Up @@ -285,6 +291,25 @@ RadixIPLookup::lookup_route(IPAddress addr, IPAddress &gw) const
}
}

void
RadixIPLookup::flush_table()
{
int level = 0;
_v.clear();
Radix::free_radix(_radix, level);
_radix = Radix::make_radix(0);
_vfree = -1;
_default_key = 0;
}

int
RadixIPLookup::flush_handler(const String &, Element *e, void *, ErrorHandler *)
{
RadixIPLookup *t = static_cast<RadixIPLookup *>(e);
t->flush_table();
return 0;
}

CLICK_ENDDECLS
ELEMENT_REQUIRES(IPRouteTable)
EXPORT_ELEMENT(RadixIPLookup)
4 changes: 4 additions & 0 deletions elements/ip/radixiplookup.hh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class RadixIPLookup : public IPRouteTable { public:


void cleanup(CleanupStage) CLICK_COLD;
void add_handlers() CLICK_COLD;

int add_route(const IPRoute&, bool, IPRoute*, ErrorHandler *);
int remove_route(const IPRoute&, IPRoute*, ErrorHandler *);
Expand Down Expand Up @@ -108,6 +109,9 @@ class RadixIPLookup : public IPRouteTable { public:
return ((comb & 0xff000000) >> 24);
}

void flush_table();

static int flush_handler(const String &, Element *, void *, ErrorHandler *);

class Radix;

Expand Down

0 comments on commit 70d83e2

Please sign in to comment.