Skip to content

Instantly share code, notes, and snippets.

@alan-mushi
Last active November 21, 2016 15:28
Show Gist options
  • Save alan-mushi/c186a0d90f63e92ec7c5 to your computer and use it in GitHub Desktop.
Save alan-mushi/c186a0d90f63e92ec7c5 to your computer and use it in GitHub Desktop.
Click modular router: example of non element compilation file
InfiniteSource(LIMIT 1)
-> UserElem()
-> Discard;
#include <click/config.h>
#include <click/glue.hh> // for click_chatter()
#include "printhello.hh"
CLICK_DECLS
void print_hello() {
click_chatter("A word from a non element file : HELLO!\n");
return 0;
}
CLICK_ENDDECLS
ELEMENT_PROVIDES(PrintHello)
#ifndef CLICK_PRINTRANDOM_HH
#define CLICK_PRINTRANDOM_HH
#include <click/config.h>
CLICK_DECLS
void print_hello();
CLICK_ENDDECLS
#endif
#include <click/config.h>
#include "userelem.hh"
#include "printhello.hh"
CLICK_DECLS
UserElem::UserElem() { }
UserElem::~UserElem() { }
Packet* UserElem::simple_action(Packet *p) {
print_hello();
return p;
}
CLICK_ENDDECLS
ELEMENT_REQUIRES(PrintHello)
EXPORT_ELEMENT(UserElem)
#ifndef CLICK_USERELEM_HH
#define CLICK_USERELEM_HH
#include <click/element.hh>
CLICK_DECLS
class UserElem : public Element {
public:
UserElem();
~UserElem();
const char *class_name() const { return "UserElem"; }
const char *port_count() const { return PORTS_1_1; }
const char *processing() const { return AGNOSTIC; }
int configure(Vector<String>&, ErrorHandler*) { return 0; }
Packet *simple_action(Packet *);
};
CLICK_ENDDECLS
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment