Last active
November 21, 2016 15:28
-
-
Save alan-mushi/c186a0d90f63e92ec7c5 to your computer and use it in GitHub Desktop.
Click modular router: example of non element compilation file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
InfiniteSource(LIMIT 1) | |
-> UserElem() | |
-> Discard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef CLICK_PRINTRANDOM_HH | |
#define CLICK_PRINTRANDOM_HH | |
#include <click/config.h> | |
CLICK_DECLS | |
void print_hello(); | |
CLICK_ENDDECLS | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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