#include <click/straccum.hh>
#include <click/driver.hh>
+#include <static_config.h>
+
#include <uk/sched.h>
#include <uk/thread.h>
+#include <uk/netdev.h>
+#include <uk/plat/memory.h>
int click_nthreads = 1;
-
void *__dso_handle = NULL;
#define NLOG(fmt, ...)
static ErrorHandler *errh;
static Master master(1);
+static String *
+get_config()
+{
+ String *cfg;
+ struct ukplat_memregion_desc img;
+ char *cstr;
+ size_t cstr_len;
+
+ /* First, try initrd */
+ if (ukplat_memregion_find_initrd0(&img) >= 0) {
+ cstr = (char *)img.base;
+ cstr_len = img.len;
+ } else {
+ /* If we can't find a config: use a fallback one statically
+ * compiled in.
+ */
+ uk_pr_warn("Could not find a config, using standard config!\n");
+ cstr = CONFIGSTRING;
+ cstr_len = strlen(CONFIGSTRING);
+ }
+ cfg = new String(cstr, cstr_len);
+ printf("Received config (length %d):\n", cfg->length());
+ printf("%s\n", cfg->c_str());
+ return cfg;
+}
+
struct router_instance {
Router *r;
u_int f_stop;
void
router_thread(void *thread_data)
{
- u_int *rid = (u_int*) thread_data;
- String *config = new String; //read_config(*rid);
- struct router_instance *ri = &router_list[*rid];
+ struct router_instance *ri = &router_list[(unsigned long)thread_data];
+ String *config = get_config();
ri->r = click_read_router(*config, true, errh, false, &master);
if (ri->r->initialize(errh) < 0) {
LOG("Master/driver stopped, closing router_thread");
free(config);
- free(rid);
}
void
--- /dev/null
+static char CONFIGSTRING[] = " define($IP 10.0.10.123);\n\
+ define($MAC0 11:22:33:44:55:66);\n\
+\n\
+ source :: FromDevice;\n\
+ sink :: ToDevice;\n\
+ // classifies packets \n\
+ c :: Classifier(\n\
+ 12/0806 20/0001, // ARP Requests goes to output 0\n\
+ 12/0806 20/0002, // ARP Replies to output 1\n\
+ 12/0800 14/45 34/08, // ICMP Requests to output 2\n\
+ -); // without a match to output 3\n\
+\n\
+ arpq :: ARPQuerier($IP, $MAC0);\n\
+ arpr :: ARPResponder($IP $MAC0);\n\
+\n\
+ source -> c;\n\
+ c[0] -> CheckARPHeader(14) -> ARPPrint -> arpr -> ARPPrint -> sink;\n\
+ c[1] -> [1]arpq;\n\
+ Idle -> [0]arpq;\n\
+ arpq -> sink;\n\
+ c[2] -> CheckIPHeader(14) -> IPPrint -> ICMPPingResponder() -> EtherMirror() -> IPPrint -> sink;\n\
+ c[3] -> Discard;";