Skip to content

Commit

Permalink
IPClassifier: Add per-output pattern handlers.
Browse files Browse the repository at this point in the history
Request from Momina Khan. Meraki has something like this.
  • Loading branch information
kohler committed May 31, 2013
1 parent ac7d376 commit 6ea8bf5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion elements/ip/ipclassifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <click/glue.hh>
#include <click/error.hh>
#include <click/confparse.hh>
#include <click/router.hh>
CLICK_DECLS

IPClassifier::IPClassifier()
Expand All @@ -42,11 +43,19 @@ IPClassifier::configure(Vector<String> &conf, ErrorHandler *errh)
for (int i = 0; i < conf.size(); i++)
new_conf.push_back(String(i) + " " + conf[i]);
int r = IPFilter::configure(new_conf, errh);
if (r >= 0)
if (r >= 0 && !router()->initialized())
_zprog.warn_unused_outputs(noutputs(), errh);
return r;
}

void IPClassifier::add_handlers() {
IPFilter::add_handlers();
for (uintptr_t i = 0; i != (uintptr_t) noutputs(); ++i) {
add_read_handler("pattern" + String(i), read_positional_handler, (void*) i);
add_write_handler("pattern" + String(i), reconfigure_positional_handler, (void*) i);
}
}

CLICK_ENDDECLS
ELEMENT_REQUIRES(IPFilter)
EXPORT_ELEMENT(IPClassifier)
Expand Down
5 changes: 5 additions & 0 deletions elements/ip/ipclassifier.hh
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ is using to classify packets. At each step in the program, four bytes
of packet data are ANDed with a mask and compared against four bytes of
classifier pattern.
=h pattern0 rw
Returns or sets the element's pattern 0. There are as many C<pattern>
handlers as there are output ports.
=a Classifier, IPFilter, CheckIPHeader, MarkIPHeader, CheckIPHeader2,
tcpdump(1) */

Expand All @@ -240,6 +244,7 @@ class IPClassifier : public IPFilter { public:
const char *processing() const { return PUSH; }

int configure(Vector<String> &, ErrorHandler *) CLICK_COLD;
void add_handlers() CLICK_COLD;

};

Expand Down

0 comments on commit 6ea8bf5

Please sign in to comment.